From 23423374c405bba5c00c71be368332d482e69e1a Mon Sep 17 00:00:00 2001 From: Lai Siyao <lai.siyao@intel.com> Date: Fri, 3 Aug 2018 22:29:38 -0700 Subject: [PATCH] LU-7763 tests: improve sanityn 33d Sanityn.sh 33d verifies that CoS (Commit-on-Sharing) for DNE, but if transaction commits before unlock, CoS will not be triggered. To avoid this, do all tests twice, it's unlikely that both will fail. This patch is back-ported from the following one: Lustre-commit: 9d49453b675fba97002a2553769be89800783db3 Lustre-change: https://review.whamcloud.com/31946 Test-Parameters: trivial testlist=sanityn mdscount=2 mdtcount=4 Change-Id: If20670321e4bda9763b3794145d62a7264e7cef6 Signed-off-by: Lai Siyao <lai.siyao@intel.com> Reviewed-on: https://review.whamcloud.com/32937 Tested-by: Jenkins Reviewed-by: Andreas Dilger <adilger@whamcloud.com> Tested-by: Maloo <hpdd-maloo@intel.com> Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com> Reviewed-by: John L. Hammond <jhammond@whamcloud.com> --- lustre/tests/sanityn.sh | 73 ++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/lustre/tests/sanityn.sh b/lustre/tests/sanityn.sh index 60dd159a26..7cc4a75052 100755 --- a/lustre/tests/sanityn.sh +++ b/lustre/tests/sanityn.sh @@ -983,16 +983,28 @@ test_33c() { } run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel" -ops_do_cos() { +# 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)) - 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 + 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() { @@ -1000,39 +1012,34 @@ test_33d() { [ $(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" + op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir" # remote directory unlink - $LFS mkdir -i 1 $DIR/$tdir - ops_do_cos "rmdir $DIR/$tdir" + op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir" # striped directory create - mkdir $DIR/$tdir - ops_do_cos "$LFS mkdir -c 2 $DIR/$tdir/subdir" + op_trigger_cos "mkdir $DIR/$tdir" "$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" + op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \ + "chmod 713 $DIR/$tdir" # striped directory unlink - $LFS mkdir -c 2 $DIR/$tdir - touch $DIR/$tdir - ops_do_cos "rmdir $DIR/$tdir" + op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \ + "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" + 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 - $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" + 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 - $LFS mkdir -i 0 $DIR/$tdir - ops_do_cos "$LFS migrate -m 1 $DIR/$tdir" + 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" -- GitLab