X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Ftests%2Fsanityn.sh;h=4cd17e5dffe658ef7fb756e7c6fc9e6716976e72;hp=d35bf13404c927179925fc68f45b616b79ab3218;hb=97a64c94671c3116eddd54ca2fdda88dfad466f0;hpb=2083f8a34b556c9e64e09a4529df7d9bdbdd7532 diff --git a/lustre/tests/sanityn.sh b/lustre/tests/sanityn.sh old mode 100644 new mode 100755 index d35bf13..4cd17e5 --- a/lustre/tests/sanityn.sh +++ b/lustre/tests/sanityn.sh @@ -3,8 +3,9 @@ set -e ONLY=${ONLY:-"$*"} -# bug number for skipped test: 3192 LU-1205 15528/3811 9977 15528/11549 18080 -ALWAYS_EXCEPT=" 14b 18c 19 28 29 35 $SANITYN_EXCEPT" +# bug number for skipped test: 9977/LU-7105 +# LU-7105 +ALWAYS_EXCEPT=" 28 $SANITYN_EXCEPT" # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT! SRCDIR=$(dirname $0) @@ -33,12 +34,12 @@ init_test_env $@ init_logging if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then -# bug number for skipped test: LU-2189 LU-2776 - ALWAYS_EXCEPT="$ALWAYS_EXCEPT 36 51a" +# bug number for skipped test: + ALWAYS_EXCEPT="$ALWAYS_EXCEPT " # LU-2829 / LU-2887 - make allowances for ZFS slowness TEST33_NFILES=${TEST33_NFILES:-1000} fi - +# 23 (min)" [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a" FAIL_ON_ERROR=false @@ -48,8 +49,7 @@ TRACE=${TRACE:-""} check_and_setup_lustre -LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1) -OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd) +OSC=${OSC:-"osc"} assert_DIR rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}* @@ -64,38 +64,29 @@ check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS build_test_filter -mkdir -p $MOUNT2 -mount_client $MOUNT2 - -test_1a() { - touch $DIR1/f1 - [ -f $DIR2/f1 ] || error -} -run_test 1a "check create on 2 mtpt's ==========================" - -test_1b() { - chmod 777 $DIR2/f1 - $CHECKSTAT -t file -p 0777 $DIR1/f1 || error - chmod a-x $DIR2/f1 -} -run_test 1b "check attribute updates on 2 mtpt's ===============" +test_1() { + touch $DIR1/$tfile + [ -f $DIR2/$tfile ] || error "Check create" + chmod 777 $DIR2/$tfile + $CHECKSTAT -t file -p 0777 $DIR1/$tfile || + error "Check attribute update for 0777" -test_1c() { - $CHECKSTAT -t file -p 0666 $DIR1/f1 || error -} -run_test 1c "check after remount attribute updates on 2 mtpt's =" + chmod a-x $DIR2/$tfile + $CHECKSTAT -t file -p 0666 $DIR1/$tfile || + error "Check attribute update for 0666" -test_1d() { - rm $DIR2/f1 - $CHECKSTAT -a $DIR1/f1 || error + rm $DIR2/$tfile + $CHECKSTAT -a $DIR1/$tfile || + error "Check unlink - removes file on other mountpoint" } -run_test 1d "unlink on one mountpoint removes file on other ====" +run_test 1 "Check attribute updates on 2 mount points" test_2a() { touch $DIR1/f2a ls -l $DIR2/f2a chmod 777 $DIR2/f2a - $CHECKSTAT -t file -p 0777 $DIR1/f2a || error + $CHECKSTAT -t file -p 0777 $DIR1/f2a || + error "Either not file type or perms not 0777" } run_test 2a "check cached attribute updates on 2 mtpt's ========" @@ -103,20 +94,23 @@ test_2b() { touch $DIR1/f2b ls -l $DIR2/f2b chmod 777 $DIR1/f2b - $CHECKSTAT -t file -p 0777 $DIR2/f2b || error + $CHECKSTAT -t file -p 0777 $DIR2/f2b || + error "Either not file type or perms not 0777" } run_test 2b "check cached attribute updates on 2 mtpt's ========" # NEED TO SAVE ROOT DIR MODE test_2c() { chmod 777 $DIR1 - $CHECKSTAT -t dir -p 0777 $DIR2 || error + $CHECKSTAT -t dir -p 0777 $DIR2 || + error "Either not dir type or perms not 0777" } run_test 2c "check cached attribute updates on 2 mtpt's root ===" test_2d() { chmod 755 $DIR1 - $CHECKSTAT -t dir -p 0755 $DIR2 || error + $CHECKSTAT -t dir -p 0755 $DIR2 || + error "Either not file type or perms not 0775" } run_test 2d "check cached attribute updates on 2 mtpt's root ===" @@ -125,7 +119,8 @@ test_2e() { ls -l $DIR1 ls -l $DIR2 chmod 777 $DIR1 - $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error + $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || + error "dd failed" } run_test 2e "check chmod on root is propagated to others" @@ -172,7 +167,7 @@ test_2g() { local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ') echo "$DIR1/$tfile has $block1 blocks" echo "$DIR2/$tfile has $block2 blocks" - [ $block1 -eq $block2 ] || error + [ $block1 -eq $block2 ] || error "$block1 not equal to $block2" } run_test 2g "check blocks update on sync write" @@ -192,7 +187,8 @@ run_test 4 "fstat validation on multiple mount points ==========" test_5() { mcreate $DIR1/f5 $TRUNCATE $DIR2/f5 100 - $CHECKSTAT -t file -s 100 $DIR1/f5 || error + $CHECKSTAT -t file -s 100 $DIR1/f5 || + error "Either not file type or size not equal to 100 bytes" rm $DIR1/f5 } run_test 5 "create a file on one mount, truncate it on the other" @@ -216,7 +212,7 @@ test_8() { } run_test 8 "remove of open special file on other node ==========" -test_9() { +test_9a() { MTPT=1 local dir > $DIR2/f9 @@ -228,7 +224,23 @@ test_9() { [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \ error "`od -a $DIR1/f9` != abcdefghijkl" } -run_test 9 "append of file with sub-page size on multiple mounts" +run_test 9a "append of file with sub-page size on multiple mounts" + +#LU-10681 - tiny writes & appending to sparse striped file +test_9b() { + [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; } + + $LFS setstripe -c 2 -S 1M $DIR/$tfile + echo "foo" >> $DIR/$tfile + dd if=/dev/zero of=$DIR2/$tfile bs=1M count=1 seek=1 conv=notrunc || + error "sparse dd $DIR2/$tfile failed" + echo "foo" >> $DIR/$tfile + + data=$(dd if=$DIR2/$tfile bs=1 count=3 skip=$((2 * 1048576)) conv=notrunc) + echo "Data read (expecting 'foo')": $data + [ "$data" = "foo" ] || error "append to sparse striped file failed" +} +run_test 9b "append to striped sparse file" test_10a() { MTPT=1 @@ -271,34 +283,34 @@ test_11() { $DIR2/d11/f RC=$? kill -USR1 $MULTIPID - wait $MULTIPID || error + wait $MULTIPID || error "wait for PID $MULTIPID failed" [ $RC -eq 0 ] && error || true } run_test 11 "execution of file opened for write should return error ====" test_12() { - DIR=$DIR DIR2=$DIR2 sh lockorder.sh + DIR=$DIR DIR2=$DIR2 sh lockorder.sh } -run_test 12 "test lock ordering (link, stat, unlink) ===========" +run_test 12 "test lock ordering (link, stat, unlink)" test_13() { # bug 2451 - directory coherency - test_mkdir $DIR1/d13 || error - cd $DIR1/d13 || error - ls - ( touch $DIR1/d13/f13 ) # needs to be a separate shell - ls - rm -f $DIR2/d13/f13 || error - ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true - # need to run it twice - ( touch $DIR1/d13/f13 ) # needs to be a separate shell - ls - rm -f $DIR2/d13/f13 || error - ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true -} -run_test 13 "test directory page revocation ====================" - -test_14() { - test_mkdir -p $DIR1/$tdir + test_mkdir $DIR1/d13 + cd $DIR1/d13 || error "cd to $DIR1/d13 failed" + ls + ( touch $DIR1/d13/f13 ) # needs to be a separate shell + ls + rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13" + ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true + # need to run it twice + ( touch $DIR1/d13/f13 ) # needs to be a separate shell + ls + rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13" + ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true +} +run_test 13 "test directory page revocation" + +test_14aa() { + test_mkdir $DIR1/$tdir cp -p /bin/ls $DIR1/$tdir/$tfile multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1 MULTIPID=$! @@ -307,58 +319,62 @@ test_14() { kill -USR1 $MULTIPID wait $MULTIPID || return 2 } -run_test 14 "execution of file open for write returns -ETXTBSY =" +run_test 14aa "execution of file open for write returns -ETXTBSY" -test_14a() { - test_mkdir -p $DIR1/d14 - cp -p `which multiop` $DIR1/d14/multiop || error "cp failed" - MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1 - MULTIOP_PID=$! - $MULTIOP $DIR2/d14/multiop Oc && error "expected error, got success" - kill -USR1 $MULTIOP_PID || return 2 - wait $MULTIOP_PID || return 3 - rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop" +test_14ab() { + test_mkdir $DIR1/$tdir + cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed" + MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c || + return 1 + MULTIOP_PID=$! + $MULTIOP $DIR2/$tdir/multiop Oc && error "expected error, got success" + kill -USR1 $MULTIOP_PID || return 2 + wait $MULTIOP_PID || return 3 + rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop" } -run_test 14a "open(RDWR) of executing file returns -ETXTBSY ====" +run_test 14ab "open(RDWR) of executing file returns -ETXTBSY" test_14b() { # bug 3192, 7040 - test_mkdir -p $DIR1/d14 - cp -p `which multiop` $DIR1/d14/multiop || error "cp failed" - MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1 - MULTIOP_PID=$! - $TRUNCATE $DIR2/d14/multiop 0 && kill -9 $MULTIOP_PID && \ + test_mkdir $DIR1/$tdir + cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed" + MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c || + return 1 + MULTIOP_PID=$! + $TRUNCATE $DIR2/$tdir/multiop 0 && kill -9 $MULTIOP_PID && \ error "expected truncate error, got success" - kill -USR1 $MULTIOP_PID || return 2 - wait $MULTIOP_PID || return 3 - cmp `which multiop` $DIR1/d14/multiop || error "binary changed" - rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop" + kill -USR1 $MULTIOP_PID || return 2 + wait $MULTIOP_PID || return 3 + cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed" + rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop" } run_test 14b "truncate of executing file returns -ETXTBSY ======" test_14c() { # bug 3430, 7040 - test_mkdir -p $DIR1/d14 - cp -p `which multiop` $DIR1/d14/multiop || error "cp failed" - MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1 - MULTIOP_PID=$! - cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success" + test_mkdir $DIR1/$tdir + cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed" + MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c || + return 1 + MULTIOP_PID=$! + cp /etc/hosts $DIR2/$tdir/multiop && error "expected error, got success" kill -USR1 $MULTIOP_PID || return 2 wait $MULTIOP_PID || return 3 - cmp `which multiop` $DIR1/d14/multiop || error "binary changed" - rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop" + cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed" + rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop" } run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY ==" test_14d() { # bug 10921 - test_mkdir -p $DIR1/d14 - cp -p `which multiop` $DIR1/d14/multiop || error "cp failed" - MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1 - MULTIOP_PID=$! + test_mkdir $DIR1/$tdir + cp -p $(which multiop) $DIR1/$tdir/multiop || error "cp failed" + MULTIOP_PROG=$DIR1/$tdir/multiop multiop_bg_pause $TMP/$tfile O_c || + return 1 + MULTIOP_PID=$! log chmod - chmod 600 $DIR1/d14/multiop || error "chmod failed" + chmod 600 $DIR1/$tdir/multiop || error "chmod failed" kill -USR1 $MULTIOP_PID || return 2 wait $MULTIOP_PID || return 3 - cmp `which multiop` $DIR1/d14/multiop || error "binary changed" - rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop" + cmp $(which multiop) $DIR1/$tdir/multiop || error "binary changed" + rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop" } run_test 14d "chmod of executing file is still possible ========" @@ -386,7 +402,31 @@ else FSXP=100 fi -test_16() { +test_16a() { + local file1=$DIR1/$tfile + local file2=$DIR2/$tfile + local stripe_size=$(do_facet $SINGLEMDS \ + "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize") + + # to allocate grant because it may run out due to test_15. + $LFS setstripe -c -1 $file1 + dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync + dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync + rm -f $file1 + + $LFS setstripe -c -1 $file1 # b=10919 + fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \ + || error "fsx failed" + rm -f $file1 + + # O_DIRECT reads and writes must be aligned to the device block size. + fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r 4096 \ + -w 4096 $file1 $file2 || error "fsx with O_DIRECT failed." +} +run_test 16a "$FSXNUM iterations of dual-mount fsx" + +# Consistency check for tiny writes, LU-9409 +test_16b() { local file1=$DIR1/$tfile local file2=$DIR2/$tfile @@ -397,9 +437,48 @@ test_16() { rm -f $file1 lfs setstripe -c -1 $file1 # b=10919 - fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 + # -o is set to 8192 because writes < 1 page and between 1 and 2 pages + # create a mix of tiny writes & normal writes + fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -o 8192 -S 0 $file1 \ + $file2 +} +run_test 16b "$FSXNUM iterations of dual-mount fsx at small size" + +test_16c() { + local file1=$DIR1/$tfile + local file2=$DIR2/$tfile + local stripe_size=$(do_facet $SINGLEMDS \ + "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize") + + [ $(facet_fstype ost1) != ldiskfs ] && skip "dio on ldiskfs only" + + # to allocate grant because it may run out due to test_15. + $LFS setstripe -c -1 $file1 + dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync + dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync + rm -f $file1 + wait_delete_completed + + local list=$(comma_list $(osts_nodes)) + if ! get_osd_param $list '' read_cache_enable >/dev/null; then + skip "not cache-capable obdfilter" + fi + + set_osd_param $list '' read_cache_enable 0 + set_osd_param $list '' writethrough_cache_enable 0 + + $LFS setstripe -c -1 $file1 # b=10919 + fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 \ + || error "fsx failed" + rm -f $file1 + + set_osd_param $list '' read_cache_enable 1 + set_osd_param $list '' writethrough_cache_enable 1 + + return 0 } -run_test 16 "$FSXNUM iterations of dual-mount fsx" +run_test 16c "verify data consistency on ldiskfs with cache disabled (b=17397)" + test_17() { # bug 3513, 3667 remote_ost_nodsh && skip "remote OST with nodsh" && return @@ -435,21 +514,20 @@ run_test 18 "mmap sanity check =================================" test_19() { # bug3811 local node=$(facet_active_host ost1) + [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS) + # check whether obdfilter is cache capable at all - if ! get_osd_param $node '' read_cache_enable >/dev/null; then - echo "not cache-capable obdfilter" - return 0 - fi + get_osd_param $node '' read_cache_enable >/dev/null || + skip "not cache-capable obdfilter" - local MAX=$(get_osd_param $node '' readcache_max_filesize | \ - head -n 1) + local MAX=$(get_osd_param $node '' readcache_max_filesize | head -n 1) set_osd_param $node '' readcache_max_filesize 4096 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2) cp $TMP/$tfile $DIR1/$tfile for i in `seq 1 20`; do [ $((i % 5)) -eq 0 ] && log "$testname loop $i" - cancel_lru_locks osc > /dev/null + cancel_lru_locks $OSC > /dev/null cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \ cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2 wait @@ -465,12 +543,12 @@ run_test 19 "test concurrent uncached read races ===============" test_20() { test_mkdir $DIR1/d20 - cancel_lru_locks osc + cancel_lru_locks $OSC CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`)) $MULTIOP $DIR1/f20 Ow8190c $MULTIOP $DIR2/f20 Oz8194w8190c $MULTIOP $DIR1/f20 Oz0r8190c - cancel_lru_locks osc + cancel_lru_locks $OSC CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT)) [ $CNTD -gt 0 ] && \ error $CNTD" page left in cache after lock cancel" || true @@ -501,7 +579,7 @@ test_23() { # Bug 5972 echo "atime should be updated while another read" > $DIR1/$tfile # clear the lock(mode: LCK_PW) gotten from creating operation - cancel_lru_locks osc + cancel_lru_locks $OSC time1=$(date +%s) echo "now is $time1" sleep $((at_diff + 1)) @@ -533,9 +611,9 @@ test_24a() { OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1` # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1` - lctl --device %$OSC deactivate + lctl --device %osc deactivate lfs df -i || error "lfs df -i with deactivated OSC failed" - lctl --device %$OSC activate + lctl --device %osc activate lfs df || error "lfs df with reactivated OSC failed" } run_test 24a "lfs df [-ih] [path] test =========================" @@ -605,7 +683,7 @@ test_25b() { run_test 25b "change ACL under remote dir on one mountpoint be seen on another" test_26a() { - utime $DIR1/f26a -s $DIR2/f26a || error + utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a" } run_test 26a "allow mtime to get older" @@ -625,7 +703,7 @@ test_26b() { run_test 26b "sync mtime between ost and mds" test_27() { - cancel_lru_locks osc + cancel_lru_locks $OSC lctl clear dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 & DD2_PID=$! @@ -669,46 +747,33 @@ test_28() { # bug 9977 EOF # reading of 1st stripe should pass - dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error + dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed" # reading of 2nd stripe should fail (this stripe was destroyed) dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error # now, recreating test file - dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error + dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed" # reading of 1st stripe should pass - dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error + dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed" # reading of 2nd stripe should pass - dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error + dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || + error "dd failed" } run_test 28 "read/write/truncate file with lost stripes" -test_29() { # bug 10999 - touch $DIR1/$tfile - #define OBD_FAIL_LDLM_GLIMPSE 0x30f - lctl set_param fail_loc=0x8000030f - ls -l $DIR2/$tfile & - usleep 500 - dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 - wait -} -#bug 11549 - permanently turn test off in b1_5 -run_test 29 "lock put race between glimpse and enqueue =========" - -test_30() { #bug #11110, LU-2523 - test_mkdir -p $DIR1/$tdir +test_30() { #b=11110, LU-2523 + test_mkdir $DIR1/$tdir cp -f /bin/bash $DIR1/$tdir/bash - /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; - cp /bin/bash $DIR2/$tdir' & + /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' & $DIR1/$tdir/bash -c 'sleep 2; openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?' wait true } - run_test 30 "recreate file race" test_31a() { - test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir" + test_mkdir $DIR1/$tdir local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \ count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}') #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314 @@ -727,7 +792,7 @@ test_31b() { wait_mds_ost_sync || error "wait_mds_ost_sync()" wait_delete_completed || error "wait_delete_completed()" - test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir" + test_mkdir $DIR1/$tdir lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1 cp /etc/hosts $DIR/$tdir/$tfile #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314 @@ -745,48 +810,51 @@ run_test 31b "voluntary OST cancel / blocking ast race==============" # enable/disable lockless truncate feature, depending on the arg 0/1 enable_lockless_truncate() { - lctl set_param -n osc.*.lockless_truncate $1 + lctl set_param -n $OSC.*.lockless_truncate $1 } test_32a() { # bug 11270 local p="$TMP/$TESTSUITE-$TESTNAME.parameters" - save_lustre_params client "osc.*.lockless_truncate" > $p - cancel_lru_locks osc - enable_lockless_truncate 1 - rm -f $DIR1/$tfile - lfs setstripe -c -1 $DIR1/$tfile - dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \ - /dev/null 2>&1 - clear_osc_stats - - log "checking cached lockless truncate" - $TRUNCATE $DIR1/$tfile 8000000 - $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size" - [ $(calc_osc_stats lockless_truncate) -ne 0 ] || + local stripe_size=$(do_facet $SINGLEMDS \ + "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize") + + save_lustre_params client "$OSC.*.lockless_truncate" > $p + cancel_lru_locks $OSC + enable_lockless_truncate 1 + rm -f $DIR1/$tfile + lfs setstripe -c -1 $DIR1/$tfile + dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$stripe_size > \ + /dev/null 2>&1 + clear_stats $OSC.*.${OSC}_stats + + log "checking cached lockless truncate" + $TRUNCATE $DIR1/$tfile 8000000 + $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size" + [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] || error "cached truncate isn't lockless" - log "checking not cached lockless truncate" - $TRUNCATE $DIR2/$tfile 5000000 - $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size" - [ $(calc_osc_stats lockless_truncate) -ne 0 ] || + log "checking not cached lockless truncate" + $TRUNCATE $DIR2/$tfile 5000000 + $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size" + [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] || error "not cached truncate isn't lockless" - log "disabled lockless truncate" - enable_lockless_truncate 0 - clear_osc_stats - $TRUNCATE $DIR2/$tfile 3000000 - $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size" - [ $(calc_osc_stats lockless_truncate) -eq 0 ] || - error "lockless truncate disabling failed" - rm $DIR1/$tfile - # restore lockless_truncate default values - restore_lustre_params < $p - rm -f $p + log "disabled lockless truncate" + enable_lockless_truncate 0 + clear_stats $OSC.*.${OSC}_stats + $TRUNCATE $DIR2/$tfile 3000000 + $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size" + [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -eq 0 ] || + error "lockless truncate disabling failed" + rm $DIR1/$tfile + # restore lockless_truncate default values + restore_lustre_params < $p + rm -f $p } run_test 32a "lockless truncate" test_32b() { # bug 11270 - remote_ost_nodsh && skip "remote OST with nodsh" && return + remote_ost_nodsh && skip "remote OST with nodsh" && return local node local facets=$(get_facets OST) @@ -799,35 +867,42 @@ test_32b() { # bug 11270 "ldlm.namespaces.filter-*.contended_locks" >> $p save_lustre_params $facets \ "ldlm.namespaces.filter-*.contention_seconds" >> $p - clear_osc_stats + clear_stats $OSC.*.${OSC}_stats - # agressive lockless i/o settings - for node in $(osts_nodes); do - do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 2000000; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 0; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 60' - done - lctl set_param -n osc.*.contention_seconds 60 - for i in $(seq 5); do - dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1 - dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1 - done - [ $(calc_osc_stats lockless_write_bytes) -ne 0 ] || error "lockless i/o was not triggered" - # disable lockless i/o (it is disabled by default) - for node in $(osts_nodes); do - do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 0; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 32; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 0' - done - # set contention_seconds to 0 at client too, otherwise Lustre still - # remembers lock contention - lctl set_param -n osc.*.contention_seconds 0 - clear_osc_stats - for i in $(seq 1); do - dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1 - dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1 - done - [ $(calc_osc_stats lockless_write_bytes) -eq 0 ] || - error "lockless i/o works when disabled" - rm -f $DIR1/$tfile - restore_lustre_params <$p - rm -f $p + # agressive lockless i/o settings + do_nodes $(comma_list $(osts_nodes)) \ + "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \ + ldlm.namespaces.filter-*.contended_locks=0 \ + ldlm.namespaces.filter-*.contention_seconds=60" + lctl set_param -n $OSC.*.contention_seconds=60 + for i in {1..5}; do + dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \ + /dev/null 2>&1 + dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \ + /dev/null 2>&1 + done + [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] || + error "lockless i/o was not triggered" + # disable lockless i/o (it is disabled by default) + do_nodes $(comma_list $(osts_nodes)) \ + "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \ + ldlm.namespaces.filter-*.contended_locks=32 \ + ldlm.namespaces.filter-*.contention_seconds=0" + # set contention_seconds to 0 at client too, otherwise Lustre still + # remembers lock contention + lctl set_param -n $OSC.*.contention_seconds=0 + clear_stats $OSC.*.${OSC}_stats + for i in {1..1}; do + dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \ + /dev/null 2>&1 + dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \ + /dev/null 2>&1 + done + [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] || + error "lockless i/o works when disabled" + rm -f $DIR1/$tfile + restore_lustre_params <$p + rm -f $p } run_test 32b "lockless i/o" @@ -879,7 +954,7 @@ test_33a() { [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat) echo "=== START createmany old: $jbdold transaction" - local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- -r $DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > /dev/null 2>&1") + local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > /dev/null 2>&1") [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat) [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold )) echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS" @@ -928,14 +1003,14 @@ test_33b() { avgjbd=0 avgtime=0 for i in 1 2 3; do - do_node $CLIENT1 "$LFS mkdir -i $MDTIDX -p \ + do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \ $DIR1/$tdir-\\\$(hostname)-$i" jbdold=$(print_jbd_stat) echo "=== START createmany old: $jbdold transaction" local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\ createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \ - -r $DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \ + -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \ /dev/null 2>&1") jbdnew=$(print_jbd_stat) jbd=$(( jbdnew - jbdold )) @@ -961,6 +1036,131 @@ test_33b() { } run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir" +test_33c() { + [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] && + skip "DNE CoS not supported" && return + + local sync_count + + mkdir $DIR/$tdir + sync_all_data + do_facet mds1 "lctl set_param -n mdt.*.sync_count=0" + # do twice in case transaction is committed before unlock, see LU-8200 + for i in 1 2; do + # remote dir is created on MDT1, which enqueued lock of $tdir on + # MDT0 + $LFS mkdir -i 1 $DIR/$tdir/remote.$i + mkdir $DIR/$tdir/local.$i + done + sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count") + echo "sync_count $sync_count" + [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered" + + sync_all_data + do_facet mds1 "lctl set_param -n mdt.*.sync_count=0" + $LFS mkdir -i 1 $DIR/$tdir/remote.3 + # during sleep remote mkdir should have been committed and canceled + # remote lock spontaneously, which shouldn't trigger sync + sleep 6 + mkdir $DIR/$tdir/local.3 + sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count") + echo "sync_count $sync_count" + [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered" +} +run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel" + +# arg1 is operations done before CoS, arg2 is the operation that triggers CoS +op_trigger_cos() { + local commit_nr + local total=0 + local nodes=$(comma_list $(mdts_nodes)) + + sync_all_data + + # trigger CoS twice in case transaction commit before unlock + for i in 1 2; do + sh -c "$1" + do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0" + sh -c "$2" + commit_nr=$(do_nodes $nodes \ + "lctl get_param -n mdt.*.async_commit_count" | calc_sum) + total=$((total + commit_nr)); + rm -rf $DIR/$tdir + sync_all_data + done + + echo "CoS count $total" + [ $total -gt 0 ] || error "$2 didn't trigger CoS" +} + +test_33d() { + [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] && + skip "DNE CoS not supported" && return + + # remote directory create + op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir" + # remote directory unlink + op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir" + # striped directory create + op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir" + # striped directory setattr + op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \ + "chmod 713 $DIR/$tdir" + # striped directory unlink + op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \ + "rmdir $DIR/$tdir" + # cross-MDT link + op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \ + $LFS mkdir -i 0 $DIR/$tdir/d1; \ + $LFS mkdir -i 1 $DIR/$tdir/d2; \ + touch $DIR/$tdir/d1/tgt" \ + "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src" + # cross-MDT rename + op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \ + $LFS mkdir -i 0 $DIR/$tdir/d1; \ + $LFS mkdir -i 1 $DIR/$tdir/d2; \ + touch $DIR/$tdir/d1/src" \ + "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt" + # migrate + op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \ + "$LFS migrate -m 1 $DIR/$tdir" + + return 0 +} +run_test 33d "DNE distributed operation should trigger COS" + +test_33e() { + [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; } + [ $CLIENTCOUNT -ge 2 ] || + { skip "Need two or more clients, have $CLIENTCOUNT" && + return 0; } + [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.63) ] && + skip "DNE CoS not supported" && return + + local client2=${CLIENT2:-$(hostname)} + + sync + + local nodes=$(comma_list $(mdts_nodes)) + do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0" + + $LFS mkdir -c 2 $DIR/$tdir + mkdir $DIR/$tdir/subdir + echo abc > $DIR/$tdir/$tfile + do_node $client2 echo dfg >> $DIR/$tdir/$tfile + do_node $client2 touch $DIR/$tdir/subdir + + local async_commit_count=$(do_nodes $nodes \ + "lctl get_param -n mdt.*.async_commit_count" | calc_sum) + [ $async_commit_count -gt 0 ] && error "CoS triggerred" + + return 0 +} +run_test 33e "DNE local operation shouldn't trigger COS" + # End commit on sharing tests get_ost_lock_timeouts() { @@ -978,11 +1178,12 @@ cleanup_34() { do_nodes $(comma_list $(osts_nodes)) \ "lctl set_param -n fail_loc=0 2>/dev/null || true" for i in $(seq $OSTCOUNT); do - wait_osc_import_state client ost$i FULL + wait_osc_import_ready client ost$i done } test_34() { #16129 + remote_ost_nodsh && skip "remote OST with nodsh" && return local OPER local lock_in local lock_out @@ -1030,52 +1231,54 @@ test_34() { #16129 run_test 34 "no lock timeout under IO" test_35() { # bug 17645 - local generation=[] - local count=0 + local generation=[] + local count=0 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation | - awk '/generation/{print $2}') + awk '/generation/{print $2}') for g in $gen; do - generation[count]=$g - let count=count+1 - done + generation[count]=$g + let count=count+1 + done - test_mkdir -p $MOUNT1/$tfile - cancel_lru_locks mdc + test_mkdir $MOUNT1/$tdir + cancel_lru_locks mdc - # Let's initiate -EINTR situation by setting fail_loc and take - # write lock on same file from same client. This will not cause - # bl_ast yet as lock is already in local cache. -#define OBD_FAIL_LDLM_INTR_CP_AST 0x317 - do_facet client "lctl set_param fail_loc=0x80000317" - local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout` - let timeout=timeout*3 - local nr=0 - while test $nr -lt 10; do - log "Race attempt $nr" - local blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'` - test "x$blk1" = "x" && blk1=0 - createmany -o $MOUNT2/$tfile/a 4000 & - pid1=$! - sleep 1 - - # Let's make conflict and bl_ast - ls -la $MOUNT1/$tfile > /dev/null & - pid2=$! - - log "Wait for $pid1 $pid2 for $timeout sec..." - sleep $timeout - kill -9 $pid1 $pid2 > /dev/null 2>&1 - wait - local blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'` - test "x$blk2" = "x" && blk2=0 - test $blk2 -gt $blk1 && break - rm -fr $MOUNT1/$tfile/* - cancel_lru_locks mdc - let nr=nr+1 - done - do_facet client "lctl set_param fail_loc=0x0" - df -h $MOUNT1 $MOUNT2 - count=0 + # Let's initiate -EINTR situation by setting fail_loc and take + # write lock on same file from same client. This will not cause + # bl_ast yet as lock is already in local cache. + #define OBD_FAIL_LDLM_INTR_CP_AST 0x317 + do_facet client "lctl set_param fail_loc=0x80000317" + local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout) + let timeout=timeout*3 + local nr=0 + while test $nr -lt 10; do + log "Race attempt $nr" + local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats | + awk '/ldlm_bl_callback/ { print $2 }') + test "x$blk1" = "x" && blk1=0 + createmany -o $MOUNT2/$tdir/a 4000 & + pid1=$! + sleep 1 + + # Let's make conflict and bl_ast + ls -la $MOUNT1/$tdir > /dev/null & + pid2=$! + + log "Wait for $pid1 $pid2 for $timeout sec..." + sleep $timeout + kill -9 $pid1 $pid2 > /dev/null 2>&1 + wait + local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats | + awk '/ldlm_bl_callback/ { print $2 }') + test "x$blk2" = "x" && blk2=0 + test $blk2 -gt $blk1 && break + rm -fr $MOUNT1/$tdir + cancel_lru_locks mdc + let nr=nr+1 + done + do_facet client "lctl set_param fail_loc=0x0" + df -h $MOUNT1 $MOUNT2 + count=0 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation | awk '/generation/{print $2}') for g in $gen; do @@ -1101,15 +1304,17 @@ test_36() { #bug 16417 local SIZE_B local i - test_mkdir -p $DIR1/$tdir + test_mkdir $DIR1/$tdir $LFS setstripe -c -1 $DIR1/$tdir i=0 SIZE=50 let SIZE_B=SIZE*1024*1024 - sync; sleep 5; sync # wait for delete thread + sync; sleep 2; sync # wait for delete thread + wait_mds_ost_sync || error "wait_mds_ost_sync failed" + wait_destroy_complete || error "wait_destroy_complete failed" while [ $i -le 10 ]; do - lctl mark "start test" + lctl mark "start test - cycle ($i)" local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }') dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE || error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed" @@ -1122,6 +1327,7 @@ test_36() { #bug 16417 rm -f $DIR1/$tdir/$tfile kill -USR1 $read_pid wait $read_pid + sync; sleep 2; sync # Ensure new statfs wait_delete_completed local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }') echo "*** cycle($i) *** before($before) after_dd($after_dd)" \ @@ -1135,7 +1341,7 @@ test_36() { #bug 16417 run_test 36 "handle ESTALE/open-unlink correctly" test_37() { # bug 18695 - test_mkdir -p $DIR1/$tdir + test_mkdir $DIR1/$tdir multiop_bg_pause $DIR1/$tdir D_c || return 1 MULTIPID=$! # create large directory (32kB seems enough from e2fsck, ~= 1000 files) @@ -1241,6 +1447,32 @@ test_39c() { } run_test 39c "check truncate mtime update ======================" +test_39d() { # LU-7310 + touch $DIR1/$tfile + touch -m -d @$TEST_39_MTIME $DIR1/$tfile + + local mtime1=$(stat -c %Y $DIR2/$tfile) + [ "$mtime1" = $TEST_39_MTIME ] || + error "mtime: $mtime1, should be $TEST_39_MTIME" + + # force sync write + # define OBD_FAIL_OSC_NO_GRANT 0x411 + $LCTL set_param fail_loc=0x411 + + local d1=$(date +%s) + echo hello >> $DIR1/$tfile + local d2=$(date +%s) + + $LCTL set_param fail_loc=0 + + cancel_lru_locks $OSC + + local mtime2=$(stat -c %Y $DIR2/$tfile) + [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || + error "mtime is not updated on write: $d1 <= $mtime2 <= $d2" +} +run_test 39d "sync write should update mtime" + # check that pid exists hence second operation wasn't blocked by first one # if it is so then there is no conflict, return 0 # else second operation is conflicting with first one, return 1 @@ -1260,6 +1492,7 @@ check_pdo_conflict() { # pdirop tests # test 40: check non-blocking operations test_40a() { + remote_mds_nodsh && skip "remote MDS with nodsh" && return #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145 touch $DIR2 @@ -1280,15 +1513,16 @@ test_40a() { rmdir $DIR2/$tfile-3 check_pdo_conflict $PID1 || error "unlink is blocked" - # all operations above shouldn't wait the first one + # all operations above shouldn't wait the first one check_pdo_conflict $PID1 || error "parallel operation is blocked" wait $PID1 - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 40a "pdirops: create vs others ==============" test_40b() { + remote_mds_nodsh && skip "remote MDS with nodsh" && return #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145 touch $DIR1/$tfile & @@ -1312,12 +1546,13 @@ test_40b() { check_pdo_conflict $PID1 || error "parallel operation is blocked" wait $PID1 - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 40b "pdirops: open|create and others ==============" test_40c() { + remote_mds_nodsh && skip "remote MDS with nodsh" && return touch $DIR1/$tfile #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145 @@ -1342,12 +1577,13 @@ test_40c() { # all operations above shouldn't wait the first one check_pdo_conflict $PID1 || error "parallel operation is blocked" wait $PID1 - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 40c "pdirops: link and others ==============" test_40d() { + remote_mds_nodsh && skip "remote MDS with nodsh" && return touch $DIR1/$tfile #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145 @@ -1377,6 +1613,7 @@ test_40d() { run_test 40d "pdirops: unlink and others ==============" test_40e() { + remote_mds_nodsh && skip "remote MDS with nodsh" && return touch $DIR1/$tfile #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145 @@ -1399,7 +1636,7 @@ test_40e() { # all operations above shouldn't wait the first one check_pdo_conflict $PID1 || error "parallel operation is blocked" wait $PID1 - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 40e "pdirops: rename and others ==============" @@ -1413,7 +1650,7 @@ test_41a() { sleep 1 mkdir $DIR2/$tfile && error "mkdir must fail" check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 41a "pdirops: create vs mkdir ==============" @@ -1426,7 +1663,7 @@ test_41b() { sleep 1 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail" check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 41b "pdirops: create vs create ==============" @@ -1440,7 +1677,7 @@ test_41c() { sleep 1 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail" check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 41c "pdirops: create vs link ==============" @@ -1453,7 +1690,7 @@ test_41d() { sleep 1 rm $DIR2/$tfile || error "unlink must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 41d "pdirops: create vs unlink ==============" @@ -1467,7 +1704,7 @@ test_41e() { sleep 1 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 41e "pdirops: create and rename (tgt) ==============" @@ -1480,7 +1717,7 @@ test_41f() { sleep 1 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 41f "pdirops: create and rename (src) ==============" @@ -1493,7 +1730,7 @@ test_41g() { sleep 1 stat $DIR2/$tfile > /dev/null || error "stat must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 41g "pdirops: create vs getattr ==============" @@ -1506,7 +1743,7 @@ test_41h() { sleep 1 ls -lia $DIR2/ > /dev/null check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 41h "pdirops: create vs readdir ==============" @@ -1520,7 +1757,7 @@ test_42a() { sleep 1 mkdir $DIR2/$tfile && error "mkdir must fail" check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 42a "pdirops: mkdir vs mkdir ==============" @@ -1533,7 +1770,7 @@ test_42b() { sleep 1 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail" check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 42b "pdirops: mkdir vs create ==============" @@ -1547,7 +1784,7 @@ test_42c() { sleep 1 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail" check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 42c "pdirops: mkdir vs link ==============" @@ -1560,7 +1797,7 @@ test_42d() { sleep 1 rmdir $DIR2/$tfile || error "unlink must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 42d "pdirops: mkdir vs unlink ==============" @@ -1574,7 +1811,7 @@ test_42e() { sleep 1 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail" check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 42e "pdirops: mkdir and rename (tgt) ==============" @@ -1587,7 +1824,7 @@ test_42f() { sleep 1 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 42f "pdirops: mkdir and rename (src) ==============" @@ -1600,7 +1837,7 @@ test_42g() { sleep 1 stat $DIR2/$tfile > /dev/null || error "stat must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 42g "pdirops: mkdir vs getattr ==============" @@ -1613,7 +1850,7 @@ test_42h() { sleep 1 ls -lia $DIR2/ > /dev/null check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 42h "pdirops: mkdir vs readdir ==============" @@ -1628,7 +1865,7 @@ test_43a() { sleep 1 mkdir $DIR2/$tfile || error "mkdir must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 43a "pdirops: unlink vs mkdir ==============" @@ -1642,7 +1879,7 @@ test_43b() { sleep 1 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 43b "pdirops: unlink vs create ==============" @@ -1657,7 +1894,7 @@ test_43c() { sleep 1 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 43c "pdirops: unlink vs link ==============" @@ -1671,7 +1908,7 @@ test_43d() { sleep 1 rm $DIR2/$tfile && error "unlink must fail" check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 43d "pdirops: unlink vs unlink ==============" @@ -1686,7 +1923,7 @@ test_43e() { sleep 1 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 43e "pdirops: unlink and rename (tgt) ==============" @@ -1700,7 +1937,7 @@ test_43f() { sleep 1 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail" check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 43f "pdirops: unlink and rename (src) ==============" @@ -1714,7 +1951,7 @@ test_43g() { sleep 1 stat $DIR2/$tfile > /dev/null && error "stat must fail" check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 43g "pdirops: unlink vs getattr ==============" @@ -1728,7 +1965,7 @@ test_43h() { sleep 1 ls -lia $DIR2/ > /dev/null check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 43h "pdirops: unlink vs readdir ==============" @@ -1744,7 +1981,7 @@ test_43i() { $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "remote mkdir isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 43i "pdirops: unlink vs remote mkdir" @@ -1759,7 +1996,7 @@ test_44a() { sleep 1 mkdir $DIR2/$tfile && error "mkdir must fail" check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 44a "pdirops: rename tgt vs mkdir ==============" @@ -1773,7 +2010,7 @@ test_44b() { sleep 1 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail" check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 44b "pdirops: rename tgt vs create ==============" @@ -1788,7 +2025,7 @@ test_44c() { sleep 1 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail" check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 44c "pdirops: rename tgt vs link ==============" @@ -1802,7 +2039,7 @@ test_44d() { sleep 1 rm $DIR2/$tfile || error "unlink must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 44d "pdirops: rename tgt vs unlink ==============" @@ -1818,7 +2055,7 @@ test_44e() { sleep 1 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 44e "pdirops: rename tgt and rename (tgt) ==============" @@ -1833,7 +2070,7 @@ test_44f() { sleep 1 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 44f "pdirops: rename tgt and rename (src) ==============" @@ -1847,7 +2084,7 @@ test_44g() { sleep 1 stat $DIR2/$tfile > /dev/null || error "stat must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 44g "pdirops: rename tgt vs getattr ==============" @@ -1861,7 +2098,7 @@ test_44h() { sleep 1 ls -lia $DIR2/ > /dev/null check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 44h "pdirops: rename tgt vs readdir ==============" @@ -1878,7 +2115,7 @@ test_44i() { $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail" check_pdo_conflict $PID1 && { wait $PID1; error "remote mkdir isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 44i "pdirops: rename tgt vs remote mkdir" @@ -1893,7 +2130,7 @@ test_45a() { sleep 1 mkdir $DIR2/$tfile || error "mkdir must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 45a "pdirops: rename src vs mkdir ==============" @@ -1907,7 +2144,7 @@ test_45b() { sleep 1 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 45b "pdirops: rename src vs create ==============" @@ -1922,7 +2159,7 @@ test_45c() { sleep 1 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 45c "pdirops: rename src vs link ==============" @@ -1936,7 +2173,7 @@ test_45d() { sleep 1 rm $DIR2/$tfile && error "unlink must fail" check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 45d "pdirops: rename src vs unlink ==============" @@ -1951,7 +2188,7 @@ test_45e() { sleep 1 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 45e "pdirops: rename src and rename (tgt) ==============" @@ -1965,7 +2202,7 @@ test_45f() { sleep 1 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail" check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 45f "pdirops: rename src and rename (src) ==============" @@ -1979,7 +2216,7 @@ test_45g() { sleep 1 stat $DIR2/$tfile > /dev/null && error "stat must fail" check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 45g "pdirops: rename src vs getattr ==============" @@ -1993,7 +2230,7 @@ test_45h() { sleep 1 ls -lia $DIR2/ > /dev/null check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 45h "pdirops: unlink vs readdir ==============" @@ -2009,7 +2246,7 @@ test_45i() { $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "create remote dir isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 45i "pdirops: rename src vs remote mkdir" @@ -2024,7 +2261,7 @@ test_46a() { sleep 1 mkdir $DIR2/$tfile && error "mkdir must fail" check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 46a "pdirops: link vs mkdir ==============" @@ -2038,7 +2275,7 @@ test_46b() { sleep 1 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail" check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 46b "pdirops: link vs create ==============" @@ -2052,7 +2289,7 @@ test_46c() { sleep 1 link $DIR2/$tfile $DIR2/$tfile && error "link must fail" check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 46c "pdirops: link vs link ==============" @@ -2066,7 +2303,7 @@ test_46d() { sleep 1 rm $DIR2/$tfile || error "unlink must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 46d "pdirops: link vs unlink ==============" @@ -2081,7 +2318,7 @@ test_46e() { sleep 1 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 46e "pdirops: link and rename (tgt) ==============" @@ -2096,7 +2333,7 @@ test_46f() { sleep 1 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 46f "pdirops: link and rename (src) ==============" @@ -2110,7 +2347,7 @@ test_46g() { sleep 1 stat $DIR2/$tfile > /dev/null || error "stat must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 46g "pdirops: link vs getattr ==============" @@ -2125,7 +2362,7 @@ test_46h() { ls -lia $DIR2/ > /dev/null check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 46h "pdirops: link vs readdir ==============" @@ -2141,7 +2378,7 @@ test_46i() { $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail" check_pdo_conflict $PID1 && { wait $PID1; error "remote mkdir isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 46i "pdirops: link vs remote mkdir" @@ -2156,7 +2393,7 @@ test_47a() { sleep 1 mkdir $DIR2/$tfile && error "mkdir must fail" check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 47a "pdirops: remote mkdir vs mkdir" @@ -2171,7 +2408,7 @@ test_47b() { multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail" check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 47b "pdirops: remote mkdir vs create" @@ -2186,7 +2423,7 @@ test_47c() { sleep 1 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail" check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 47c "pdirops: remote mkdir vs link" @@ -2201,7 +2438,7 @@ test_47d() { rmdir $DIR2/$tfile || error "unlink must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 47d "pdirops: remote mkdir vs unlink" @@ -2217,7 +2454,7 @@ test_47e() { mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail" check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 47e "pdirops: remote mkdir and rename (tgt)" @@ -2232,7 +2469,7 @@ test_47f() { mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 47f "pdirops: remote mkdir and rename (src)" @@ -2247,7 +2484,7 @@ test_47g() { stat $DIR2/$tfile > /dev/null || error "stat must succeed" check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; } - rm -r $DIR1/* + rm -rf $DIR/$tfile* return 0 } run_test 47g "pdirops: remote mkdir vs getattr" @@ -2269,13 +2506,13 @@ test_51a() { local filesize local origfile=/etc/hosts - filesize=`stat -c %s $origfile` + filesize=$(stat -c %s $origfile) # create an empty file - $MCREATE $DIR1/$tfile + $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile" # cache layout lock on both mount point - stat $DIR1/$tfile > /dev/null - stat $DIR2/$tfile > /dev/null + stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed" + stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed" # open and sleep 2 seconds then read $MULTIOP $DIR2/$tfile o_2r${filesize}c & @@ -2283,12 +2520,16 @@ test_51a() { sleep 1 # create the layout of testing file - dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null + dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null || + error "dd $DIR1/$tfile failed" # MULTIOP proc should be able to read enough bytes and exit - sleep 2 - kill -0 $pid && error "multiop is still there" - cmp $origfile $DIR2/$tfile || error "$MCREATE and $DIR2/$tfile differs" + for ((i = 0; i < 6; i++)); do + sleep 1 + kill -0 $pid || break + done + kill -0 $pid 2> /dev/null && error "multiop is still there" + cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs" rm -f $DIR1/$tfile } @@ -2301,7 +2542,7 @@ test_51b() { local tmpfile=`mktemp` # create an empty file - $MCREATE $DIR1/$tfile + $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed" # delay glimpse so that layout has changed when glimpse finish #define OBD_FAIL_GLIMPSE_DELAY 0x1404 @@ -2311,10 +2552,11 @@ test_51b() { sleep 1 # create layout of testing file - dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc > /dev/null + dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null || + error "dd $DIR1/$tfile failed" wait $pid - local fsize=`cat $tmpfile` + local fsize=$(cat $tmpfile) [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024" @@ -2323,14 +2565,15 @@ test_51b() { run_test 51b "layout lock: glimpse should be able to restart if layout changed" test_51c() { - [ $OSTCOUNT -ge 2 ] || { skip "need at least 2 osts"; return; } + [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; } # set default layout to have 1 stripe - mkdir -p $DIR1/$tdir + mkdir $DIR1/$tdir $LFS setstripe -c 1 $DIR1/$tdir # create a file with empty layout - $MCREATE $DIR1/$tdir/$tfile + $MCREATE $DIR1/$tdir/$tfile || + error "$MCREATE $DIR1/$tdir/$tfile failed" #define OBD_FAIL_MDS_LL_BLOCK 0x172 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172 @@ -2343,8 +2586,14 @@ test_51c() { # write something to the file, it should be blocked on fetching layout dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc - local cnt=$($LFS getstripe -c $DIR2/$tdir/$tfile) - [ $cnt -eq $OSTCOUNT ] || error "have $cnt stripes, expected $OSTCOUNT" + local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile) + wait $pid + + # lod_qos.c::min_stripe_count() allows setstripe with a default stripe + # count to succeed with only 3/4 of the number of stripes (rounded up), + # so creating striped files does not fail if an OST is offline or full + [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] || + error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4" rm -fr $DIR1/$tdir } @@ -2363,14 +2612,14 @@ test_51d() { local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}') echo "Before revoking layout lock: $br KB mapped" - # delete the file will revoke layout lock - rm -f $DIR2/$tfile + # cancel layout lock manually + cancel_lru_locks mdc # rss after revoking local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}') kill -USR1 $PID - wait $PID || error + wait $PID || error "wait PID $PID failed" [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained" } @@ -2381,7 +2630,7 @@ test_54_part1() echo "==> rename vs getattr vs setxattr should not deadlock" mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed" - do_facet mds $LCTL set_param fail_loc=$1 + do_facet mds1 $LCTL set_param fail_loc=$1 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 & PID1=$! @@ -2403,7 +2652,7 @@ test_54_part2() { echo "==> rename vs getattr vs open vs getattr should not deadlock" mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed" - do_facet mds $LCTL set_param fail_loc=$1 + do_facet mds1 $LCTL set_param fail_loc=$1 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 & PID1=$! @@ -2448,7 +2697,7 @@ test_55a() { mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed" #define OBD_FAIL_MDS_RENAME4 0x156 - do_facet mds $LCTL set_param fail_loc=0x80000156 + do_facet mds1 $LCTL set_param fail_loc=0x80000156 mv -T $DIR/d1/d2 $DIR/d3/d2 & PID1=$! @@ -2466,7 +2715,7 @@ test_55b() mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed" #define OBD_FAIL_MDS_RENAME4 0x156 - do_facet mds $LCTL set_param fail_loc=0x80000156 + do_facet mds1 $LCTL set_param fail_loc=0x80000156 mv -T $DIR/d1/d2 $DIR/d3/d2 & PID1=$! @@ -2484,7 +2733,7 @@ test_55c() mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed" #define OBD_FAIL_MDS_RENAME4 0x156 - do_facet mds $LCTL set_param fail_loc=0x156 + do_facet mds1 $LCTL set_param fail_loc=0x156 mv -T $DIR/d1/d2 $DIR/d3/d2 & PID1=$! @@ -2512,7 +2761,7 @@ test_55d() touch $DIR/f1 #define OBD_FAIL_MDS_RENAME3 0x155 - do_facet mds $LCTL set_param fail_loc=0x155 + do_facet mds1 $LCTL set_param fail_loc=0x155 mv $DIR/f1 $DIR/$tdir & PID1=$! sleep 2 @@ -2534,7 +2783,7 @@ test_60() { skip "MDS version $MDSVER must be >= 2.3.0" && return 0 # Create a file - test_mkdir -p $DIR1/$tdir + test_mkdir $DIR1/$tdir file1=$DIR1/$tdir/file file2=$DIR2/$tdir/file @@ -2616,7 +2865,7 @@ test_70b() { # LU-2781 } run_test 70b "remove files after calling rm_entry" -test_71() { +test_71a() { local server_version=$(lustre_version_code $SINGLEMDS) [[ $server_version -lt $(version_code 2.1.6) ]] && @@ -2625,7 +2874,8 @@ test_71() { # Patch not applied to 2.2 and 2.3 branches [[ $server_version -ge $(version_code 2.2.0) ]] && [[ $server_version -lt $(version_code 2.4.0) ]] && - skip "Need MDS version at least 2.4.0" && return + skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" && + return checkfiemap --test || { skip "checkfiemap not runnable: $?" && return; } @@ -2657,7 +2907,34 @@ test_71() { echo $can2 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured." } -run_test 71 "correct file map just after write operation is finished" +run_test 71a "correct file map just after write operation is finished" + +test_71b() { + local server_version=$(lustre_version_code $SINGLEMDS) + + [[ $server_version -lt $(version_code 2.1.6) ]] && + skip "Need MDS version at least 2.1.6" && return + + # Patch not applied to 2.2 and 2.3 branches + [[ $server_version -ge $(version_code 2.2.0) ]] && + [[ $server_version -lt $(version_code 2.4.0) ]] && + skip "Need MDS version earlier than 2.2.0 or at least 2.4.0" && + return + [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; } + + checkfiemap --test || + { skip "error $?: checkfiemap failed" && return; } + + mkdir -p $DIR1/$tdir + + $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed" + dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1 + [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tdir/$tfile) + 1)))" = \ + "zfs" ] && + skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0 + checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed" +} +run_test 71b "check fiemap support for stripecount > 1" test_72() { local p="$TMP/sanityN-$TESTNAME.parameters" @@ -2702,14 +2979,16 @@ test_73() { error "setfattr1 failed" getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed" getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed" - clear_llite_stats + clear_stats llite.*.stats # PR lock should be cached by now on both clients getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed" # 2 hits for getfattr(0)+getfattr(size) - [ $(calc_llite_stats getxattr_hits) -eq 2 ] || error "not cached in $DIR1" + [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] || + error "not cached in $DIR1" getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed" # 4 hits for more getfattr(0)+getfattr(size) - [ $(calc_llite_stats getxattr_hits) -eq 4 ] || error "not cached in $DIR2" + [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] || + error "not cached in $DIR2" rm -f $DIR2/$tfile restore_lustre_params < $p @@ -2754,7 +3033,7 @@ test_76() { #LU-946 skip "Need MDS version at least 2.5.53" && return remote_mds_nodsh && skip "remote MDS with nodsh" && return - local fcount=2048 + local fcount=$((MDSCOUNT * 256)) declare -a fd_list declare -a fid_list @@ -2765,25 +3044,33 @@ test_76() { #LU-946 fi rm -rf $DIR/$tdir - test_mkdir -p $DIR/$tdir + test_mkdir $DIR/$tdir # drop all open locks and close any cached "open" files on the client cancel_lru_locks mdc - echo -n "open files " - ulimit -n 8096 + local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files" + local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd)) + local already=${#fid_list[@]} + for (( i = 0; i < $already; i++ )) ; do + log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})" + done + + echo -n "opening files: " + ulimit -n $((fcount + 50)) for ((i = 0; i < $fcount; i++)); do touch $DIR/$tdir/f_$i - local fd=$(free_fd) - local cmd="exec $fd<$DIR/$tdir/f_$i" - eval $cmd + local fd=$(free_fd ${fd_list[i]}) + local open_cmd="exec $fd<$DIR/$tdir/f_$i" + eval $open_cmd + fd_list[i]=$fd - echo -n "." + + (( $i % 32 == 0 )) && echo -n "." done echo - local get_open_fids="$LCTL get_param -n mdt.*.exports.'$nid'.open_files" - local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $get_open_fids)) + fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd)) # Possible errors in openfiles FID list. # 1. Missing FIDs. Check 1 @@ -2793,19 +3080,28 @@ test_76() { #LU-946 # 5. Valid FID, points to some other file. Check 3 # Check 1 - [ ${#fid_list[@]} -ne $fcount ] && - error "${#fid_list[@]} != $fcount open files" - - for (( i = 0; i < $fcount; i++ )) ; do - cmd="exec ${fd_list[i]} /dev/null 2>&1 + do_nodes $CLIENTS $myRUNAS \ + dd if=/dev/zero of="$dir/nrs_r_$HOSTNAME" bs=1M count=$n || + error "dd at 0 on client failed (1)" for ((i = 0; i < $n; i++)); do - do_nodes $CLIENTS dd if=/dev/zero of="$dir/nrs_w_$HOSTNAME"\ - bs=1M seek=$i count=1 > /dev/null 2>&1 & + do_nodes $CLIENTS $myRUNAS dd if=/dev/zero \ + of="$dir/nrs_w_$HOSTNAME" bs=1M seek=$i count=1 || + error "dd at ${i}MB on client failed (2)" & local pids_w[$i]=$! done do_nodes $CLIENTS sync; cancel_lru_locks osc for ((i = 0; i < $n; i++)); do - do_nodes $CLIENTS dd if="$dir/nrs_w_$HOSTNAME" of=/dev/zero\ - bs=1M seek=$i count=1 > /dev/null 2>&1 & + do_nodes $CLIENTS $myRUNAS dd if="$dir/nrs_w_$HOSTNAME" \ + of=/dev/zero bs=1M seek=$i count=1 > /dev/null || + error "dd at ${i}MB on client failed (3)" & local pids_r[$i]=$! done cancel_lru_locks osc @@ -2849,26 +3150,43 @@ nrs_write_read() { } test_77a() { #LU-3266 - do_facet $SINGLEMDS lctl set_param ost.OSS.*.nrs_policies="fifo" + local rc + + oss=$(comma_list $(osts_nodes)) + do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" || + rc=$? + [[ $rc -eq 3 ]] && skip "no NRS exists" && return + [[ $rc -ne 0 ]] && error "failed to set fifo policy" nrs_write_read return 0 } run_test 77a "check FIFO NRS policy" - test_77b() { #LU-3266 - do_facet $SINGLEMDS lctl set_param ost.OSS.*.nrs_policies="crrn" - do_facet $SINGLEMDS lctl set_param ost.OSS.*.nrs_crrn_quantum=1 + local rc + + oss=$(comma_list $(osts_nodes)) + + do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \ + ost.OSS.*.nrs_crrn_quantum=1 || rc=$? + [[ $rc -eq 3 ]] && skip "no NRS exists" && return + [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1" echo "policy: crr-n, crrn_quantum 1" nrs_write_read - do_facet $SINGLEMDS lctl set_param ost.OSS.*.nrs_crrn_quantum=64 + do_nodes $oss lctl set_param \ + ost.OSS.*.nrs_crrn_quantum=64 || rc=$? + [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64" echo "policy: crr-n, crrn_quantum 64" nrs_write_read + # cleanup + do_nodes $oss lctl set_param \ + ost.OSS.ost_io.nrs_policies="fifo" || rc=$? + [[ $rc -ne 0 ]] && error "failed to set fifo policy" return 0 } run_test 77b "check CRR-N NRS policy" @@ -2876,138 +3194,923 @@ run_test 77b "check CRR-N NRS policy" orr_trr() { local policy=$1 - for i in $(seq 1 $OSTCOUNT) - do - do_facet ost"$i" lctl set_param \ - ost.OSS.ost_io.nrs_policies=$policy - do_facet ost"$i" lctl set_param \ - ost.OSS.*.nrs_"$policy"_quantum=1 - do_facet ost"$i" lctl set_param \ - ost.OSS.*.nrs_"$policy"_offset_type="physical" - do_facet ost"$i" lctl set_param \ - ost.OSS.*.nrs_"$policy"_supported="reads" - done + oss=$(comma_list $(osts_nodes)) + + do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \ + ost.OSS.*.nrs_"$policy"_quantum=1 \ + ost.OSS.*.nrs_"$policy"_offset_type="physical" \ + ost.OSS.*.nrs_"$policy"_supported="reads" || return $? - echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type \ - physical, ${policy}_supported reads" + echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \ + "physical, ${policy}_supported reads" nrs_write_read - for i in $(seq 1 $OSTCOUNT) - do - do_facet ost"$i" lctl set_param \ - ost.OSS.*.nrs_${policy}_supported="writes" - do_facet ost"$i" lctl set_param \ - ost.OSS.*.nrs_${policy}_quantum=64 - done - echo "policy: $policy, ${policy}_quantum 64, \ - ${policy}_offset_type physical, ${policy}_supported writes" + do_nodes $oss lctl set_param \ + ost.OSS.*.nrs_${policy}_supported="writes" \ + ost.OSS.*.nrs_${policy}_quantum=64 || return $? + + echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \ + "physical, ${policy}_supported writes" nrs_write_read - for i in $(seq 1 $OSTCOUNT) - do - do_facet ost"$i" lctl set_param \ - ost.OSS.*.nrs_${policy}_supported="reads_and_writes" - do_facet ost"$i" lctl set_param \ - ost.OSS.*.nrs_${policy}_offset_type="logical" - done - echo "policy: $policy, ${policy}_quantum 64, \ - ${policy}_offset_type logical, ${policy}_supported reads_and_writes" + do_nodes $oss lctl set_param \ + ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \ + ost.OSS.*.nrs_${policy}_offset_type="logical" || return $? + echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \ + "logical, ${policy}_supported reads_and_writes" nrs_write_read + # cleanup + do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" || + return $? return 0 } test_77c() { #LU-3266 - orr_trr "orr" + local rc + orr_trr "orr" || rc=$? + [[ $rc -eq 3 ]] && skip "no NRS exists" && return + [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc" return 0 } run_test 77c "check ORR NRS policy" test_77d() { #LU-3266 - orr_trr "trr" + local rc + orr_trr "trr" || rc=$? + [[ $rc -eq 3 ]] && skip "no NRS exists" && return + [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc" return 0 } run_test 77d "check TRR nrs policy" -test_80() { - [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return - local MDTIDX=1 - local mdt_index - local i - local file - local pid +tbf_rule_operate() +{ + local facet=$1 + shift 1 - mkdir -p $DIR1/$tdir/dir - createmany -o $DIR1/$tdir/dir/f 10 || - error "create files under remote dir failed $i" + do_facet $facet lctl set_param \ + ost.OSS.ost_io.nrs_tbf_rule="$*" + [ $? -ne 0 ] && + error "failed to run operate '$*' on TBF rules" +} - cp /etc/passwd $DIR1/$tdir/$tfile +cleanup_tbf_verify() +{ + local rc=0 + trap 0 + echo "cleanup_tbf $DIR/$tdir" + rm -rf $DIR/$tdir + rc=$? + wait_delete_completed + return $rc +} - #migrate open file should fails - multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed" - pid=$! - # give multiop a chance to open - sleep 1 +tbf_verify() { + local dir=$DIR/$tdir + local client1=${CLIENT1:-$(hostname)} + local myRUNAS="$3" - $LFS mv -M $MDTIDX $DIR1/$tdir && - error "migrate open files should failed with open files" + local np=$(check_cpt_number ost1) + [ $np -gt 0 ] || error "CPU partitions should not be $np." + echo "cpu_npartitions on ost1 is $np" - kill -USR1 $pid + mkdir $dir || error "mkdir $dir failed" + $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed" + chmod 777 $dir + + trap cleanup_tbf_verify EXIT + echo "Limited write rate: $1, read rate: $2" + echo "Verify the write rate is under TBF control" + local start=$SECONDS + do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \ + bs=1M count=100 oflag=direct 2>&1 + local runtime=$((SECONDS - start + 1)) + local rate=$(bc <<< "scale=6; 100 / $runtime") + echo "Write runtime is $runtime s, speed is $rate IOPS" + + # verify the write rate does not exceed TBF rate limit + [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] || + error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)" - $LFS mv -M $MDTIDX $DIR1/$tdir || - error "migrate remote dir error" + cancel_lru_locks osc - echo "Finish migration, then checking.." - for file in $(find $DIR1/$tdir); do - mdt_index=$($LFS getstripe -M $file) - [ $mdt_index == $MDTIDX ] || - error "$file is not on MDT${MDTIDX}" - done + echo "Verify the read rate is under TBF control" + start=$SECONDS + do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \ + bs=1M count=100 iflag=direct 2>&1 + runtime=$((SECONDS - start + 1)) + rate=$(bc <<< "scale=6; 100 / $runtime") + echo "Read runtime is $runtime s, speed is $rate IOPS" - diff /etc/passwd $DIR1/$tdir/$tfile || - error "file different after migration" + # verify the read rate does not exceed TBF rate limit + [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] || + error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)" - rm -rf $DIR1/$tdir || error "rm dir failed after migration" + cancel_lru_locks osc + cleanup_tbf_verify || error "rm -rf $dir failed" } -run_test 80 "migrate directory when some children is being opened" -test_81() { - [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return +test_77e() { + local rc - rm -rf $DIR1/$tdir + oss=$(comma_list $(osts_nodes)) - mkdir -p $DIR1/$tdir + do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" || + rc=$? + [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return + [[ $rc -ne 0 ]] && error "failed to set TBF NID policy" - $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0 - $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1 + local idis + local rateis + if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then + idis="nid=" + rateis="rate=" + fi - cd $DIR1/$tdir - touch d0/0 || error "create 0 failed" - mv d0/0 d1/0 || error "rename d0/0 d1/0 failed" - stat d0/0 && error "stat mv filed succeed" - mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || "rename d1/0 d0/0 failed" - stat d0/0 || error "stat failed" + # Only operate rules on ost1 since OSTs might run on the same OSS + # Add some rules + tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000" + local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)") + local client_nids=$(nids_list $address "\\") + tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100" + tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50" + nrs_write_read - local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l) + # Change the rules + tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001" + tbf_rule_operate ost1 "change\ clients\ ${rateis}101" + tbf_rule_operate ost1 "change\ others\ ${rateis}51" + nrs_write_read - if [ $t -ne 3 ]; then - ls -ai $DIR1/$tdir/d0 - error "expect 3 get $t" - fi + # Stop the rules + tbf_rule_operate ost1 "stop\ localhost" + tbf_rule_operate ost1 "stop\ clients" + tbf_rule_operate ost1 "stop\ others" + nrs_write_read + # Cleanup the TBF policy + do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" + [ $? -ne 0 ] && error "failed to set policy back to fifo" + nrs_write_read return 0 } -run_test 81 "rename and stat under striped directory" +run_test 77e "check TBF NID nrs policy" -test_82() { - [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] || - { skip "Need MDS version at least 2.6.92"; return 0; } +test_77f() { + local rc - # Client 1 creates a file. - multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1" - pid1=$! - # Client 2 opens the file. - multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2" + oss=$(comma_list $(osts_nodes)) + + do_nodes $oss $LCTL set_param \ + ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$? + [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return + [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy" + + # Configure jobid_var + local saved_jobid_var=$($LCTL get_param -n jobid_var) + rc=$? + [[ $rc -eq 3 ]] && skip "jobid_var not found" && return + [[ $rc -ne 0 ]] && error "failed to get param jobid_var" + if [ $saved_jobid_var != procname_uid ]; then + set_persistent_param_and_check client \ + "jobid_var" "$FSNAME.sys.jobid_var" procname_uid + fi + + local idis + local rateis + if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then + idis="jobid=" + rateis="rate=" + fi + + # Only operate rules on ost1 since OSTs might run on the same OSS + # Add some rules + tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000" + tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100" + tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50" + nrs_write_read "$RUNAS" + + # Change the rules + tbf_rule_operate ost1 "change\ runas\ ${rateis}1001" + tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101" + tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51" + nrs_write_read "$RUNAS" + + # Stop the rules + tbf_rule_operate ost1 "stop\ runas" + tbf_rule_operate ost1 "stop\ iozone_runas" + tbf_rule_operate ost1 "stop\ dd_runas" + nrs_write_read "$RUNAS" + + # Cleanup the TBF policy + do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" + [ $? -ne 0 ] && error "failed to set policy back to fifo" + nrs_write_read "$RUNAS" + + local current_jobid_var=$($LCTL get_param -n jobid_var) + [[ $? -ne 0 ]] && error "failed to get param jobid_var" + if [ $saved_jobid_var != $current_jobid_var ]; then + set_persistent_param_and_check client \ + "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var + fi + return 0 +} +run_test 77f "check TBF JobID nrs policy" + +test_77g() { + local rc=0 + + oss=$(comma_list $(osts_nodes)) + + do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" || + rc=$? + [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return + [[ $rc -ne 0 ]] && error "failed to set TBF NID policy" + + do_nodes $oss lctl set_param \ + ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$? + [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy" + + local idis + local rateis + if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then + idis="jobid=" + rateis="rate=" + fi + + # Add a rule that only valid for Jobid TBF. If direct change between + # TBF types is not supported, this operation will fail. + tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50" + + # Cleanup the TBF policy + do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" + [ $? -ne 0 ] && error "failed to set policy back to fifo" + return 0 +} +run_test 77g "Change TBF type directly" + +test_77h() { + [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] || + { skip "Need OST version at least 2.8.55"; return 0; } + + local old_policy=$(do_facet ost1 \ + lctl get_param ost.OSS.ost_io.nrs_policies) + local new_policy + + do_facet ost1 lctl set_param \ + ost.OSS.ost_io.nrs_policies="abc" + [ $? -eq 0 ] && error "should return error" + + do_facet ost1 lctl set_param \ + ost.OSS.ost_io.nrs_policies="tbf\ abc" + [ $? -eq 0 ] && error "should return error" + + do_facet ost1 lctl set_param \ + ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc" + [ $? -eq 0 ] && error "should return error" + + do_facet ost1 lctl set_param \ + ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg" + [ $? -eq 0 ] && error "should return error" + + new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies) + [ $? -eq 0 ] || error "shouldn't LBUG" + + [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same" + + return 0 +} +run_test 77h "Wrong policy name should report error, not LBUG" + +tbf_rule_check() +{ + local facet=$1 + local expected=$2 + local error_message=$3 + local rule_number=0 + for rule in $expected; do + rule_number=$((rule_number + 1)) + done + local stop_line=$(($rule_number + 3)) + local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'" + + local output=$(do_facet $facet lctl get_param \ + ost.OSS.ost_io.nrs_tbf_rule | + eval $awk_command | + tr "\n" " " | + sed 's/[ ]*$//') + if [ "$output" != "$expected" ]; then + error "$error_message, expected '$expected', got '$output'" + fi +} + +test_77i() { + [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] || + { skip "Need OST version at least 2.8.55"; return 0; } + + for i in $(seq 1 $OSTCOUNT) + do + do_facet ost"$i" lctl set_param \ + ost.OSS.ost_io.nrs_policies="tbf\ jobid" + [ $? -ne 0 ] && + error "failed to set TBF policy" + done + + tbf_rule_check ost1 "default" "error before inserting any rule" + + tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000" + tbf_rule_check ost1 "before default" \ + "error when inserting rule 'before'" + + tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default" + tbf_rule_check ost1 "before after default" \ + "error when inserting rule 'after'" + + tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after" + tbf_rule_check ost1 "before target after default" \ + "error when inserting rule 'target'" + + echo "Move before itself" + tbf_rule_operate ost1 "change\ target\ rank=target" + tbf_rule_check ost1 "before target after default" \ + "error when moving before itself" + + echo "Move to higher rank" + tbf_rule_operate ost1 "change\ target\ rank=before" + tbf_rule_check ost1 "target before after default" \ + "error when moving to higher rank" + + echo "Move to lower rank" + tbf_rule_operate ost1 "change\ target\ rank=after" + tbf_rule_check ost1 "before target after default" \ + "error when moving to lower rank" + + echo "Move before default" + tbf_rule_operate ost1 "change\ target\ rank=default" + tbf_rule_check ost1 "before after target default" \ + error "error when moving before default" + + # Cleanup the TBF policy + do_nodes $(comma_list $(osts_nodes)) \ + $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo + return 0 +} +run_test 77i "Change rank of TBF rule" + +test_77j() { + local idis + local rateis + local ost_version=$(lustre_version_code ost1) + + [ $ost_version -ge $(version_code 2.9.53) ] || + { skip "Need OST version at least 2.9.53"; return 0; } + if [ $ost_version -ge $(version_code 2.8.60) ]; then + idis="opcode=" + rateis="rate=" + fi + + do_nodes $(comma_list $(osts_nodes)) \ + lctl set_param jobid_var=procname_uid \ + ost.OSS.ost_io.nrs_policies="tbf\ opcode" \ + ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \ + ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20" + [ $? -ne 0 ] && error "failed to set TBF OPCode policy" + + nrs_write_read + tbf_verify 20 5 + + do_nodes $(comma_list $(osts_nodes)) \ + lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \ + ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \ + ost.OSS.ost_io.nrs_policies="fifo" + + # sleep 3 seconds to wait the tbf policy stop completely, + # or the next test case is possible get -EAGAIN when + # setting the tbf policy + sleep 3 +} +run_test 77j "check TBF-OPCode NRS policy" + +test_id() { + local idstr="${1}id" + local policy="${idstr}={$2}" + local rate="rate=$3" + + do_nodes $(comma_list $(osts_nodes)) \ + lctl set_param jobid_var=procname_uid \ + ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \ + ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}" + [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy" + + nrs_write_read "runas $4" + tbf_verify $3 $3 "runas $4" + + do_nodes $(comma_list $(osts_nodes)) \ + lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \ + ost.OSS.ost_io.nrs_policies="fifo" + + # sleep 3 seconds to wait the tbf policy stop completely, + # or the next test case is possible get -eagain when + # setting the tbf policy + sleep 3 +} + +test_77ja(){ + if [ $(lustre_version_code ost1) -lt $(version_code 2.11.50) ]; then + skip "Need OST version at least 2.11.50" + return 0 + fi + test_id "u" "500" "5" "-u 500" + test_id "g" "500" "5" "-u 500 -g 500" +} +run_test 77ja "check TBF-UID/GID NRS policy" + +cleanup_77k() +{ + local rule_lists=$1 + local old_nrs=$2 + + trap 0 + for rule in $rule_lists; do + do_nodes $(comma_list $(osts_nodes)) \ + lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule" + done + + do_nodes $(comma_list $(osts_nodes)) \ + lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs" + + sleep 3 +} + +test_77k() { + [[ $(lustre_version_code ost1) -ge $(version_code 2.9.53) ]] || + { skip "Need OST version at least 2.9.53"; return 0; } + + do_nodes $(comma_list $(osts_nodes)) \ + lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \ + ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \ + ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10" + + nrs_write_read "$RUNAS" + tbf_verify 20 10 "$RUNAS" + + local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)") + local client_nids=$(nids_list $address "\\") + do_nodes $(comma_list $(osts_nodes)) \ + lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \ + ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \ + ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \ + ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10" + + nrs_write_read + tbf_verify 20 10 + + do_nodes $(comma_list $(osts_nodes)) \ + lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \ + ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \ + ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20" + + nrs_write_read "$RUNAS" + tbf_verify 20 20 "$RUNAS" + + do_nodes $(comma_list $(osts_nodes)) \ + lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \ + ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \ + ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10" + + nrs_write_read "$RUNAS" + # with parameter "RUNAS", it will match the latest rule + # "ext_b" first, so the limited write rate is 10. + tbf_verify 10 10 "$RUNAS" + tbf_verify 20 10 + + trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT + + [[ $(lustre_version_code ost1) -ge $(version_code 2.10.58) ]] || + { skip "Need OST version at least 2.10.58"; return 0; } + + do_nodes $(comma_list $(osts_nodes)) \ + lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \ + ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \ + ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5" + nrs_write_read "runas -u 500 -g 1000" + tbf_verify 5 5 "runas -u 500 -g 1000" + + do_nodes $(comma_list $(osts_nodes)) \ + lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \ + ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \ + ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10" + + nrs_write_read "runas -u 500" + tbf_verify 20 10 "runas -u 500" + + do_nodes $(comma_list $(osts_nodes)) \ + lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \ + ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \ + ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \ + ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10" + nrs_write_read "runas -u 500" + tbf_verify 10 10 "runas -u 500" + tbf_verify 20 10 "runas -u 500" + cleanup_77k "ext_a ext_b" "fifo" +} +run_test 77k "check TBF policy with NID/JobID/OPCode expression" + +test_77l() { + [[ $(lustre_version_code ost1) -ge $(version_code 2.10.56) ]] || + { skip "Need OST version at least 2.10.56"; return 0; } + + do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" + do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" + + local output=$(do_facet ost1 lctl get_param \ + ost.OSS.ost_io.nrs_policies | \ + awk '/name: tbf/ {print;exit}' | \ + awk -F ': ' '{print $2}') + + if [ "$output" != "tbf" ]; then + error "The generic TBF output is '$output', not 'tbf'" + fi + + do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo" +} +run_test 77l "check the output of NRS policies for generic TBF" + +test_77m() { + if [ $(lustre_version_code ost1) -lt $(version_code 2.9.54) ]; then + skip "Need OST version at least 2.9.54" + return 0 + fi + + local dir=$DIR/$tdir + + mkdir $dir || error "mkdir $dir failed" + $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed" + chmod 777 $dir + + local nodes=$(comma_list $(osts_nodes)) + do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \ + ost.OSS.ost_io.nrs_delay_min=4 \ + ost.OSS.ost_io.nrs_delay_max=4 \ + ost.OSS.ost_io.nrs_delay_pct=100 + [ $? -ne 0 ] && error "Failed to set delay policy" + + local start=$SECONDS + do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \ + dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \ + oflag=direct conv=fdatasync || + { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"; + error "dd on client failed (1)"; } + local elapsed=$((SECONDS - start)) + + # NRS delay doesn't do sub-second timing, so a request enqueued at + # 0.9 seconds can be dequeued at 4.0 + [ $elapsed -lt 3 ] && + { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"; + error "Single 1M write should take at least 3 seconds"; } + + start=$SECONDS + do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \ + dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \ + oflag=direct conv=fdatasync || + { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"; + error "dd on client failed (2)"; } + elapsed=$((SECONDS - start)) + + [ $elapsed -lt 30 ] && + { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"; + error "Ten 1M writes should take at least 30 seconds"; } + + do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo" + [ $? -ne 0 ] && error "failed to set policy back to fifo" + + return 0 +} +run_test 77m "check NRS Delay slows write RPC processing" + +test_77n() { #LU-10802 + if [ $(lustre_version_code ost1) -lt $(version_code 2.10.58) ]; then + skip "Need OST version at least 2.10.58" + return 0 + fi + + # Configure jobid_var + local saved_jobid_var=$($LCTL get_param -n jobid_var) + if [ $saved_jobid_var != procname_uid ]; then + set_persistent_param_and_check client \ + "jobid_var" "$FSNAME.sys.jobid_var" procname_uid + fi + + do_nodes $(comma_list $(osts_nodes)) \ + lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \ + ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \ + ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20" + + nrs_write_read + tbf_verify 20 20 "$RUNAS" + + do_nodes $(comma_list $(osts_nodes)) \ + lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \ + ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20" + + nrs_write_read + tbf_verify 20 20 + + do_nodes $(comma_list $(osts_nodes)) \ + lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \ + ost.OSS.ost_io.nrs_policies="fifo" + + sleep 3 + + local current_jobid_var=$($LCTL get_param -n jobid_var) + if [ $saved_jobid_var != $current_jobid_var ]; then + set_persistent_param_and_check client \ + "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var + fi +} +run_test 77n "check wildcard support for TBF JobID NRS policy" + +test_78() { #LU-6673 + local rc + + oss=$(comma_list $(osts_nodes)) + do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" & + do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1 + rc=$? + [[ $rc -eq 3 ]] && skip "no NRS exists" && return + # Valid return codes are: + # 0: Tuning succeeded + # ENODEV: Policy is still stopped + # EAGAIN: Policy is being initialized + [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] || + error "Expected set_param to return 0|ENODEV|EAGAIN" + + # Cleanup the ORR policy + do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" + [ $? -ne 0 ] && error "failed to set policy back to fifo" + return 0 +} +run_test 78 "Enable policy and specify tunings right away" + +test_79() { + remote_mds_nodsh && skip "remote MDS with nodsh" && return + test_mkdir $DIR/$tdir + + # Prevent interference from layout intent RPCs due to + # asynchronous writeback. These will be tested in 130c below. + do_nodes ${CLIENTS:-$HOSTNAME} sync + + setfattr -n trusted.name1 -v value1 $DIR/$tdir || + error "setfattr -n trusted.name1=value1 $DIR/$tdir failed" + +#define OBD_FAIL_MDS_INTENT_DELAY 0x160 + local mdtidx=$($LFS getstripe -m $DIR/$tdir) + local facet=mds$((mdtidx + 1)) + stat $DIR/$tdir + set_nodes_failloc $(facet_active_host $facet) 0x80000160 + getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null & + local pid=$! + sleep 2 + +#define OBD_FAIL_MDS_GETXATTR_PACK 0x131 + set_nodes_failloc $(facet_active_host $facet) 0x80000131 + + wait $pid + return 0 +} +run_test 79 "xattr: intent error" + +test_80a() { + [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return + local MDTIDX=1 + local mdt_index + local i + local file + local pid + + mkdir -p $DIR1/$tdir/dir + createmany -o $DIR1/$tdir/dir/f 10 || + error "create files under remote dir failed $i" + + cp /etc/passwd $DIR1/$tdir/$tfile + + #migrate open file should fails + multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed" + pid=$! + # give multiop a chance to open + sleep 1 + + $LFS migrate -m $MDTIDX $DIR1/$tdir && + error "migrate open files should failed with open files" + + kill -USR1 $pid + + $LFS migrate -m $MDTIDX $DIR1/$tdir || + error "migrate remote dir error" + + echo "Finish migration, then checking.." + for file in $(find $DIR1/$tdir); do + mdt_index=$($LFS getstripe -m $file) + [ $mdt_index == $MDTIDX ] || + error "$file is not on MDT${MDTIDX}" + done + + diff /etc/passwd $DIR1/$tdir/$tfile || + error "file different after migration" + + rm -rf $DIR1/$tdir || error "rm dir failed after migration" +} +run_test 80a "migrate directory when some children is being opened" + +cleanup_80b() { + trap 0 + kill -9 $migrate_pid +} + +test_80b() { + [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return + local migrate_dir1=$DIR1/$tdir/migrate_dir + local migrate_dir2=$DIR2/$tdir/migrate_dir + local migrate_run=$LUSTRE/tests/migrate.sh + local start_time + local end_time + local show_time=1 + local mdt_idx + local rc=0 + local rc1=0 + + trap cleanup_80b EXIT + #prepare migrate directory + mkdir -p $migrate_dir1 + for F in {1,2,3,4,5}; do + echo "$F$F$F$F$F" > $migrate_dir1/file$F + echo "$F$F$F$F$F" > $DIR/$tdir/file$F + done + + #migrate the directories among MDTs + ( + while true; do + mdt_idx=$((RANDOM % MDSCOUNT)) + $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null || + rc=$? + [ $rc -ne 0 -o $rc -ne 16 ] || break + done + ) & + migrate_pid=$! + + echo "start migration thread $migrate_pid" + #Access the files at the same time + start_time=$(date +%s) + echo "accessing the migrating directory for 5 minutes..." + while true; do + ls $migrate_dir2 > /dev/null || { + echo "read dir fails" + break + } + diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || { + echo "access file1 fails" + break + } + + cat $migrate_dir2/file2 > $migrate_dir2/file3 || { + echo "access file2/3 fails" + break + } + + echo "aaaaa" > $migrate_dir2/file4 > /dev/null || { + echo "access file4 fails" + break + } + + stat $migrate_dir2/file5 > /dev/null || { + echo "stat file5 fails" + break + } + + touch $migrate_dir2/source_file > /dev/null || rc1=$? + [ $rc1 -ne 0 -o $rc1 -ne 1 ] || { + echo "touch file failed with $rc1" + break; + } + + if [ -e $migrate_dir2/source_file ]; then + ln $migrate_dir2/source_file $migrate_dir2/link_file \ + &>/dev/null || rc1=$? + if [ -e $migrate_dir2/link_file ]; then + rm -rf $migrate_dir2/link_file + fi + + mrename $migrate_dir2/source_file \ + $migrate_dir2/target_file &>/dev/null || rc1=$? + [ $rc1 -ne 0 -o $rc1 -ne 1 ] || { + echo "rename failed with $rc1" + break + } + + if [ -e $migrate_dir2/target_file ]; then + rm -rf $migrate_dir2/target_file &>/dev/null || + rc1=$? + else + rm -rf $migrate_dir2/source_file &>/dev/null || + rc1=$? + fi + [ $rc1 -ne 0 -o $rc1 -ne 1 ] || { + echo "unlink failed with $rc1" + break + } + fi + + end_time=$(date +%s) + duration=$((end_time - start_time)) + if [ $((duration % 10)) -eq 0 ]; then + if [ $show_time -eq 1 ]; then + echo "...$duration seconds" + show_time=0 + fi + else + show_time=1 + fi + + kill -0 $migrate_pid || { + echo "migration stopped 1" + break + } + + [ $duration -ge 300 ] && break + done + + #check migration are still there + kill -0 $migrate_pid || error "migration stopped 2" + cleanup_80b +} +run_test 80b "Accessing directory during migration" + +test_81a() { + [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return + + rm -rf $DIR1/$tdir + + mkdir -p $DIR1/$tdir + + $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0 + $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1 + + cd $DIR1/$tdir + touch d0/0 || error "create 0 failed" + mv d0/0 d1/0 || error "rename d0/0 d1/0 failed" + stat d0/0 && error "stat mv filed succeed" + mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed" + stat d0/0 || error "stat failed" + + local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l) + + if [ $t -ne 3 ]; then + ls -ai $DIR1/$tdir/d0 + error "expect 3 get $t" + fi + + return 0 +} +run_test 81a "rename and stat under striped directory" + +test_81b() { + [ $MDSCOUNT -lt 2 ] && + skip "We need at least 2 MDTs for this test" + + local total + local setattr_pid + + total=1000 + + $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir" + createmany -o $DIR1/$tdir/$tfile. $total || error "createmany" + + ( + while true; do + touch $DIR1/$tdir + done + ) & + setattr_pid=$! + + for i in $(seq $total); do + mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \ + > /dev/null + done + + kill -9 $setattr_pid +} +run_test 81b "rename under striped directory doesn't deadlock" + +test_82() { + [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.91) ]] || + { skip "Need MDS version at least 2.6.92"; return 0; } + + # Client 1 creates a file. + multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1" + pid1=$! + # Client 2 opens the file. + multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2" pid2=$! # Client 1 makes the file an orphan. rm $DIR1/$tfile || error "rm" @@ -3023,9 +4126,356 @@ test_82() { } run_test 82 "fsetxattr and fgetxattr on orphan files" +test_83() { + [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return + local pid1 + local pid2 + + ( + cd $DIR1 + while true; do + $LFS mkdir -i1 -c2 $tdir + rmdir $tdir + done + ) & + pid1=$! + echo "start pid $pid1 to create/unlink striped directory" + + # Access the directory at the same time + ( + cd $DIR2 + while true; do + stat $tdir > /dev/null 2>&1 + done + ) & + pid2=$! + echo "start pid $pid2 to stat striped directory" + + sleep 120 + kill $pid1 $pid2 + wait $pid1 $pid2 + + return 0 +} +run_test 83 "access striped directory while it is being created/unlinked" + +test_90() { + [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return + local pid1 + local pid2 + local duration=180 + + [ "$SLOW" = "yes" ] && duration=600 + # Open/Create under striped directory + ( + cd $DIR1 + while true; do + $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1 + touch $tdir/f{0..3} > /dev/null 2>&1 + done + ) & + pid1=$! + echo "start pid $pid1 to open/create under striped directory" + + # unlink the striped directory at the same time + ( + cd $DIR2 + while true; do + rm -rf $tdir > /dev/null 2>&1 + done + ) & + pid2=$! + echo "start pid $pid2 to unlink striped directory" + + sleep $duration + + kill $pid1 $pid2 + wait $pid1 $pid2 + + return 0 +} +run_test 90 "open/create and unlink striped directory" + +test_91() { + [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return + local pid1 + local pid2 + local duration=180 + + [ "$SLOW" = "yes" ] && duration=600 + # chmod striped directory + ( + cd $DIR1 + while true; do + $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1 + chmod go+w $tdir > /dev/null 2>&1 + done + ) & + pid1=$! + echo "start pid $pid1 to chmod striped directory" + + # unlink the striped directory at the same time + ( + cd $DIR2 + while true; do + rm -rf $tdir > /dev/null 2>&1 + done + ) & + pid2=$! + echo "start pid $pid2 to unlink striped directory" + + sleep $duration + + kill $pid1 $pid2 + wait $pid1 $pid2 + + return 0 +} +run_test 91 "chmod and unlink striped directory" + +test_92() { + [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return + + local fd=$(free_fd) + local cmd="exec $fd<$DIR1/$tdir" + $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails" + eval $cmd + cmd="exec $fd<&-" + trap "eval $cmd" EXIT + cd $DIR1/$tdir || error "cd $DIR1/$tdir fails" + rmdir ../$tdir || error "rmdir ../$tdir fails" + + #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408 + $LCTL set_param fail_loc=0x1408 + mkdir $DIR2/$tdir/dir && error "create dir succeeds" + $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir && + error "create remote dir succeeds" + $LCTL set_param fail_loc=0 + eval $cmd + return 0 +} +run_test 92 "create remote directory under orphan directory" + +test_93() { + local rc1=0 + local rc2=0 + local old_rr + + mkdir -p $DIR1/$tfile-1/ + mkdir -p $DIR2/$tfile-2/ + local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \ + 'lod.lustre-MDT*/qos_threshold_rr' | sed -e 's/%//') + do_facet $SINGLEMDS lctl set_param -n \ + 'lod.lustre-MDT*/qos_threshold_rr' 100 + #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163 + do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163" + + $SETSTRIPE -c -1 $DIR1/$tfile-1/file1 & + local PID1=$! + sleep 1 + $SETSTRIPE -c -1 $DIR2/$tfile-2/file2 & + local PID2=$! + wait $PID2 + wait $PID1 + do_facet $SINGLEMDS "lctl set_param fail_loc=0x0" + do_facet $SINGLEMDS "lctl set_param -n \ + 'lod.lustre-MDT*/qos_threshold_rr' $old_rr" + + $GETSTRIPE $DIR1/$tfile-1/file1 + rc1=$($GETSTRIPE -q $DIR1/$tfile-1/file1 | + awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l) + $GETSTRIPE $DIR2/$tfile-2/file2 + rc2=$($GETSTRIPE -q $DIR2/$tfile-2/file2 | + awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l) + echo "rc1=$rc1 and rc2=$rc2 " + [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] || + error "object allocate on same ost detected" +} +run_test 93 "alloc_rr should not allocate on same ost" + +# Data-on-MDT tests +test_100a() { + skip "Reserved for glimpse-ahead" && return + [ $(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 -E EOF $DIR/$tdir/dom + + lctl set_param -n mdc.*.stats=clear + dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1 + + $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1" + # first stat from server should return size data and save glimpse + local gls=$(lctl get_param -n mdc.*.stats | \ + awk '/ldlm_glimpse/ {print $2}') + [ -z $gls ] || error "Unexpected $gls glimpse RPCs" + # second stat to check size is NOT cached on client without IO lock + $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2" + + local gls=$(lctl get_param -n mdc.*.stats | grep ldlm_glimpse | wc -l) + [ "1" == "$gls" ] || error "Expect 1 glimpse RPCs but got $gls" + rm -f $dom +} +run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)" + +test_100b() { + [ $(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 -E EOF $DIR/$tdir/dom + + lctl set_param -n mdc.*.stats=clear + dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1 + cancel_lru_locks mdc + # first stat data from server should have size + $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1" + # second stat to check size is cached on client + $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2" + + local gls=$(lctl get_param -n mdc.*.stats | + awk '/ldlm_glimpse/ {print $2}') + # both stats should cause no glimpse requests + [ -z $gls ] || error "Unexpected $gls glimpse RPCs" + rm -f $dom +} +run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)" + +test_100c() { + [ $(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 -E EOF $DIR/$tdir/dom + + lctl set_param -n mdc.*.stats=clear + lctl set_param -n osc.*.stats=clear + dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1 + + # check that size is merged from MDT and OST correctly + $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom || + error "Wrong size from stat #1" + + local gls=$(lctl get_param -n osc.*.stats | grep ldlm_glimpse | wc -l) + [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none" + + rm -f $dom +} +run_test 100c "DoM: write vs stat without IO lock (combined file)" + +test_100d() { + [ $(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 -E EOF $DIR/$tdir/dom + + + dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1 + lctl set_param -n mdc.*.stats=clear + $TRUNCATE $DIR2/$tdir/dom 4096 + + # check that reported size is valid after file grows to OST and + # is truncated back to MDT stripe size + $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || + error "Wrong size from stat #1" + + local gls=$(lctl get_param -n osc.*.stats | grep ldlm_glimpse | wc -l) + [ $gls -eq 0 ] && error "Expect OST glimpse but got none" + + rm -f $dom +} +run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)" + +test_101a() { + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] && + skip "Need MDS version at least 2.10.55" && return + + $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile + # to get layout + $CHECKSTAT -t file $DIR1/$tfile + + local old_wb=$(sysctl -n vm.dirty_writeback_centisecs) + sysctl -wq vm.dirty_writeback_centisecs=0 + + trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT + + # open + IO lock + dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || + error_noexit "Write fails" + # must discard pages + lctl set_param -n mdc.*.stats=clear + rm $DIR2/$tfile || error "Unlink fails" + + local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l) + [ $writes -eq 0 ] || error "Found WRITE RPC but expect none" +} +run_test 101a "Discard DoM data on unlink" + +test_101b() { + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] && + skip "Need MDS version at least 2.10.55" && return + + $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile + touch $DIR1/${tfile}_2 + # to get layout + $CHECKSTAT -t file $DIR1/$tfile + + local old_wb=$(sysctl -n vm.dirty_writeback_centisecs) + sysctl -wq vm.dirty_writeback_centisecs=0 + + trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT + + # open + IO lock + dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails" + # must discard pages + lctl set_param -n mdc.*.stats=clear + mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails" + + local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l) + [ $writes -eq 0 ] || error "Found WRITE RPC but expect none" +} +run_test 101b "Discard DoM data on rename" + +test_101c() { + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] && + skip "Need MDS version at least 2.10.55" && return + + $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile + # to get layout + $CHECKSTAT -t file $DIR1/$tfile + + local old_wb=$(sysctl -n vm.dirty_writeback_centisecs) + sysctl -wq vm.dirty_writeback_centisecs=0 + + trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT + + # open + IO lock + dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails" + $MULTIOP $DIR1/$tfile O_c & + MULTIOP_PID=$! + sleep 1 + lctl set_param -n mdc.*.stats=clear + rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file" + kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure" + + local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l) + [ $writes -eq 0 ] || error "Found WRITE RPC but expect none" +} +run_test 101c "Discard DoM data on close-unlink" + log "cleanup: ======================================================" -[ "$(mount | grep $MOUNT2)" ] && umount $MOUNT2 +# kill and wait in each test only guarentee script finish, but command in script +# like 'rm' 'chmod' may still be running, wait for all commands to finish +# otherwise umount below will fail +[ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" || + true complete $SECONDS rm -f $SAMPLE_FILE