Whamcloud - gitweb
LU-7429 tests: generate dangling name entry properly 63/24763/2
authorFan Yong <fan.yong@intel.com>
Sun, 25 Sep 2016 00:24:10 +0000 (08:24 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 24 Jan 2017 05:23:54 +0000 (05:23 +0000)
There may be some creation after the dangling injection, such as
create ".lustre/lost+found/MDTxxxx" for LFSCK, create some quota
related local files. These creations may reuse the just released
local object/inode that is referenced by the dangling name entry.
That will fail the dangling injection as to the subsequent LFSCK
will not find dangling name entry. So before deleting the target
object for the dangling name entry, remove some other objects to
avoid the target object being reused by some potential creations.

Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: I0e1bb60c1095119e10009fe2a8ce38687e3e7692
Reviewed-on: https://review.whamcloud.com/24763
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Jian Yu <jian.yu@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/sanity-lfsck.sh

index 24d8e4d..d0cbaee 100644 (file)
@@ -3197,30 +3197,21 @@ test_23b() {
 
        check_mount_and_prep
 
-       [[ -d $MOUNT/.lustre/lost+found/MDT0000 ]] || {
-               # Trigger LFSCK firstly, that will generate the
-               # .lustre/lost+found/MDTxxxx in advance to avoid
-               # reusing the local object for the dangling name
-               # entry. LU-7429
-               $START_NAMESPACE -r ||
-                       error "(0) Fail to start LFSCK for namespace"
-
-               wait_all_targets_blocked namespace completed 0.1
-       }
-
        $LFS mkdir -i 0 $DIR/$tdir/d0 || error "(1) Fail to mkdir d0 on MDT0"
        $LFS path2fid $DIR/$tdir/d0
 
+       createmany -o $DIR/$tdir/d0/t 10 || error "(1.5) Fail to creatmany"
+
        echo "dummy" > $DIR/$tdir/d0/f0 || error "(2) Fail to touch on MDT0"
        $LFS path2fid $DIR/$tdir/d0/f0
 
        echo "dead" > $DIR/$tdir/d0/f1 || error "(3) Fail to touch on MDT0"
        $LFS path2fid $DIR/$tdir/d0/f1
 
-       local OID=$($LFS path2fid $DIR/$tdir/d0/f1 | awk -F':' '{print $2}')
-       OID=$(printf %d $OID)
+       local SEQ0=$($LFS path2fid $DIR/$tdir/d0/f0 | awk -F':' '{print $1}')
+       local SEQ1=$($LFS path2fid $DIR/$tdir/d0/f1 | awk -F':' '{print $1}')
 
-       if [ $OID -eq 1 ]; then
+       if [ "$SEQ0" != "$SEQ1" ]; then
                # To guarantee that the f0 and f1 are in the same FID seq
                rm -f $DIR/$tdir/d0/f0 ||
                        error "(3.1) Fail to unlink $DIR/$tdir/d0/f0"
@@ -3229,12 +3220,23 @@ test_23b() {
                $LFS path2fid $DIR/$tdir/d0/f0
        fi
 
+       local OID=$($LFS path2fid $DIR/$tdir/d0/f1 | awk -F':' '{print $2}')
+       OID=$(printf %d $OID)
+
        echo "Inject failure stub on MDT0 to simulate dangling name entry"
        #define OBD_FAIL_LFSCK_DANGLING3        0x1621
        do_facet $SINGLEMDS $LCTL set_param fail_val=$OID fail_loc=0x1621
        ln $DIR/$tdir/d0/f0 $DIR/$tdir/d0/foo || error "(4) Fail to hard link"
        do_facet $SINGLEMDS $LCTL set_param fail_val=0 fail_loc=0
 
+       # If there is creation after the dangling injection, it may re-use
+       # the just released local object (inode) that is referenced by the
+       # dangling name entry. It will fail the dangling injection.
+       # So before deleting the target object for the dangling name entry,
+       # remove some other objects to avoid the target object being reused
+       # by some potential creations. LU-7429
+       unlinkmany $DIR/$tdir/d0/t 10 || error "(5.0) Fail to unlinkmany"
+
        rm -f $DIR/$tdir/d0/f1 || error "(5) Fail to unlink $DIR/$tdir/d0/f1"
 
        echo "'ls' should fail because of dangling name entry"
@@ -3286,30 +3288,21 @@ test_23c() {
 
        check_mount_and_prep
 
-       [[ -d $MOUNT/.lustre/lost+found/MDT0000 ]] || {
-               # Trigger LFSCK firstly, that will generate the
-               # .lustre/lost+found/MDTxxxx in advance to avoid
-               # reusing the local object for the dangling name
-               # entry. LU-7429
-               $START_NAMESPACE -r ||
-                       error "(0) Fail to start LFSCK for namespace"
-
-               wait_all_targets_blocked namespace completed 0.1
-       }
-
        $LFS mkdir -i 0 $DIR/$tdir/d0 || error "(1) Fail to mkdir d0 on MDT0"
        $LFS path2fid $DIR/$tdir/d0
 
+       createmany -o $DIR/$tdir/d0/t 10 || error "(1.5) Fail to creatmany"
+
        echo "dummy" > $DIR/$tdir/d0/f0 || error "(2) Fail to touch on MDT0"
        $LFS path2fid $DIR/$tdir/d0/f0
 
        echo "dead" > $DIR/$tdir/d0/f1 || error "(3) Fail to touch on MDT0"
        $LFS path2fid $DIR/$tdir/d0/f1
 
-       local OID=$($LFS path2fid $DIR/$tdir/d0/f1 | awk -F':' '{print $2}')
-       OID=$(printf %d $OID)
+       local SEQ0=$($LFS path2fid $DIR/$tdir/d0/f0 | awk -F':' '{print $1}')
+       local SEQ1=$($LFS path2fid $DIR/$tdir/d0/f1 | awk -F':' '{print $1}')
 
-       if [ $OID -eq 1 ]; then
+       if [ "$SEQ0" != "$SEQ1" ]; then
                # To guarantee that the f0 and f1 are in the same FID seq
                rm -f $DIR/$tdir/d0/f0 ||
                        error "(3.1) Fail to unlink $DIR/$tdir/d0/f0"
@@ -3318,12 +3311,23 @@ test_23c() {
                $LFS path2fid $DIR/$tdir/d0/f0
        fi
 
+       local OID=$($LFS path2fid $DIR/$tdir/d0/f1 | awk -F':' '{print $2}')
+       OID=$(printf %d $OID)
+
        echo "Inject failure stub on MDT0 to simulate dangling name entry"
        #define OBD_FAIL_LFSCK_DANGLING3        0x1621
        do_facet $SINGLEMDS $LCTL set_param fail_val=$OID fail_loc=0x1621
        ln $DIR/$tdir/d0/f0 $DIR/$tdir/d0/foo || error "(4) Fail to hard link"
        do_facet $SINGLEMDS $LCTL set_param fail_val=0 fail_loc=0
 
+       # If there is creation after the dangling injection, it may re-use
+       # the just released local object (inode) that is referenced by the
+       # dangling name entry. It will fail the dangling injection.
+       # So before deleting the target object for the dangling name entry,
+       # remove some other objects to avoid the target object being reused
+       # by some potential creations. LU-7429
+       unlinkmany $DIR/$tdir/d0/t 10 || error "(5.0) Fail to unlinkmany"
+
        rm -f $DIR/$tdir/d0/f1 || error "(5) Fail to unlink $DIR/$tdir/d0/f1"
 
        echo "'ls' should fail because of dangling name entry"
@@ -3339,7 +3343,7 @@ test_23c() {
 
        wait_update_facet client "stat $DIR/$tdir/d0/foo |
                awk '/Size/ { print \\\$2 }'" "0" $LTIME || {
-               stat $DIR/$tdir/guard
+               stat $DIR/$tdir/d0/foo
                $SHOW_NAMESPACE
                error "(8) unexpected size"
        }