Whamcloud - gitweb
LU-5810 tests: add client hostname to lctl mark
[fs/lustre-release.git] / lustre / tests / sanityn.sh
old mode 100644 (file)
new mode 100755 (executable)
index ddb16fa..738c837
@@ -5,8 +5,6 @@ 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"
-#              LU-7072
-ALWAYS_EXCEPT="78     $SANITYN_EXCEPT"
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
 SRCDIR=$(dirname $0)
@@ -40,7 +38,7 @@ if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
 # 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
@@ -50,9 +48,6 @@ 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)
-
 assert_DIR
 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
 
@@ -299,7 +294,7 @@ test_13() { # bug 2451 - directory coherency
 }
 run_test 13 "test directory page revocation ===================="
 
-test_14() {
+test_14aa() {
        test_mkdir -p $DIR1/$tdir
        cp -p /bin/ls $DIR1/$tdir/$tfile
        multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
@@ -309,9 +304,9 @@ 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_14ab() {
        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
@@ -321,7 +316,7 @@ test_14a() {
         wait $MULTIOP_PID || return 3
         rm $TMP/test14.junk $DIR1/d14/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
@@ -930,7 +925,7 @@ 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)
@@ -963,6 +958,118 @@ 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
+
+       sync
+
+       mkdir $DIR/$tdir
+       # remote mkdir is done on MDT2, which enqueued lock of $tdir on MDT1
+       $LFS mkdir -i 1 $DIR/$tdir/d1
+       do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
+       mkdir $DIR/$tdir/d2
+       local sync_count=$(do_facet mds1 \
+               "lctl get_param -n mdt.*MDT0000.sync_count")
+       [ $sync_count -eq 1 ] || error "Sync-Lock-Cancel not triggered"
+
+       $LFS mkdir -i 1 $DIR/$tdir/d3
+       do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
+       # during sleep remote mkdir should have been committed and canceled
+       # remote lock spontaneously, which shouldn't trigger sync
+       sleep 6
+       mkdir $DIR/$tdir/d4
+       local sync_count=$(do_facet mds1 \
+               "lctl get_param -n mdt.*MDT0000.sync_count")
+       [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
+}
+run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
+
+ops_do_cos() {
+       local nodes=$(comma_list $(mdts_nodes))
+       do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
+       sh -c "$@"
+       local async_commit_count=$(do_nodes $nodes \
+               "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
+       [ $async_commit_count -gt 0 ] || error "CoS not triggerred"
+
+       rm -rf $DIR/$tdir
+       sync
+}
+
+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
+
+       sync
+       # remote directory create
+       mkdir $DIR/$tdir
+       ops_do_cos "$LFS mkdir -i 1 $DIR/$tdir/subdir"
+       # remote directory unlink
+       $LFS mkdir -i 1 $DIR/$tdir
+       ops_do_cos "rmdir $DIR/$tdir"
+       # striped directory create
+       mkdir $DIR/$tdir
+       ops_do_cos "$LFS mkdir -c 2 $DIR/$tdir/subdir"
+       # striped directory setattr
+       $LFS mkdir -c 2 $DIR/$tdir
+       touch $DIR/$tdir
+       ops_do_cos "chmod 713 $DIR/$tdir"
+       # striped directory unlink
+       $LFS mkdir -c 2 $DIR/$tdir
+       touch $DIR/$tdir
+       ops_do_cos "rmdir $DIR/$tdir"
+       # cross-MDT link
+       $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
+       ops_do_cos "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
+       # cross-MDT rename
+       $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
+       ops_do_cos "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
+       # migrate
+       $LFS mkdir -i 0 $DIR/$tdir
+       ops_do_cos "$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() {
@@ -1112,7 +1219,7 @@ test_36() { #bug 16417
        sync; sleep 5; sync # wait for delete thread
 
        while [ $i -le 10 ]; do
-               lctl mark "start test"
+               lctl mark "$HOSTNAME start test loop $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"
@@ -2960,25 +3067,25 @@ test_77e() {
                        error "failed to set TBF policy"
        done
 
-       # Only operate rules on ost0 since OSTs might run on the same OSS
+       # Only operate rules on ost1 since OSTs might run on the same OSS
        # Add some rules
-       tbf_rule_operate ost0 "start\ localhost\ {0@lo}\ 1000"
+       tbf_rule_operate ost1 "start\ localhost\ {0@lo}\ 1000"
        local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
        local client_nids=$(nids_list $address "\\")
-       tbf_rule_operate ost0 "start\ clients\ {$client_nids}\ 100"
-       tbf_rule_operate ost0 "start\ others\ {*.*.*.*@$NETTYPE}\ 50"
+       tbf_rule_operate ost1 "start\ clients\ {$client_nids}\ 100"
+       tbf_rule_operate ost1 "start\ others\ {*.*.*.*@$NETTYPE}\ 50"
        nrs_write_read
 
        # Change the rules
-       tbf_rule_operate ost0 "change\ localhost\ 1001"
-       tbf_rule_operate ost0 "change\ clients\ 101"
-       tbf_rule_operate ost0 "change\ others\ 51"
+       tbf_rule_operate ost1 "change\ localhost\ 1001"
+       tbf_rule_operate ost1 "change\ clients\ 101"
+       tbf_rule_operate ost1 "change\ others\ 51"
        nrs_write_read
 
        # Stop the rules
-       tbf_rule_operate ost0 "stop\ localhost"
-       tbf_rule_operate ost0 "stop\ clients"
-       tbf_rule_operate ost0 "stop\ others"
+       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
@@ -3011,23 +3118,23 @@ test_77f() {
                        error "failed to set TBF policy"
        done
 
-       # Only operate rules on ost0 since OSTs might run on the same OSS
+       # Only operate rules on ost1 since OSTs might run on the same OSS
        # Add some rules
-       tbf_rule_operate ost0 "start\ runas\ {iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ 1000"
-       tbf_rule_operate ost0 "start\ iozone_runas\ {iozone.$RUNAS_ID}\ 100"
-       tbf_rule_operate ost0 "start\ dd_runas\ {dd.$RUNAS_ID}\ 50"
+       tbf_rule_operate ost1 "start\ runas\ {iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ 1000"
+       tbf_rule_operate ost1 "start\ iozone_runas\ {iozone.$RUNAS_ID}\ 100"
+       tbf_rule_operate ost1 "start\ dd_runas\ {dd.$RUNAS_ID}\ 50"
        nrs_write_read "$RUNAS"
 
        # Change the rules
-       tbf_rule_operate ost0 "change\ runas\ 1001"
-       tbf_rule_operate ost0 "change\ iozone_runas\ 101"
-       tbf_rule_operate ost0 "change\ dd_runas\ 51"
+       tbf_rule_operate ost1 "change\ runas\ 1001"
+       tbf_rule_operate ost1 "change\ iozone_runas\ 101"
+       tbf_rule_operate ost1 "change\ dd_runas\ 51"
        nrs_write_read "$RUNAS"
 
        # Stop the rules
-       tbf_rule_operate ost0 "stop\ runas"
-       tbf_rule_operate ost0 "stop\ iozone_runas"
-       tbf_rule_operate ost0 "stop\ dd_runas"
+       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
@@ -3069,7 +3176,7 @@ test_77g() {
 
        # 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 ost0 "start\ dd_runas\ {dd.$RUNAS_ID}\ 50"
+       tbf_rule_operate ost1 "start\ dd_runas\ {dd.$RUNAS_ID}\ 50"
 
        # Cleanup the TBF policy
        for i in $(seq 1 $OSTCOUNT)
@@ -3093,8 +3200,12 @@ test_78() { #LU-6673
                do_facet ost"$i" lctl set_param \
                        ost.OSS.*.nrs_orr_quantum=1
                rc=$?
-               [ $rc -eq 0 -o $rc -eq 11 ] ||
-                       error "Expected set_param to return 0 or EAGAIN"
+               # 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"
        done
 
        # Cleanup the ORR policy
@@ -3359,8 +3470,110 @@ test_83() {
 }
 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"
+
 log "cleanup: ======================================================"
 
+# 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
+wait_update $HOSTNAME "fuser -m $MOUNT2" "" || true
+
 [ "$(mount | grep $MOUNT2)" ] && umount $MOUNT2
 
 complete $SECONDS