X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Ftests%2Fsanity.sh;h=4fc5ac25176b9c9c6d74a5d36a1f85147e7cf905;hp=a1063007caedf2a3e9e2e7629547d5a9d4fef419;hb=eb8e82dede79552be895bc25b206b0da4a5adcbc;hpb=947b22b08d3725852a811a9e330562dd986d7336 diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index a1063007..4fc5ac2 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -8,44 +8,26 @@ set -e ONLY=${ONLY:-"$*"} -# bug number for skipped test: LU-9693 LU-6493 LU-9693 3561 5188 -ALWAYS_EXCEPT=" 42a 42b 42c 45 68b $SANITY_EXCEPT" +# bug number for skipped test: LU-9693 LU-6493 LU-9693 +ALWAYS_EXCEPT="$SANITY_EXCEPT 42a 42b 42c" # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT! # skipped tests: LU-8411 LU-9096 LU-9054 -ALWAYS_EXCEPT=" 407 253 312 $ALWAYS_EXCEPT" +ALWAYS_EXCEPT=" 407 253 312 $ALWAYS_EXCEPT" # Check Grants after these tests GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c" -is_sles11() # LU-4341 -{ - if [ -r /etc/SuSE-release ] - then - local vers=$(grep VERSION /etc/SuSE-release | awk '{print $3}') - local patchlev=$(grep PATCHLEVEL /etc/SuSE-release | - awk '{ print $3 }') - if [ $vers -eq 11 ] && [ $patchlev -ge 3 ]; then - return 0 - fi - fi - return 1 -} - -if is_sles11; then # LU-4341 - ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170" -fi - SRCDIR=$(cd $(dirname $0); echo $PWD) export PATH=$PATH:/sbin TMP=${TMP:-/tmp} +OSC=${OSC:-"osc"} CC=${CC:-cc} CHECKSTAT=${CHECKSTAT:-"checkstat -v"} CREATETEST=${CREATETEST:-createtest} LFS=${LFS:-lfs} -LFIND=${LFIND:-"$LFS find"} LVERIFY=${LVERIFY:-ll_dirstripe_verify} LCTL=${LCTL:-lctl} OPENFILE=${OPENFILE:-openfile} @@ -87,6 +69,30 @@ if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b" fi +# Get the SLES version so we can make decisions on if a test should be run +# +# Returns a version string that should only be used in comparing +# strings returned by version_code() + +sles_version_code() +{ + local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2) + + # All SuSE Linux versions have one decimal. version_code expects two + local sles_version=$version.0 + version_code $sles_version +} + +if [ -r /etc/SuSE-release ]; then + sles_version=$(sles_version_code) + [ $sles_version -lt $(version_code 11.4.0) ] && + # bug number for skipped test: LU-4341 + ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170" + [ $sles_version -lt $(version_code 12.0.0) ] && + # bug number for skipped test: LU-3703 + ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234" +fi + FAIL_ON_ERROR=false cleanup() { @@ -112,8 +118,6 @@ check_and_setup_lustre DIR=${DIR:-$MOUNT} assert_DIR -MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | - awk '{ gsub(/_UUID/,""); print $1 }' | head -n1) MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))} [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo @@ -164,6 +168,45 @@ test_0c() { } run_test 0c "check import proc" +test_0d() { # LU-3397 + [ $(lustre_version_code mgs) -lt $(version_code 2.10.57) ] && + skip "proc exports not supported before 2.10.57" && return + + local mgs_exp="mgs.MGS.exports" + local client_uuid=$($LCTL get_param -n mgc.*.uuid) + local exp_client_nid + local exp_client_version + local exp_val + local imp_val + local temp_imp=$DIR/$tfile.import + local temp_exp=$DIR/$tfile.export + + # save mgc import file to $temp_imp + $LCTL get_param mgc.*.import | tee $temp_imp + # Check if client uuid is found in MGS export + for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do + [ $(do_facet mgs $LCTL get_param $exp_client_nid.uuid) == \ + $client_uuid ] && + break; + done + # save mgs export file to $temp_exp + do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp + + # Compare the value of field "connect_flags" + imp_val=$(grep "connect_flags" $temp_imp) + exp_val=$(grep "connect_flags" $temp_exp) + [ "$exp_val" == "$imp_val" ] || + error "export flags '$exp_val' != import flags '$imp_val'" + + # Compare the value of client version + exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp) + exp_val=$(version_code $exp_client_version) + imp_val=$(lustre_version_code client) + [ "$exp_val" == "$imp_val" ] || + error "export client version '$exp_val' != '$imp_val'" +} +run_test 0d "check export proc =============================" + test_1() { test_mkdir $DIR/$tdir test_mkdir $DIR/$tdir/d2 @@ -498,11 +541,7 @@ test_17h() { #bug 17378 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return local mdt_idx test_mkdir $DIR/$tdir - if [[ $MDSCOUNT -gt 1 ]]; then - mdt_idx=$($LFS getdirstripe -i $DIR/$tdir) - else - mdt_idx=0 - fi + mdt_idx=$($LFS getdirstripe -i $DIR/$tdir) $LFS setstripe -c -1 $DIR/$tdir #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141 @@ -516,18 +555,14 @@ test_17i() { #bug 20018 test_mkdir -c1 $DIR/$tdir local foo=$DIR/$tdir/$tfile local mdt_idx - if [[ $MDSCOUNT -gt 1 ]]; then - mdt_idx=$($LFS getdirstripe -i $DIR/$tdir) - else - mdt_idx=0 - fi + mdt_idx=$($LFS getdirstripe -i $DIR/$tdir) ln -s $foo $foo || error "create symlink failed" #define OBD_FAIL_MDS_READLINK_EPROTO 0x143 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143 ls -l $foo && error "error not detected" return 0 } -run_test 17i "don't panic on short symlink" +run_test 17i "don't panic on short symlink (should return error)" test_17k() { #bug 22301 [[ -z "$(which rsync 2>/dev/null)" ]] && @@ -813,6 +848,38 @@ test_23b() { # bug 18988 } run_test 23b "O_APPEND check" +# LU-9409, size with O_APPEND and tiny writes +test_23c() { + local file=$DIR/$tfile + + # single dd + dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 + $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400" + rm -f $file + + # racing tiny writes + dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 & + dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 & + wait + $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800" + rm -f $file + + #racing tiny & normal writes + dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 & + dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 & + wait + $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184" + rm -f $file + + #racing tiny & normal writes 2, ugly numbers + dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 & + dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 & + wait + $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030" + rm -f $file +} +run_test 23c "O_APPEND size checks for tiny writes" + # rename sanity test_24a() { echo '-- same directory rename' @@ -857,8 +924,8 @@ test_24e() { test_mkdir $DIR/R5b touch $DIR/R5a/f mv $DIR/R5a/f $DIR/R5b/g - $CHECKSTAT -a $DIR/R5a/f || error - $CHECKSTAT -t file $DIR/R5b/g || error + $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists" + $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type" } run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======" @@ -867,8 +934,8 @@ test_24f() { test_mkdir $DIR/R6b touch $DIR/R6a/f $DIR/R6b/g mv $DIR/R6a/f $DIR/R6b/g - $CHECKSTAT -a $DIR/R6a/f || error - $CHECKSTAT -t file $DIR/R6b/g || error + $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists" + $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type" } run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ====" @@ -877,8 +944,8 @@ test_24g() { test_mkdir $DIR/R7b test_mkdir $DIR/R7a/d mv $DIR/R7a/d $DIR/R7b/e - $CHECKSTAT -a $DIR/R7a/d || error - $CHECKSTAT -t dir $DIR/R7b/e || error + $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists" + $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type" } run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======" @@ -888,8 +955,8 @@ test_24h() { test_mkdir -c1 $DIR/R8a/d test_mkdir -c1 $DIR/R8b/e mrename $DIR/R8a/d $DIR/R8b/e - $CHECKSTAT -a $DIR/R8a/d || error - $CHECKSTAT -t dir $DIR/R8b/e || error + $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists" + $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type" } run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e" @@ -899,18 +966,18 @@ test_24i() { test_mkdir $DIR/R9/a touch $DIR/R9/f mrename $DIR/R9/f $DIR/R9/a - $CHECKSTAT -t file $DIR/R9/f || error - $CHECKSTAT -t dir $DIR/R9/a || error - $CHECKSTAT -a $DIR/R9/a/f || error + $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type" + $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type" + $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists" } run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a" test_24j() { test_mkdir $DIR/R10 mrename $DIR/R10/f $DIR/R10/g - $CHECKSTAT -t dir $DIR/R10 || error - $CHECKSTAT -a $DIR/R10/f || error - $CHECKSTAT -a $DIR/R10/g || error + $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type" + $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists" + $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists" } run_test 24j "source does not exist ============================" @@ -919,15 +986,15 @@ test_24k() { test_mkdir $DIR/R11a/d touch $DIR/R11a/f mv $DIR/R11a/f $DIR/R11a/d - $CHECKSTAT -a $DIR/R11a/f || error - $CHECKSTAT -t file $DIR/R11a/d/f || error + $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists" + $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type" } run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d =======" # bug 2429 - rename foo foo foo creates invalid file test_24l() { f="$DIR/f24l" - $MULTIOP $f OcNs || error + $MULTIOP $f OcNs || error "rename of ${f} to itself failed" } run_test 24l "Renaming a file to itself ========================" @@ -945,10 +1012,10 @@ test_24n() { f="$DIR/f24n" # this stats the old file after it was renamed, so it should fail touch ${f} - $CHECKSTAT ${f} + $CHECKSTAT ${f} || error "${f} missing" mv ${f} ${f}.rename - $CHECKSTAT ${f}.rename - $CHECKSTAT -a ${f} + $CHECKSTAT ${f}.rename || error "${f}.rename missing" + $CHECKSTAT -a ${f} || error "${f} exists" } run_test 24n "Statting the old file after renaming (Posix rename 2)" @@ -963,8 +1030,8 @@ test_24p() { test_mkdir $DIR/R12b DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'` mrename $DIR/R12a $DIR/R12b - $CHECKSTAT -a $DIR/R12a || error - $CHECKSTAT -t dir $DIR/R12b || error + $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists" + $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type" DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'` [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2" } @@ -1023,7 +1090,7 @@ test_24t() { run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a =" test_24u() { # bug12192 - $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error + $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed" $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size" } run_test 24u "create stripe file" @@ -1284,13 +1351,14 @@ test_25a() { test_mkdir $DIR/d25 ln -s d25 $DIR/s25 - touch $DIR/s25/foo || error + touch $DIR/s25/foo || + error "File creation in symlinked directory failed" } run_test 25a "create file in symlinked directory ===============" test_25b() { [ ! -d $DIR/d25 ] && test_25a - $CHECKSTAT -t file $DIR/s25/foo || error + $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type" } run_test 25b "lookup file in symlinked directory ===============" @@ -1298,14 +1366,14 @@ test_26a() { test_mkdir $DIR/d26 test_mkdir $DIR/d26/d26-2 ln -s d26/d26-2 $DIR/s26 - touch $DIR/s26/foo || error + touch $DIR/s26/foo || error "File creation failed" } run_test 26a "multiple component symlink =======================" test_26b() { test_mkdir -p $DIR/$tdir/d26-2 ln -s $tdir/d26-2/foo $DIR/s26-2 - touch $DIR/s26-2 || error + touch $DIR/s26-2 || error "File creation failed" } run_test 26b "multiple component symlink at end of lookup ======" @@ -1354,7 +1422,7 @@ test_27a() { $LFS getstripe $DIR/$tdir $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed" $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed" - cp /etc/hosts $DIR/$tdir/$tfile || error + cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file" } run_test 27a "one stripe file" @@ -1479,7 +1547,7 @@ run_test 27m "create file while OST0 was full" sleep_maxage() { local delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | - head -n 1 | awk '{ print $1 * 2 }') + awk '{ print $1 * 2; exit; }') sleep $delay } @@ -1546,8 +1614,8 @@ test_27n() { reset_enospc rm -f $DIR/$tdir/$tfile exhaust_precreations 0 0x80000215 - $LFS setstripe -c -1 $DIR/$tdir - touch $DIR/$tdir/$tfile || error + $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed" + touch $DIR/$tdir/$tfile || error "touch failed" $LFS getstripe $DIR/$tdir/$tfile reset_enospc } @@ -1627,7 +1695,7 @@ test_27r() { rm -f $DIR/$tdir/$tfile exhaust_precreations 0 0x80000215 - $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile # && error + $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed" reset_enospc } @@ -1673,7 +1741,8 @@ test_27u() { # bug 4900 unlinkmany $DIR/$tdir/t- 1000 trap 0 [[ $OBJS -gt 0 ]] && - error "$OBJS objects created on OST-0. See $TLOG" || pass + error "$OBJS objects created on OST-0. See $TLOG" || + rm -f $TLOG } run_test 27u "skip object creation on OSC w/o objects" @@ -1970,9 +2039,9 @@ run_test 27z "check SEQ/OID on the MDT and OST filesystems" test_27A() { # b=19102 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return - local restore_size=$($GETSTRIPE -S $MOUNT) - local restore_count=$($GETSTRIPE -c $MOUNT) - local restore_offset=$($GETSTRIPE -i $MOUNT) + + save_layout_restore_at_exit $MOUNT + $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 || error "stripe count $($GETSTRIPE -c $MOUNT) != 1" @@ -1982,7 +2051,6 @@ test_27A() { # b=19102 [ $default_size -eq $dsize ] || error "stripe size $default_size != $dsize" [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1" - $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT } run_test 27A "check filesystem-wide default LOV EA values" @@ -2058,20 +2126,28 @@ test_27D() { local ost_list=$(seq $first_ost $ost_step $last_ost) local ost_range="$first_ost $last_ost $ost_step" + if ! combined_mgs_mds ; then + mount_mgs_client + fi + test_mkdir $DIR/$tdir pool_add $POOL || error "pool_add failed" pool_add_targets $POOL $ost_range || error "pool_add_targets failed" local skip27D [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ] && - skip27D += "-s 29" + skip27D+="-s 29" [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.55) -o \ $(lustre_version_code client) -lt $(version_code 2.9.55) ] && - skip27D += "-s 30,31" + skip27D+=" -s 30,31" llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D || error "llapi_layout_test failed" destroy_test_pools || error "destroy test pools failed" + + if ! combined_mgs_mds ; then + umount_mgs_client + fi } run_test 27D "validate llapi_layout API" @@ -2149,7 +2225,7 @@ run_test 27F "Client resend delayed layout creation with non-zero size" # then visible correctly (#2091) test_28() { # bug 2091 test_mkdir $DIR/d28 - $CREATETEST $DIR/d28/ct || error + $CREATETEST $DIR/d28/ct || error "createtest failed" } run_test 28 "create/mknod/mkdir with bad file types ============" @@ -2205,7 +2281,7 @@ run_test 29 "IT_GETATTR regression ============================" test_30a() { # was test_30 cp $(which ls) $DIR || cp /bin/ls $DIR - $DIR/ls / || error + $DIR/ls / || error "Can't execute binary from lustre" rm $DIR/ls } run_test 30a "execute binary from Lustre (execve) ==============" @@ -2213,7 +2289,7 @@ run_test 30a "execute binary from Lustre (execve) ==============" test_30b() { cp `which ls` $DIR || cp /bin/ls $DIR chmod go+rx $DIR/ls - $RUNAS $DIR/ls / || error + $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root" rm $DIR/ls } run_test 30b "execute binary from Lustre as non-root ===========" @@ -2224,29 +2300,30 @@ test_30c() { # b=22376 chmod a-rw $DIR/ls cancel_lru_locks mdc cancel_lru_locks osc - $RUNAS $DIR/ls / || error + $RUNAS $DIR/ls / || error "Can't execute binary from lustre" rm -f $DIR/ls } run_test 30c "execute binary from Lustre without read perms ====" test_31a() { - $OPENUNLINK $DIR/f31 $DIR/f31 || error - $CHECKSTAT -a $DIR/f31 || error + $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed" + $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists" } run_test 31a "open-unlink file ==================================" test_31b() { - touch $DIR/f31 || error - ln $DIR/f31 $DIR/f31b || error - $MULTIOP $DIR/f31b Ouc || error - $CHECKSTAT -t file $DIR/f31 || error + touch $DIR/f31 || error "touch $DIR/f31 failed" + ln $DIR/f31 $DIR/f31b || error "ln failed" + $MULTIOP $DIR/f31b Ouc || error "multiop failed" + $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type" } run_test 31b "unlink file with multiple links while open =======" test_31c() { - touch $DIR/f31 || error - ln $DIR/f31 $DIR/f31c || error - multiop_bg_pause $DIR/f31 O_uc || return 1 + touch $DIR/f31 || error "touch $DIR/f31 failed" + ln $DIR/f31 $DIR/f31c || error "ln failed" + multiop_bg_pause $DIR/f31 O_uc || + error "multiop_bg_pause for $DIR/f31 failed" MULTIPID=$! $MULTIOP $DIR/f31c Ouc kill -USR1 $MULTIPID @@ -2255,13 +2332,13 @@ test_31c() { run_test 31c "open-unlink file with multiple links =============" test_31d() { - opendirunlink $DIR/d31d $DIR/d31d || error - $CHECKSTAT -a $DIR/d31d || error + opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed" + $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists" } run_test 31d "remove of open directory =========================" test_31e() { # bug 2904 - openfilleddirunlink $DIR/d31e || error + openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed" } run_test 31e "remove of open non-empty directory ===============" @@ -2422,7 +2499,7 @@ test_31p() { test_mkdir $DIR/$tdir $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir - $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir + $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir opendirunlink $DIR/$tdir/striped_dir/test1 || error "open unlink test1 failed" @@ -2452,8 +2529,10 @@ test_32a() { [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir trap cleanup_test32_mount EXIT test_mkdir -p $DIR/$tdir/ext2-mountpoint - mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error - $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error + mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || + error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint" + $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || + error "$DIR/$tdir/ext2-mountpoint/.. not dir type" cleanup_test32_mount } run_test 32a "stat d32a/ext2-mountpoint/.. =====================" @@ -2463,8 +2542,10 @@ test_32b() { [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir trap cleanup_test32_mount EXIT test_mkdir -p $DIR/$tdir/ext2-mountpoint - mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error - ls -al $DIR/$tdir/ext2-mountpoint/.. || error + mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || + error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint" + ls -al $DIR/$tdir/ext2-mountpoint/.. || + error "Can't list $DIR/$tdir/ext2-mountpoint/.." cleanup_test32_mount } run_test 32b "open d32b/ext2-mountpoint/.. =====================" @@ -2474,9 +2555,11 @@ test_32c() { [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir trap cleanup_test32_mount EXIT test_mkdir -p $DIR/$tdir/ext2-mountpoint - mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error + mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || + error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint" test_mkdir -p $DIR/$tdir/d2/test_dir - $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error + $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || + error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type" cleanup_test32_mount } run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir =========" @@ -2486,9 +2569,11 @@ test_32d() { [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir trap cleanup_test32_mount EXIT test_mkdir -p $DIR/$tdir/ext2-mountpoint - mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error + mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || + error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint" test_mkdir -p $DIR/$tdir/d2/test_dir - ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error + ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || + error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir" cleanup_test32_mount } run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir" @@ -2545,9 +2630,11 @@ test_32i() { [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir trap cleanup_test32_mount EXIT test_mkdir -p $DIR/$tdir/ext2-mountpoint - mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error + mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || + error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint" touch $DIR/$tdir/test_file - $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error + $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || + error "$DIR/$tdir/ext2-mountpoint/../test_file not file type" cleanup_test32_mount } run_test 32i "stat d32i/ext2-mountpoint/../test_file ===========" @@ -2557,9 +2644,11 @@ test_32j() { [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir trap cleanup_test32_mount EXIT test_mkdir -p $DIR/$tdir/ext2-mountpoint - mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error + mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || + error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint" touch $DIR/$tdir/test_file - cat $DIR/$tdir/ext2-mountpoint/../test_file || error + cat $DIR/$tdir/ext2-mountpoint/../test_file || + error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file" cleanup_test32_mount } run_test 32j "open d32j/ext2-mountpoint/../test_file ===========" @@ -2569,10 +2658,12 @@ test_32k() { rm -fr $DIR/$tdir trap cleanup_test32_mount EXIT test_mkdir -p $DIR/$tdir/ext2-mountpoint - mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint + mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || + error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint" test_mkdir -p $DIR/$tdir/d2 - touch $DIR/$tdir/d2/test_file || error - $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error + touch $DIR/$tdir/d2/test_file || error "touch failed" + $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || + error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type" cleanup_test32_mount } run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========" @@ -2582,10 +2673,12 @@ test_32l() { rm -fr $DIR/$tdir trap cleanup_test32_mount EXIT test_mkdir -p $DIR/$tdir/ext2-mountpoint - mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error + mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || + error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint" test_mkdir -p $DIR/$tdir/d2 - touch $DIR/$tdir/d2/test_file - cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error + touch $DIR/$tdir/d2/test_file || error "touch failed" + cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || + error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file" cleanup_test32_mount } run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========" @@ -2596,8 +2689,10 @@ test_32m() { TMP_DIR=$DIR/d32m/tmp ln -s $DIR $TMP_DIR/symlink11 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01 - $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error - $CHECKSTAT -t link $DIR/d32m/symlink01 || error + $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || + error "symlink11 not a link" + $CHECKSTAT -t link $DIR/d32m/symlink01 || + error "symlink01 not a link" } run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======" @@ -2607,8 +2702,8 @@ test_32n() { TMP_DIR=$DIR/d32n/tmp ln -s $DIR $TMP_DIR/symlink11 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01 - ls -l $DIR/d32n/tmp/symlink11 || error - ls -l $DIR/d32n/symlink01 || error + ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11" + ls -l $DIR/d32n/symlink01 || error "listing symlink01" } run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======" @@ -2618,10 +2713,13 @@ test_32o() { TMP_DIR=$DIR/d32o/tmp ln -s $DIR/$tfile $TMP_DIR/symlink12 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02 - $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error - $CHECKSTAT -t link $DIR/d32o/symlink02 || error - $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error - $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error + $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || + error "symlink12 not a link" + $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link" + $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || + error "$DIR/d32o/tmp/symlink12 not file type" + $CHECKSTAT -t file -f $DIR/d32o/symlink02 || + error "$DIR/d32o/symlink02 not file type" } run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile" @@ -2641,9 +2739,10 @@ test_32p() { log 32p_7 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02 log 32p_8 - cat $DIR/d32p/tmp/symlink12 || error + cat $DIR/d32p/tmp/symlink12 || + error "Can't open $DIR/d32p/tmp/symlink12" log 32p_9 - cat $DIR/d32p/symlink02 || error + cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02" log 32p_10 } run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile" @@ -2653,8 +2752,9 @@ test_32q() { [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir trap cleanup_test32_mount EXIT test_mkdir -p $DIR/$tdir/ext2-mountpoint - touch $DIR/$tdir/ext2-mountpoint/under_the_mount - mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint + touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed" + mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || + error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint" ls $DIR/$tdir/ext2-mountpoint | grep "\" && error cleanup_test32_mount } @@ -2665,8 +2765,9 @@ test_32r() { [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir trap cleanup_test32_mount EXIT test_mkdir -p $DIR/$tdir/ext2-mountpoint - touch $DIR/$tdir/ext2-mountpoint/under_the_mount - mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint + touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed" + mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || + error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint" ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true cleanup_test32_mount } @@ -2853,7 +2954,7 @@ test_33f() { do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1 trap cleanup_33f EXIT - $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir || + $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir || error "cannot create striped directory" $RUNAS touch $DIR/$tdir/striped_dir/{0..16} || @@ -2881,47 +2982,59 @@ run_test 33g "nonroot user create already existing root created file" TEST_34_SIZE=${TEST_34_SIZE:-2000000000000} test_34a() { rm -f $DIR/f34 - $MCREATE $DIR/f34 || error - $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error - $TRUNCATE $DIR/f34 $TEST_34_SIZE || error - $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error - $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error + $MCREATE $DIR/f34 || error "mcreate failed" + $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || + error "getstripe failed" + $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed" + $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || + error "getstripe failed" + $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || + error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes" } run_test 34a "truncate file that has not been opened ===========" test_34b() { [ ! -f $DIR/f34 ] && test_34a - $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error + $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || + error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes" $OPENFILE -f O_RDONLY $DIR/f34 - $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error - $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error + $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || + error "getstripe failed" + $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || + error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes" } run_test 34b "O_RDONLY opening file doesn't create objects =====" test_34c() { [ ! -f $DIR/f34 ] && test_34a - $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error + $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || + error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes" $OPENFILE -f O_RDWR $DIR/f34 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error - $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error + $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || + error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes" } run_test 34c "O_RDWR opening file-with-size works ==============" test_34d() { [ ! -f $DIR/f34 ] && test_34a - dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error - $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error + dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || + error "dd failed" + $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || + error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes" rm $DIR/f34 } run_test 34d "write to sparse file =============================" test_34e() { rm -f $DIR/f34e - $MCREATE $DIR/f34e || error - $TRUNCATE $DIR/f34e 1000 || error - $CHECKSTAT -s 1000 $DIR/f34e || error + $MCREATE $DIR/f34e || error "mcreate failed" + $TRUNCATE $DIR/f34e 1000 || error "truncate failed" + $CHECKSTAT -s 1000 $DIR/f34e || + error "Size of $DIR/f34e not equal to 1000 bytes" $OPENFILE -f O_RDWR $DIR/f34e - $CHECKSTAT -s 1000 $DIR/f34e || error + $CHECKSTAT -s 1000 $DIR/f34e || + error "Size of $DIR/f34e not equal to 1000 bytes" } run_test 34e "create objects, some with size and some without ==" @@ -2929,7 +3042,7 @@ test_34f() { # bug 6242, 6243 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return SIZE34F=48000 rm -f $DIR/f34f - $MCREATE $DIR/f34f || error + $MCREATE $DIR/f34f || error "mcreate failed" $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F" dd if=$DIR/f34f of=$TMP/f34f $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes" @@ -2942,18 +3055,20 @@ run_test 34f "read from a file with no objects until EOF =======" test_34g() { [ $PARALLEL == "yes" ] && skip "skip parallel run" && return - dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error - $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error - $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed" + dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || + error "dd failed" + $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed" + $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || + error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))" cancel_lru_locks osc - $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \ + $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "wrong size after lock cancel" - $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error - $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \ + $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed" + $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || error "expanding truncate failed" cancel_lru_locks osc - $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \ + $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || error "wrong expanded size after lock cancel" } run_test 34g "truncate long file ===============================" @@ -2963,7 +3078,7 @@ test_34h() { local gid=10 local sz=1000 - dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error + dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed" sync # Flush the cache so that multiop below does not block on cache # flush when getting the group lock $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c & @@ -2997,13 +3112,13 @@ run_test 35a "exec file with mode 444 (should return and not leak)" test_36a() { rm -f $DIR/f36 - utime $DIR/f36 || error + utime $DIR/f36 || error "utime failed for MDS" } run_test 36a "MDS utime check (mknod, utime)" test_36b() { echo "" > $DIR/f36 - utime $DIR/f36 || error + utime $DIR/f36 || error "utime failed for OST" } run_test 36b "OST utime check (open, utime)" @@ -3011,14 +3126,14 @@ test_36c() { rm -f $DIR/d36/f36 test_mkdir $DIR/d36 chown $RUNAS_ID $DIR/d36 - $RUNAS utime $DIR/d36/f36 || error + $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root" } run_test 36c "non-root MDS utime check (mknod, utime)" test_36d() { [ ! -d $DIR/d36 ] && test_36c echo "" > $DIR/d36/f36 - $RUNAS utime $DIR/d36/f36 || error + $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root" } run_test 36d "non-root OST utime check (open, utime)" @@ -3587,7 +3702,7 @@ test_41() { run_test 41 "test small file write + fstat =====================" count_ost_writes() { - lctl get_param -n osc.*.stats | + lctl get_param -n ${OSC}.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } \ END { printf("%0.0f", writes) }' } @@ -3647,7 +3762,7 @@ setup_test42() { test_42a() { [ $PARALLEL == "yes" ] && skip "skip parallel run" && return setup_test42 - cancel_lru_locks osc + cancel_lru_locks $OSC stop_writeback sync; sleep 1; sync # just to be safe BEFOREWRITES=`count_ost_writes` @@ -3663,7 +3778,7 @@ run_test 42a "ensure that we don't flush on close" test_42b() { [ $PARALLEL == "yes" ] && skip "skip parallel run" && return setup_test42 - cancel_lru_locks osc + cancel_lru_locks $OSC stop_writeback sync dd if=/dev/zero of=$DIR/f42b bs=1024 count=100 @@ -3699,21 +3814,21 @@ run_test 42b "test destroy of file with cached dirty data ======" # start the file with a full-file pw lock to match against # until the truncate. trunc_test() { - test=$1 - file=$DIR/$test - offset=$2 - cancel_lru_locks osc + test=$1 + file=$DIR/$test + offset=$2 + cancel_lru_locks $OSC stop_writeback # prime the file with 0,EOF PW to match touch $file $TRUNCATE $file 0 sync; sync # now the real test.. - dd if=/dev/zero of=$file bs=1024 count=100 - BEFOREWRITES=`count_ost_writes` - $TRUNCATE $file $offset - cancel_lru_locks osc - AFTERWRITES=`count_ost_writes` + dd if=/dev/zero of=$file bs=1024 count=100 + BEFOREWRITES=`count_ost_writes` + $TRUNCATE $file $offset + cancel_lru_locks $OSC + AFTERWRITES=`count_ost_writes` start_writeback } @@ -3830,6 +3945,7 @@ test_43a() { cp -p multiop $DIR/$tdir/multiop MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c || error "multiop open $TMP/$tfile.junk failed" + rm $TMP/$tfile.junk # delete junk file on close (not part of test) MULTIOP_PID=$! $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success" kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed" @@ -3844,6 +3960,7 @@ test_43b() { cp -p multiop $DIR/$tdir/multiop MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c || error "multiop open $TMP/$tfile.junk failed" + rm $TMP/$tfile.junk # delete junk file on close (not part of test) MULTIOP_PID=$! $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success" kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed" @@ -3912,7 +4029,7 @@ run_test 44a "test sparse pwrite ===============================" dirty_osc_total() { tot=0 - for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do + for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do tot=$(($tot + $d)) done echo $tot @@ -4153,11 +4270,13 @@ test_51b() { [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)" && return - trap cleanup_print_lfsdf EXIT + trap cleanup_print_lfs_df EXIT # create files - createmany -d $dir/d $nrdirs || + createmany -d $dir/d $nrdirs || { + unlinkmany $dir/d $nrdirs error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir" + } # really created : nrdirs=$(ls -U $dir | wc -l) @@ -4266,8 +4385,10 @@ test_51f() { echo "left ulimit at $ulimit_old" fi - createmany -o -k -t 120 $DIR/$tdir/f $numfree || + createmany -o -k -t 120 $DIR/$tdir/f $numfree || { + unlinkmany $DIR/$tdir/f $numfree error "create+open $numfree files in $DIR/$tdir failed" + } ulimit -n $ulimit_old # if createmany exits at 120s there will be fewer than $numfree files @@ -4468,107 +4589,117 @@ test_54e() { } run_test 54e "console/tty device works in lustre ======================" -#The test_55 used to be iopen test and it was removed by bz#24037. -#run_test 55 "check iopen_connect_dentry() ======================" - -test_56a() { # was test_56 - rm -rf $DIR/$tdir - $SETSTRIPE -d $DIR - test_mkdir -p $DIR/$tdir/dir - NUMFILES=3 - NUMFILESx2=$(($NUMFILES * 2)) - for i in $(seq 1 $NUMFILES); do - touch $DIR/$tdir/file$i - touch $DIR/$tdir/dir/file$i - done +test_56a() { + local numfiles=3 + local dir=$DIR/$tdir + + rm -rf $dir + test_mkdir -p $dir/dir + for i in $(seq $numfiles); do + touch $dir/file$i + touch $dir/dir/file$i + done + + local numcomp=$($LFS getstripe --component-count $dir) + + [[ $numcomp == 0 ]] && numcomp=1 + + # test lfs getstripe with --recursive + local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx") - # test lfs getstripe with --recursive - FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx) - [[ $FILENUM -eq $NUMFILESx2 ]] || - error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2" - FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx) - [[ $FILENUM -eq $NUMFILES ]] || - error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES" - echo "$GETSTRIPE --recursive passed." + [[ $filenum -eq $((numfiles * 2)) ]] || + error "$LFS getstripe -r: found $filenum != $((numfiles * 2))" + filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx") + [[ $filenum -eq $numfiles ]] || + error "$LFS getstripe $dir: found $filenum, not $numfiles" + echo "$LFS getstripe showed obdidx or l_ost_idx" # test lfs getstripe with file instead of dir - FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx) - [[ $FILENUM -eq 1 ]] || - error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1" - echo "$GETSTRIPE file1 passed." + filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx") + [[ $filenum -eq 1 ]] || + error "$LFS getstripe $dir/file1: found $filenum, not 1" + echo "$LFS getstripe file1 passed" #test lfs getstripe with --verbose - [[ $($GETSTRIPE --verbose $DIR/$tdir | - grep -c lmm_magic) -eq $NUMFILES ]] || - error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES" - [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] || - error "$GETSTRIPE $DIR/$tdir: showed lmm_magic" + filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic) + [[ $filenum -eq $((numfiles * numcomp)) ]] || + error "$LFS getstripe --verbose $dir: "\ + "got $filenum want $((numfiles * numcomp)) lmm_magic" + [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] || + error "$LFS getstripe $dir: showed lmm_magic" #test lfs getstripe with -v prints lmm_fid - [[ $($GETSTRIPE -v $DIR/$tdir | grep -c lmm_fid) -eq $NUMFILES ]] || - error "$GETSTRIPE -v $DIR/$tdir: want $NUMFILES lmm_fid: lines" - [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_fid) -eq 0 ]] || - error "$GETSTRIPE $DIR/$tdir: showed lmm_fid" - echo "$GETSTRIPE --verbose passed." + filenum=$($LFS getstripe -v $dir | grep -c lmm_fid) + [[ $filenum -eq $((numfiles * numcomp)) ]] || + error "$LFS getstripe -v $dir: "\ + "got $filenum want $((numfiles * numcomp)) lmm_fid" + [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] || + error "$LFS getstripe $dir: showed lmm_fid by default" + echo "$LFS getstripe --verbose passed" #check for FID information - local fid1=$($GETSTRIPE --fid $DIR/$tdir/file1) - local fid2=$($GETSTRIPE --verbose $DIR/$tdir/file1 | - awk '/lmm_fid: / { print $2 }') - local fid3=$($LFS path2fid $DIR/$tdir/file1) + local fid1=$($LFS getstripe --fid $dir/file1) + local fid2=$($LFS getstripe --verbose $dir/file1 | + awk '/lmm_fid: / { print $2; exit; }') + local fid3=$($LFS path2fid $dir/file1) + [ "$fid1" != "$fid2" ] && - error "getstripe --fid $fid1 != getstripe --verbose $fid2" + error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'" [ "$fid1" != "$fid3" ] && - error "getstripe --fid $fid1 != lfs path2fid $fid3" - echo "$GETSTRIPE --fid passed." + error "getstripe --fid '$fid1' != lfs path2fid '$fid3'" + echo "$LFS getstripe --fid passed" #test lfs getstripe with --obd - $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 | - grep -q "unknown obduuid" || - error "$GETSTRIPE --obd wrong_uuid should return error message" + $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" || + error "$LFS getstripe --obd wrong_uuid: should return error" [[ $OSTCOUNT -lt 2 ]] && - skip_env "skipping other $GETSTRIPE --obd test" && return - - OSTIDX=1 - OBDUUID=$(ostuuid_from_index $OSTIDX) - FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l) - FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l) - [[ $FOUND -eq $FILENUM ]] || - error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM" - [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir | - sed '/^[ ]*'${OSTIDX}'[ ]/d' | + skip_env "skip '$LFS getstripe --obd' tests: $OSTCOUNT < 2" && + return + + local ostidx=1 + local obduuid=$(ostuuid_from_index $ostidx) + local found=$($LFS getstripe -r --obd $obduuid $dir | + egrep -c "obdidx|l_ost_idx") + + filenum=$($LFS getstripe -ir $dir | grep "^$ostidx\$" | wc -l) + [[ $found -eq $filenum ]] || + error "$LFS getstripe --obd: found $found expect $filenum" + [[ $($LFS getstripe -r -v --obd $obduuid $dir | + sed '/^[ ]*'${ostidx}'[ ]/d' | sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] || - error "$GETSTRIPE --obd: should not show file on other obd" - echo "$GETSTRIPE --obd passed" + error "$LFS getstripe --obd: should not show file on other obd" + echo "$LFS getstripe --obd passed" } -run_test 56a "check $GETSTRIPE" +run_test 56a "check $LFS getstripe" test_56b() { - test_mkdir $DIR/$tdir - NUMDIRS=3 - for i in $(seq 1 $NUMDIRS); do - test_mkdir $DIR/$tdir/dir$i + local dir=$DIR/$tdir + local numdirs=3 + + test_mkdir $dir + for i in $(seq $numdirs); do + test_mkdir $dir/dir$i done # test lfs getdirstripe default mode is non-recursion, which is # different from lfs getstripe - dircnt=$($LFS getdirstripe $DIR/$tdir | grep -c lmv_stripe_count) + local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count) + [[ $dircnt -eq 1 ]] || error "$LFS getdirstripe: found $dircnt, not 1" - dircnt=$($LFS getdirstripe --recursive $DIR/$tdir | + dircnt=$($LFS getdirstripe --recursive $dir | grep -c lmv_stripe_count) - [[ $dircnt -eq $((NUMDIRS + 1)) ]] || - error "$LFS getdirstripe --recursive: found $dircnt, \ - not $((NUMDIRS + 1))" + [[ $dircnt -eq $((numdirs + 1)) ]] || + error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))" } run_test 56b "check $LFS getdirstripe" test_56c() { local ost_idx=0 local ost_name=$(ostname_from_index $ost_idx) - local old_status=$(ost_dev_status $ost_idx) + [[ -z "$old_status" ]] || { skip_env "OST $ost_name is in $old_status status"; return 0; } @@ -4576,6 +4707,7 @@ test_56c() { sleep_maxage local new_status=$(ost_dev_status $ost_idx) + [[ "$new_status" = "D" ]] || error "OST $ost_name is in status of '$new_status', not 'D'" @@ -4591,474 +4723,479 @@ run_test 56c "check 'lfs df' showing device status" NUMFILES=3 NUMDIRS=3 setup_56() { - local LOCAL_NUMFILES="$1" - local LOCAL_NUMDIRS="$2" - local MKDIR_PARAMS="$3" - local DIR_STRIPE_PARAMS="$4" - - if [ ! -d "$TDIR" ] ; then - test_mkdir -p $DIR_STRIPE_PARAMS $TDIR - [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR - for i in `seq 1 $LOCAL_NUMFILES` ; do - touch $TDIR/file$i + local local_tdir="$1" + local local_numfiles="$2" + local local_numdirs="$3" + local dir_params="$4" + local dir_stripe_params="$5" + + if [ ! -d "$local_tdir" ] ; then + test_mkdir -p $dir_stripe_params $local_tdir + [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir + for i in $(seq $local_numfiles) ; do + touch $local_tdir/file$i done - for i in `seq 1 $LOCAL_NUMDIRS` ; do - test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i - for j in `seq 1 $LOCAL_NUMFILES` ; do - touch $TDIR/dir$i/file$j + for i in $(seq $local_numdirs) ; do + test_mkdir $dir_stripe_params $local_tdir/dir$i + for j in $(seq $local_numfiles) ; do + touch $local_tdir/dir$i/file$j done done fi } setup_56_special() { - LOCAL_NUMFILES=$1 - LOCAL_NUMDIRS=$2 - setup_56 $1 $2 - if [ ! -e "$TDIR/loop1b" ] ; then - for i in `seq 1 $LOCAL_NUMFILES` ; do - mknod $TDIR/loop${i}b b 7 $i - mknod $TDIR/null${i}c c 1 3 - ln -s $TDIR/file1 $TDIR/link${i}l + local local_tdir=$1 + local local_numfiles=$2 + local local_numdirs=$3 + + setup_56 $local_tdir $local_numfiles $local_numdirs + + if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then + for i in $(seq $local_numfiles) ; do + mknod $local_tdir/loop${i}b b 7 $i + mknod $local_tdir/null${i}c c 1 3 + ln -s $local_tdir/file1 $local_tdir/link${i} done - for i in `seq 1 $LOCAL_NUMDIRS` ; do - mknod $TDIR/dir$i/loop${i}b b 7 $i - mknod $TDIR/dir$i/null${i}c c 1 3 - ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l + for i in $(seq $local_numdirs) ; do + mknod $local_tdir/dir$i/loop${i}b b 7 $i + mknod $local_tdir/dir$i/null${i}c c 1 3 + ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i} done fi } test_56g() { - $SETSTRIPE -d $DIR - - TDIR=$DIR/${tdir}g - setup_56 $NUMFILES $NUMDIRS - - EXPECTED=$(($NUMDIRS + 2)) - # test lfs find with -name - for i in $(seq 1 $NUMFILES) ; do - NUMS=$($LFIND -name "*$i" $TDIR | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "lfs find -name \"*$i\" $TDIR wrong: "\ - "found $NUMS, expected $EXPECTED" - done + local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE + local expected=$(($NUMDIRS + 2)) + + setup_56 $dir $NUMFILES $NUMDIRS + + # test lfs find with -name + for i in $(seq $NUMFILES) ; do + local nums=$($LFS find -name "*$i" $dir | wc -l) + + [ $nums -eq $expected ] || + error "lfs find -name '*$i' $dir wrong: "\ + "found $nums, expected $expected" + done } -run_test 56g "check lfs find -name =============================" +run_test 56g "check lfs find -name" test_56h() { - $SETSTRIPE -d $DIR - - TDIR=$DIR/${tdir}g - setup_56 $NUMFILES $NUMDIRS - - EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES)) - # test lfs find with ! -name - for i in $(seq 1 $NUMFILES) ; do - NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "lfs find ! -name \"*$i\" $TDIR wrong: "\ - "found $NUMS, expected $EXPECTED" - done + local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE + local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES)) + + setup_56 $dir $NUMFILES $NUMDIRS + + # test lfs find with ! -name + for i in $(seq $NUMFILES) ; do + local nums=$($LFS find ! -name "*$i" $dir | wc -l) + + [ $nums -eq $expected ] || + error "lfs find ! -name '*$i' $dir wrong: "\ + "found $nums, expected $expected" + done } run_test 56h "check lfs find ! -name" test_56i() { - tdir=${tdir}i - test_mkdir $DIR/$tdir - UUID=$(ostuuid_from_index 0 $DIR/$tdir) - CMD="$LFIND -ost $UUID $DIR/$tdir" - OUT=$($CMD) - [ -z "$OUT" ] || error "'$CMD' returned directory '$OUT'" + local dir=$DIR/$tdir + + test_mkdir $dir + + local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir" + local out=$($cmd) + + [ -z "$out" ] || error "'$cmd' returned directory '$out'" } run_test 56i "check 'lfs find -ost UUID' skips directories" test_56j() { - TDIR=$DIR/${tdir}g - setup_56_special $NUMFILES $NUMDIRS + local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE + + setup_56_special $dir $NUMFILES $NUMDIRS + + local expected=$((NUMDIRS + 1)) + local cmd="$LFS find -type d $dir" + local nums=$($cmd | wc -l) - EXPECTED=$((NUMDIRS + 1)) - CMD="$LFIND -type d $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" } -run_test 56j "check lfs find -type d =============================" +run_test 56j "check lfs find -type d" test_56k() { - TDIR=$DIR/${tdir}g - setup_56_special $NUMFILES $NUMDIRS + local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE - EXPECTED=$(((NUMDIRS + 1) * NUMFILES)) - CMD="$LFIND -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + setup_56_special $dir $NUMFILES $NUMDIRS + + local expected=$(((NUMDIRS + 1) * NUMFILES)) + local cmd="$LFS find -type f $dir" + local nums=$($cmd | wc -l) + + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" } -run_test 56k "check lfs find -type f =============================" +run_test 56k "check lfs find -type f" test_56l() { - TDIR=$DIR/${tdir}g - setup_56_special $NUMFILES $NUMDIRS + local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE + + setup_56_special $dir $NUMFILES $NUMDIRS + + local expected=$((NUMDIRS + NUMFILES)) + local cmd="$LFS find -type b $dir" + local nums=$($cmd | wc -l) - EXPECTED=$((NUMDIRS + NUMFILES)) - CMD="$LFIND -type b $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" } -run_test 56l "check lfs find -type b =============================" +run_test 56l "check lfs find -type b" test_56m() { - TDIR=$DIR/${tdir}g - setup_56_special $NUMFILES $NUMDIRS + local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE - EXPECTED=$((NUMDIRS + NUMFILES)) - CMD="$LFIND -type c $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + setup_56_special $dir $NUMFILES $NUMDIRS + + local expected=$((NUMDIRS + NUMFILES)) + local cmd="$LFS find -type c $dir" + local nums=$($cmd | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" } -run_test 56m "check lfs find -type c =============================" +run_test 56m "check lfs find -type c" test_56n() { - TDIR=$DIR/${tdir}g - setup_56_special $NUMFILES $NUMDIRS + local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE + setup_56_special $dir $NUMFILES $NUMDIRS + + local expected=$((NUMDIRS + NUMFILES)) + local cmd="$LFS find -type l $dir" + local nums=$($cmd | wc -l) - EXPECTED=$((NUMDIRS + NUMFILES)) - CMD="$LFIND -type l $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" } -run_test 56n "check lfs find -type l =============================" +run_test 56n "check lfs find -type l" test_56o() { - TDIR=$DIR/${tdir}o - setup_56 $NUMFILES $NUMDIRS - utime $TDIR/file1 > /dev/null || error "utime (1)" - utime $TDIR/file2 > /dev/null || error "utime (2)" - utime $TDIR/dir1 > /dev/null || error "utime (3)" - utime $TDIR/dir2 > /dev/null || error "utime (4)" - utime $TDIR/dir1/file1 > /dev/null || error "utime (5)" - dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync - - EXPECTED=4 - NUMS=`$LFIND -mtime +0 $TDIR | wc -l` - [ $NUMS -eq $EXPECTED ] || \ - error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED" - - EXPECTED=12 - CMD="$LFIND -mtime 0 $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" -} -run_test 56o "check lfs find -mtime for old files ==========================" + local dir=$DIR/$tdir + + setup_56 $dir $NUMFILES $NUMDIRS + utime $dir/file1 > /dev/null || error "utime (1)" + utime $dir/file2 > /dev/null || error "utime (2)" + utime $dir/dir1 > /dev/null || error "utime (3)" + utime $dir/dir2 > /dev/null || error "utime (4)" + utime $dir/dir1/file1 > /dev/null || error "utime (5)" + dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync + + local expected=4 + local nums=$($LFS find -mtime +0 $dir | wc -l) + + [ $nums -eq $expected ] || + error "lfs find -mtime +0 $dir: found $nums expect $expected" + + expected=12 + cmd="$LFS find -mtime 0 $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" +} +run_test 56o "check lfs find -mtime for old files" test_56p() { [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return - TDIR=$DIR/${tdir}p - setup_56 $NUMFILES $NUMDIRS + local dir=$DIR/$tdir + + setup_56 $dir $NUMFILES $NUMDIRS + chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed" - chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed" - EXPECTED=$NUMFILES - CMD="$LFIND -uid $RUNAS_ID $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || \ - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + local expected=$NUMFILES + local cmd="$LFS find -uid $RUNAS_ID $dir" + local nums=$($cmd | wc -l) - EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1)) - CMD="$LFIND ! -uid $RUNAS_ID $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || \ - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" + + expected=$(((NUMFILES + 1) * NUMDIRS + 1)) + cmd="$LFS find ! -uid $RUNAS_ID $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" } -run_test 56p "check lfs find -uid and ! -uid ===============================" +run_test 56p "check lfs find -uid and ! -uid" test_56q() { [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return - TDIR=$DIR/${tdir}q - setup_56 $NUMFILES $NUMDIRS + local dir=$DIR/$tdir + + setup_56 $dir $NUMFILES $NUMDIRS + chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed" - chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed" + local expected=$NUMFILES + local cmd="$LFS find -gid $RUNAS_GID $dir" + local nums=$($cmd | wc -l) - EXPECTED=$NUMFILES - CMD="$LFIND -gid $RUNAS_GID $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" - EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1)) - CMD="$LFIND ! -gid $RUNAS_GID $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + expected=$(( ($NUMFILES+1) * $NUMDIRS + 1)) + cmd="$LFS find ! -gid $RUNAS_GID $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" } -run_test 56q "check lfs find -gid and ! -gid ===============================" +run_test 56q "check lfs find -gid and ! -gid" test_56r() { - TDIR=$DIR/${tdir}r - setup_56 $NUMFILES $NUMDIRS - - EXPECTED=12 - CMD="$LFIND -size 0 -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" - EXPECTED=0 - CMD="$LFIND ! -size 0 -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" - echo "test" > $TDIR/$tfile - echo "test2" > $TDIR/$tfile.2 && sync - EXPECTED=1 - CMD="$LFIND -size 5 -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" - EXPECTED=1 - CMD="$LFIND -size +5 -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" - EXPECTED=2 - CMD="$LFIND -size +0 -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" - EXPECTED=2 - CMD="$LFIND ! -size -5 -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" - EXPECTED=12 - CMD="$LFIND -size -5 -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" -} -run_test 56r "check lfs find -size works ==========================" - -test_56s() { # LU-611 - TDIR=$DIR/${tdir}s - - #LU-9369 - setup_56 0 $NUMDIRS - for i in $(seq 1 $NUMDIRS); do - $SETSTRIPE -c $((OSTCOUNT + 1)) $TDIR/dir$i/$tfile + local dir=$DIR/$tdir + + setup_56 $dir $NUMFILES $NUMDIRS + + local expected=12 + local cmd="$LFS find -size 0 -type f $dir" + local nums=$($cmd | wc -l) + + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" + expected=0 + cmd="$LFS find ! -size 0 -type f $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" + echo "test" > $dir/$tfile + echo "test2" > $dir/$tfile.2 && sync + expected=1 + cmd="$LFS find -size 5 -type f $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" + expected=1 + cmd="$LFS find -size +5 -type f $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" + expected=2 + cmd="$LFS find -size +0 -type f $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" + expected=2 + cmd="$LFS find ! -size -5 -type f $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" + expected=12 + cmd="$LFS find -size -5 -type f $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" +} +run_test 56r "check lfs find -size works" + +test_56s() { # LU-611 #LU-9369 + [[ $OSTCOUNT -lt 2 ]] && skip "need at least 2 OSTs" && return 0 + + local dir=$DIR/$tdir + local onestripe=$(((NUMDIRS + 1) * NUMFILES)) + + setup_56 $dir $NUMFILES $NUMDIRS "-c 1" + for i in $(seq $NUMDIRS); do + $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile done - EXPECTED=$NUMDIRS - CMD="$LFIND -c $OSTCOUNT $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || { - $GETSTRIPE -R $TDIR - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" - } - rm -rf $TDIR - setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" - if [[ $OSTCOUNT -gt 1 ]]; then - $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3} - ONESTRIPE=4 - EXTRA=4 - else - ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES)) - EXTRA=0 - fi + local expected=$NUMDIRS + local cmd="$LFS find -c $OSTCOUNT $dir" + local nums=$($cmd | wc -l) - EXPECTED=$(((NUMDIRS + 1) * NUMFILES)) - CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || { - $GETSTRIPE -R $TDIR - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + [ $nums -eq $expected ] || { + $LFS getstripe -R $dir + error "'$cmd' wrong: found $nums, expected $expected" } - EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA)) - CMD="$LFIND -stripe-count +0 -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || { - $GETSTRIPE -R $TDIR - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + expected=$((NUMDIRS + onestripe)) + cmd="$LFS find -stripe-count +0 -type f $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || { + $LFS getstripe -R $dir + error "'$cmd' wrong: found $nums, expected $expected" } - EXPECTED=$ONESTRIPE - CMD="$LFIND -stripe-count 1 -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || { - $GETSTRIPE -R $TDIR - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + expected=$onestripe + cmd="$LFS find -stripe-count 1 -type f $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || { + $LFS getstripe -R $dir + error "'$cmd' wrong: found $nums, expected $expected" } - CMD="$LFIND -stripe-count -2 -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || { - $GETSTRIPE -R $TDIR - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + cmd="$LFS find -stripe-count -2 -type f $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || { + $LFS getstripe -R $dir + error "'$cmd' wrong: found $nums, expected $expected" } - EXPECTED=0 - CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || { - $GETSTRIPE -R $TDIR - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + expected=0 + cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || { + $LFS getstripe -R $dir + error "'$cmd' wrong: found $nums, expected $expected" } } run_test 56s "check lfs find -stripe-count works" -test_56t() { # LU-611 - TDIR=$DIR/${tdir}t +test_56t() { # LU-611 #LU-9369 + local dir=$DIR/$tdir - #LU-9369 - setup_56 0 $NUMDIRS - for i in $(seq 1 $NUMDIRS); do - $SETSTRIPE -S 4M $TDIR/dir$i/$tfile + setup_56 $dir 0 $NUMDIRS + for i in $(seq $NUMDIRS); do + $LFS setstripe -S 4M $dir/dir$i/$tfile done - EXPECTED=$NUMDIRS - CMD="$LFIND -S 4M $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || { - $GETSTRIPE -R $TDIR - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + + local expected=$NUMDIRS + local cmd="$LFS find -S 4M $dir" + local nums=$($cmd | wc -l) + + [ $nums -eq $expected ] || { + $LFS getstripe -R $dir + error "'$cmd' wrong: found $nums, expected $expected" } - rm -rf $TDIR - - setup_56 $NUMFILES $NUMDIRS "--stripe-size 512k" - - $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3} - - EXPECTED=$(((NUMDIRS + 1) * NUMFILES)) - CMD="$LFIND -stripe-size 512k -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" - - CMD="$LFIND -stripe-size +320k -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" - - EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4)) - CMD="$LFIND -stripe-size +200k -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" - - CMD="$LFIND -stripe-size -640k -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" - - EXPECTED=4 - CMD="$LFIND -stripe-size 256k -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" - - CMD="$LFIND -stripe-size -320k -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" - - EXPECTED=0 - CMD="$LFIND -stripe-size 1024k -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + rm -rf $dir + + setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k" + + $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3} + + expected=$(((NUMDIRS + 1) * NUMFILES)) + cmd="$LFS find -stripe-size 512k -type f $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" + + cmd="$LFS find -stripe-size +320k -type f $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" + + expected=$(((NUMDIRS + 1) * NUMFILES + 4)) + cmd="$LFS find -stripe-size +200k -type f $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" + + cmd="$LFS find -stripe-size -640k -type f $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" + + expected=4 + cmd="$LFS find -stripe-size 256k -type f $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" + + cmd="$LFS find -stripe-size -320k -type f $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" + + expected=0 + cmd="$LFS find -stripe-size 1024k -type f $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" } run_test 56t "check lfs find -stripe-size works" test_56u() { # LU-611 - TDIR=$DIR/${tdir}u - setup_56 $NUMFILES $NUMDIRS "-i 0" + local dir=$DIR/$tdir + + setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1" if [[ $OSTCOUNT -gt 1 ]]; then - $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3} - ONESTRIPE=4 + $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3} + onestripe=4 else - ONESTRIPE=0 + onestripe=0 fi - EXPECTED=$(((NUMDIRS + 1) * NUMFILES)) - CMD="$LFIND -stripe-index 0 -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + local expected=$(((NUMDIRS + 1) * NUMFILES)) + local cmd="$LFS find -stripe-index 0 -type f $dir" + local nums=$($cmd | wc -l) + + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" - EXPECTED=$ONESTRIPE - CMD="$LFIND -stripe-index 1 -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + expected=$onestripe + cmd="$LFS find -stripe-index 1 -type f $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" - CMD="$LFIND ! -stripe-index 0 -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + cmd="$LFS find ! -stripe-index 0 -type f $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" - EXPECTED=0 + expected=0 # This should produce an error and not return any files - CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR" - NUMS=$($CMD 2>/dev/null | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir" + nums=$($cmd 2>/dev/null | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" if [[ $OSTCOUNT -gt 1 ]]; then - EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE)) - CMD="$LFIND -stripe-index 0,1 -type f $TDIR" - NUMS=$($CMD | wc -l) - [ $NUMS -eq $EXPECTED ] || - error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + expected=$(((NUMDIRS + 1) * NUMFILES + onestripe)) + cmd="$LFS find -stripe-index 0,1 -type f $dir" + nums=$($cmd | wc -l) + [ $nums -eq $expected ] || + error "'$cmd' wrong: found $nums, expected $expected" fi } run_test 56u "check lfs find -stripe-index works" test_56v() { - local MDT_IDX=0 + local MDT_IDX=0 + local dir=$DIR/$tdir - TDIR=$DIR/${tdir}v - rm -rf $TDIR - setup_56 $NUMFILES $NUMDIRS + setup_56 $dir $NUMFILES $NUMDIRS - UUID=$(mdtuuid_from_index $MDT_IDX $TDIR) - [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX" + UUID=$(mdtuuid_from_index $MDT_IDX $dir) + [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $MDT_IDX" - for file in $($LFIND -mdt $UUID $TDIR); do - file_mdt_idx=$($GETSTRIPE -M $file) - [ $file_mdt_idx -eq $MDT_IDX ] || - error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)" - done + for file in $($LFS find -mdt $UUID $dir); do + file_mdt_idx=$($LFS getstripe -M $file) + [ $file_mdt_idx -eq $MDT_IDX ] || + error "lfind -mdt $UUID != getstripe -M $file_mdt_idx" + done } run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' =======" test_56w() { [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return [ $PARALLEL == "yes" ] && skip "skip parallel run" && return - TDIR=$DIR/${tdir}w + local dir=$DIR/$tdir - rm -rf $TDIR || error "remove $TDIR failed" - setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1" + setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1" - local stripe_size - stripe_size=$($GETSTRIPE -S -d $TDIR) || - error "$GETSTRIPE -S -d $TDIR failed" + local stripe_size=$($LFS getstripe -S -d $dir) || + error "$LFS getstripe -S -d $dir failed" stripe_size=${stripe_size%% *} local file_size=$((stripe_size * OSTCOUNT)) local file_num=$((NUMDIRS * NUMFILES + NUMFILES)) local required_space=$((file_num * file_size)) - local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail | head -n1) [[ $free_space -le $((required_space / 1024)) ]] && - skip_env "need $required_space bytes, have $free_space KB" && + skip_env "need $required_space, have $free_space kbytes" && return local dd_bs=65536 @@ -5068,14 +5205,15 @@ test_56w() { local i local j local file - for i in $(seq 1 $NUMFILES); do - file=$TDIR/file$i + + for i in $(seq $NUMFILES); do + file=$dir/file$i yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null || error "write data into $file failed" done - for i in $(seq 1 $NUMDIRS); do - for j in $(seq 1 $NUMFILES); do - file=$TDIR/dir$i/file$j + for i in $(seq $NUMDIRS); do + for j in $(seq $NUMFILES); do + file=$dir/dir$i/file$j yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null || error "write data into $file failed" done @@ -5083,83 +5221,302 @@ test_56w() { # $LFS_MIGRATE will fail if hard link migration is unsupported if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then - createmany -l$TDIR/dir1/file1 $TDIR/dir1/link 200 || - error "creating links to $TDIR/dir1/file1 failed" + createmany -l$dir/dir1/file1 $dir/dir1/link 200 || + error "creating links to $dir/dir1/file1 failed" fi local expected=-1 + [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1)) # lfs_migrate file - local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1" + local cmd="$LFS_MIGRATE -y -c $expected $dir/file1" + echo "$cmd" eval $cmd || error "$cmd failed" - check_stripe_count $TDIR/file1 $expected + check_stripe_count $dir/file1 $expected if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ]; then # lfs_migrate file onto OST 0 if it is on OST 1, or onto # OST 1 if it is on OST 0. This file is small enough to # be on only one stripe. - file=$TDIR/migr_1_ost + file=$dir/migr_1_ost dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 || error "write data into $file failed" local obdidx=$($LFS getstripe -i $file) local oldmd5=$(md5sum $file) local newobdidx=0 + [[ $obdidx -eq 0 ]] && newobdidx=1 cmd="$LFS migrate -i $newobdidx $file" echo $cmd eval $cmd || error "$cmd failed" + local realobdix=$($LFS getstripe -i $file) local newmd5=$(md5sum $file) + [[ $newobdidx -ne $realobdix ]] && - error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)" + error "new OST is different (was=$obdidx, "\ + "wanted=$newobdidx, got=$realobdix)" [[ "$oldmd5" != "$newmd5" ]] && error "md5sum differ: $oldmd5, $newmd5" fi - # lfs_migrate dir - cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1" - echo "$cmd" - eval $cmd || error "$cmd failed" + # lfs_migrate dir + cmd="$LFS_MIGRATE -y -c $expected $dir/dir1" + echo "$cmd" + eval $cmd || error "$cmd failed" - for j in $(seq 1 $NUMFILES); do - check_stripe_count $TDIR/dir1/file$j $expected - done + for j in $(seq $NUMFILES); do + check_stripe_count $dir/dir1/file$j $expected + done - # lfs_migrate works with lfs find - cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR | - $LFS_MIGRATE -y -c $expected" - echo "$cmd" - eval $cmd || error "$cmd failed" + # lfs_migrate works with lfs find + cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir | + $LFS_MIGRATE -y -c $expected" + echo "$cmd" + eval $cmd || error "$cmd failed" - for i in $(seq 2 $NUMFILES); do - check_stripe_count $TDIR/file$i $expected - done - for i in $(seq 2 $NUMDIRS); do - for j in $(seq 1 $NUMFILES); do - check_stripe_count $TDIR/dir$i/file$j $expected - done - done + for i in $(seq 2 $NUMFILES); do + check_stripe_count $dir/file$i $expected + done + for i in $(seq 2 $NUMDIRS); do + for j in $(seq $NUMFILES); do + check_stripe_count $dir/dir$i/file$j $expected + done + done } run_test 56w "check lfs_migrate -c stripe_count works" +test_56wb() { + local file1=$DIR/$tdir/file1 + local create_pool=false + local initial_pool=$($LFS getstripe -p $DIR) + local pool_list=() + local pool="" + + echo -n "Creating test dir..." + test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir" + echo "done." + + echo -n "Creating test file..." + touch $file1 || error "cannot create file" + echo "done." + + echo -n "Detecting existing pools..." + pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2)) + + if [ ${#pool_list[@]} -gt 0 ]; then + echo "${pool_list[@]}" + for thispool in "${pool_list[@]}"; do + if [[ -z "$initial_pool" || + "$initial_pool" != "$thispool" ]]; then + pool="$thispool" + echo "Using existing pool '$pool'" + break + fi + done + else + echo "none detected." + fi + if [ -z "$pool" ]; then + pool=${POOL:-testpool} + [ "$initial_pool" = "$pool" ] && pool="testpool2" + echo -n "Creating pool '$pool'..." + create_pool=true + pool_add $pool &> /dev/null || + error "pool_add failed" + echo "done." + + echo -n "Adding target to pool..." + pool_add_targets $pool 0 0 1 &> /dev/null || + error "pool_add_targets failed" + echo "done." + fi + + echo -n "Setting pool using -p option..." + $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null || + error "migrate failed rc = $?" + echo "done." + + echo -n "Verifying test file is in pool after migrating..." + [ "$($LFS getstripe -p $file1)" = $pool ] || + error "file was not migrated to pool $pool" + echo "done." + + echo -n "Removing test file from pool '$pool'..." + $LFS migrate $file1 &> /dev/null || + error "cannot remove from pool" + [ "$($LFS getstripe -p $file1)" ] && + error "pool still set" + echo "done." + + echo -n "Setting pool using --pool option..." + $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null || + error "migrate failed rc = $?" + echo "done." + + # Clean up + rm -f $file1 + if $create_pool; then + destroy_test_pools 2> /dev/null || + error "destroy test pools failed" + fi +} +run_test 56wb "check lfs_migrate pool support" + +test_56wc() { + local file1="$DIR/$tdir/file 1" + + echo -n "Creating test dir..." + test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir" + $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null || + error "cannot set stripe" + echo "done" + + echo -n "Setting initial stripe for test file..." + $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null || + error "cannot set stripe" + [ $($LFS getstripe -S "$file1") -eq 524288 ] || + error "stripe size not set" + echo "done." + + # File currently set to -S 512K -c 1 + + # Ensure -c and -S options are rejected when -R is set + echo -n "Verifying incompatible options are detected..." + $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null && + error "incompatible -c and -R options not detected" + $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null && + error "incompatible -S and -R options not detected" + echo "done." + + # Ensure unrecognized options are passed through to 'lfs migrate' + echo -n "Verifying -S option is passed through to lfs migrate..." + $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null || + error "migration failed" + [ $($LFS getstripe -S "$file1") -eq 1048576 ] || + error "file was not restriped" + echo "done." + + # File currently set to -S 1M -c 1 + + # Ensure long options are supported + echo -n "Verifying long options supported..." + $LFS_MIGRATE -y --non-block "$file1" &> /dev/null || + error "long option without argument not supported" + $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null || + error "long option with argument not supported" + [ $($LFS getstripe -S "$file1") -eq 524288 ] || + error "file not restriped with --stripe-size option" + echo "done." + + # File currently set to -S 512K -c 1 + + if [ "$OSTCOUNT" -gt 1 ]; then + echo -n "Verifying explicit stripe count can be set..." + $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null || + error "migrate failed" + [ $($LFS getstripe -c "$file1") -eq 2 ] || + error "file not restriped to explicit count" + echo "done." + fi + + # File currently set to -S 512K -c 1 or -S 512K -c 2 + + # Ensure parent striping is used if -R is set, and no stripe + # count or size is specified + echo -n "Setting stripe for parent directory..." + $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null || + error "cannot set stripe" + echo "done." + + echo -n "Verifying restripe option uses parent stripe settings..." + $LFS_MIGRATE -y -R "$file1" &> /dev/null || + error "migrate failed" + [ $($LFS getstripe -S "$file1") -eq 1048576 ] || + error "file not restriped to parent settings" + [ $($LFS getstripe -c "$file1") -eq 1 ] || + error "file not restriped to parent settings" + echo "done." + + # File currently set to -S 1M -c 1 + + # Ensure striping is preserved if -R is not set, and no stripe + # count or size is specified + echo -n "Verifying striping size preserved when not specified..." + $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null || + error "cannot set stripe on parent directory" + $LFS_MIGRATE -y "$file1" &> /dev/null || + error "migrate failed" + [ $($LFS getstripe -S "$file1") -eq 1048576 ] || + error "file was restriped" + echo "done." + + # Ensure file name properly detected when final option has no argument + echo -n "Verifying file name properly detected..." + $LFS_MIGRATE -y "$file1" &> /dev/null || + error "file name interpreted as option argument" + echo "done." + + # Clean up + rm -f "$file1" +} +run_test 56wc "check unrecognized options for lfs_migrate are passed through" + +test_56wd() { + [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return + local file1=$DIR/$tdir/file1 + + echo -n "Creating test dir..." + test_mkdir $DIR/$tdir || error "cannot create dir" + echo "done." + + echo -n "Creating test file..." + touch $file1 + echo "done." + + # Ensure 'lfs migrate' will fail by using a non-existent option, + # and make sure rsync is not called to recover + echo -n "Make sure --no-rsync option works..." + $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 | + grep -q 'refusing to fall back to rsync' || + error "rsync was called with --no-rsync set" + echo "done." + + # Ensure rsync is called without trying 'lfs migrate' first + echo -n "Make sure --rsync option works..." + $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 | + grep -q 'falling back to rsync' && + error "lfs migrate was called with --rsync set" + echo "done." + + echo -n "Make sure --rsync and --no-rsync options are exclusive..." + $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 | + grep -q 'at the same time' || + error "--rsync and --no-rsync accepted concurrently" + echo "done." + + # Clean up + rm -f $file1 +} +run_test 56wd "check lfs_migrate --rsync and --no-rsync work" + test_56x() { check_swap_layouts_support && return 0 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return - local dir0=$DIR/$tdir/$testnum - test_mkdir -p $dir0 - + local dir=$DIR/$tdir local ref1=/etc/passwd - local file1=$dir0/file1 + local file1=$dir/file1 - $SETSTRIPE -c 2 $file1 + test_mkdir $dir || error "creating dir $dir" + $LFS setstripe -c 2 $file1 cp $ref1 $file1 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?" - stripe=$($GETSTRIPE -c $file1) + stripe=$($LFS getstripe -c $file1) [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1" cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1" @@ -5172,16 +5529,19 @@ test_56xa() { check_swap_layouts_support && return 0 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return - local dir0=$DIR/$tdir/$testnum - test_mkdir -p $dir0 + local dir=$DIR/$tdir/$testnum + + test_mkdir -p $dir local ref1=/etc/passwd - local file1=$dir0/file1 + local file1=$dir/file1 - $SETSTRIPE -c 2 $file1 + $LFS setstripe -c 2 $file1 cp $ref1 $file1 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?" - local stripe=$($GETSTRIPE -c $file1) + + local stripe=$($LFS getstripe -c $file1) + [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1" cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1" @@ -5190,34 +5550,143 @@ test_56xa() { } run_test 56xa "lfs migration --block support" +check_migrate_links() { + local dir="$1" + local file1="$dir/file1" + local begin="$2" + local count="$3" + local total_count=$(($begin + $count - 1)) + local symlink_count=10 + local uniq_count=10 + + if [ ! -f "$file1" ]; then + echo -n "creating initial file..." + $LFS setstripe -c 1 -S "512k" "$file1" || + error "cannot setstripe initial file" + echo "done" + + echo -n "creating symlinks..." + for s in $(seq 1 $symlink_count); do + ln -s "$file1" "$dir/slink$s" || + error "cannot create symlinks" + done + echo "done" + + echo -n "creating nonlinked files..." + createmany -o "$dir/uniq" 1 10 &> /dev/null || + error "cannot create nonlinked files" + echo "done" + fi + + # create hard links + if [ ! -f "$dir/file$total_count" ]; then + echo -n "creating hard links $begin:$total_count..." + createmany -l"$file1" "$dir/file" "$begin" "$count" &> \ + /dev/null || error "cannot create hard links" + echo "done" + fi + + echo -n "checking number of hard links listed in xattrs..." + local fid=$($LFS getstripe -F "$file1") + local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null)) + + echo "${#paths[*]}" + if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then + echo "hard link list has unexpected size, skipping test" + return 0 + fi + if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then + error "link names should exceed xattrs size" + fi + + echo -n "migrating files..." + local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir) + local rc=$? + [ $rc -eq 0 ] || error "migrate failed rc = $rc" + echo "done" + + # make sure all links have been properly migrated + echo -n "verifying files..." + fid=$($LFS getstripe -F "$file1") || + error "cannot get fid for file $file1" + for i in $(seq 2 $total_count); do + local fid2=$($LFS getstripe -F $dir/file$i) + + [ "$fid2" == "$fid" ] || + error "migrated hard link has mismatched FID" + done + + # make sure hard links were properly detected, and migration was + # performed only once for the entire link set; nonlinked files should + # also be migrated + local actual=$(grep -c 'done migrate' <<< "$migrate_out") + local expected=$(($uniq_count + 1)) + + [ "$actual" -eq "$expected" ] || + error "hard links individually migrated ($actual != $expected)" + + # make sure the correct number of hard links are present + local hardlinks=$(stat -c '%h' "$file1") + + [ $hardlinks -eq $total_count ] || + error "num hard links $hardlinks != $total_count" + echo "done" + + return 0 +} + +test_56xb() { + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] && + skip "Need MDS version at least 2.10.55" && return + + local dir="$DIR/$tdir" + + test_mkdir "$dir" || error "cannot create dir $dir" + + echo "testing lfs migrate mode when all links fit within xattrs" + LFS_MIGRATE_RSYNC=false check_migrate_links "$dir" 2 99 + + echo "testing rsync mode when all links fit within xattrs" + LFS_MIGRATE_RSYNC=true check_migrate_links "$dir" 2 99 + + echo "testing lfs migrate mode when all links do not fit within xattrs" + LFS_MIGRATE_RSYNC=false check_migrate_links "$dir" 101 100 + + echo "testing rsync mode when all links do not fit within xattrs" + LFS_MIGRATE_RSYNC=true check_migrate_links "$dir" 101 100 + + # clean up + rm -rf $dir +} +run_test 56xb "lfs migration hard link support" + test_56y() { [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] && skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" && return local res="" - local dir0=$DIR/$tdir/$testnum - test_mkdir -p $dir0 - local f1=$dir0/file1 - local f2=$dir0/file2 + local dir=$DIR/$tdir + local f1=$dir/file1 + local f2=$dir/file2 + test_mkdir -p $dir || error "creating dir $dir" touch $f1 || error "creating std file $f1" $MULTIOP $f2 H2c || error "creating released file $f2" # a directory can be raid0, so ask only for files - res=$($LFIND $dir0 -L raid0 -type f | wc -l) + res=$($LFS find $dir -L raid0 -type f | wc -l) [[ $res == 2 ]] || error "search raid0: found $res files != 2" - res=$($LFIND $dir0 \! -L raid0 -type f | wc -l) + res=$($LFS find $dir \! -L raid0 -type f | wc -l) [[ $res == 0 ]] || error "search !raid0: found $res files != 0" # only files can be released, so no need to force file search - res=$($LFIND $dir0 -L released) + res=$($LFS find $dir -L released) [[ $res == $f2 ]] || error "search released: found $res != $f2" - res=$($LFIND $dir0 \! -L released) + res=$($LFS find $dir -type f \! -L released) [[ $res == $f1 ]] || error "search !released: found $res != $f1" - } run_test 56y "lfs find -L raid0|released" @@ -5228,18 +5697,22 @@ test_56z() { # LU-4824 # errors out # - If errors are encountered during the search, it should not terminate # early + local dir=$DIR/$tdir local i - test_mkdir $DIR/$tdir + + test_mkdir $dir for i in d{0..9}; do - test_mkdir $DIR/$tdir/$i + test_mkdir $dir/$i done - touch $DIR/$tdir/d{0..9}/$tfile - $LFS find $DIR/non_existent_dir $DIR/$tdir && + touch $dir/d{0..9}/$tfile + $LFS find $DIR/non_existent_dir $dir && error "$LFS find did not return an error" # Make a directory unsearchable. This should NOT be the last entry in # directory order. Arbitrarily pick the 6th entry - chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d') - local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l) + chmod 700 $($LFS find $dir -type d | sed '6!d') + + local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l) + # The user should be able to see 10 directories and 9 files [ $count == 19 ] || error "$LFS find did not continue after error" } @@ -5248,30 +5721,168 @@ run_test 56z "lfs find should continue after an error" test_56aa() { # LU-5937 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return - mkdir $DIR/$tdir - $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir + local dir=$DIR/$tdir + + mkdir $dir + $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir - createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024 - local dirs=$(lfs find --size +8k $DIR/$tdir/) + createmany -o $dir/striped_dir/${tfile}- 1024 + local dirs=$(lfs find --size +8k $dir/) [ -n "$dirs" ] || error "lfs find --size wrong under striped dir" } run_test 56aa "lfs find --size under striped dir" -test_57a() { - [ $PARALLEL == "yes" ] && skip "skip parallel run" && return - # note test will not do anything if MDS is not local - if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then - skip "ldiskfs only test" - return - fi +test_56ba() { + # Create composite files with one component + local dir=$DIR/$tdir - remote_mds_nodsh && skip "remote MDS with nodsh" && return - local MNTDEV="osd*.*MDT*.mntdev" - DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV) - [ -z "$DEV" ] && error "can't access $MNTDEV" - for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do - do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump || + setup_56 $dir/1Mfiles 5 1 "--component-end 1M" + # Create composite files with three components + setup_56 $dir/2Mfiles 5 2 "-E 2M -E 4M -E 6M" + # Create non-composite files + createmany -o $dir/${tfile}- 10 + + local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l) + + [[ $nfiles == 10 ]] || + error "lfs find -E 1M found $nfiles != 10 files" + + nfiles=$($LFS find ! -E 1M --type f $dir | wc -l) + [[ $nfiles == 25 ]] || + error "lfs find ! -E 1M found $nfiles != 25 files" + + # All files have a component that starts at 0 + nfiles=$($LFS find --component-start 0 --type f $dir | wc -l) + [[ $nfiles == 35 ]] || + error "lfs find --component-start 0 - $nfiles != 35 files" + + nfiles=$($LFS find --component-start 2M --type f $dir | wc -l) + [[ $nfiles == 15 ]] || + error "lfs find --component-start 2M - $nfiles != 15 files" + + # All files created here have a componenet that does not starts at 2M + nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l) + [[ $nfiles == 35 ]] || + error "lfs find ! --component-start 2M - $nfiles != 35 files" + + # Find files with a specified number of components + local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l) + [[ $nfiles == 15 ]] || + error "lfs find --component-count 3 - $nfiles != 15 files" + + # Remember non-composite files have a component count of zero + local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l) + [[ $nfiles == 10 ]] || + error "lfs find --component-count 0 - $nfiles != 10 files" + + nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l) + [[ $nfiles == 20 ]] || + error "lfs find ! --component-count 3 - $nfiles != 20 files" + + # All files have a flag called "init" + local nfiles=$($LFS find --component-flags init --type f $dir | wc -l) + [[ $nfiles == 35 ]] || + error "lfs find --component-flags init - $nfiles != 35 files" + + # Multi-component files will have a component not initialized + local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l) + [[ $nfiles == 15 ]] || + error "lfs find !--component-flags init - $nfiles != 15 files" + + rm -rf $dir + +} +run_test 56ba "test lfs find --component-end, -start, -count, and -flags" + +test_56ca() { + [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.57) ]] || + { skip "Need MDS version at least 2.10.57"; return 0; } + + local td=$DIR/$tdir + local tf=$td/$tfile + local dir + local nfiles + local cmd + local i + local j + + # create mirrored directories and mirrored files + mkdir $td || error "mkdir $td failed" + $LFS mirror create -N3 $td || error "create mirrored dir $td failed" + createmany -o $tf- 10 || error "create $tf- failed" + + for i in $(seq 2); do + dir=$td/dir$i + mkdir $dir || error "mkdir $dir failed" + $LFS mirror create -N$((3 + i)) $dir || + error "create mirrored dir $dir failed" + createmany -o $dir/$tfile- 10 || + error "create $dir/$tfile- failed" + done + + # change the states of some mirrored files + echo foo > $tf-6 + for i in $(seq 2); do + dir=$td/dir$i + for j in $(seq 4 9); do + echo foo > $dir/$tfile-$j + done + done + + # find mirrored files with specific mirror count + cmd="$LFS find --mirror-count 3 --type f $td" + nfiles=$($cmd | wc -l) + [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files" + + cmd="$LFS find ! --mirror-count 3 --type f $td" + nfiles=$($cmd | wc -l) + [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files" + + cmd="$LFS find --mirror-count +2 --type f $td" + nfiles=$($cmd | wc -l) + [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files" + + cmd="$LFS find --mirror-count -6 --type f $td" + nfiles=$($cmd | wc -l) + [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files" + + # find mirrored files with specific file state + cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td" + [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6" + + cmd="$LFS find --mirror-state=ro --type f $td" + nfiles=$($cmd | wc -l) + [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files" + + cmd="$LFS find ! --mirror-state=ro --type f $td" + nfiles=$($cmd | wc -l) + [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files" + + cmd="$LFS find --mirror-state=wp --type f $td" + nfiles=$($cmd | wc -l) + [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files" + + cmd="$LFS find ! --mirror-state=sp --type f $td" + nfiles=$($cmd | wc -l) + [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files" +} +run_test 56ca "check lfs find --mirror-count|-N and --mirror-state" + +test_57a() { + [ $PARALLEL == "yes" ] && skip "skip parallel run" && return + # note test will not do anything if MDS is not local + if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then + skip "ldiskfs only test" + return + fi + + remote_mds_nodsh && skip "remote MDS with nodsh" && return + local MNTDEV="osd*.*MDT*.mntdev" + DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV) + [ -z "$DEV" ] && error "can't access $MNTDEV" + for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do + do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump || error "can't access $DEV" DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump) [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE" @@ -5610,6 +6221,95 @@ test_64c() { } run_test 64c "verify grant shrink" +# this does exactly what osc_request.c:osc_announce_cached() does in +# order to calculate max amount of grants to ask from server +want_grant() { + local tgt=$1 + + local page_size=$(get_page_size client) + + local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc) + local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight) + + ((rpc_in_flight ++)); + nrpages=$((nrpages * rpc_in_flight)) + + local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb) + + dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / page_size)) + + [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages + local undirty=$((nrpages * page_size)) + + local max_extent_pages + max_extent_pages=$($LCTL get_param osc.${tgt}.import | + grep grant_max_extent_size | awk '{print $2}') + max_extent_pages=$((max_extent_pages / page_size)) + local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages)) + local grant_extent_tax + grant_extent_tax=$($LCTL get_param osc.${tgt}.import | + grep grant_extent_tax | awk '{print $2}') + + undirty=$((undirty + nrextents * grant_extent_tax)) + + echo $undirty +} + +# this is size of unit for grant allocation. It should be equal to +# what tgt_grant.c:tgt_grant_chunk() calculates +grant_chunk() { + local tgt=$1 + local max_brw_size + local grant_extent_tax + + max_brw_size=$($LCTL get_param osc.${tgt}.import | + grep max_brw_size | awk '{print $2}') + + grant_extent_tax=$($LCTL get_param osc.${tgt}.import | + grep grant_extent_tax | awk '{print $2}') + + echo $(((max_brw_size + grant_extent_tax) * 2)) +} + +test_64d() { + [ $(lustre_version_code ost1) -lt $(version_code 2.10.56) ] && + skip "OST < 2.10.55 doesn't limit grants enough" && return 0 + + local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}') + + [[ $($LCTL get_param osc.${tgt}.import | + grep "connect_flags:.*grant_param") ]] || \ + { skip "no grant_param connect flag"; return; } + + local olddebug=$($LCTL get_param -n debug 2> /dev/null) + + $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true + + local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt))) + + $SETSTRIPE $DIR/$tfile -i 0 -c 1 + dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 & + ddpid=$! + + while true + do + local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes) + if [[ $cur_grant -gt $max_cur_granted ]] + then + kill $ddpid + error "cur_grant $cur_grant > $max_cur_granted" + fi + kill -0 $ddpid + [[ $? -ne 0 ]] && break; + sleep 2 + done + + rm -f $DIR/$tfile + wait_delete_completed + $LCTL set_param debug="$olddebug" 2> /dev/null || true +} +run_test 64d "check grant limit exceed" + # bug 1414 - set/get directories' stripe info test_65a() { [ $PARALLEL == "yes" ] && skip "skip parallel run" && return @@ -5710,42 +6410,55 @@ test_65h() { } run_test 65h "directory stripe info inherit ====================" -test_65i() { # bug6367 +test_65i() { [ $PARALLEL == "yes" ] && skip "skip parallel run" && return - $SETSTRIPE -S 65536 -c -1 $MOUNT -} -run_test 65i "set non-default striping on root directory (bug 6367)=" -test_65ia() { # bug12836 - [ $PARALLEL == "yes" ] && skip "skip parallel run" && return - $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed" -} -run_test 65ia "getstripe on -1 default directory striping" + save_layout_restore_at_exit $MOUNT -test_65ib() { # bug12836 - [ $PARALLEL == "yes" ] && skip "skip parallel run" && return - $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed" -} -run_test 65ib "getstripe -v on -1 default directory striping" + # bug6367: set non-default striping on root directory + $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe" -test_65ic() { # bug12836 - [ $PARALLEL == "yes" ] && skip "skip parallel run" && return + # bug12836: getstripe on -1 default directory striping + $LFS getstripe $MOUNT || error "getstripe $MOUNT failed" + + # bug12836: getstripe -v on -1 default directory striping + $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed" + + # bug12836: new find on -1 default directory striping $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed" } -run_test 65ic "new find on -1 default directory striping" +run_test 65i "various tests to set root directory striping" test_65j() { # bug6367 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return + sync; sleep 1 + # if we aren't already remounting for each test, do so for this test if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then cleanup || error "failed to unmount" setup fi + + save_layout_restore_at_exit $MOUNT + $SETSTRIPE -d $MOUNT || error "setstripe failed" } run_test 65j "set default striping on root directory (bug 6367)=" +cleaup_65k() { + rm -rf $DIR/$tdir + wait_delete_completed + do_facet $SINGLEMDS "lctl set_param -n \ + osp.$ost*MDT0000.max_create_count=$max_count" + do_facet $SINGLEMDS "lctl set_param -n \ + osp.$ost*MDT0000.create_count=$count" + do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate + echo $INACTIVE_OSC "is Activate" + + wait_osc_import_state mds ost$ostnum FULL +} + test_65k() { # bug11679 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return @@ -5789,7 +6502,8 @@ test_65k() { # bug11679 [ -f $DIR/$tdir/$idx ] && continue echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx" $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx || - error "setstripe $idx should succeed" + { cleanup_65k; + error "setstripe $idx should succeed"; } rm -f $DIR/$tdir/$idx || error "rm $idx failed" done unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000 @@ -5816,7 +6530,11 @@ test_65l() { # bug 12836 run_test 65l "lfs find on -1 stripe dir ========================" test_65m() { - $RUNAS $SETSTRIPE -c 2 $MOUNT && error "setstripe should fail" + local layout=$(save_layout $MOUNT) + $RUNAS $SETSTRIPE -c 2 $MOUNT && { + restore_layout $MOUNT $layout + error "setstripe should fail by non-root users" + } true } run_test 65m "normal user can't set filesystem default stripe" @@ -6181,7 +6899,7 @@ test_77c() { [[ "$orig_cksum" == "$dump_cksum" ]] || error "dump content does not match on Client" - $check_ost || skip "No need to check cksum dump on OSS" + $check_ost || { skip "No need to check cksum dump on OSS"; return 0; } # check cksum dump on OSS ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*) @@ -6771,7 +7489,7 @@ test_101e() { done echo "Cancel LRU locks on lustre client to flush the client cache" - cancel_lru_locks osc + cancel_lru_locks $OSC echo "Reset readahead stats" $LCTL set_param -n llite.*.read_ahead_stats 0 @@ -6863,14 +7581,19 @@ test_101g() { local list=$(comma_list $(osts_nodes)) local p="$TMP/$TESTSUITE-$TESTNAME.parameters" local brw_size="obdfilter.*.brw_size" + local ostver=$(lustre_version_code ost1) + local cliver=$(lustre_version_code client) $LFS setstripe -i 0 -c 1 $DIR/$tfile local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1) - if [ $(lustre_version_code ost1) -ge $(version_code 2.8.52) -a \ - $(lustre_version_code client) -ge $(version_code 2.8.52) ]; then - [ $(lustre_version_code ost1) -ge $(version_code 2.9.52) ] && - suffix="M" + if [ $ostver -ge $(version_code 2.8.52) -o \ + \( $ostver -ge $(version_code 2.7.17) -a \ + $ostver -lt $(version_code 2.7.50) \) ] && + [ $cliver -ge $(version_code 2.8.52) -o \ + \( $cliver -ge $(version_code 2.7.17) -a \ + $cliver -lt $(version_code 2.7.50) \) ]; then + [ $ostver -ge $(version_code 2.9.52) ] && suffix="M" if [[ $orig_mb -lt 16 ]]; then save_lustre_params $osts "$brw_size" > $p do_nodes $list $LCTL set_param -n $brw_size=16$suffix || @@ -8326,6 +9049,34 @@ run_test 118m "fdatasync dir =========" [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT +test_118n() +{ + local begin + local end + + [ $PARALLEL == "yes" ] && skip "skip parallel run" && return + remote_ost_nodsh && skip "remote OSTs with nodsh" && return + + # Sleep to avoid a cached response. + #define OBD_STATFS_CACHE_SECONDS 1 + sleep 2 + + # Inject a 10 second delay in the OST_STATFS handler. + #define OBD_FAIL_OST_STATFS_DELAY 0x242 + set_nodes_failloc "$(osts_nodes)" 0x242 + + begin=$SECONDS + stat --file-system $MOUNT > /dev/null + end=$SECONDS + + set_nodes_failloc "$(osts_nodes)" 0 + + if ((end - begin > 20)); then + error "statfs took $((end - begin)) seconds, expected 10" + fi +} +run_test 118n "statfs() sends OST_STATFS requests in parallel" + test_119a() # bug 11737 { BSIZE=$((512 * 1024)) @@ -9154,7 +9905,7 @@ test_129() { check_mds_dmesg '"has reached"' || error_exit "reached message should be output" - [ $has_warning -eq 0 ] && + [ $has_warning = "false" ] && error_exit "warning message should be output" dirsize=$(stat -c%s "$DIR/$tdir") @@ -9201,7 +9952,7 @@ test_130a() { skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return [ $RC != 0 ] && error "filefrag $fm_file failed" - filefrag_op=$(filefrag -ve $fm_file | + filefrag_op=$(filefrag -ve -k $fm_file | sed -n '/ext:/,/found/{/ext:/d; /found/d; p}') lun=$($GETSTRIPE -i $fm_file) @@ -9251,7 +10002,7 @@ test_130b() { error "dd failed on $fm_file" filefrag -ves $fm_file || error "filefrag $fm_file failed" - filefrag_op=$(filefrag -ve $fm_file | + filefrag_op=$(filefrag -ve -k $fm_file | sed -n '/ext:/,/found/{/ext:/d; /found/d; p}') last_lun=$(echo $filefrag_op | cut -d: -f5 | @@ -9310,7 +10061,7 @@ test_130c() { error "dd failed on $fm_file" filefrag -ves $fm_file || error "filefrag $fm_file failed" - filefrag_op=$(filefrag -ve $fm_file | + filefrag_op=$(filefrag -ve -k $fm_file | sed -n '/ext:/,/found/{/ext:/d; /found/d; p}') last_lun=$(echo $filefrag_op | cut -d: -f5 | @@ -9378,7 +10129,7 @@ test_130d() { error "dd failed on $fm_file" filefrag -ves $fm_file || error "filefrag $fm_file failed" - filefrag_op=$(filefrag -ve $fm_file | + filefrag_op=$(filefrag -ve -k $fm_file | sed -n '/ext:/,/found/{/ext:/d; /found/d; p}') last_lun=$(echo $filefrag_op | cut -d: -f5 | @@ -9440,7 +10191,7 @@ test_130e() { done filefrag -ves $fm_file || error "filefrag $fm_file failed" - filefrag_op=$(filefrag -ve $fm_file | + filefrag_op=$(filefrag -ve -k $fm_file | sed -n '/ext:/,/found/{/ext:/d; /found/d; p}') last_lun=$(echo $filefrag_op | cut -d: -f5 | @@ -9482,6 +10233,27 @@ test_130e() { } run_test 130e "FIEMAP (test continuation FIEMAP calls)" +test_130f() { + filefrag_op=$(filefrag -e 2>&1 | grep "invalid option") + [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && + return + + local fm_file=$DIR/$tfile + $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c || + error "multiop create with lov_delay_create on $fm_file" + + filefrag -ves $fm_file || error "filefrag $fm_file failed" + filefrag_extents=$(filefrag -vek $fm_file | + awk '/extents? found/ { print $2 }') + if [[ "$filefrag_extents" != "0" ]]; then + error "FIEMAP on $fm_file failed; " \ + "returned $filefrag_extents expected 0" + fi + + rm -f $fm_file +} +run_test 130f "FIEMAP (unstriped file)" + # Test for writev/readv test_131a() { rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || @@ -9842,8 +10614,6 @@ run_test 133e "Verifying OST {read,write}_bytes nid stats =================" proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/" test_133f() { - remote_mds_nodsh && skip "remote MDS with nodsh" && return - remote_ost_nodsh && skip "remote OST with nodsh" && return # First without trusting modes. local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null) echo "proc_dirs='$proc_dirs'" @@ -9853,10 +10623,27 @@ test_133f() { # Second verifying readability. $LCTL get_param -R '*' &> /dev/null || error "proc file read failed" + # Verifing writability with badarea_io. + find $proc_dirs \ + -ignore_readdir_race \ + -type f \ + -not -name force_lbug \ + -not -name changelog_mask \ + -exec badarea_io '{}' \; || + error "find $proc_dirs failed" +} +run_test 133f "Check reads/writes of client lustre proc files with bad area io" + +test_133g() { + remote_mds_nodsh && skip "remote MDS with nodsh" && return + remote_ost_nodsh && skip "remote OST with nodsh" && return + # eventually, this can also be replaced with "lctl get_param -R", # but not until that option is always available on the server local facet for facet in mds1 ost1; do + [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] && + skip "Too old lustre on $facet" && continue local facet_proc_dirs=$(do_facet $facet \ \\\ls -d $proc_regexp 2>/dev/null) echo "${facet}_proc_dirs='$facet_proc_dirs'" @@ -9870,37 +10657,13 @@ test_133f() { -type f \ -exec cat '{}' \\\; &> /dev/null || error "proc file read failed" - done -} -run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc" -test_133g() { - remote_mds_nodsh && skip "remote MDS with nodsh" && return - remote_ost_nodsh && skip "remote OST with nodsh" && return - # Second verifying writability. - local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null) - echo "proc_dirs='$proc_dirs'" - [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME" - find $proc_dirs \ - -type f \ - -not -name force_lbug \ - -not -name changelog_mask \ - -exec badarea_io '{}' \; &> /dev/null || - error "find $proc_dirs failed" - - local facet - for facet in mds1 ost1; do - [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] && - skip "Too old lustre on $facet" && continue - local facet_proc_dirs=$(do_facet $facet \ - \\\ls -d $proc_regexp 2> /dev/null) - echo "${facet}_proc_dirs='$facet_proc_dirs'" - [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet" do_facet $facet find $facet_proc_dirs \ + -ignore_readdir_race \ -type f \ -not -name force_lbug \ -not -name changelog_mask \ - -exec badarea_io '{}' \\\; &> /dev/null || + -exec badarea_io '{}' \\\; || error "$facet find $facet_proc_dirs failed" done @@ -9909,7 +10672,7 @@ test_133g() { setup || error "failed to setup" true } -run_test 133g "Check for Oopses on bad io area writes/reads in /proc" +run_test 133g "Check reads/writes of server lustre proc files with bad area io" test_133h() { remote_mds_nodsh && skip "remote MDS with nodsh" && return @@ -10059,31 +10822,31 @@ test_150() { [ $PARALLEL == "yes" ] && skip "skip parallel run" && return local TF="$TMP/$tfile" - dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed" - cp $TF $DIR/$tfile - cancel_lru_locks osc - cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ" - remount_client $MOUNT - df -P $MOUNT - cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)" + dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed" + cp $TF $DIR/$tfile + cancel_lru_locks $OSC + cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ" + remount_client $MOUNT + df -P $MOUNT + cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)" - $TRUNCATE $TF 6000 - $TRUNCATE $DIR/$tfile 6000 - cancel_lru_locks osc - cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)" + $TRUNCATE $TF 6000 + $TRUNCATE $DIR/$tfile 6000 + cancel_lru_locks $OSC + cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)" - echo "12345" >>$TF - echo "12345" >>$DIR/$tfile - cancel_lru_locks osc - cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)" + echo "12345" >>$TF + echo "12345" >>$DIR/$tfile + cancel_lru_locks $OSC + cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)" - echo "12345" >>$TF - echo "12345" >>$DIR/$tfile - cancel_lru_locks osc - cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)" + echo "12345" >>$TF + echo "12345" >>$DIR/$tfile + cancel_lru_locks $OSC + cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)" - rm -f $TF - true + rm -f $TF + true } run_test 150 "truncate/append tests" @@ -10262,11 +11025,9 @@ dot_lustre_fid_permission_check() { rm -f $test_dir/$tfile.1 echo "truncate fid $fid" $TRUNCATE $ffid 777 || error "truncate $ffid failed." - if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working - echo "link fid $fid" - ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed." - fi - if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then + echo "link fid $fid" + ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed." + if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then echo "setfacl fid $fid" setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed." echo "getfacl fid $fid" @@ -10421,6 +11182,8 @@ test_154a() { dot_lustre_fid_permission_check "$fid" $DIR || error "dot lustre permission check $fid failed" + ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed" + rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked" touch $MOUNT/.lustre/file && @@ -10631,7 +11394,7 @@ test_155_small_load() { dd if=/dev/urandom of=$temp bs=6096 count=1 || \ error "dd of=$temp bs=6096 count=1 failed" cp $temp $file - cancel_lru_locks osc + cancel_lru_locks $OSC cmp $temp $file || error "$temp $file differ" $TRUNCATE $temp 6000 @@ -10933,147 +11696,127 @@ test_156() { log "cache hits:: before: $BEFORE, after: $AFTER" fi - rm -f $file restore_lustre_params < $p - rm -f $p + rm -f $p $file } run_test 156 "Verification of tunables" -#Changelogs -cleanup_changelog () { - trap 0 - echo "Deregistering changelog client $CL_USER" - do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER -} - -err17935 () { - if [[ $MDSCOUNT -gt 1 ]]; then - error_ignore bz17935 $* - else - error $* - fi -} - -changelog_chmask() -{ - local CL_MASK_PARAM="mdd.$MDT0.changelog_mask" - - MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1") - - if [ $MASK -eq 1 ]; then - do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1" - else - do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1" - fi -} - -changelog_extract_field() { - local mdt=$1 - local cltype=$2 - local file=$3 - local identifier=$4 - - $LFS changelog $mdt | gawk "/$cltype.*$file$/ { - print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' | - tail -1 -} - test_160a() { [ $PARALLEL == "yes" ] && skip "skip parallel run" && return remote_mds_nodsh && skip "remote MDS with nodsh" && return [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] || { skip "Need MDS version at least 2.2.0"; return; } - local CL_USERS="mdd.$MDT0.changelog_users" - local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS" - CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \ - changelog_register -n) - echo "Registered as changelog user $CL_USER" - trap cleanup_changelog EXIT - $GET_CL_USERS | grep -q $CL_USER || - error "User $CL_USER not found in changelog_users" + changelog_register || error "changelog_register failed" + local cl_user="${CL_USERS[$SINGLEMDS]%% *}" + changelog_users $SINGLEMDS | grep -q $cl_user || + error "User $cl_user not found in changelog_users" # change something test_mkdir -p $DIR/$tdir/pics/2008/zachy - touch $DIR/$tdir/pics/2008/zachy/timestamp - cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg + changelog_clear 0 || error "changelog_clear failed" + touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1 + cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg rm $DIR/$tdir/pics/desktop.jpg - $LFS changelog $MDT0 | tail -5 + changelog_dump | tail -10 echo "verifying changelog mask" - changelog_chmask "MKDIR" - changelog_chmask "CLOSE" + changelog_chmask "-MKDIR" + changelog_chmask "-CLOSE" - test_mkdir -p $DIR/$tdir/pics/zach/sofia - echo "zzzzzz" > $DIR/$tdir/pics/zach/file + test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged + echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged - changelog_chmask "MKDIR" - changelog_chmask "CLOSE" + changelog_chmask "+MKDIR" + changelog_chmask "+CLOSE" - test_mkdir -p $DIR/$tdir/pics/2008/sofia - echo "zzzzzz" > $DIR/$tdir/pics/zach/file + test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1 + echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3 - $LFS changelog $MDT0 - MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR") - CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE") - [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1" - [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1" + changelog_dump | tail -10 + MKDIRS=$(changelog_dump | grep -c "MKDIR") + CLOSES=$(changelog_dump | grep -c "CLOSE") + [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1" + [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3" # verify contents echo "verifying target fid" - fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=") - fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp) + local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=") + local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile) [ "$fidc" == "$fidf" ] || - err17935 "fid in changelog $fidc != file fid $fidf" + error "changelog '$tfile' fid $fidc != file fid $fidf" echo "verifying parent fid" - fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=") - fidf=$($LFS path2fid $DIR/$tdir/pics/zach) - [ "$fidc" == "$fidf" ] || - err17935 "pfid in changelog $fidc != dir fid $fidf" - - USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}") - $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 5)) - USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}") - echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2" - [ $USER_REC2 == $(($USER_REC1 + 5)) ] || - err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2" - - MIN_REC=$($GET_CL_USERS | - awk 'min == "" || $2 < min {min = $2}; END {print min}') - FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}') - echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC" - [ $FIRST_REC == $(($MIN_REC + 1)) ] || - err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC" + # The FID returned from the Changelog may be the directory shard on + # a different MDT, and not the FID returned by path2fid on the parent. + # Instead of comparing FIDs, verify that fid2path(fidp) is correct, + # since this is what will matter when recreating this file in the tree. + local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=") + local pathp=$($LFS fid2path $MOUNT "$fidp") + [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] || + error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach" + + echo "getting records for $cl_user" + changelog_users $SINGLEMDS + local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user) + local nclr=3 + __changelog_clear $SINGLEMDS $cl_user +$nclr || + error "changelog_clear failed" + local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user) + echo "verifying user clear: $user_rec1 + $nclr == $user_rec2" + [ $user_rec2 == $((user_rec1 + nclr)) ] || + error "user index expect $user_rec1 + $nclr != $user_rec2" + + local min0_rec=$(changelog_users $SINGLEMDS | + awk 'min == "" || $2 < min { min = $2 }; END { print min }') + local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) | + awk '{ print $1; exit; }') + + changelog_dump | tail -n 5 + echo "verifying user min purge: $min0_rec + 1 == $first_rec" + [ $first_rec == $((min0_rec + 1)) ] || + error "first index should be $min0_rec + 1 not $first_rec" # LU-3446 changelog index reset on MDT restart - local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/}) - CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ') - $LFS changelog_clear $MDT0 $CL_USER 0 - stop $SINGLEMDS || error "Fail to stop MDT." - start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT." - CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ') - echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2" - [ $CUR_REC1 == $CUR_REC2 ] || - err17935 "current index should be $CUR_REC1 is $CUR_REC2" - - echo "verifying user deregister" - cleanup_changelog - $GET_CL_USERS | grep -q $CL_USER && - error "User $CL_USER still in changelog_users" - - USERS=$(( $($GET_CL_USERS | wc -l) - 2 )) - if [ $CL_USER -eq 0 ]; then - LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ') + local cur_rec1=$(changelog_users $SINGLEMDS | + awk '/^current.index:/ { print $NF }') + changelog_clear 0 || + error "clear all changelog records for $cl_user failed" + stop $SINGLEMDS || error "Fail to stop $SINGLEMDS" + start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS || + error "Fail to start $SINGLEMDS" + local cur_rec2=$(changelog_users $SINGLEMDS | + awk '/^current.index:/ { print $NF }') + echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2" + [ $cur_rec1 == $cur_rec2 ] || + error "current index should be $cur_rec1 not $cur_rec2" + + echo "verifying users from this test are deregistered" + changelog_deregister || error "changelog_deregister failed" + changelog_users $SINGLEMDS | grep -q $cl_user && + error "User '$cl_user' still in changelog_users" + + # lctl get_param -n mdd.*.changelog_users + # current index: 144 + # ID index (idle seconds) + # cl3 144 (2) + if ! changelog_users $SINGLEMDS | grep "^cl"; then + # this is the normal case where all users were deregistered + # make sure no new records are added when no users are present + local last_rec1=$(changelog_users $SINGLEMDS | + awk '/^current.index:/ { print $NF }') touch $DIR/$tdir/chloe - LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ') - echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2" - [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off" + local last_rec2=$(changelog_users $SINGLEMDS | + awk '/^current.index:/ { print $NF }') + echo "verify changelogs are off: $last_rec1 == $last_rec2" + [ $last_rec1 == $last_rec2 ] || error "changelogs not off" else - echo "$CL_USER other changelog users; can't verify off" + # any changelog users must be leftovers from a previous test + changelog_users $SINGLEMDS + echo "other changelog users; can't verify off" fi } run_test 160a "changelog sanity" @@ -11084,27 +11827,22 @@ test_160b() { # LU-3587 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] || { skip "Need MDS version at least 2.2.0"; return; } - local CL_USERS="mdd.$MDT0.changelog_users" - local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS" - CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \ - changelog_register -n) - echo "Registered as changelog user $CL_USER" - trap cleanup_changelog EXIT - $GET_CL_USERS | grep -q $CL_USER || - error "User $CL_USER not found in changelog_users" + changelog_register || error "changelog_register failed" + local cl_user="${CL_USERS[$SINGLEMDS]%% *}" + changelog_users $SINGLEMDS | grep -q $cl_user || + error "User '$cl_user' not found in changelog_users" - local LONGNAME1=$(str_repeat a 255) - local LONGNAME2=$(str_repeat b 255) + local longname1=$(str_repeat a 255) + local longname2=$(str_repeat b 255) cd $DIR echo "creating very long named file" - touch $LONGNAME1 || error "create of $LONGNAME1 failed" - echo "moving very long named file" - mv $LONGNAME1 $LONGNAME2 + touch $longname1 || error "create of '$longname1' failed" + echo "renaming very long named file" + mv $longname1 $longname2 - $LFS changelog $MDT0 | grep RENME - rm -f $LONGNAME2 - cleanup_changelog + changelog_dump | grep RENME | tail -n 5 + rm -f $longname2 } run_test 160b "Verify that very long rename doesn't crash in changelog" @@ -11121,24 +11859,18 @@ test_160c() { [ $PARALLEL == "yes" ] && skip "skip parallel run" && return # Registration step - CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \ - changelog_register -n) - trap cleanup_changelog EXIT + changelog_register || error "changelog_register failed" rm -rf $DIR/$tdir mkdir -p $DIR/$tdir $MCREATE $DIR/$tdir/foo_160c - changelog_chmask "TRUNC" + changelog_chmask "-TRUNC" $TRUNCATE $DIR/$tdir/foo_160c 200 - changelog_chmask "TRUNC" + changelog_chmask "+TRUNC" $TRUNCATE $DIR/$tdir/foo_160c 199 - $LFS changelog $MDT0 - TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC") - [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1" - $LFS changelog_clear $MDT0 $CL_USER 0 - - # Deregistration step - cleanup_changelog + changelog_dump | tail -n 5 + local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC) + [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1" } run_test 160c "verify that changelog log catch the truncate event" @@ -11146,30 +11878,20 @@ test_160d() { remote_mds_nodsh && skip "remote MDS with nodsh" && return [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return - local server_version=$(lustre_version_code mds1) - local CL_MASK_PARAM="mdd.$MDT0.changelog_mask" - - [[ $server_version -ge $(version_code 2.7.60) ]] || + [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.60) ]] || { skip "Need MDS version at least 2.7.60+"; return; } [ $PARALLEL == "yes" ] && skip "skip parallel run" && return # Registration step - CL_USER=$(do_facet mds1 $LCTL --device $MDT0 \ - changelog_register -n) + changelog_register || error "changelog_register failed" - trap cleanup_changelog EXIT mkdir -p $DIR/$tdir/migrate_dir - $LFS changelog_clear $MDT0 $CL_USER 0 + changelog_clear 0 || error "changelog_clear failed" $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails" - $LFS changelog $MDT0 - MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT") - $LFS changelog_clear $MDT0 $CL_USER 0 - [ $MIGRATES -eq 1 ] || - error "MIGRATE changelog mask count $MIGRATES != 1" - - # Deregistration step - cleanup_changelog + changelog_dump | tail -n 5 + local migrates=$(changelog_dump | grep -c "MIGRT") + [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1" } run_test 160d "verify that changelog log catch the migrate event" @@ -11177,24 +11899,21 @@ test_160e() { remote_mds_nodsh && skip "remote MDS with nodsh" && return # Create a user - CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \ - changelog_register -n) - echo "Registered as changelog user $CL_USER" - trap cleanup_changelog EXIT + changelog_register || error "changelog_register failed" # Delete a future user (expect fail) - do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister cl77 + local MDT0=$(facet_svc $SINGLEMDS) + do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77" local rc=$? if [ $rc -eq 0 ]; then error "Deleted non-existant user cl77" elif [ $rc -ne 2 ]; then - error "changelog_deregister failed with $rc, " \ - "expected 2 (ENOENT)" + error "changelog_deregister failed with $rc, expect 2 (ENOENT)" fi # Clear to a bad index (1 billion should be safe) - $LFS changelog_clear $MDT0 $CL_USER 1000000000 + $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000 rc=$? if [ $rc -eq 0 ]; then @@ -11203,7 +11922,152 @@ test_160e() { error "changelog_clear failed with $rc, expected 22 (EINVAL)" fi } -run_test 160e "changelog negative testing" +run_test 160e "changelog negative testing (should return errors)" + +test_160f() { + local mdts=$(comma_list $(mdts_nodes)) + + # Create a user + changelog_register || error "first changelog_register failed" + changelog_register || error "second changelog_register failed" + local cl_users=(${CL_USERS[$SINGLEMDS]}) + local cl_user1="${cl_users[0]}" + local cl_user2="${cl_users[1]}" + + # generate some changelog records to accumulate on each MDT + test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed" + createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) || + error "create $DIR/$tdir/$tfile failed" + + # check changelogs have been generated + nbcl=$(changelog_dump | wc -l) + [[ $nbcl -eq 0 ]] && error "no changelogs found" + + # changelog_gc=1 should be set by default + for param in "changelog_max_idle_time=10" \ + "changelog_min_gc_interval=2" \ + "changelog_min_free_cat_entries=3"; do + local MDT0=$(facet_svc $SINGLEMDS) + local var="${param%=*}" + local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var") + + stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT + do_nodes $mdts $LCTL set_param mdd.*.$param + done + + # simulate changelog catalog almost full + #define OBD_FAIL_CAT_FREE_RECORDS 0x1313 + do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3 + + sleep 6 + local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user1) + [ -n "$user_rec1" ] || + error "User $cl_user1 not found in changelog_users" + __changelog_clear $SINGLEMDS $cl_user1 +2 + local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user1) + [ -n "$user_rec2" ] || + error "User $cl_user1 not found in changelog_users" + echo "verifying user clear: $user_rec1 + 2 == $user_rec2" + [ $((user_rec1 + 2)) == $user_rec2 ] || + error "user index expected $user_rec1 + 2, but is $user_rec2" + sleep 5 + + # generate one more changelog to trigger fail_loc + rm -rf $DIR/$tdir || error "rm -rf $tdir failed" + + # ensure gc thread is done + wait_update_facet $SINGLEMDS \ + "ps -e -o comm= | grep chlg_gc_thread" "" 20 + + # check user still registered + changelog_users $SINGLEMDS | grep -q "$cl_user1" || + error "User $cl_user1 not found in changelog_users" + # check user2 unregistered + changelog_users $SINGLEMDS | grep -q "$cl_user2" && + error "User $cl_user2 still found in changelog_users" + + # check changelogs are present and starting at $user_rec2 + 1 + local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) | + awk '{ print $1; exit; }') + + echo "verifying min purge: $user_rec2 + 1 == $first_rec" + [ $((user_rec2 + 1)) == $first_rec ] || + error "first index should be $user_rec2 + 1, but is $first_rec" +} +run_test 160f "changelog garbage collect (timestamped users)" + +test_160g() { + local mdts=$(comma_list $(mdts_nodes)) + + #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314 + do_nodes $mdts $LCTL set_param fail_loc=0x1314 + + # Create a user + changelog_register || error "first changelog_register failed" + changelog_register || error "second changelog_register failed" + local cl_users=(${CL_USERS[$SINGLEMDS]}) + local cl_user1="${cl_users[0]}" + local cl_user2="${cl_users[1]}" + + # generate some changelog records to accumulate on each MDT + test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed" + createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) || + error "create $DIR/$tdir/$tfile failed" + + # check changelogs have been generated + nbcl=$(changelog_dump | wc -l) + [[ $nbcl -eq 0 ]] && error "no changelogs found" + + # changelog_gc=1 should be set by default + for param in "changelog_max_idle_indexes=$((nbcl / 2))" \ + "changelog_min_gc_interval=2" \ + "changelog_min_free_cat_entries=3"; do + local MDT0=$(facet_svc $SINGLEMDS) + local var="${param%=*}" + local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var") + + stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT + do_nodes $mdts $LCTL set_param mdd.*.$param || + error "unable to set mdd.*.$param" + done + + # simulate changelog catalog almost full + #define OBD_FAIL_CAT_FREE_RECORDS 0x1313 + do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3 + + local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user1) + + __changelog_clear $SINGLEMDS $cl_user1 +3 + + local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user1) + + echo "verifying user clear: $user_rec1 + 3 == $user_rec2" + [ $((user_rec1 + 3)) == $user_rec2 ] || + error "user index expected $user_rec1 + 3, but is $user_rec2" + + # generate one more changelog to trigger fail_loc + rm -rf $DIR/$tdir || error "rm -rf $tdir failed" + + # ensure gc thread is done + wait_update_facet $SINGLEMDS \ + "ps -e -o comm= | grep chlg_gc_thread" "" 20 + + # check user still registered + [ -n "$(changelog_user_rec $SINGLEMDS $cl_user1)" ] || + error "User $cl_user1 not found in changelog_users" + # check user2 unregistered + [ -z "$(changelog_user_rec $SINGLEMDS $cl_user2)" ] || + error "User $cl_user2 still found in changelog_users" + + # check changelogs are present and starting at $user_rec2 + 1 + local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) | + awk '{ print $1; exit; }') + + echo "verifying min purge: $user_rec2 + 1 == $first_rec" + [ $((user_rec2 + 1)) == $first_rec ] || + error "first index should be $user_rec2 + 1, but is $first_rec" +} +run_test 160g "changelog garbage collect (old users)" test_161a() { [ $PARALLEL == "yes" ] && skip "skip parallel run" && return @@ -11218,33 +12082,29 @@ test_161a() { local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]') if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then $LFS fid2path $DIR $FID - err17935 "bad link ea" + error "bad link ea" fi - # middle - rm $DIR/$tdir/foo2/zachary - # last - rm $DIR/$tdir/foo2/thor - # first - rm $DIR/$tdir/$tfile - # rename - mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie - if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] - then - $LFS fid2path $DIR $FID - err17935 "bad link rename" - fi - rm $DIR/$tdir/foo2/maggie + # middle + rm $DIR/$tdir/foo2/zachary + # last + rm $DIR/$tdir/foo2/thor + # first + rm $DIR/$tdir/$tfile + # rename + mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie + [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] && + { $LFS fid2path $DIR $FID; error "bad link rename"; } + rm $DIR/$tdir/foo2/maggie # overflow the EA - local longname=filename_avg_len_is_thirty_two_ + local longname=$tfile.avg_len_is_thirty_two_ + stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \ + error_noexit 'failed to unlink many hardlinks'" EXIT createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || error "failed to hardlink many files" links=$($LFS fid2path $DIR $FID | wc -l) echo -n "${links}/1000 links in link EA" - [[ $links -gt 60 ]] || - err17935 "expected at least 60 links in link EA" - unlinkmany $DIR/$tdir/foo2/$longname 1000 || - error "failed to unlink many hardlinks" + [[ $links -gt 60 ]] || error "expected at least 60 links in link EA" } run_test 161a "link ea sanity" @@ -11270,7 +12130,7 @@ test_161b() { tr -d ']') if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then $LFS fid2path $DIR $FID - err17935 "bad link ea" + error "bad link ea" fi # middle rm $remote_dir/foo2/zachary @@ -11283,7 +12143,7 @@ test_161b() { local link_path=$($LFS fid2path $FSNAME --link 1 $FID) if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then $LFS fid2path $DIR $FID - err17935 "bad link rename" + error "bad link rename" fi rm $remote_dir/foo2/maggie @@ -11294,7 +12154,7 @@ test_161b() { links=$($LFS fid2path $DIR $FID | wc -l) echo -n "${links}/1000 links in link EA" [[ ${links} -gt 60 ]] || - err17935 "expected at least 60 links in link EA" + error "expected at least 60 links in link EA" unlinkmany $remote_dir/foo2/$longname 1000 || error "failed to unlink many hardlinks" } @@ -11308,33 +12168,29 @@ test_161c() { # define CLF_RENAME_LAST 0x0001 # rename overwrite a target having nlink = 1 (changelog flag 0x1) - CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \ - changelog_register -n) + changelog_register || error "changelog_register failed" - trap cleanup_changelog EXIT rm -rf $DIR/$tdir - mkdir -p $DIR/$tdir + test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir touch $DIR/$tdir/foo_161c touch $DIR/$tdir/bar_161c mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c - $LFS changelog $MDT0 | grep RENME - local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \ - cut -f5 -d' ') - $LFS changelog_clear $MDT0 $CL_USER 0 + changelog_dump | grep RENME | tail -n 5 + local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ') + changelog_clear 0 || error "changelog_clear failed" if [ x$flags != "x0x1" ]; then error "flag $flags is not 0x1" fi - echo "rename overwrite a target having nlink = 1," \ - "changelog record has flags of $flags" + echo "rename overwrite target with nlink = 1, changelog flags=$flags" # rename overwrite a target having nlink > 1 (changelog flag 0x0) touch $DIR/$tdir/foo_161c touch $DIR/$tdir/bar_161c ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c - $LFS changelog $MDT0 | grep RENME - flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ') - $LFS changelog_clear $MDT0 $CL_USER 0 + changelog_dump | grep RENME | tail -n 5 + flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ') + changelog_clear 0 || error "changelog_clear failed" if [ x$flags != "x0x0" ]; then error "flag $flags is not 0x0" fi @@ -11344,9 +12200,9 @@ test_161c() { # rename doesn't overwrite a target (changelog flag 0x0) touch $DIR/$tdir/foo_161c mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c - $LFS changelog $MDT0 | grep RENME - flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ') - $LFS changelog_clear $MDT0 $CL_USER 0 + changelog_dump | grep RENME | tail -n 5 + flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ') + changelog_clear 0 || error "changelog_clear failed" if [ x$flags != "x0x0" ]; then error "flag $flags is not 0x0" fi @@ -11356,9 +12212,9 @@ test_161c() { # define CLF_UNLINK_LAST 0x0001 # unlink a file having nlink = 1 (changelog flag 0x1) rm -f $DIR/$tdir/foo2_161c - $LFS changelog $MDT0 | grep UNLNK - flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ') - $LFS changelog_clear $MDT0 $CL_USER 0 + changelog_dump | grep UNLNK | tail -n 5 + flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ') + changelog_clear 0 || error "changelog_clear failed" if [ x$flags != "x0x1" ]; then error "flag $flags is not 0x1" fi @@ -11368,29 +12224,21 @@ test_161c() { # unlink a file having nlink > 1 (changelog flag 0x0) ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c rm -f $DIR/$tdir/foobar_161c - $LFS changelog $MDT0 | grep UNLNK - flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ') - $LFS changelog_clear $MDT0 $CL_USER 0 + changelog_dump | grep UNLNK | tail -n 5 + flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ') + changelog_clear 0 || error "changelog_clear failed" if [ x$flags != "x0x0" ]; then error "flag $flags is not 0x0" fi - echo "unlink a file having nlink > 1," \ - "changelog record has flags of $flags" - cleanup_changelog + echo "unlink a file having nlink > 1, changelog record flags '$flags'" } run_test 161c "check CL_RENME[UNLINK] changelog record flags" test_161d() { - local user local pid local fid - # cleanup previous run - rm -rf $DIR/$tdir/$tfile - - user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \ - changelog_register -n) - [[ $? -eq 0 ]] || error "changelog_register failed" + changelog_register || error "changelog_register failed" # work in a standalone dir to avoid locking on $DIR/$MOUNT to # interfer with $MOUNT/.lustre/fid/ access @@ -11413,7 +12261,7 @@ test_161d() { [[ $? -eq 0 ]] || error "create should be blocked" local tempfile=$(mktemp) - fid=$(changelog_extract_field $MDT0 "CREAT" "$tfile" "t=") + fid=$(changelog_extract_field "CREAT" "$tfile" "t=") cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed" # some delay may occur during ChangeLog publishing and file read just # above, that could allow file write to happen finally @@ -11423,35 +12271,28 @@ test_161d() { wait $pid [[ $? -eq 0 ]] || error "create failed" - - $LFS changelog_clear $MDT0 $user 0 - do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $user } run_test 161d "create with concurrent .lustre/fid access" check_path() { - local expected=$1 - shift - local fid=$2 + local expected="$1" + shift + local fid="$2" - local path=$(${LFS} fid2path $*) - # Remove the '//' indicating a remote directory - path=$(echo $path | sed 's#//#/#g') - RC=$? + local path + path=$($LFS fid2path "$@") + local rc=$? - if [ $RC -ne 0 ]; then - err17935 "path looked up of $expected failed. Error $RC" - return $RC - elif [ "${path}" != "${expected}" ]; then - err17935 "path looked up \"${path}\" instead of \"${expected}\"" - return 2 - fi - echo "fid $fid resolves to path $path (expected $expected)" + if [ $rc -ne 0 ]; then + error "path looked up of '$expected' failed: rc=$rc" + elif [ "$path" != "$expected" ]; then + error "path looked up '$path' instead of '$expected'" + else + echo "FID '$fid' resolves to path '$path' as expected" + fi } test_162a() { # was test_162 - # Make changes to filesystem - [ $PARALLEL == "yes" ] && skip "skip parallel run" && return test_mkdir -p -c1 $DIR/$tdir/d2 touch $DIR/$tdir/d2/$tfile touch $DIR/$tdir/d2/x1 @@ -11459,43 +12300,34 @@ test_162a() { # was test_162 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r # regular file - FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]') - check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 || - error "check path $tdir/d2/$tfile failed" + local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]') + check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0 # softlink ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink - FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]') - check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 || - error "check path $tdir/d2/p/q/r/slink failed" + fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]') + check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0 # softlink to wrong file ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong - FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]') - check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 || - error "check path $tdir/d2/p/q/r/slink.wrong failed" + fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]') + check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0 # hardlink ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file - FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]') + fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]') # fid2path dir/fsname should both work - check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 || - error "check path $tdir/d2/a/b/c/new_file failed" - check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 || - error "check path $DIR/$tdir/d2/p/q/r/hlink failed" + check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1 + check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0 # hardlink count: check that there are 2 links - # Doesnt work with CMD yet: 17935 - ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \ - err17935 "expected 2 links" + local nlinks=$($LFS fid2path $DIR "$fid" | wc -l) + [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks" # hardlink indexing: remove the first link rm $DIR/$tdir/d2/p/q/r/hlink - check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 || - error "check path $DIR/$tdir/d2/a/b/c/new_file failed" - - return 0 + check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0 } run_test 162a "path lookup sanity" @@ -11504,7 +12336,7 @@ test_162b() { [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return mkdir $DIR/$tdir - $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir || + $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir || error "create striped dir failed" local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir | @@ -11518,13 +12350,11 @@ test_162b() { for ((i=0;i<5;i++)); do FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') || error "get fid for f$i failed" - check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 || - error "check path $tdir/striped_dir/f$i failed" + check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') || error "get fid for d$i failed" - check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 || - error "check path $tdir/striped_dir/d$i failed" + check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 done return 0 @@ -11545,15 +12375,13 @@ test_162c() { mkdir $DIR/$lpath FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') || error "get fid for local directory $DIR/$lpath failed" - check_path "$DIR/$lpath" $MOUNT $FID --link 0 || - error "check path for local directory $DIR/$lpath failed" + check_path "$DIR/$lpath" $MOUNT $FID --link 0 rpath="$rpath/$i" test_mkdir $DIR/$rpath FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') || error "get fid for remote directory $DIR/$rpath failed" - check_path "$DIR/$rpath" $MOUNT $FID --link 0 || - error "check path for remote directory $DIR/$rpath failed" + check_path "$DIR/$rpath" $MOUNT $FID --link 0 done return 0 @@ -11579,16 +12407,17 @@ run_test 169 "parallel read and truncate should not deadlock" test_170() { [ $PARALLEL == "yes" ] && skip "skip parallel run" && return - $LCTL clear # bug 18514 - $LCTL debug_daemon start $TMP/${tfile}_log_good - touch $DIR/$tfile - $LCTL debug_daemon stop - sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad || - error "sed failed to read log_good" - $LCTL debug_daemon start $TMP/${tfile}_log_good - rm -rf $DIR/$tfile - $LCTL debug_daemon stop + $LCTL clear # bug 18514 + $LCTL debug_daemon start $TMP/${tfile}_log_good + touch $DIR/$tfile + $LCTL debug_daemon stop + sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad || + error "sed failed to read log_good" + + $LCTL debug_daemon start $TMP/${tfile}_log_good + rm -rf $DIR/$tfile + $LCTL debug_daemon stop $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 || error "lctl df log_bad failed" @@ -11765,8 +12594,7 @@ test_180c() { # LU-2598 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho && rmmod_remote=true || error "failed to load module obdecho" - target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' | - head -n1) + target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4; exit; }') if [ -n "$target" ]; then obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]} else @@ -11878,6 +12706,8 @@ test_184a() { cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)" cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)" + + lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred" } run_test 184a "Basic layout swap" @@ -12123,8 +12953,12 @@ test_200() { local test_path=$POOL_ROOT/$POOL_DIR_NAME local file_dir=$POOL_ROOT/file_tst local subdir=$test_path/subdir - local rc=0 + + if ! combined_mgs_mds ; then + mount_mgs_client + fi + while : ; do # former test_200a test_200b pool_add $POOL || { rc=$? ; break; } @@ -12144,7 +12978,7 @@ test_200() { pool_create_files $POOL $file_dir $files "$ost_list" \ || { rc=$? ; break; } # former test_200g test_200h - pool_lfs_df $POOL || { rc=$? ; break; } + pool_lfs_df $POOL || { rc=$? ; break; } pool_file_rel_path $POOL $test_path || { rc=$? ; break; } # former test_201a test_201b test_201c @@ -12152,11 +12986,15 @@ test_200() { local f=$test_path/$tfile pool_remove_all_targets $POOL $f || { rc=$? ; break; } - pool_remove $POOL $f || { rc=$? ; break; } + pool_remove $POOL $f || { rc=$? ; break; } break done destroy_test_pools + + if ! combined_mgs_mds ; then + umount_mgs_client + fi return $rc } run_test 200 "OST pools" @@ -12325,18 +13163,10 @@ verify_jobstats() { } jobstats_set() { - trap 0 - NEW_JOBENV=${1:-$OLD_JOBENV} - do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV - wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV -} + local new_jobenv=$1 -cleanup_205() { - trap 0 - do_facet $SINGLEMDS \ - $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL - [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV - cleanup_changelog + do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$new_jobenv + wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $new_jobenv } test_205() { # Job stats @@ -12352,20 +13182,22 @@ test_205() { # Job stats skip "Server doesn't support jobstats" && return 0 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return - OLD_JOBENV=$($LCTL get_param -n jobid_var) - if [ $OLD_JOBENV != $JOBENV ]; then + local old_jobenv=$($LCTL get_param -n jobid_var) + if [ $old_jobenv != $JOBENV ]; then jobstats_set $JOBENV - trap cleanup_205 EXIT + stack_trap "do_facet mgs \ + $LCTL conf_param $FSNAME.sys.jobid_var=$old_jobenv" EXIT fi - CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n) - echo "Registered as changelog user $CL_USER" + changelog_register - OLD_INTERVAL=$(do_facet $SINGLEMDS \ - lctl get_param -n mdt.*.job_cleanup_interval) - local interval_new=5 + local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \ + mdt.*.job_cleanup_interval | head -n 1) + local new_interval=5 do_facet $SINGLEMDS \ - $LCTL set_param mdt.*.job_cleanup_interval=$interval_new + $LCTL set_param mdt.*.job_cleanup_interval=$new_interval + stack_trap "do_facet $SINGLEMDS \ + $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT local start=$SECONDS local cmd @@ -12407,7 +13239,7 @@ test_205() { # Job stats cmd="mv -f $DIR/$tfile $DIR/$tdir.rename" verify_jobstats "$cmd" "$SINGLEMDS" # jobstats expiry - sleep until old stats should be expired - local left=$((interval_new + 5 - (SECONDS - start))) + local left=$((new_interval + 5 - (SECONDS - start))) [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \ "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \ "0" $left @@ -12417,10 +13249,9 @@ test_205() { # Job stats grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired" # Ensure that jobid are present in changelog (if supported by MDS) - if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ] - then - $LFS changelog $MDT0 | tail -9 - jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=") + if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ];then + changelog_dump | tail -10 + jobids=$(changelog_dump | tail -9 | grep -c "j=") [ $jobids -eq 9 ] || error "Wrong changelog jobid count $jobids != 9" @@ -12428,13 +13259,11 @@ test_205() { # Job stats JOBENV="disable" jobstats_set $JOBENV touch $DIR/$tfile - $LFS changelog $MDT0 | tail -1 - jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=") + changelog_dump | grep $tfile + jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=") [ $jobids -eq 0 ] || error "Unexpected jobids when jobid_var=$JOBENV" fi - - cleanup_205 } run_test 205 "Verify job stats" @@ -12834,6 +13663,10 @@ test_220() { #LU-325 $LFS df -i + if ! combined_mgs_mds ; then + mount_mgs_client + fi + do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1 #define OBD_FAIL_OST_ENOINO 0x229 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229 @@ -12864,10 +13697,16 @@ test_220() { #LU-325 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0 - do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4 - do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5 + do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || + error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed" + do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || + error "$LCTL pool_destroy $FSNAME.$TESTNAME failed" echo "unlink $MDSOBJS files @$next_id..." - unlinkmany $DIR/$tdir/f $MDSOBJS || return 6 + unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed" + + if ! combined_mgs_mds ; then + umount_mgs_client + fi } run_test 220 "preallocated MDS objects still used if ENOSPC from OST" @@ -13003,26 +13842,23 @@ test_225a () { skip_env "mds-survey not found" && return fi - [ $MDSCOUNT -ge 2 ] && - skip "skipping now for more than one MDT" && return - - [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] || - { skip "Need MDS version at least 2.2.51"; return; } + [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] || + { skip "Need MDS version at least 2.2.51"; return; } - local mds=$(facet_host $SINGLEMDS) - local target=$(do_nodes $mds 'lctl dl' | \ - awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}") + local mds=$(facet_host $SINGLEMDS) + local target=$(do_nodes $mds 'lctl dl' | + awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}') - local cmd1="file_count=1000 thrhi=4" - local cmd2="dir_count=2 layer=mdd stripe_count=0" - local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY" - local cmd="$cmd1 $cmd2 $cmd3" + local cmd1="file_count=1000 thrhi=4" + local cmd2="dir_count=2 layer=mdd stripe_count=0" + local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY" + local cmd="$cmd1 $cmd2 $cmd3" - rm -f ${TMP}/mds_survey* - echo + $cmd - eval $cmd || error "mds-survey with zero-stripe failed" - cat ${TMP}/mds_survey* - rm -f ${TMP}/mds_survey* + rm -f ${TMP}/mds_survey* + echo + $cmd + eval $cmd || error "mds-survey with zero-stripe failed" + cat ${TMP}/mds_survey* + rm -f ${TMP}/mds_survey* } run_test 225a "Metadata survey sanity with zero-stripe" @@ -13039,22 +13875,20 @@ test_225b () { skip_env "Need to mount OST to test" && return fi - [ $MDSCOUNT -ge 2 ] && - skip "skipping now for more than one MDT" && return - local mds=$(facet_host $SINGLEMDS) - local target=$(do_nodes $mds 'lctl dl' | \ - awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}") + local mds=$(facet_host $SINGLEMDS) + local target=$(do_nodes $mds 'lctl dl' | + awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}') - local cmd1="file_count=1000 thrhi=4" - local cmd2="dir_count=2 layer=mdd stripe_count=1" - local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY" - local cmd="$cmd1 $cmd2 $cmd3" + local cmd1="file_count=1000 thrhi=4" + local cmd2="dir_count=2 layer=mdd stripe_count=1" + local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY" + local cmd="$cmd1 $cmd2 $cmd3" - rm -f ${TMP}/mds_survey* - echo + $cmd - eval $cmd || error "mds-survey with stripe_count failed" - cat ${TMP}/mds_survey* - rm -f ${TMP}/mds_survey* + rm -f ${TMP}/mds_survey* + echo + $cmd + eval $cmd || error "mds-survey with stripe_count failed" + cat ${TMP}/mds_survey* + rm -f ${TMP}/mds_survey* } run_test 225b "Metadata survey sanity with stripe_count = 1" @@ -13292,7 +14126,7 @@ test_229() { # LU-2482, LU-3448 $GETSTRIPE -v $DIR/$tfile local pattern=$($GETSTRIPE -L $DIR/$tfile) - [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)" + [ X"$pattern" = X"released" ] || error "pattern error ($pattern)" local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe" [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)" @@ -13789,19 +14623,44 @@ test_231b() { } run_test 231b "must not assert on fully utilized OST request buffer" -test_232() { +test_232a() { mkdir -p $DIR/$tdir + $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile + #define OBD_FAIL_LDLM_OST_LVB 0x31c - $LCTL set_param fail_loc=0x31c + do_facet ost1 $LCTL set_param fail_loc=0x31c # ignore dd failure dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true - $LCTL set_param fail_loc=0 + do_facet ost1 $LCTL set_param fail_loc=0 + umount_client $MOUNT || error "umount failed" + mount_client $MOUNT || error "mount failed" + stop ost1 || error "cannot stop ost1" + start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1" +} +run_test 232a "failed lock should not block umount" + +test_232b() { + mkdir -p $DIR/$tdir + $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile + dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 + sync + cancel_lru_locks osc + + #define OBD_FAIL_LDLM_OST_LVB 0x31c + do_facet ost1 $LCTL set_param fail_loc=0x31c + + # ignore failure + $LFS data_version $DIR/$tdir/$tfile || true + + do_facet ost1 $LCTL set_param fail_loc=0 umount_client $MOUNT || error "umount failed" mount_client $MOUNT || error "mount failed" + stop ost1 || error "cannot stop ost1" + start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1" } -run_test 232 "failed lock should not block umount" +run_test 232b "failed data version lock should not block umount" test_233a() { [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] || @@ -13839,17 +14698,8 @@ test_234() { touch $DIR/$tdir/$tfile || error "touch failed" # OBD_FAIL_LLITE_XATTR_ENOMEM $LCTL set_param fail_loc=0x1405 - # output of the form: attr 2 4 44 3 fc13 x86_64 - V=($(IFS=".-" rpm -q attr)) - if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 || - ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then - # attr pre-2.4.44-7 had a bug with rc - # LU-3703 - SLES 11 and FC13 clients have older attr - getfattr -n user.attr $DIR/$tdir/$tfile && - error "getfattr should have failed with ENOMEM" - else - skip "LU-3703: attr version $(getfattr --version) too old" - fi + getfattr -n user.attr $DIR/$tdir/$tfile && + error "getfattr should have failed with ENOMEM" $LCTL set_param fail_loc=0x0 rm -rf $DIR/$tdir @@ -13939,7 +14789,7 @@ test_238() { } run_test 238 "Verify linkea consistency" -test_239() { +test_239A() { # was test_239 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] && skip "Need MDS version at least 2.5.60" && return local list=$(comma_list $(mdts_nodes)) @@ -13947,12 +14797,13 @@ test_239() { mkdir -p $DIR/$tdir createmany -o $DIR/$tdir/f- 5000 unlinkmany $DIR/$tdir/f- 5000 - do_nodes $list "lctl set_param -n osp*.*.sync_changes 1" - changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \ - osc.*MDT*.sync_in_flight" | calc_sum) + [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.10.53) ] && + do_nodes $list "lctl set_param -n osp.*.force_sync=1" + changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \ + osp.*MDT*.sync_in_flight" | calc_sum) [ "$changes" -eq 0 ] || error "$changes not synced" } -run_test 239 "osp_sync test" +run_test 239A "osp_sync test" test_239a() { #LU-5297 remote_mds_nodsh && skip "remote MDS with nodsh" && return @@ -14002,7 +14853,7 @@ run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)" test_241_bio() { for LOOP in $(seq $1); do dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null - cancel_lru_locks osc || true + cancel_lru_locks $OSC || true done } @@ -14016,7 +14867,7 @@ test_241_dio() { test_241a() { # was test_241 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960 ls -la $DIR/$tfile - cancel_lru_locks osc + cancel_lru_locks $OSC test_241_bio 1000 & PID=$! test_241_dio 1000 @@ -14104,6 +14955,14 @@ test_246() { # LU-7371 } run_test 246 "Read file of size 4095 should return right length" +cleanup_247() { + local submount=$1 + + trap 0 + umount_client $submount + rmdir $submount +} + test_247a() { lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree || @@ -14115,11 +14974,11 @@ test_247a() { mkdir -p $submount || error "mkdir $submount failed" FILESET="$FILESET/$tdir" mount_client $submount || error "mount $submount failed" + trap "cleanup_247 $submount" EXIT echo foo > $submount/$tfile || error "write $submount/$tfile failed" [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] || error "read $MOUNT/$tdir/$tfile failed" - umount_client $submount || error "umount $submount failed" - rmdir $submount + cleanup_247 $submount } run_test 247a "mount subdir as fileset" @@ -14146,12 +15005,12 @@ test_247c() { mkdir -p $MOUNT/$tdir/dir1 mkdir -p $submount || error "mkdir $submount failed" + trap "cleanup_247 $submount" EXIT FILESET="$FILESET/$tdir" mount_client $submount || error "mount $submount failed" local fid=$($LFS path2fid $MOUNT/) $LFS fid2path $submount $fid && error "fid2path should fail" - umount_client $submount || error "umount $submount failed" - rmdir $submount + cleanup_247 $submount } run_test 247c "running fid2path outside root" @@ -14165,10 +15024,10 @@ test_247d() { mkdir -p $submount || error "mkdir $submount failed" FILESET="$FILESET/$tdir" mount_client $submount || error "mount $submount failed" + trap "cleanup_247 $submount" EXIT local fid=$($LFS path2fid $submount/dir1) $LFS fid2path $submount $fid || error "fid2path should succeed" - umount_client $submount || error "umount $submount failed" - rmdir $submount + cleanup_247 $submount } run_test 247d "running fid2path inside root" @@ -14204,12 +15063,13 @@ test_248() { # small read with fast read enabled $LCTL set_param -n llite.*.fast_read=1 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 | - awk '/copied/ { print $6 }') - + egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 | + sed -e 's/,/./' -e 's/[eE]+*/\*10\^/') # small read with fast read disabled $LCTL set_param -n llite.*.fast_read=0 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 | - awk '/copied/ { print $6 }') + egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 | + sed -e 's/,/./' -e 's/[eE]+*/\*10\^/') # verify that fast read is 4 times faster for cache read [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] || @@ -14222,12 +15082,14 @@ test_248() { # 1k non-cache read cancel_lru_locks osc local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 | - awk '/copied/ { print $6 }') + egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 | + sed -e 's/,/./' -e 's/[eE]+*/\*10\^/') # 1M non-cache read cancel_lru_locks osc local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 | - awk '/copied/ { print $6 }') + egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 | + sed -e 's/,/./' -e 's/[eE]+*/\*10\^/') # verify that big IO is not 4 times faster than small IO [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] || @@ -14390,6 +15252,9 @@ test_253() { osp.$mdtosc_proc1.reserved_mb_low) echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l" + if ! combined_mgs_mds ; then + mount_mgs_client + fi create_pool $FSNAME.$TESTNAME || error "Pool creation failed" do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name || error "Adding $ost_name to pool failed" @@ -14454,6 +15319,10 @@ test_253() { error "Remove $ost_name from pool failed" do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || error "Pool destroy fialed" + + if ! combined_mgs_mds ; then + umount_mgs_client + fi } run_test 253 "Check object allocation limit" @@ -14462,15 +15331,17 @@ test_254() { [ $PARALLEL == "yes" ] && skip "skip parallel run" && return remote_mds_nodsh && skip "remote MDS with nodsh" && return - do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size || + + local MDT0=$(facet_svc $SINGLEMDS) + + do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size || { skip "MDS does not support changelog_size" && return; } - cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n) - echo "Registered as changelog user $cl_user" + changelog_register || error "changelog_register failed" - $LFS changelog_clear $MDT0 $cl_user 0 + changelog_clear 0 || error "changelog_clear failed" - local size1=$(do_facet mds1 \ + local size1=$(do_facet $SINGLEMDS \ $LCTL get_param -n mdd.$MDT0.changelog_size) echo "Changelog size $size1" @@ -14485,16 +15356,12 @@ test_254() { ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg rm $DIR/$tdir/pics/desktop.jpg - local size2=$(do_facet mds1 \ + local size2=$(do_facet $SINGLEMDS \ $LCTL get_param -n mdd.$MDT0.changelog_size) echo "Changelog size after work $size2" - do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user - - if (( size2 <= size1 )); then - error "Changelog size after work should be greater than original" - fi - return 0 + (( $size2 > $size1 )) || + error "new Changelog size=$size2 less than old size=$size1" } run_test 254 "Check changelog size" @@ -14593,7 +15460,7 @@ ladvise_willread_performance() local lowest_speedup=20 if [ ${average_cache%.*} -lt $lowest_speedup ]; then - echo "Speedup with OSS cached read less than $lowest_speedup%, " + echo "Speedup with OSS cached read less than $lowest_speedup%," \ "got $average_cache%. Skipping ladvise willread check." return 0 fi @@ -14699,6 +15566,8 @@ facet_meminfo() { } test_255b() { + [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] && + skip "lustre < 2.8.54 does not support ladvise " && return remote_ost_nodsh && skip "remote OST with nodsh" && return lfs setstripe -c 1 -i 0 $DIR/$tfile @@ -14765,12 +15634,16 @@ test_255c() { local difference local i local rc + + [ $(lustre_version_code ost1) -lt $(version_code 2.10.50) ] && + skip "lustre < 2.10.53 does not support lockahead" && return + test_mkdir -p $DIR/$tdir $SETSTRIPE -i 0 $DIR/$tdir #test 10 returns only success/failure i=10 - lockahead_test -d $DIR/$tdir -t $i + lockahead_test -d $DIR/$tdir -t $i -f $tfile rc=$? if [ $rc -eq 255 ]; then error "Ladvise test${i} failed, ${rc}" @@ -14782,7 +15655,7 @@ test_255c() { $LCTL get_param -n ost.OSS.ost.stats) count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }') - lockahead_test -d $DIR/$tdir -t $i + lockahead_test -d $DIR/$tdir -t $i -f $tfile rc=$? if [ $rc -eq 255 ]; then error "Ladvise test${i} failed, ${rc}" @@ -14808,7 +15681,7 @@ test_255c() { count=$($LCTL get_param -n \ ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count) - lockahead_test -d $DIR/$tdir -t $i + lockahead_test -d $DIR/$tdir -t $i -f $tfile rc=$? if [ $rc -eq 255 ]; then error "Ladvise test ${i} failed, ${rc}" @@ -14818,9 +15691,9 @@ test_255c() { ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count) difference="$((new_count - count))" - # Test 15 output is divided by 1000 to map down to valid return + # Test 15 output is divided by 100 to map down to valid return if [ $i -eq 15 ]; then - rc="$((rc * 1000))" + rc="$((rc * 100))" fi if [ $difference -ne $rc ]; then @@ -14831,12 +15704,11 @@ test_255c() { #test 22 returns only success/failure i=22 - lockahead_test -d $DIR/$tdir -t $i + lockahead_test -d $DIR/$tdir -t $i -f $tfile rc=$? if [ $rc -eq 255 ]; then error "Ladvise test${i} failed, ${rc}" fi - } run_test 255c "suite of ladvise lockahead tests" @@ -14847,65 +15719,51 @@ test_256() { [ $PARALLEL == "yes" ] && skip "skip parallel run" && return remote_mds_nodsh && skip "remote MDS with nodsh" && return - [ "$(facet_fstype mds1)" != "ldiskfs" ] && + [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] && skip "ldiskfs only test" && return mdt_dev=$(mdsdevname 1) echo $mdt_dev - cl_user=$(do_facet mds1 \ - "$LCTL get_param -n mdd.$MDT0.changelog_users | grep cl") - if [[ -n $cl_user ]]; then - skip "active changelog user" - return - fi + changelog_users $SINGLEMDS | grep "^cl" && + skip "active changelog user" && return - cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n) - echo "Registered as changelog user $cl_user" + changelog_register || error "changelog_register failed" rm -rf $DIR/$tdir mkdir -p $DIR/$tdir - $LFS changelog_clear $MDT0 $cl_user 0 + changelog_clear 0 || error "changelog_clear failed" # change something touch $DIR/$tdir/{1..10} # stop the MDT - stop mds1 || error "Fail to stop MDT." + stop $SINGLEMDS || error "Fail to stop MDT" # remount the MDT - start mds1 $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT." + + start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT" #after mount new plainllog is used touch $DIR/$tdir/{11..19} - do_facet mds1 sync - local TEMP256FILE=$(mktemp -u TEMP256XXXXXX) - cat_sl=$(do_facet mds1 \ - "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \ - llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l") - do_facet mds1 rm $TEMP256FILE - - if (( cat_sl != 2 )); then - do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user - error "Changelog catalog has wrong number of slots $cat_sl" - fi + local tmpfile=$(mktemp -u $tfile.XXXXXX) + cat_sl=$(do_facet $SINGLEMDS "sync; \ + $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \ + llog_reader $tmpfile | grep -c type=1064553b") + do_facet $SINGLEMDS llog_reader $tmpfile - $LFS changelog_clear $MDT0 $cl_user 0 + [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots" - do_facet mds1 sync - TEMP256FILE=$(mktemp -u TEMP256XXXXXX) - cat_sl=$(do_facet mds1 \ - "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \ - llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l") - do_facet mds1 rm $TEMP256FILE + changelog_clear 0 || error "changelog_clear failed" - do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user + cat_sl=$(do_facet $SINGLEMDS "sync; \ + $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \ + llog_reader $tmpfile | grep -c type=1064553b; rm -f $tmpfile") if (( cat_sl == 2 )); then error "Empty plain llog was not deleted from changelog catalog" - fi - if (( cat_sl != 1 )); then - error "Active plain llog shouldn\`t be deleted from catalog" + elif (( cat_sl != 1 )); then + error "Active plain llog shouldn't be deleted from catalog" fi } run_test 256 "Check llog delete for empty and not full state" @@ -14974,6 +15832,420 @@ test_260() { } run_test 260 "Check mdc_close fail" +### Data-on-MDT sanity tests ### +test_270a() { + + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] && + skip "Need MDS version at least 2.10.55" && return + + # create DoM file + local dom=$DIR/$tdir/dom_file + local tmp=$DIR/$tdir/tmp_file + + mkdir -p $DIR/$tdir + + # basic checks for DoM component creation + $LFS setstripe -E 1024K -E 1024K -L mdt $dom 2>/dev/null && + error "Can set MDT layout to non-first entry" + + $LFS setstripe -E 1024K -L mdt -E 1024K -L mdt $dom 2>/dev/null && + error "Can define multiple entries as MDT layout" + + $LFS setstripe -E 1M -L mdt $dom || + error "Can't create DoM layout" + + [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern" + [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count" + [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size" + + local mdtidx=$($GETSTRIPE -M $dom) + local mdtname=MDT$(printf %04x $mdtidx) + local facet=mds$((mdtidx + 1)) + local space_check=1 + + # Skip free space checks with ZFS + if [ "$(facet_fstype $facet)" == "zfs" ]; then + space_check=0 + fi + + # write + sync + local mdtfree1=$(do_facet $facet \ + lctl get_param -n osd*.*$mdtname.kbytesfree) + dd if=/dev/urandom of=$tmp bs=1024 count=100 + # check also direct IO along write + dd if=$tmp of=$dom bs=102400 count=1 oflag=direct + sync + cmp $tmp $dom || error "file data is different" + [ $(stat -c%s $dom) == 102400 ] || error "bad size after write" + if [ $space_check == 1 ]; then + local mdtfree2=$(do_facet $facet \ + lctl get_param -n osd*.*$mdtname.kbytesfree) + [ $(($mdtfree1 - $mdtfree2)) -ge 102 ] || + error "MDT free space is wrong after write" + fi + + # truncate + $TRUNCATE $dom 10000 + [ $(stat -c%s $dom) == 10000 ] || error "bad size after truncate" + if [ $space_check == 1 ]; then + mdtfree1=$(do_facet $facet \ + lctl get_param -n osd*.*$mdtname.kbytesfree) + [ $(($mdtfree1 - $mdtfree2)) -ge 92 ] || + error "MDT free space is wrong after truncate" + fi + + # append + cat $tmp >> $dom + sync + [ $(stat -c%s $dom) == 112400 ] || error "bad size after append" + if [ $space_check == 1 ]; then + mdtfree2=$(do_facet $facet \ + lctl get_param -n osd*.*$mdtname.kbytesfree) + [ $(($mdtfree1 - $mdtfree2)) -ge 102 ] || + error "MDT free space is wrong after append" + fi + + # delete + rm $dom + if [ $space_check == 1 ]; then + mdtfree1=$(do_facet $facet \ + lctl get_param -n osd*.*$mdtname.kbytesfree) + [ $(($mdtfree1 - $mdtfree2)) -ge 112 ] || + error "MDT free space is wrong after removal" + fi + + # combined striping + $LFS setstripe -E 1024K -L mdt -E EOF $dom || + error "Can't create DoM + OST striping" + + dd if=/dev/urandom of=$tmp bs=1024 count=2000 + # check also direct IO along write + dd if=$tmp of=$dom bs=102400 count=20 oflag=direct + sync + cmp $tmp $dom || error "file data is different" + [ $(stat -c%s $dom) == 2048000 ] || error "bad size after write" + rm $dom + rm $tmp + + return 0 +} +run_test 270a "DoM: basic functionality tests" + +test_270b() { + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] && + skip "Need MDS version at least 2.10.55" && return + + local dom=$DIR/$tdir/dom_file + local max_size=1048576 + + mkdir -p $DIR/$tdir + $LFS setstripe -E $max_size -L mdt $dom + + # truncate over the limit + $TRUNCATE $dom $(($max_size + 1)) && + error "successful truncate over the maximum size" + # write over the limit + dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 && + error "successful write over the maximum size" + # append over the limit + dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1 + echo "12345" >> $dom && error "successful append over the maximum size" + rm $dom + + return 0 +} +run_test 270b "DoM: maximum size overflow checks for DoM-only file" + +test_270c() { + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] && + skip "Need MDS version at least 2.10.55" && return + + mkdir -p $DIR/$tdir + $LFS setstripe -E 1024K -L mdt $DIR/$tdir + + # check files inherit DoM EA + touch $DIR/$tdir/first + [ $($GETSTRIPE -L $DIR/$tdir/first) == "mdt" ] || + error "bad pattern" + [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] || + error "bad stripe count" + [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] || + error "bad stripe size" + + # check directory inherits DoM EA and uses it as default + mkdir $DIR/$tdir/subdir + touch $DIR/$tdir/subdir/second + [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] || + error "bad pattern in sub-directory" + [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] || + error "bad stripe count in sub-directory" + [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] || + error "bad stripe size in sub-directory" + return 0 +} +run_test 270c "DoM: DoM EA inheritance tests" + +test_270d() { + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] && + skip "Need MDS version at least 2.10.55" && return + + mkdir -p $DIR/$tdir + $LFS setstripe -E 1024K -L mdt $DIR/$tdir + + # inherit default DoM striping + mkdir $DIR/$tdir/subdir + touch $DIR/$tdir/subdir/f1 + + # change default directory striping + $LFS setstripe -c 1 $DIR/$tdir/subdir + touch $DIR/$tdir/subdir/f2 + [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] || + error "wrong default striping in file 2" + [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] || + error "bad pattern in file 2" + return 0 +} +run_test 270d "DoM: change striping from DoM to RAID0" + +test_270e() { + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] && + skip "Need MDS version at least 2.10.55" && return + + mkdir -p $DIR/$tdir/dom + mkdir -p $DIR/$tdir/norm + DOMFILES=20 + NORMFILES=10 + $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom + $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm + + createmany -o $DIR/$tdir/dom/dom- $DOMFILES + createmany -o $DIR/$tdir/norm/norm- $NORMFILES + + # find DoM files by layout + NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l) + [ $NUM -eq $DOMFILES ] || + error "lfs find -L: found $NUM, expected $DOMFILES" + echo "Test 1: lfs find 20 DOM files by layout: OK" + + # there should be 1 dir with default DOM striping + NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l) + [ $NUM -eq 1 ] || + error "lfs find -L: found $NUM, expected 1 dir" + echo "Test 2: lfs find 1 DOM dir by layout: OK" + + # find DoM files by stripe size + NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l) + [ $NUM -eq $DOMFILES ] || + error "lfs find -S: found $NUM, expected $DOMFILES" + echo "Test 4: lfs find 20 DOM files by stripe size: OK" + + # find files by stripe offset except DoM files + NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l) + [ $NUM -eq $NORMFILES ] || + error "lfs find -i: found $NUM, expected $NORMFILES" + echo "Test 5: lfs find no DOM files by stripe index: OK" + return 0 +} +run_test 270e "DoM: lfs find with DoM files test" + +test_270f() { + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] && + skip "Need MDS version at least 2.10.55" && return + + local mdtname=${FSNAME}-MDT0000-mdtlov + local dom=$DIR/$tdir/dom_file + local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \ + lod.$mdtname.dom_stripesize) + local dom_limit=131072 + + do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit + local dom_current=$(do_facet mds1 $LCTL get_param -n \ + lod.$mdtname.dom_stripesize) + [ ${dom_limit} -eq ${dom_current} ] || + error "Cannot change per-MDT DoM stripe limit to $dom_limit" + + $LFS mkdir -i 0 -c 1 $DIR/$tdir + $LFS setstripe -d $DIR/$tdir + $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir || + error "Can't set directory default striping" + + # exceed maximum stripe size + $LFS setstripe -E $(($dom_limit * 2)) -L mdt $dom && + error "Able to create DoM component size more than LOD limit" + + do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0 + dom_current=$(do_facet mds1 $LCTL get_param -n \ + lod.$mdtname.dom_stripesize) + [ 0 -eq ${dom_current} ] || + error "Can't set zero DoM stripe limit" + + # too low values to be aligned with smallest stripe size 64K + do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000 + dom_current=$(do_facet mds1 $LCTL get_param -n \ + lod.$mdtname.dom_stripesize) + [ 30000 -eq ${dom_current} ] && + error "Can set too small DoM stripe limit" + + do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648 + dom_current=$(do_facet mds1 $LCTL get_param -n \ + lod.$mdtname.dom_stripesize) + echo $dom_current + [ 2147483648 -eq ${dom_current} ] && + error "Can set too large DoM stripe limit" + + do_facet mds1 $LCTL set_param -n \ + lod.$mdtname.dom_stripesize=$((dom_limit * 2)) + $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom || + error "Can't create DoM component size after limit change" + do_facet mds1 $LCTL set_param -n \ + lod.$mdtname.dom_stripesize=$((dom_limit / 2)) + $LFS setstripe -E $dom_limit -L mdt ${dom}_big && + error "Can create big DoM component after limit decrease" + touch ${dom}_def || + error "Can't create file with old default layout" + + do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved + return 0 +} +run_test 270f "DoM: maximum DoM stripe size checks" + +test_271a() { + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] && + skip "Need MDS version at least 2.10.55" && return + + local dom=$DIR/$tdir/dom + + mkdir -p $DIR/$tdir + + $LFS setstripe -E 1024K -L mdt $dom + + lctl set_param -n mdc.*.stats=clear + dd if=/dev/zero of=$dom bs=4096 count=1 || return 1 + cat $dom > /dev/null + local reads=$(lctl get_param -n mdc.*.stats | + awk '/ost_read/ {print $2}') + [ -z $reads ] || error "Unexpected $reads READ RPCs" + ls $dom + rm -f $dom +} +run_test 271a "DoM: data is cached for read after write" + +test_271b() { + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] && + skip "Need MDS version at least 2.10.55" && return + + local dom=$DIR/$tdir/dom + + mkdir -p $DIR/$tdir + + $LFS setstripe -E 1024K -L mdt -E EOF $dom + + lctl set_param -n mdc.*.stats=clear + dd if=/dev/zero of=$dom bs=4096 count=1 || return 1 + cancel_lru_locks mdc + $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails" + # second stat to check size is cached on client + $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails" + local gls=$(lctl get_param -n mdc.*.stats | + awk '/ldlm_glimpse/ {print $2}') + [ -z $gls ] || error "Unexpected $gls glimpse RPCs" + rm -f $dom +} +run_test 271b "DoM: no glimpse RPC for stat (DoM only file)" + +test_271ba() { + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] && + skip "Need MDS version at least 2.10.55" && return + + local dom=$DIR/$tdir/dom + + mkdir -p $DIR/$tdir + + $LFS setstripe -E 1024K -L mdt -E EOF $dom + + lctl set_param -n mdc.*.stats=clear + lctl set_param -n osc.*.stats=clear + dd if=/dev/zero of=$dom bs=2048K count=1 || return 1 + cancel_lru_locks mdc + $CHECKSTAT -t file -s 2097152 $dom || error "stat" + # second stat to check size is cached on client + $CHECKSTAT -t file -s 2097152 $dom || error "stat" + local gls=$(lctl get_param -n mdc.*.stats | + awk '/ldlm_glimpse/ {print $2}') + [ -z $gls ] || error "Unexpected $gls glimpse RPCs" + local gls=$(lctl get_param -n osc.*.stats | + awk '/ldlm_glimpse/ {print $2}') + [ -z $gls ] || error "Unexpected $gls OSC glimpse RPCs" + rm -f $dom +} +run_test 271ba "DoM: no glimpse RPC for stat (combined file)" + +test_271c() { + # test to be enabled with lock_convert + skip "skipped until lock convert will be implemented" && return + + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] && + skip "Need MDS version at least 2.10.55" && return + + local dom=$DIR/$tdir/dom + + mkdir -p $DIR/$tdir + + $LFS setstripe -E 1024K -L mdt $DIR/$tdir + + local mdtidx=$($LFS getstripe -M $DIR/$tdir) + local facet=mds$((mdtidx + 1)) + + cancel_lru_locks mdc + do_facet $facet lctl set_param -n mdt.*.dom_lock=0 + createmany -o $dom 1000 + lctl set_param -n mdc.*.stats=clear + smalliomany -w $dom 1000 200 + lctl get_param -n mdc.*.stats + local enq=$(lctl get_param -n mdc.*.stats | + awk '/ldlm_ibits_enqueue/ {print $2}') + # Each file has 1 open, 1 IO enqueues, total 2000 + # but now we have also +1 getxattr for security.capability, total 3000 + [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000" + unlinkmany $dom 1000 + + cancel_lru_locks mdc + do_facet $facet lctl set_param -n mdt.*.dom_lock=1 + createmany -o $dom 1000 + lctl set_param -n mdc.*.stats=clear + smalliomany -w $dom 1000 200 + lctl get_param -n mdc.*.stats + local enq_2=$(lctl get_param -n mdc.*.stats | + awk '/ldlm_ibits_enqueue/ {print $2}') + # Expect to see reduced amount of RPCs by 1000 due to single enqueue + # for OPEN and IO lock. + [ $((enq - enq_2)) -ge 1000 ] || + error "Too many enqueues $enq_2, expected about $((enq - 1000))" + unlinkmany $dom 1000 + return 0 +} +run_test 271c "DoM: IO lock at open saves enqueue RPCs" + +test_276() { + remote_ost_nodsh && skip "remote OST with nodsh" && return + local pid + + do_facet ost1 "(while true; do \ + $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \ + done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" & + pid=$! + + for LOOP in $(seq 20); do + stop ost1 + start ost1 $(ostdevname 1) $OST_MOUNT_OPTS + done + kill -9 $pid + do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \ + rm $TMP/sanity_276_pid" +} +run_test 276 "Race between mount and obd_statfs" + cleanup_test_300() { trap 0 umask $SAVE_UMASK @@ -14988,7 +16260,7 @@ test_striped_dir() { SAVE_UMASK=$(umask) trap cleanup_test_300 RETURN EXIT - $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \ + $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \ $DIR/$tdir/striped_dir || error "set striped dir error" @@ -15067,23 +16339,19 @@ test_300b() { local mtime2 local mtime3 - test_mkdir $DIR/$tdir - $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir || + test_mkdir $DIR/$tdir || error "mkdir fail" + $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir || error "set striped dir error" - for ((i=0; i<10; i++)); do + for i in {0..9}; do mtime1=$(stat -c %Y $DIR/$tdir/striped_dir) sleep 1 - touch $DIR/$tdir/striped_dir/file_$i || - error "touch error $i" + touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i" mtime2=$(stat -c %Y $DIR/$tdir/striped_dir) - [ $mtime1 -eq $mtime2 ] && - error "mtime not change after create" + [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create" sleep 1 - rm -f $DIR/$tdir/striped_dir/file_$i || - error "unlink error $i" + rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i" mtime3=$(stat -c %Y $DIR/$tdir/striped_dir) - [ $mtime2 -eq $mtime3 ] && - error "mtime did not change after unlink" + [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink" done true } @@ -15126,7 +16394,7 @@ test_300d() { $SETSTRIPE -c 2 $DIR/$tdir #local striped directory - $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir || + $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir || error "set striped dir error" createmany -o $DIR/$tdir/striped_dir/f 10 || error "create 10 files failed" @@ -15157,7 +16425,7 @@ test_300e() { mkdir -p $DIR/$tdir - $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir || + $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir || error "set striped dir error" touch $DIR/$tdir/striped_dir/a @@ -15168,13 +16436,13 @@ test_300e() { mkdir $DIR/$tdir/striped_dir/dir_b mkdir $DIR/$tdir/striped_dir/dir_c - $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a || + $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a || error "set striped adir under striped dir error" $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b || error "set striped bdir under striped dir error" - $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c || + $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c || error "set striped cdir under striped dir error" mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b || @@ -15204,10 +16472,10 @@ test_300f() { rm -rf $DIR/$tdir mkdir -p $DIR/$tdir - $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir || + $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir || error "set striped dir error" - $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 || + $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 || error "set striped dir error" touch $DIR/$tdir/striped_dir/a @@ -15341,8 +16609,7 @@ test_300h() { local stripe_count mkdir $DIR/$tdir - $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \ - $DIR/$tdir/striped_dir || + $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir || error "set striped dir error" test_300_check_default_striped_dir striped_dir $MDSCOUNT 1 @@ -15373,7 +16640,7 @@ test_300i() { mkdir $DIR/$tdir - $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir || + $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir || error "set striped dir error" createmany -o $DIR/$tdir/striped_dir/f- 10 || @@ -15429,7 +16696,7 @@ test_300j() { #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702 $LCTL set_param fail_loc=0x1702 - $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir || + $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir || error "set striped dir error" createmany -o $DIR/$tdir/striped_dir/f- 10 || @@ -15623,8 +16890,8 @@ test_300p() { #define OBD_FAIL_OUT_ENOSPC 0x1704 do_facet mds2 lctl set_param fail_loc=0x80001704 - $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 && - error "create striped directory should fail" + $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \ + && error "create striped directory should fail" [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists" @@ -15657,7 +16924,8 @@ prepare_remote_file() { mkdir $DIR/$tdir/src_dir || error "create remote source failed" - cp /etc/hosts $DIR/$tdir/src_dir/a || error + cp /etc/hosts $DIR/$tdir/src_dir/a || + error "cp to remote source failed" touch $DIR/$tdir/src_dir/a $LFS mkdir -i 1 $DIR/$tdir/tgt_dir || @@ -15688,8 +16956,9 @@ test_310a() { prepare_remote_file || error "prepare remote file failed" #open-unlink file - $OPENUNLINK $remote_file $remote_file || error - $CHECKSTAT -a $remote_file || error + $OPENUNLINK $remote_file $remote_file || + error "openunlink $remote_file failed" + $CHECKSTAT -a $remote_file || error "$remote_file exists" } run_test 310a "open unlink remote file" @@ -15898,6 +17167,33 @@ test_313() { } run_test 313 "io should fail after last_rcvd update fail" +test_314() { + $SETSTRIPE -c 2 -i 0 $DIR/$tfile || error "setstripe failed" + do_facet ost1 "$LCTL set_param fail_loc=0x720" + rm -f $DIR/$tfile + wait_delete_completed + do_facet ost1 "$LCTL set_param fail_loc=0" +} +run_test 314 "OSP shouldn't fail after last_rcvd update failure" + +test_315() { # LU-618 + local file=$DIR/$tfile + rm -f $file + + $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4096000c + $MULTIOP $file oO_RDONLY:r4096000_c & + PID=$! + + sleep 2 + + local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io) + kill -USR1 $PID + + [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)" + rm -f $file +} +run_test 315 "read should be accounted" + test_fake_rw() { local read_write=$1 if [ "$read_write" = "write" ]; then @@ -16167,7 +17463,7 @@ test_403() { wait - [ `cat $tfile` -gt 0 ] || error "wrong nlink count: `cat $tfile`" + [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)" rm -f $tfile $file1 $file2 } @@ -16225,73 +17521,68 @@ test_406() { [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] && skip "Need MDS version at least 2.8.50" && return - local def_stripe_count=$($GETSTRIPE -c $MOUNT) - local def_stripe_size=$($GETSTRIPE -S $MOUNT) - local def_stripe_offset=$($GETSTRIPE -i $MOUNT) - local def_pool=$($GETSTRIPE -p $MOUNT) - + local def_stripe_size=$($LFS getstripe -S $MOUNT) local test_pool=$TESTNAME + + if ! combined_mgs_mds ; then + mount_mgs_client + fi pool_add $test_pool || error "pool_add failed" pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 || error "pool_add_targets failed" + save_layout_restore_at_exit $MOUNT + # parent set default stripe count only, child will stripe from both # parent and fs default - $SETSTRIPE -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT || + $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT || error "setstripe $MOUNT failed" $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed" - $SETSTRIPE -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed" + $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed" for i in $(seq 10); do local f=$DIR/$tdir/$tfile.$i touch $f || error "touch failed" - local count=$($GETSTRIPE -c $f) + local count=$($LFS getstripe -c $f) [ $count -eq $OSTCOUNT ] || error "$f stripe count $count != $OSTCOUNT" - local offset=$($GETSTRIPE -i $f) + local offset=$($LFS getstripe -i $f) [ $offset -eq 1 ] || error "$f stripe offset $offset != 1" - local size=$($GETSTRIPE -S $f) + local size=$($LFS getstripe -S $f) [ $size -eq $((def_stripe_size * 2)) ] || error "$f stripe size $size != $((def_stripe_size * 2))" - local pool=$($GETSTRIPE -p $f) + local pool=$($LFS getstripe -p $f) [ $pool == $test_pool ] || error "$f pool $pool != $test_pool" done # change fs default striping, delete parent default striping, now child # will stripe from new fs default striping only - $SETSTRIPE -c 1 -S $def_stripe_size -i 0 $MOUNT || + $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT || error "change $MOUNT default stripe failed" - $SETSTRIPE -c 0 $DIR/$tdir || error "delete $tdir default stripe failed" + $LFS setstripe -c 0 $DIR/$tdir || + error "delete $tdir default stripe failed" for i in $(seq 11 20); do local f=$DIR/$tdir/$tfile.$i touch $f || error "touch $f failed" - local count=$($GETSTRIPE -c $f) + local count=$($LFS getstripe -c $f) [ $count -eq 1 ] || error "$f stripe count $count != 1" - local offset=$($GETSTRIPE -i $f) + local offset=$($LFS getstripe -i $f) [ $offset -eq 0 ] || error "$f stripe offset $offset != 0" - local size=$($GETSTRIPE -S $f) + local size=$($LFS getstripe -S $f) [ $size -eq $def_stripe_size ] || error "$f stripe size $size != $def_stripe_size" - local pool=$($GETSTRIPE -p $f) - [ "#$pool" == "#" ] || error "$f pool $pool is set" - + local pool=$($LFS getstripe -p $f) + [ $pool == $test_pool ] || error "$f pool $pool isn't set" done unlinkmany $DIR/$tdir/$tfile. 1 20 - # restore FS default striping - if [ -z $def_pool ]; then - $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \ - -i $def_stripe_offset $MOUNT || - error "restore default striping failed" - else - $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \ - -i $def_stripe_offset -p $def_pool $MOUNT || - error "restore default striping with $def_pool failed" - fi - local f=$DIR/$tdir/$tfile pool_remove_all_targets $test_pool $f pool_remove $test_pool $f + + if ! combined_mgs_mds ; then + umount_mgs_client + fi } run_test 406 "DNE support fs default striping" @@ -16426,6 +17717,62 @@ test_411() { } run_test 411 "Slab allocation error with cgroup does not LBUG" +test_412() { + [ $MDSCOUNT -lt 2 ] && + skip "We need at least 2 MDTs for this test" && return + + if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then + skip "Need server version at least 2.10.55" && exit 0 + fi + + $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir || + error "mkdir failed" + $LFS getdirstripe $DIR/$tdir + local stripe_index=$($LFS getdirstripe -i $DIR/$tdir) + [ $stripe_index -eq $((MDSCOUNT - 1)) ] || + error "expect $((MDSCOUT - 1)) get $stripe_index" + local stripe_count=$($LFS getdirstripe -T $DIR/$tdir) + [ $stripe_count -eq 2 ] || + error "expect 2 get $stripe_count" +} +run_test 412 "mkdir on specific MDTs" + +test_413() { + [ $MDSCOUNT -lt 2 ] && + skip "We need at least 2 MDTs for this test" && return + + if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then + skip "Need server version at least 2.10.55" && exit 0 + fi + + mkdir $DIR/$tdir || error "mkdir failed" + + # find MDT that is the most full + local max=$($LFS df | grep MDT | + awk 'BEGIN { a=0 } + { sub("%", "", $5) + if (0+$5 >= a) + { + a = $5 + b = $6 + } + } + END { split(b, c, ":") + sub("]", "", c[2]) + print c[2] + }') + + for i in $(seq $((MDSCOUNT - 1))); do + $LFS mkdir -c $i $DIR/$tdir/d$i || + error "mkdir d$i failed" + $LFS getdirstripe $DIR/$tdir/d$i + local stripe_index=$($LFS getdirstripe -i $DIR/$tdir/d$i) + [ $stripe_index -ne $max ] || + error "don't expect $max" + done +} +run_test 413 "mkdir on less full MDTs" + prep_801() { [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] || [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] && @@ -16694,6 +18041,138 @@ test_802() { } run_test 802 "simulate readonly device" +test_803() { + [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] && + skip "MDS needs to be newer than 2.10.54" && return + + mkdir -p $DIR/$tdir + # Create some objects on all MDTs to trigger related logs objects + for idx in $(seq $MDSCOUNT); do + $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \ + $DIR/$tdir/dir${idx} || + error "Fail to create $DIR/$tdir/dir${idx}" + done + + sync; sleep 3 + echo "before create:" + $LFS df -i $MOUNT + local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}') + + for ((i=0; i<10; i++)); do + $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i || + error "Fail to create $DIR/$tdir/foo$i" + done + + sync; sleep 3 + echo "after create:" + $LFS df -i $MOUNT + local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}') + + [ $after_used -ge $((before_used + 10)) ] || + error "before ($before_used) + 10 > after ($after_used)" + + for ((i=0; i<10; i++)); do + rm -rf $DIR/$tdir/foo$i || + error "Fail to remove $DIR/$tdir/foo$i" + done + + sleep 3 # avoid MDT return cached statfs + wait_delete_completed + echo "after unlink:" + $LFS df -i $MOUNT + before_used=$after_used + after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}') + + [ $after_used -le $((before_used - 8)) ] || + error "before ($before_used) - 8 < after ($after_used)" +} +run_test 803 "verify agent object for remote object" + +test_804() { + [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] && + skip "MDS needs to be newer than 2.10.54" && return + + [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] && + skip "ldiskfs only test" && return 0 + + mkdir -p $DIR/$tdir + $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 || + error "Fail to create $DIR/$tdir/dir0" + + local fid=$($LFS path2fid $DIR/$tdir/dir0) + local dev=$(mdsdevname 2) + + do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" | + grep ${fid} || error "NOT found agent entry for dir0" + + $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 || + error "Fail to create $DIR/$tdir/dir1" + + touch $DIR/$tdir/dir1/foo0 || + error "Fail to create $DIR/$tdir/dir1/foo0" + fid=$($LFS path2fid $DIR/$tdir/dir1/foo0) + local rc=0 + + for idx in $(seq $MDSCOUNT); do + dev=$(mdsdevname $idx) + do_facet mds${idx} \ + "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" | + grep ${fid} && rc=$idx + done + + mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 || + error "Fail to rename foo0 to foo1" + if [ $rc -eq 0 ]; then + for idx in $(seq $MDSCOUNT); do + dev=$(mdsdevname $idx) + do_facet mds${idx} \ + "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" | + grep ${fid} && rc=$idx + done + fi + + mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 || + error "Fail to rename foo1 to foo2" + if [ $rc -eq 0 ]; then + for idx in $(seq $MDSCOUNT); do + dev=$(mdsdevname $idx) + do_facet mds${idx} \ + "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" | + grep ${fid} && rc=$idx + done + fi + + [ $rc -ne 0 ] || error "NOT found agent entry for foo" + + ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard || + error "Fail to link to $DIR/$tdir/dir1/foo2" + mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 || + error "Fail to rename foo2 to foo0" + unlink $DIR/$tdir/dir1/foo0 || + error "Fail to unlink $DIR/$tdir/dir1/foo0" + rm -rf $DIR/$tdir/dir0 || + error "Fail to rm $DIR/$tdir/dir0" + + for idx in $(seq $MDSCOUNT); do + dev=$(mdsdevname $idx) + rc=0 + + stop mds${idx} + run_e2fsck $(facet_active_host mds$idx) $dev -n || + rc=$? + start mds${idx} $dev $MDS_MOUNT_OPTS || + error "mount mds$idx failed" + df $MOUNT > /dev/null 2>&1 + + # e2fsck should not return error + [ $rc -eq 0 ] || + error "e2fsck detected error on MDT${idx}: rc=$rc" + done +} +run_test 804 "verify agent entry for remote entry" + # # tests that do cleanup/setup should be run at the end #