X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fsanity-lfsck.sh;h=69f278373f05f1cd8409300a517830080911e383;hb=9667225cdcf7308402893ff7216fce26df7ee04a;hp=4025f389347c146396d7ab2ffdabaa1d821e6755;hpb=169738e30a7e0b57f27a517d78d2c928b3bb0f5c;p=fs%2Flustre-release.git diff --git a/lustre/tests/sanity-lfsck.sh b/lustre/tests/sanity-lfsck.sh index 4025f38..69f2783 100644 --- a/lustre/tests/sanity-lfsck.sh +++ b/lustre/tests/sanity-lfsck.sh @@ -8,8 +8,8 @@ set -e ONLY=${ONLY:-"$*"} -#Bug number for excepting test LU-4684 LU-10406 -ALWAYS_EXCEPT="$SANITY_LFSCK_EXCEPT 15c 29c 31c" +#Bug number for excepting test +ALWAYS_EXCEPT="$SANITY_LFSCK_EXCEPT" [ "$SLOW" = "no" ] && EXCEPT_SLOW="" # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT! @@ -1882,6 +1882,11 @@ test_16() { dd if=/dev/zero of=$DIR/$tdir/f0 bs=1M count=1 cancel_lru_locks osc + # created but no setattr or write to the file. + mkdir $DIR/$tdir/d1 + chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/d1 + $RUNAS createmany -o $DIR/$tdir/d1/o 100 || error "create failed" + echo "Inject failure stub to skip OST-object owner changing" #define OBD_FAIL_LFSCK_BAD_OWNER 0x1613 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1613 @@ -3889,6 +3894,18 @@ test_23b() { } run_test 23b "LFSCK can repair dangling name entry (2)" +cleanup_23c() { + do_facet $SINGLEMDS $LCTL set_param fail_val=0 fail_loc=0 + wait_update_facet $SINGLEMDS "$LCTL get_param -n \ + mdd.${MDT_DEV}.lfsck_namespace | + awk '/^status/ { print \\\$2 }'" "completed" 32 || { + $SHOW_NAMESPACE + error "(10) unexpected status" + } + + stop_full_debug_logging +} + test_23c() { echo "#####" echo "The objectA has multiple hard links, one of them corresponding" @@ -3908,34 +3925,34 @@ test_23c() { check_mount_and_prep $LFS mkdir -i 0 $DIR/$tdir/d0 || error "(1) Fail to mkdir d0 on MDT0" - $LFS path2fid $DIR/$tdir/d0 + parent_fid="$($LFS path2fid $DIR/$tdir/d0)" + echo "parent_fid=$parent_fid" 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 + f0_fid="$($LFS path2fid $DIR/$tdir/d0/f0)" + echo "f0_fid=$f0_fid" echo "dead" > $DIR/$tdir/d0/f1 || error "(3) Fail to touch on MDT0" - $LFS path2fid $DIR/$tdir/d0/f1 + f1_fid="$($LFS path2fid $DIR/$tdir/d0/f1)" + echo "f1_fid=$f1_fid" - 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 [ "$SEQ0" != "$SEQ1" ]; then + if [ "${fid_f0/:.*/}" != "${fid_f1/:.*/}" ]; 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" echo "dummy" > $DIR/$tdir/d0/f0 || error "(3.2) Fail to touch on MDT0" - $LFS path2fid $DIR/$tdir/d0/f0 + f0_fid="$($LFS path2fid $DIR/$tdir/d0/f0)" + echo "f0_fid=$f0_fid (replaced)" fi - local OID=$($LFS path2fid $DIR/$tdir/d0/f1 | awk -F':' '{print $2}') - OID=$(printf %d $OID) + local oid=$(awk -F':' '{ printf $2 }' <<< $f1_fid) 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 + 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 @@ -3960,8 +3977,17 @@ test_23c() { $START_NAMESPACE -r -C || error "(7) Fail to start LFSCK for namespace" - wait_update_facet client "stat $DIR/$tdir/d0/foo | - awk '/Size/ { print \\\$2 }'" "0" $LTIME || { + wait_update_facet client "stat -c%s $DIR/$tdir/d0/foo" "0" $LTIME || { + # While unexpected by the test, it is valid for LFSCK to repair + # the link to the original object before any data is written. + local size=$(stat -c %s $DIR/$tdir/d0/foo) + + if [ "$size" = "6" -a "$(<$DIR/$tdir/d0/foo)" = "dummy" ]; then + log "LFSCK repaired file prematurely" + cleanup_23c + return 0 + fi + stat $DIR/$tdir/d0/foo $SHOW_NAMESPACE error "(8) unexpected size" @@ -3970,15 +3996,7 @@ test_23c() { echo "data" >> $DIR/$tdir/d0/foo || error "(9) Fail to write" cancel_lru_locks osc - do_facet $SINGLEMDS $LCTL set_param fail_val=0 fail_loc=0 - wait_update_facet $SINGLEMDS "$LCTL get_param -n \ - mdd.${MDT_DEV}.lfsck_namespace | - awk '/^status/ { print \\\$2 }'" "completed" 32 || { - $SHOW_NAMESPACE - error "(10) unexpected status" - } - - stop_full_debug_logging + cleanup_23c local repaired=$($SHOW_NAMESPACE | awk '/^dangling_repaired/ { print $2 }') @@ -5204,13 +5222,6 @@ test_35() } run_test 35 "LFSCK can rebuild the lost agent entry" -# It will be replaced by "lfs getstripe -N" via LU-11124. -get_mirrors_count() { - local mirrors=$($LFS getstripe $1 | - awk '/lcm_mirror_count/ { print $2 }') - echo $mirrors -} - test_36a() { [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs" && return @@ -5280,11 +5291,11 @@ test_36a() { local mirrors - mirrors=$(get_mirrors_count $DIR/$tdir/f0) + mirrors=$($LFS getstripe -N $DIR/$tdir/f0) [ $mirrors -eq 2 ] || error "(18) $DIR/$tdir/f0 has $mirrors mirrors" - mirrors=$(get_mirrors_count $DIR/$tdir/f1) + mirrors=$($LFS getstripe -N $DIR/$tdir/f1) [ $mirrors -eq 2 ] || error "(19) $DIR/$tdir/f1 has $mirrors mirrors" - mirrors=$(get_mirrors_count $DIR/$tdir/f2) + mirrors=$($LFS getstripe -N $DIR/$tdir/f2) [ $mirrors -eq 2 ] || error "(20) $DIR/$tdir/f2 has $mirrors mirrors" echo "Trigger layout LFSCK on all devices to find out orphan OST-object" @@ -5314,11 +5325,11 @@ test_36a() { [ $repaired -eq 9 ] || error "(24) Expect 9 fixed on mds1, but got: $repaired" - mirrors=$(get_mirrors_count $DIR/$tdir/f0) + mirrors=$($LFS getstripe -N $DIR/$tdir/f0) [ $mirrors -eq 3 ] || error "(25) $DIR/$tdir/f0 has $mirrors mirrors" - mirrors=$(get_mirrors_count $DIR/$tdir/f1) + mirrors=$($LFS getstripe -N $DIR/$tdir/f1) [ $mirrors -eq 3 ] || error "(26) $DIR/$tdir/f1 has $mirrors mirrors" - mirrors=$(get_mirrors_count $DIR/$tdir/f2) + mirrors=$($LFS getstripe -N $DIR/$tdir/f2) [ $mirrors -eq 3 ] || error "(27) $DIR/$tdir/f2 has $mirrors mirrors" $LFS getstripe $DIR/$tdir/f0 | grep "lcme_mirror_id:.*1" || { @@ -5402,11 +5413,11 @@ test_36b() { [ $count -eq 9 ] || error "(8) Expect 9 fixed on mds1, but got: $count" local name=$MOUNT/.lustre/lost+found/MDT0000/${fid}-R-0 - count=$($LFS getstripe $name | awk '/lcm_mirror_count/ { print $2 }') + count=$($LFS getstripe --mirror-count $name) [ $count -eq 3 ] || error "(9) $DIR/$tdir/f0 has $count mirrors" - count=$($LFS getstripe $name | awk '/lcm_entry_count/ { print $2 }') - [ $count -eq 6 ] || error "(10) $DIR/$tdir/f0 has $count entries" + count=$($LFS getstripe --component-count $name) + [ $count -eq 6 ] || error "(10) $DIR/$tdir/f0 has $count components" $LFS getstripe $name | grep "lcme_mirror_id:.*1" || { $LFS getstripe $name @@ -5499,11 +5510,11 @@ test_36c() { [ $count -eq 6 ] || error "(7) Expect 9 fixed on mds1, but got: $count" local name=$MOUNT/.lustre/lost+found/MDT0000/${fid}-R-0 - count=$($LFS getstripe $name | awk '/lcm_mirror_count/ { print $2 }') + count=$($LFS getstripe --mirror-count $name) [ $count -eq 2 ] || error "(8) $DIR/$tdir/f0 has $count mirrors" - count=$($LFS getstripe $name | awk '/lcm_entry_count/ { print $2 }') - [ $count -eq 4 ] || error "(9) $DIR/$tdir/f0 has $count entries" + count=$($LFS getstripe --component-count $name) + [ $count -eq 4 ] || error "(9) $DIR/$tdir/f0 has $count components" local flags=$($LFS getstripe $name | head -n 10 | awk '/lcme_flags/ { print $2 }')