Whamcloud - gitweb
LU-10754 tests: sanityn/47b to sleep for 1s
[fs/lustre-release.git] / lustre / tests / sanityn.sh
index 09263a0..a4006aa 100755 (executable)
@@ -4,7 +4,8 @@ set -e
 
 ONLY=${ONLY:-"$*"}
 # bug number for skipped test: 9977/LU-7105
-ALWAYS_EXCEPT="                28           $SANITYN_EXCEPT"
+#              LU-7105
+ALWAYS_EXCEPT=" 28     $SANITYN_EXCEPT"
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
 SRCDIR=$(dirname $0)
@@ -30,6 +31,7 @@ CLEANUP=${CLEANUP:-:}
 SETUP=${SETUP:-:}
 init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
+get_lustre_env
 init_logging
 
 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
@@ -315,65 +317,52 @@ test_14aa() {
        MULTIPID=$!
 
        $DIR2/$tdir/$tfile && error || true
-       kill -USR1 $MULTIPID
-       wait $MULTIPID || return 2
+       kill $MULTIPID
 }
 run_test 14aa "execution of file open for write returns -ETXTBSY"
 
 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"
+       cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
+       $DIR1/$tdir/sleep 60 &
+       SLEEP_PID=$!
+       $MULTIOP $DIR2/$tdir/sleep Oc && error "expected error, got success"
+       kill $SLEEP_PID
 }
 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
 
 test_14b() { # bug 3192, 7040
        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 && \
+       cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
+       $DIR1/$tdir/sleep 60 &
+       SLEEP_PID=$!
+       $TRUNCATE $DIR2/$tdir/sleep 60 && kill -9 $SLEEP_PID && \
                error "expected truncate error, got success"
-       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"
+       kill $SLEEP_PID
+       cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
 }
 run_test 14b "truncate of executing file returns -ETXTBSY ======"
 
 test_14c() { # bug 3430, 7040
        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/$tdir/multiop || error "binary changed"
-       rm $TMP/$tfile $DIR1/$tdir/multiop || error "removing multiop"
+       cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
+       $DIR1/$tdir/sleep 60 &
+       SLEEP_PID=$!
+       cp /etc/hosts $DIR2/$tdir/sleep && error "expected error, got success"
+       kill $SLEEP_PID
+       cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
 }
 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
 
 test_14d() { # bug 10921
        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 -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
+       $DIR1/$tdir/sleep 60 &
+       SLEEP_PID=$!
        log chmod
-       chmod 600 $DIR1/$tdir/multiop || error "chmod failed"
-       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"
+       chmod 600 $DIR1/$tdir/sleep || error "chmod failed"
+       kill $SLEEP_PID
+       cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
 }
 run_test 14d "chmod of executing file is still possible ========"
 
@@ -443,6 +432,42 @@ test_16b() {
 }
 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 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
 
@@ -480,13 +505,10 @@ test_19() { # bug3811
        [ "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)
@@ -780,11 +802,13 @@ enable_lockless_truncate() {
 }
 
 test_32a() { # bug 11270
-       local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
+       local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
        local stripe_size=$(do_facet $SINGLEMDS \
                "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
 
-       save_lustre_params client "$OSC.*.lockless_truncate" > $p
+       save_lustre_params client "$OSC.*.lockless_truncate" > $save
+       # restore lockless_truncate default values on exit
+       stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
        cancel_lru_locks $OSC
        enable_lockless_truncate 1
        rm -f $DIR1/$tfile
@@ -812,10 +836,7 @@ test_32a() { # bug 11270
        $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
+       rm -f $DIR1/$tfile
 }
 run_test 32a "lockless truncate"
 
@@ -1250,7 +1271,7 @@ test_35() { # bug 17645
        for g in $gen; do
            if ! test "$g" -eq "${generation[count]}"; then
                list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
-               local c = 0
+               local c=0
                for imp in $list; do
                        if [ $c = $count ]; then
                                break
@@ -1439,13 +1460,21 @@ test_39d() { # LU-7310
 }
 run_test 39d "sync write should update mtime"
 
+pdo_sched() {
+       # how long 40-47 take with specific delay
+       # sleep 0.1 # 78s
+       sleep 0.2 # 103s
+       # sleep 0.3 # 124s
+       # sleep 0.5 # 164s
+}
+
 # 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
 check_pdo_conflict() {
        local pid=$1
        local conflict=0
-       sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
+       pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
        if [[ `ps --pid $pid | wc -l` == 1 ]]; then
                conflict=1
                echo "Conflict"
@@ -1459,12 +1488,12 @@ check_pdo_conflict() {
 # test 40: check non-blocking operations
 test_40a() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       cancel_lru_locks mdc
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        touch $DIR2
        mkdir $DIR1/$tfile &
-       PID1=$!
-       sleep 1
+       PID1=$!; pdo_sched
        touch $DIR2/$tfile-2
        check_pdo_conflict $PID1 || error "create is blocked"
        mkdir $DIR2/$tfile-3
@@ -1481,6 +1510,7 @@ test_40a() {
 
        #  all operations above shouldn't wait the first one
        check_pdo_conflict $PID1 || error "parallel operation is blocked"
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        wait $PID1
        rm -rf $DIR/$tfile*
        return 0
@@ -1489,11 +1519,11 @@ run_test 40a "pdirops: create vs others =============="
 
 test_40b() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       cancel_lru_locks mdc
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        touch $DIR1/$tfile &
-       PID1=$!
-       sleep 1
+       PID1=$!; pdo_sched
        # open|create
        touch $DIR2/$tfile-2
        check_pdo_conflict $PID1 || error "create is blocked"
@@ -1511,6 +1541,7 @@ test_40b() {
        # all operations above shouldn't wait the first one
 
         check_pdo_conflict $PID1 || error "parallel operation is blocked"
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        wait $PID1
        rm -rf $DIR/$tfile*
        return 0
@@ -1519,12 +1550,12 @@ run_test 40b "pdirops: open|create and others =============="
 
 test_40c() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        link $DIR1/$tfile $DIR1/$tfile-0 &
-       PID1=$!
-       sleep 1
+       PID1=$!; pdo_sched
        # open|create
        touch $DIR2/$tfile-2
        check_pdo_conflict $PID1 || error "create is blocked"
@@ -1542,6 +1573,7 @@ test_40c() {
 
         # all operations above shouldn't wait the first one
        check_pdo_conflict $PID1 || error "parallel operation is blocked"
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        wait $PID1
        rm -rf $DIR/$tfile*
        return 0
@@ -1550,12 +1582,12 @@ run_test 40c "pdirops: link and others =============="
 
 test_40d() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        rm $DIR1/$tfile &
-       PID1=$!
-       sleep 1
+       PID1=$!; pdo_sched
        # open|create
        touch $DIR2/$tfile-2
        check_pdo_conflict $PID1 || error "create is blocked"
@@ -1573,6 +1605,7 @@ test_40d() {
 
        # all operations above shouldn't wait the first one
        check_pdo_conflict $PID1 || error "parallel operation is blocked"
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        wait $PID1
        return 0
 }
@@ -1580,12 +1613,12 @@ run_test 40d "pdirops: unlink and others =============="
 
 test_40e() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mv $DIR1/$tfile $DIR1/$tfile-0 &
-       PID1=$!
-       sleep 1
+       PID1=$!; pdo_sched
        # open|create
        touch $DIR2/$tfile-2
        check_pdo_conflict $PID1 || error "create is blocked"
@@ -1601,6 +1634,7 @@ test_40e() {
 
        # all operations above shouldn't wait the first one
        check_pdo_conflict $PID1 || error "parallel operation is blocked"
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        wait $PID1
        rm -rf $DIR/$tfile*
        return 0
@@ -1609,106 +1643,130 @@ run_test 40e "pdirops: rename and others =============="
 
 # test 41: create blocking operations
 test_41a() {
+       cancel_lru_locks mdc
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
-       PID1=$!
-       sleep 1
-       mkdir $DIR2/$tfile && error "mkdir must fail"
+       PID1=$! ; pdo_sched
+       mkdir $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 41a "pdirops: create vs mkdir =============="
 
 test_41b() {
+       cancel_lru_locks mdc
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
-       PID1=$!
-       sleep 1
-       $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
+       PID1=$! ; pdo_sched
+       $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 41b "pdirops: create vs create =============="
 
 test_41c() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
-       PID1=$!
-       sleep 1
-       link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
+       PID1=$! ; pdo_sched
+       link $DIR2/$tfile-2 $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 41c "pdirops: create vs link =============="
 
 test_41d() {
+       cancel_lru_locks mdc
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
-       PID1=$!
-       sleep 1
-       rm $DIR2/$tfile || error "unlink must succeed"
+       PID1=$! ; pdo_sched
+       rm $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 41d "pdirops: create vs unlink =============="
 
 test_41e() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
-       PID1=$!
-       sleep 1
-       mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
+       PID1=$! ; pdo_sched
+       mv $DIR2/$tfile-2 $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 41e "pdirops: create and rename (tgt) =============="
 
 test_41f() {
+       cancel_lru_locks mdc
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
-       PID1=$!
-       sleep 1
-       mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
+       PID1=$! ; pdo_sched
+       mv $DIR2/$tfile $DIR2/$tfile-2 &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 41f "pdirops: create and rename (src) =============="
 
 test_41g() {
+       cancel_lru_locks mdc
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
-       PID1=$!
-       sleep 1
-       stat $DIR2/$tfile > /dev/null || error "stat must succeed"
+       PID1=$! ; pdo_sched
+       stat $DIR2/$tfile > /dev/null &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 41g "pdirops: create vs getattr =============="
 
 test_41h() {
+       cancel_lru_locks mdc
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
-       PID1=$!
-       sleep 1
-       ls -lia $DIR2/ > /dev/null
+       PID1=$! ; pdo_sched
+       ls -lia $DIR2/ > /dev/null &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
+       wait $PID2
        rm -rf $DIR/$tfile*
        return 0
 }
@@ -1716,106 +1774,130 @@ run_test 41h "pdirops: create vs readdir =============="
 
 # test 42: unlink and blocking operations
 test_42a() {
+       cancel_lru_locks mdc
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mkdir $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       mkdir $DIR2/$tfile && error "mkdir must fail"
+       PID1=$! ; pdo_sched
+       mkdir $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 42a "pdirops: mkdir vs mkdir =============="
 
 test_42b() {
+       cancel_lru_locks mdc
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mkdir $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
+       PID1=$! ; pdo_sched
+       $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 42b "pdirops: mkdir vs create =============="
 
 test_42c() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mkdir $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
+       PID1=$! ; pdo_sched
+       link $DIR2/$tfile-2 $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 42c "pdirops: mkdir vs link =============="
 
 test_42d() {
+       cancel_lru_locks mdc
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mkdir $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       rmdir $DIR2/$tfile || error "unlink must succeed"
+       PID1=$! ; pdo_sched
+       rmdir $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 42d "pdirops: mkdir vs unlink =============="
 
 test_42e() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mkdir $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
+       PID1=$! ; pdo_sched
+       mv -T $DIR2/$tfile-2 $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 42e "pdirops: mkdir and rename (tgt) =============="
 
 test_42f() {
+       cancel_lru_locks mdc
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mkdir $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
+       PID1=$! ; pdo_sched
+       mv $DIR2/$tfile $DIR2/$tfile-2 &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 42f "pdirops: mkdir and rename (src) =============="
 
 test_42g() {
+       cancel_lru_locks mdc
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mkdir $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       stat $DIR2/$tfile > /dev/null || error "stat must succeed"
+       PID1=$! ; pdo_sched
+       stat $DIR2/$tfile > /dev/null &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 42g "pdirops: mkdir vs getattr =============="
 
 test_42h() {
+       cancel_lru_locks mdc
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mkdir $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       ls -lia $DIR2/ > /dev/null
+       PID1=$! ; pdo_sched
+       ls -lia $DIR2/ > /dev/null &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
+       wait $PID2
        rm -rf $DIR/$tfile*
        return 0
 }
@@ -1823,114 +1905,138 @@ run_test 42h "pdirops: mkdir vs readdir =============="
 
 # test 43: unlink and blocking operations
 test_43a() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        rm $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       mkdir $DIR2/$tfile || error "mkdir must succeed"
+       PID1=$! ; pdo_sched
+       mkdir $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "mkdir must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 43a "pdirops: unlink vs mkdir =============="
 
 test_43b() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        rm $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
+       PID1=$! ; pdo_sched
+       $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 43b "pdirops: unlink vs create =============="
 
 test_43c() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        rm $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
+       PID1=$! ; pdo_sched
+       link $DIR2/$tfile-2 $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 43c "pdirops: unlink vs link =============="
 
 test_43d() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        rm $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       rm $DIR2/$tfile && error "unlink must fail"
+       PID1=$! ; pdo_sched
+       rm $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 43d "pdirops: unlink vs unlink =============="
 
 test_43e() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        rm $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
+       PID1=$! ; pdo_sched
+       mv -u $DIR2/$tfile-2 $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 43e "pdirops: unlink and rename (tgt) =============="
 
 test_43f() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        rm $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
+       PID1=$! ; pdo_sched
+       mv $DIR2/$tfile $DIR2/$tfile-2 &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 43f "pdirops: unlink and rename (src) =============="
 
 test_43g() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        rm $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       stat $DIR2/$tfile > /dev/null && error "stat must fail"
+       PID1=$! ; pdo_sched
+       stat $DIR2/$tfile > /dev/null &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 43g "pdirops: unlink vs getattr =============="
 
 test_43h() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        rm $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       ls -lia $DIR2/ > /dev/null
+       PID1=$! ; pdo_sched
+       ls -lia $DIR2/ > /dev/null &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
+       wait $PID2
        rm -rf $DIR/$tfile*
        return 0
 }
@@ -1938,15 +2044,18 @@ run_test 43h "pdirops: unlink vs readdir =============="
 
 test_43i() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        rm $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
+       PID1=$! ; pdo_sched
+       $LFS mkdir -i 1 $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 &&
                { wait $PID1; error "remote mkdir isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
@@ -1954,116 +2063,141 @@ run_test 43i "pdirops: unlink vs remote mkdir"
 
 # test 44: rename tgt and blocking operations
 test_44a() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2   0x146
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
        mv $DIR1/$tfile-2 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       mkdir $DIR2/$tfile && error "mkdir must fail"
-       check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
+       PID1=$! ; pdo_sched
+       mkdir $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
+       check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
+       date
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 44a "pdirops: rename tgt vs mkdir =============="
 
 test_44b() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2    0x146
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
        mv $DIR1/$tfile-2 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
+       PID1=$! ; pdo_sched
+       $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 44b "pdirops: rename tgt vs create =============="
 
 test_44c() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
        touch $DIR1/$tfile-3
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2    0x146
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
        mv $DIR1/$tfile-2 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
+       PID1=$! ; pdo_sched
+       link $DIR2/$tfile-3 $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 44c "pdirops: rename tgt vs link =============="
 
 test_44d() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2    0x146
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
        mv $DIR1/$tfile-2 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       rm $DIR2/$tfile || error "unlink must succeed"
+       PID1=$! ; pdo_sched
+       rm $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 44d "pdirops: rename tgt vs unlink =============="
 
 test_44e() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
        touch $DIR1/$tfile-2
        touch $DIR1/$tfile-3
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2    0x146
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
        mv $DIR1/$tfile-2 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
+       PID1=$! ; pdo_sched
+       mv $DIR2/$tfile-3 $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
 
 test_44f() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
        touch $DIR1/$tfile-3
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2    0x146
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
        mv $DIR1/$tfile-2 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
+       PID1=$! ; pdo_sched
+       mv $DIR2/$tfile $DIR2/$tfile-3 &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 44f "pdirops: rename tgt and rename (src) =============="
 
 test_44g() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2    0x146
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
        mv $DIR1/$tfile-2 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       stat $DIR2/$tfile > /dev/null || error "stat must succeed"
+       PID1=$! ; pdo_sched
+       stat $DIR2/$tfile > /dev/null &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 44g "pdirops: rename tgt vs getattr =============="
 
 test_44h() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2    0x146
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
        mv $DIR1/$tfile-2 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       ls -lia $DIR2/ > /dev/null
+       PID1=$! ; pdo_sched
+       ls -lia $DIR2/ > /dev/null &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
+       wait $PID2
        rm -rf $DIR/$tfile*
        return 0
 }
@@ -2072,15 +2206,18 @@ run_test 44h "pdirops: rename tgt vs readdir =============="
 # test 44: rename tgt and blocking operations
 test_44i() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2   0x146
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
        mv $DIR1/$tfile-2 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
+       PID1=$! ; pdo_sched
+       $LFS mkdir -i 1 $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1;
                                error "remote mkdir isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
@@ -2088,114 +2225,137 @@ run_test 44i "pdirops: rename tgt vs remote mkdir"
 
 # test 45: rename src and blocking operations
 test_45a() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mv $DIR1/$tfile $DIR1/$tfile-2 &
-       PID1=$!
-       sleep 1
-       mkdir $DIR2/$tfile || error "mkdir must succeed"
+       PID1=$! ; pdo_sched
+       mkdir $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "mkdir must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 45a "pdirops: rename src vs mkdir =============="
 
 test_45b() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mv $DIR1/$tfile $DIR1/$tfile-2 &
-       PID1=$!
-       sleep 1
-       $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
+       PID1=$! ; pdo_sched
+       $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 45b "pdirops: rename src vs create =============="
 
 test_45c() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
        touch $DIR1/$tfile-3
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mv $DIR1/$tfile $DIR1/$tfile-2 &
-       PID1=$!
-       sleep 1
-       link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
+       PID1=$! ; pdo_sched
+       link $DIR2/$tfile-3 $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 45c "pdirops: rename src vs link =============="
 
 test_45d() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mv $DIR1/$tfile $DIR1/$tfile-2 &
-       PID1=$!
-       sleep 1
-       rm $DIR2/$tfile && error "unlink must fail"
+       PID1=$! ; pdo_sched
+       rm $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 45d "pdirops: rename src vs unlink =============="
 
 test_45e() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
        touch $DIR1/$tfile-3
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mv $DIR1/$tfile $DIR1/$tfile-2 &
-       PID1=$!
-       sleep 1
-       mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
+       PID1=$! ; pdo_sched
+       mv $DIR2/$tfile-3 $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 45e "pdirops: rename src and rename (tgt) =============="
 
 test_45f() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mv $DIR1/$tfile $DIR1/$tfile-2 &
-       PID1=$!
-       sleep 1
-       mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
+       PID1=$! ; pdo_sched
+       mv $DIR2/$tfile $DIR2/$tfile-3 &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 45f "pdirops: rename src and rename (src) =============="
 
 test_45g() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mv $DIR1/$tfile $DIR1/$tfile-2 &
-       PID1=$!
-       sleep 1
-       stat $DIR2/$tfile > /dev/null && error "stat must fail"
+       PID1=$! ; pdo_sched
+       stat $DIR2/$tfile > /dev/null &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 45g "pdirops: rename src vs getattr =============="
 
 test_45h() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mv $DIR1/$tfile $DIR1/$tfile-2 &
-       PID1=$!
-       sleep 1
-       ls -lia $DIR2/ > /dev/null
+       PID1=$! ; pdo_sched
+       ls -lia $DIR2/ > /dev/null &
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
+       wait $PID2
        rm -rf $DIR/$tfile*
        return 0
 }
@@ -2203,15 +2363,18 @@ run_test 45h "pdirops: unlink vs readdir =============="
 
 test_45i() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       cancel_lru_locks mdc
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mv $DIR1/$tfile $DIR1/$tfile-2 &
-       PID1=$!
-       sleep 1
-       $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
+       PID1=$! ; pdo_sched
+       $LFS mkdir -i 1 $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1;
                                error "create remote dir isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
@@ -2219,115 +2382,138 @@ run_test 45i "pdirops: rename src vs remote mkdir"
 
 # test 46: link and blocking operations
 test_46a() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        link $DIR1/$tfile-2 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       mkdir $DIR2/$tfile && error "mkdir must fail"
+       PID1=$! ; pdo_sched
+       mkdir $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 46a "pdirops: link vs mkdir =============="
 
 test_46b() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        link $DIR1/$tfile-2 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
+       PID1=$! ; pdo_sched
+       $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 46b "pdirops: link vs create =============="
 
 test_46c() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        link $DIR1/$tfile-2 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
+       PID1=$! ; pdo_sched
+       link $DIR2/$tfile $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 46c "pdirops: link vs link =============="
 
 test_46d() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        link $DIR1/$tfile-2 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       rm $DIR2/$tfile || error "unlink must succeed"
+       PID1=$! ; pdo_sched
+       rm $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 46d "pdirops: link vs unlink =============="
 
 test_46e() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
        touch $DIR1/$tfile-3
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        link $DIR1/$tfile-2 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
+       PID1=$! ; pdo_sched
+       mv $DIR2/$tfile-3 $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 46e "pdirops: link and rename (tgt) =============="
 
 test_46f() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
        touch $DIR1/$tfile-3
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        link $DIR1/$tfile-2 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
+       PID1=$! ; pdo_sched
+       mv $DIR2/$tfile $DIR2/$tfile-3 &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 46f "pdirops: link and rename (src) =============="
 
 test_46g() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        link $DIR1/$tfile-2 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       stat $DIR2/$tfile > /dev/null || error "stat must succeed"
+       PID1=$! ; pdo_sched
+       stat $DIR2/$tfile > /dev/null &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
 run_test 46g "pdirops: link vs getattr =============="
 
 test_46h() {
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        link $DIR1/$tfile-2 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       ls -lia $DIR2/ > /dev/null
-       check_pdo_conflict $PID1 && { wait $PID1;
-                       error "readdir isn't blocked"; }
+       PID1=$! ; pdo_sched
+       ls -lia $DIR2/ > /dev/null &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
+       check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
+       wait $PID2
        rm -rf $DIR/$tfile*
        return 0
 }
@@ -2335,15 +2521,18 @@ run_test 46h "pdirops: link vs readdir =============="
 
 test_46i() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        link $DIR1/$tfile-2 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
+       PID1=$! ; pdo_sched
+       $LFS mkdir -i 1 $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1;
                                error "remote mkdir isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
@@ -2351,14 +2540,18 @@ run_test 46i "pdirops: link vs remote mkdir"
 
 # test 47: remote mkdir and blocking operations
 test_47a() {
+       cancel_lru_locks mdc
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       cancel_lru_locks mdc
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        $LFS mkdir -i 1 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       mkdir $DIR2/$tfile && error "mkdir must fail"
+       PID1=$! ; pdo_sched
+       mkdir $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
@@ -2367,13 +2560,17 @@ run_test 47a "pdirops: remote mkdir vs mkdir"
 test_47b() {
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       cancel_lru_locks mdc
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        $LFS mkdir -i 1 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
+       PID1=$! ; pdo_sched
+       sleep 1 # please do not remove this sleep, see LU-10754
+       multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1;
                                        error "create isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
@@ -2381,14 +2578,17 @@ run_test 47b "pdirops: remote mkdir vs create"
 
 test_47c() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        $LFS mkdir -i 1 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
+       PID1=$! ; pdo_sched
+       link $DIR2/$tfile-2 $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
@@ -2396,14 +2596,17 @@ run_test 47c "pdirops: remote mkdir vs link"
 
 test_47d() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       cancel_lru_locks mdc
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        $LFS mkdir -i 1 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       rmdir $DIR2/$tfile || error "unlink must succeed"
+       PID1=$! ; pdo_sched
+       rmdir $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1;
                                        error "unlink isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
@@ -2411,15 +2614,18 @@ run_test 47d "pdirops: remote mkdir vs unlink"
 
 test_47e() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       cancel_lru_locks mdc
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        $LFS mkdir -i 1 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
+       PID1=$! ; pdo_sched
+       mv -T $DIR2/$tfile-2 $DIR2/$tfile &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1;
                                        error "rename isn't blocked"; }
+       wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
        rm -rf $DIR/$tfile*
        return 0
 }
@@ -2427,14 +2633,17 @@ run_test 47e "pdirops: remote mkdir and rename (tgt)"
 
 test_47f() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       cancel_lru_locks mdc
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        $LFS mkdir -i 1 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
+       PID1=$! ; pdo_sched
+       mv $DIR2/$tfile $DIR2/$tfile-2 &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1;
                                        error "rename isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
@@ -2442,14 +2651,19 @@ run_test 47f "pdirops: remote mkdir and rename (src)"
 
 test_47g() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       sync
+       sync_all_data
+       cancel_lru_locks mdc
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        $LFS mkdir -i 1 $DIR1/$tfile &
-       PID1=$!
-       sleep 1
-       stat $DIR2/$tfile > /dev/null || error "stat must succeed"
+       PID1=$! ; pdo_sched
+       stat $DIR2/$tfile > /dev/null &
+       PID2=$! ; pdo_sched
+       do_facet $SINGLEMDS lctl set_param fail_loc=0
        check_pdo_conflict $PID1 && { wait $PID1;
                                        error "getattr isn't blocked"; }
+       wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
        rm -rf $DIR/$tfile*
        return 0
 }
@@ -2847,7 +3061,7 @@ test_71a() {
                { skip "checkfiemap not runnable: $?" && return; }
        # write data this way: hole - data - hole - data
        dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
-       [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
+       [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
                "zfs" ] &&
                skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
        dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
@@ -2895,7 +3109,7 @@ test_71b() {
 
        $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)))" = \
+       [ "$(facet_fstype ost$(($($LFS 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"
@@ -3088,31 +3302,47 @@ nrs_write_read() {
        chmod 777 $dir
 
        do_nodes $CLIENTS $myRUNAS \
-               dd if=/dev/zero of="$dir/nrs_r_$HOSTNAME" bs=1M count=$n ||
+               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 $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 $myRUNAS \
+               "declare -a pids_w;
+               for ((i = 0; i < $n; i++)); do
+                       dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
+seek=\\\$i count=1 conv=notrunc &
+                       pids_w[\\\$i]=\\\$!;
+               done;
+               rc_w=0;
+               for ((i = 0; i < $n; i++)); do
+                       wait \\\${pids_w[\\\$i]};
+                       newrc=\\\$?;
+                       [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
+               done;
+               exit \\\$rc_w" &
+       local pid_w=$!
        do_nodes $CLIENTS sync;
        cancel_lru_locks osc
 
-       for ((i = 0; i < $n; i++)); do
-               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
+       do_nodes $CLIENTS $myRUNAS \
+               "declare -a pids_r;
+               for ((i = 0; i < $n; i++)); do
+                       dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
+seek=\\\$i count=1 &
+                       pids_r[\\\$i]=\\\$!;
+               done;
+               rc_r=0;
+               for ((i = 0; i < $n; i++)); do
+                       wait \\\${pids_r[\\\$i]};
+                       newrc=\\\$?;
+                       [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
+               done;
+               exit \\\$rc_r" &
+       local pid_r=$!
        cancel_lru_locks osc
 
-       for ((i = 0; i < $n; i++)); do
-               wait ${pids_w[$i]}
-               wait ${pids_r[$i]}
-       done
-       rm -rf $dir || error "rm -rf $dir failed"
+       wait $pid_w || error "dd (write) failed (2)"
+       wait $pid_r || error "dd (read) failed (3)"
+       rm -rvf $dir || error "rm -rf $dir failed"
 }
 
 test_77a() { #LU-3266
@@ -3339,9 +3569,8 @@ test_77f() {
        [[ $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_conf_param_and_check client                 \
-                       "$LCTL get_param -n jobid_var"          \
-                       "$FSNAME.sys.jobid_var" procname_uid
+               set_persistent_param_and_check client \
+                       "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
        fi
 
        local idis
@@ -3378,9 +3607,8 @@ test_77f() {
        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_conf_param_and_check client                 \
-                       "$LCTL get_param -n jobid_var"          \
-                       "$FSNAME.sys.jobid_var" $saved_jobid_var
+               set_persistent_param_and_check client \
+                       "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
        fi
        return 0
 }
@@ -3766,9 +3994,8 @@ test_77n() { #LU-10802
        # Configure jobid_var
        local saved_jobid_var=$($LCTL get_param -n jobid_var)
        if [ $saved_jobid_var != procname_uid ]; then
-               set_conf_param_and_check client                 \
-                       "$LCTL get_param -n jobid_var"          \
-                       "$FSNAME.sys.jobid_var" procname_uid
+               set_persistent_param_and_check client \
+                       "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
        fi
 
        do_nodes $(comma_list $(osts_nodes)) \
@@ -3794,9 +4021,8 @@ test_77n() { #LU-10802
 
        local current_jobid_var=$($LCTL get_param -n jobid_var)
        if [ $saved_jobid_var != $current_jobid_var ]; then
-               set_conf_param_and_check client                 \
-                       "$LCTL get_param -n jobid_var"          \
-                       "$FSNAME.sys.jobid_var" $saved_jobid_var
+               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"
@@ -4240,10 +4466,10 @@ test_93() {
        #define OBD_FAIL_MDS_LOV_CREATE_RACE     0x163
        do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
 
-       $SETSTRIPE -c -1 $DIR1/$tfile-1/file1 &
+       $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
        local PID1=$!
        sleep 1
-       $SETSTRIPE -c -1 $DIR2/$tfile-2/file2 &
+       $LFS setstripe -c -1 $DIR2/$tfile-2/file2 &
        local PID2=$!
        wait $PID2
        wait $PID1
@@ -4251,11 +4477,11 @@ test_93() {
        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 |
+       $LFS getstripe $DIR1/$tfile-1/file1
+       rc1=$($LFS 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 |
+       $LFS getstripe $DIR2/$tfile-2/file2
+       rc2=$($LFS 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 ] ||
@@ -4278,14 +4504,13 @@ test_100a() {
 
        $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"
+       local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
+       [ $gls -eq 0 ] || 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"
+       local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
+       [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
        rm -f $dom
 }
 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
@@ -4306,10 +4531,9 @@ test_100b() {
        # 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}')
+       local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
        # both stats should cause no glimpse requests
-       [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
+       [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
        rm -f $dom
 }
 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
@@ -4330,7 +4554,7 @@ test_100c() {
        $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)
+       local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
        [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
 
        rm -f $dom
@@ -4355,7 +4579,7 @@ test_100d() {
        $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)
+       local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
        [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
 
        rm -f $dom
@@ -4370,19 +4594,19 @@ test_101a() {
        # to get layout
        $CHECKSTAT -t file $DIR1/$tfile
 
-       OLD_VAL=$(cat /proc/sys/vm/dirty_writeback_centisecs)
-       echo 0 > /proc/sys/vm/dirty_writeback_centisecs
-       echo $OLD_VAL
+       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_noexit "Unlink fails"
-       local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
-       echo $OLD_VAL > /proc/sys/vm/dirty_writeback_centisecs
+       rm $DIR2/$tfile || error "Unlink fails"
 
+       local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
        [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
 }
 run_test 101a "Discard DoM data on unlink"
@@ -4396,18 +4620,18 @@ test_101b() {
        # to get layout
        $CHECKSTAT -t file $DIR1/$tfile
 
-       OLD_VAL=$(cat /proc/sys/vm/dirty_writeback_centisecs)
-       echo 0 > /proc/sys/vm/dirty_writeback_centisecs
-       echo $OLD_VAL
+       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"
+       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_noexit "Rename fails"
-       local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
-       echo $OLD_VAL > /proc/sys/vm/dirty_writeback_centisecs
+       mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
+
+       local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
        [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
 }
 run_test 101b "Discard DoM data on rename"
@@ -4420,26 +4644,44 @@ test_101c() {
        # to get layout
        $CHECKSTAT -t file $DIR1/$tfile
 
-       OLD_VAL=$(cat /proc/sys/vm/dirty_writeback_centisecs)
-       echo 0 > /proc/sys/vm/dirty_writeback_centisecs
-       echo $OLD_VAL
+       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"
+       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_noexit "Unlink fails"
-       kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID ||
-               error_noexit "multiop failure"
-       local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
-       echo $OLD_VAL > /proc/sys/vm/dirty_writeback_centisecs
+       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 -c ost_write)
        [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
 }
 run_test 101c "Discard DoM data on close-unlink"
 
+# test to verify file handle related system calls
+# (name_to_handle_at/open_by_handle_at)
+# The new system calls are supported in glibc >= 2.14.
+
+# test to verify we can open by handle an unlinked file from > 1 client
+# This test opens the file normally on $DIR1, which is on one mount, and then
+# opens it by handle on $DIR2, which is on a different mount.
+test_102() {
+       [ $MDS1_VERSION -lt $(version_code 2.11.57) ] &&
+               skip "Needs MDS version 2.11.57 or later"
+
+       echo "Test file_handle syscalls" > $DIR/$tfile ||
+               error "write failed"
+       check_fhandle_syscalls $DIR/$tfile $DIR2 ||
+               error "check_fhandle_syscalls failed"
+       rm -f $DIR2/$tfile
+}
+run_test 102 "Test open by handle of unlinked file"
+
 log "cleanup: ======================================================"
 
 # kill and wait in each test only guarentee script finish, but command in script