Whamcloud - gitweb
LU-5496 ldlm: granting the same lock twice on recovery 69/11469/3
authorVitaly Fertman <vitaly_fertman@xyratex.com>
Fri, 15 Aug 2014 11:09:39 +0000 (15:09 +0400)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 27 Aug 2014 01:42:03 +0000 (01:42 +0000)
the previous fix was not correct, check for resend before removing
from resource, otherwise conflicts can be granted in parallel.

also, some minor cleanups.

Signed-off-by: Vitaly Fertman <vitaly_fertman@xyratex.com>
Change-Id: I461608878d40d6bba4e23179a7379de835d526c3
Reviewed-by: Andriy Skulysh <andriy_skulysh@xyratex.com>
Reviewed-by: Alexander Boyko <alexander_boyko@xyratex.com>
Tested-by: Alexander Lezhoev <alexander_lezhoev@xyratex.com>
Xyratex-bug-id: MRP-1944
Reviewed-on: http://review.whamcloud.com/11469
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Reviewed-by: Bobi Jam <bobijam@gmail.com>
lustre/ldlm/ldlm_lock.c
lustre/mdt/mdt_reint.c
lustre/tests/sanityn.sh

index 8d4a39a..588a8a9 100644 (file)
@@ -1661,6 +1661,9 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns,
                 }
         }
 
+       if (*flags & LDLM_FL_RESENT)
+               RETURN(ELDLM_OK);
+
        /* For a replaying lock, it might be already in granted list. So
         * unlinking the lock will cause the interval node to be freed, we
         * have to allocate the interval node early otherwise we can't regrant
@@ -1717,8 +1720,6 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns,
                         ldlm_grant_lock(lock, NULL);
                GOTO(out, rc = ELDLM_OK);
 #ifdef HAVE_SERVER_SUPPORT
-       } else if (*flags & LDLM_FL_RESENT) {
-               GOTO(out, rc = ELDLM_OK);
         } else if (*flags & LDLM_FL_REPLAY) {
                 if (*flags & LDLM_FL_BLOCK_CONV) {
                         ldlm_resource_add_lock(res, &res->lr_converting, lock);
index 063ddd3..d2c36c2 100644 (file)
@@ -1863,6 +1863,10 @@ static int mdt_reint_rename_internal(struct mdt_thread_info *info,
                        GOTO(out_put_new, rc = -EXDEV);
                }
 
+               /* Before locking the target dir, check we do not replace
+                * a dir with a non-dir, otherwise it may deadlock with
+                * link op which tries to create a link in this dir
+                * back to this non-dir. */
                if (S_ISDIR(lu_object_attr(&mnew->mot_obj)) &&
                    !S_ISDIR(lu_object_attr(&mold->mot_obj)))
                        GOTO(out_put_new, rc = -EISDIR);
index 6edb104..adbc37b 100644 (file)
@@ -2496,22 +2496,18 @@ test_55d()
 
 #define OBD_FAIL_MDS_RENAME3              0x155
        do_facet mds $LCTL set_param fail_loc=0x155
-       mv $DIR/f1 $DIR/d1 &
+       mv $DIR/f1 $DIR/$tdir &
        PID1=$!
        sleep 2
 
-       # while rename is sleeping, create d2, but as a directory
-       mkdir -p $DIR2/d1 || error "(1) mkdir failed"
+       # while rename is sleeping, create $tdir, but as a directory
+       mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
 
        # link in reverse locking order
-       ln $DIR2/f1 $DIR2/d1/
+       ln $DIR2/f1 $DIR2/$tdir/
 
        wait $PID1 && error "(2) mv succeeded"
-       lctl dk > ../log1
-       ls -la $DIR/
-       ls -la $DIR/d1
-
-       rm -rf $DIR/d1
+       rm -rf $DIR/f1
 }
 run_test 55d "rename file vs link"