Whamcloud - gitweb
Branch b_release_1_8_1
authorzam <zam>
Wed, 27 May 2009 11:18:56 +0000 (11:18 +0000)
committerzam <zam>
Wed, 27 May 2009 11:18:56 +0000 (11:18 +0000)
b=19039
i=vitaly.fertman
i=oleg.drokin

ldlm_lock_enqueue: don't enqueue a destroyed lock.

lustre/include/obd_support.h
lustre/ldlm/ldlm_extent.c
lustre/ldlm/ldlm_lock.c
lustre/tests/recovery-small.sh

index ad8ec2a..51a0309 100644 (file)
@@ -256,6 +256,7 @@ extern unsigned int obd_alloc_fail_rate;
 #define OBD_FAIL_LDLM_OST_FAIL_RACE      0x316
 #define OBD_FAIL_LDLM_INTR_CP_AST        0x317
 #define OBD_FAIL_LDLM_CP_BL_RACE         0x318
+#define OBD_FAIL_LDLM_ENQUEUE_LOCAL      0x319
 
 /* LOCKLESS IO */
 #define OBD_FAIL_LDLM_SET_CONTENTION     0x385
index 22c42c1..d4a94a3 100644 (file)
@@ -859,6 +859,7 @@ void ldlm_extent_add_lock(struct ldlm_resource *res,
         int idx;
 
         LASSERT(lock->l_granted_mode == lock->l_req_mode);
+        LASSERT(!lock->l_destroyed);
 
         node = lock->l_tree_node;
         LASSERT(node != NULL);
index d2face5..4dbe222 100644 (file)
@@ -1207,8 +1207,13 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns,
         if (!local && (*flags & LDLM_FL_REPLAY) && res->lr_type == LDLM_EXTENT)
                 OBD_SLAB_ALLOC(node, ldlm_interval_slab, CFS_ALLOC_IO,
                                sizeof(*node));
+        if(res->lr_type == LDLM_EXTENT)
+                OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_ENQUEUE_LOCAL, 30);
 
         lock_res_and_lock(lock);
+        if (lock->l_destroyed)
+                GOTO(out, rc = -EAGAIN);
+
         if (local && lock->l_req_mode == lock->l_granted_mode) {
                 /* The server returned a blocked lock, but it was granted
                  * before we got a chance to actually enqueue it.  We don't
@@ -1649,6 +1654,10 @@ struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode,
                  "new_mode %u, granted %u\n", new_mode, lock->l_granted_mode);
 
         lock_res_and_lock(lock);
+        if (unlikely(lock->l_destroyed != 0)) {
+                unlock_res_and_lock(lock);
+                RETURN(NULL);
+        }
 
         res = lock->l_resource;
         ns = res->lr_namespace;
index 4de9dd1..69df85f 100755 (executable)
@@ -403,6 +403,29 @@ test_20b() {       # bug 2986 - ldlm_handle_enqueue error during open
 }
 run_test 20b "ldlm_handle_enqueue error (should return error)"
 
+test_20c() {
+        # bug 19039 -- a race between ldlm_enqueue and lock
+        # destroying when the client export is disconnected
+
+        local ddpid
+
+        mkdir -p $DIR/$tdir
+        rm -f $DIR/$tdir/$tfile
+        # OBD_FAIL_LDLM_ENQUEUE_LOCAL 0x319
+        do_facet ost1 lctl set_param fail_loc=0x80000319
+        lfs setstripe -c 1 -o 0 $DIR/$tdir/$tfile
+        dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M conv=notrunc count=1 &
+        ddpid=$!
+        sleep 3
+        kill  $ddpid
+        stop ost1
+        sleep 30
+        start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
+        rm -rf $DIR/$tdir
+        return 0
+}
+run_test 20c "ldlm_lock_enqueue is called for a destroyed lock (shouldn't LBUG)"
+
 test_21a() {
        mkdir -p $DIR/$tdir-1
        mkdir -p $DIR/$tdir-2