Whamcloud - gitweb
LU-13194 tests: check server version sanityn 104
[fs/lustre-release.git] / lustre / tests / sanityn.sh
index a4006aa..8ee25b7 100755 (executable)
@@ -3,46 +3,35 @@
 set -e
 
 ONLY=${ONLY:-"$*"}
-# 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)
-PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
 
 SIZE=${SIZE:-40960}
-CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
 OPENFILE=${OPENFILE:-openfile}
 OPENUNLINK=${OPENUNLINK:-openunlink}
-export MULTIOP=${MULTIOP:-multiop}
 export TMP=${TMP:-/tmp}
 MOUNT_2=${MOUNT_2:-"yes"}
 CHECK_GRANT=${CHECK_GRANT:-"yes"}
 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
 
-SAVE_PWD=$PWD
-
-export NAME=${NAME:-local}
-
-LUSTRE=${LUSTRE:-`dirname $0`/..}
+LUSTRE=${LUSTRE:-$(dirname $0)/..}
 . $LUSTRE/tests/test-framework.sh
-CLEANUP=${CLEANUP:-:}
-SETUP=${SETUP:-:}
 init_test_env $@
-. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
-get_lustre_env
 init_logging
 
+ALWAYS_EXCEPT="$SANITYN_EXCEPT "
+# bug number for skipped test:  LU-7105
+ALWAYS_EXCEPT+="                28"
+# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
+
 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
-# bug number for skipped test:
-       ALWAYS_EXCEPT="$ALWAYS_EXCEPT "
-# LU-2829 / LU-2887 - make allowances for ZFS slowness
+       # LU-2829 / LU-2887 - make allowances for ZFS slowness
        TEST33_NFILES=${TEST33_NFILES:-1000}
 fi
+
 #                                  23   (min)"
 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
 
+build_test_filter
+
 FAIL_ON_ERROR=false
 
 SETUP=${SETUP:-:}
@@ -63,8 +52,6 @@ dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
 
 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
 
-build_test_filter
-
 test_1() {
        touch $DIR1/$tfile
        [ -f $DIR2/$tfile ] || error "Check create"
@@ -370,7 +357,7 @@ test_15() { # bug 974 - ENOSPC
        echo "PATH=$PATH"
        sh oos2.sh $MOUNT1 $MOUNT2
        wait_delete_completed
-       grant_error=`dmesg | grep "> available"`
+       grant_error=$(dmesg | grep "< tot_grant")
        [ -z "$grant_error" ] || error "$grant_error"
 }
 run_test 15 "test out-of-space with multiple writers ==========="
@@ -417,18 +404,21 @@ run_test 16a "$FSXNUM iterations of dual-mount fsx"
 test_16b() {
        local file1=$DIR1/$tfile
        local file2=$DIR2/$tfile
+       local stripe_size=($($LFS getstripe -S $DIR))
 
        # 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_BYTES count=$OSTCOUNT oflag=sync
-       dd if=/dev/zero of=$file2 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
+       dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
+               error "dd failed writing to file=$file1"
+       dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
+               error "dd failed writing to file=$file2"
        rm -f $file1
 
        lfs setstripe -c -1 $file1 # b=10919
        # -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
+       $file2 || error "fsx with tiny write failed."
 }
 run_test 16b "$FSXNUM iterations of dual-mount fsx at small size"
 
@@ -1463,9 +1453,20 @@ 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.2 # 103s
        # sleep 0.3 # 124s
-       # sleep 0.5 # 164s
+       sleep 0.5 # 164s
+}
+
+# for pdo testing, we must cancel MDT-MDT locks as well as client locks to
+# avoid unexpected delays due to previous tests
+pdo_lru_clear() {
+       cancel_lru_locks mdc
+       do_nodes $(comma_list $(mdts_nodes)) \
+               $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
+       do_nodes $(comma_list $(mdts_nodes)) \
+               $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
+                       ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
 }
 
 # check that pid exists hence second operation wasn't blocked by first one
@@ -1488,7 +1489,7 @@ check_pdo_conflict() {
 # test 40: check non-blocking operations
 test_40a() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       cancel_lru_locks mdc
+       pdo_lru_clear
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        touch $DIR2
@@ -1519,7 +1520,7 @@ run_test 40a "pdirops: create vs others =============="
 
 test_40b() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       cancel_lru_locks mdc
+       pdo_lru_clear
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        touch $DIR1/$tfile &
@@ -1550,7 +1551,7 @@ run_test 40b "pdirops: open|create and others =============="
 
 test_40c() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -1582,7 +1583,7 @@ run_test 40c "pdirops: link and others =============="
 
 test_40d() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -1613,7 +1614,7 @@ run_test 40d "pdirops: unlink and others =============="
 
 test_40e() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -1643,7 +1644,7 @@ run_test 40e "pdirops: rename and others =============="
 
 # test 41: create blocking operations
 test_41a() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
 #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 &
@@ -1659,7 +1660,7 @@ test_41a() {
 run_test 41a "pdirops: create vs mkdir =============="
 
 test_41b() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
 #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 &
@@ -1675,7 +1676,7 @@ test_41b() {
 run_test 41b "pdirops: create vs create =============="
 
 test_41c() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -1692,7 +1693,7 @@ test_41c() {
 run_test 41c "pdirops: create vs link =============="
 
 test_41d() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
 #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 &
@@ -1708,7 +1709,7 @@ test_41d() {
 run_test 41d "pdirops: create vs unlink =============="
 
 test_41e() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -1725,7 +1726,7 @@ test_41e() {
 run_test 41e "pdirops: create and rename (tgt) =============="
 
 test_41f() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
 #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 &
@@ -1741,7 +1742,7 @@ test_41f() {
 run_test 41f "pdirops: create and rename (src) =============="
 
 test_41g() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
 #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 &
@@ -1757,7 +1758,7 @@ test_41g() {
 run_test 41g "pdirops: create vs getattr =============="
 
 test_41h() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
 #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 &
@@ -1774,7 +1775,7 @@ run_test 41h "pdirops: create vs readdir =============="
 
 # test 42: unlink and blocking operations
 test_42a() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mkdir $DIR1/$tfile &
@@ -1790,7 +1791,7 @@ test_42a() {
 run_test 42a "pdirops: mkdir vs mkdir =============="
 
 test_42b() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mkdir $DIR1/$tfile &
@@ -1806,7 +1807,7 @@ test_42b() {
 run_test 42b "pdirops: mkdir vs create =============="
 
 test_42c() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -1823,7 +1824,7 @@ test_42c() {
 run_test 42c "pdirops: mkdir vs link =============="
 
 test_42d() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mkdir $DIR1/$tfile &
@@ -1839,7 +1840,7 @@ test_42d() {
 run_test 42d "pdirops: mkdir vs unlink =============="
 
 test_42e() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -1856,7 +1857,7 @@ test_42e() {
 run_test 42e "pdirops: mkdir and rename (tgt) =============="
 
 test_42f() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mkdir $DIR1/$tfile &
@@ -1872,7 +1873,7 @@ test_42f() {
 run_test 42f "pdirops: mkdir and rename (src) =============="
 
 test_42g() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mkdir $DIR1/$tfile &
@@ -1888,7 +1889,7 @@ test_42g() {
 run_test 42g "pdirops: mkdir vs getattr =============="
 
 test_42h() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        mkdir $DIR1/$tfile &
@@ -1905,7 +1906,7 @@ run_test 42h "pdirops: mkdir vs readdir =============="
 
 # test 43: unlink and blocking operations
 test_43a() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -1922,7 +1923,7 @@ test_43a() {
 run_test 43a "pdirops: unlink vs mkdir =============="
 
 test_43b() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -1939,7 +1940,7 @@ test_43b() {
 run_test 43b "pdirops: unlink vs create =============="
 
 test_43c() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
@@ -1957,7 +1958,7 @@ test_43c() {
 run_test 43c "pdirops: unlink vs link =============="
 
 test_43d() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -1974,7 +1975,7 @@ test_43d() {
 run_test 43d "pdirops: unlink vs unlink =============="
 
 test_43e() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
@@ -1992,7 +1993,7 @@ test_43e() {
 run_test 43e "pdirops: unlink and rename (tgt) =============="
 
 test_43f() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -2009,7 +2010,7 @@ test_43f() {
 run_test 43f "pdirops: unlink and rename (src) =============="
 
 test_43g() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -2026,7 +2027,7 @@ test_43g() {
 run_test 43g "pdirops: unlink vs getattr =============="
 
 test_43h() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -2044,7 +2045,7 @@ run_test 43h "pdirops: unlink vs readdir =============="
 
 test_43i() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -2063,7 +2064,7 @@ run_test 43i "pdirops: unlink vs remote mkdir"
 
 # test 44: rename tgt and blocking operations
 test_44a() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2   0x146
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
@@ -2081,7 +2082,7 @@ test_44a() {
 run_test 44a "pdirops: rename tgt vs mkdir =============="
 
 test_44b() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2    0x146
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
@@ -2098,7 +2099,7 @@ test_44b() {
 run_test 44b "pdirops: rename tgt vs create =============="
 
 test_44c() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
        touch $DIR1/$tfile-3
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2    0x146
@@ -2116,7 +2117,7 @@ test_44c() {
 run_test 44c "pdirops: rename tgt vs link =============="
 
 test_44d() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2    0x146
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
@@ -2133,7 +2134,7 @@ test_44d() {
 run_test 44d "pdirops: rename tgt vs unlink =============="
 
 test_44e() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
        touch $DIR1/$tfile-2
        touch $DIR1/$tfile-3
@@ -2152,7 +2153,7 @@ test_44e() {
 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
 
 test_44f() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
        touch $DIR1/$tfile-3
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2    0x146
@@ -2170,7 +2171,7 @@ test_44f() {
 run_test 44f "pdirops: rename tgt and rename (src) =============="
 
 test_44g() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2    0x146
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
@@ -2187,7 +2188,7 @@ test_44g() {
 run_test 44g "pdirops: rename tgt vs getattr =============="
 
 test_44h() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2    0x146
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
@@ -2206,7 +2207,7 @@ 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
+       pdo_lru_clear
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2   0x146
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
@@ -2225,7 +2226,7 @@ run_test 44i "pdirops: rename tgt vs remote mkdir"
 
 # test 45: rename src and blocking operations
 test_45a() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -2242,7 +2243,7 @@ test_45a() {
 run_test 45a "pdirops: rename src vs mkdir =============="
 
 test_45b() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -2259,7 +2260,7 @@ test_45b() {
 run_test 45b "pdirops: rename src vs create =============="
 
 test_45c() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
        touch $DIR1/$tfile-3
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
@@ -2277,7 +2278,7 @@ test_45c() {
 run_test 45c "pdirops: rename src vs link =============="
 
 test_45d() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -2294,7 +2295,7 @@ test_45d() {
 run_test 45d "pdirops: rename src vs unlink =============="
 
 test_45e() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
        touch $DIR1/$tfile-3
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
@@ -2312,7 +2313,7 @@ test_45e() {
 run_test 45e "pdirops: rename src and rename (tgt) =============="
 
 test_45f() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -2329,7 +2330,7 @@ test_45f() {
 run_test 45f "pdirops: rename src and rename (src) =============="
 
 test_45g() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -2346,7 +2347,7 @@ test_45g() {
 run_test 45g "pdirops: rename src vs getattr =============="
 
 test_45h() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -2363,7 +2364,7 @@ run_test 45h "pdirops: unlink vs readdir =============="
 
 test_45i() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -2382,7 +2383,7 @@ run_test 45i "pdirops: rename src vs remote mkdir"
 
 # test 46: link and blocking operations
 test_46a() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -2399,7 +2400,7 @@ test_46a() {
 run_test 46a "pdirops: link vs mkdir =============="
 
 test_46b() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -2416,7 +2417,7 @@ test_46b() {
 run_test 46b "pdirops: link vs create =============="
 
 test_46c() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -2433,7 +2434,7 @@ test_46c() {
 run_test 46c "pdirops: link vs link =============="
 
 test_46d() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -2450,7 +2451,7 @@ test_46d() {
 run_test 46d "pdirops: link vs unlink =============="
 
 test_46e() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
        touch $DIR1/$tfile-3
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
@@ -2468,7 +2469,7 @@ test_46e() {
 run_test 46e "pdirops: link and rename (tgt) =============="
 
 test_46f() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
        touch $DIR1/$tfile-3
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
@@ -2486,7 +2487,7 @@ test_46f() {
 run_test 46f "pdirops: link and rename (src) =============="
 
 test_46g() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -2503,7 +2504,7 @@ test_46g() {
 run_test 46g "pdirops: link vs getattr =============="
 
 test_46h() {
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -2521,7 +2522,7 @@ run_test 46h "pdirops: link vs readdir =============="
 
 test_46i() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -2540,10 +2541,9 @@ 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
+       pdo_lru_clear
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        $LFS mkdir -i 1 $DIR1/$tfile &
        PID1=$! ; pdo_sched
@@ -2560,7 +2560,7 @@ 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
+       pdo_lru_clear
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
        $LFS mkdir -i 1 $DIR1/$tfile &
        PID1=$! ; pdo_sched
@@ -2578,7 +2578,7 @@ run_test 47b "pdirops: remote mkdir vs create"
 
 test_47c() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -2596,7 +2596,7 @@ run_test 47c "pdirops: remote mkdir vs link"
 
 test_47d() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
-       cancel_lru_locks mdc
+       pdo_lru_clear
 #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 &
@@ -2614,7 +2614,7 @@ run_test 47d "pdirops: remote mkdir vs unlink"
 
 test_47e() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
-       cancel_lru_locks mdc
+       pdo_lru_clear
        touch $DIR1/$tfile-2
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
@@ -2633,7 +2633,7 @@ run_test 47e "pdirops: remote mkdir and rename (tgt)"
 
 test_47f() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
-       cancel_lru_locks mdc
+       pdo_lru_clear
 #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 &
@@ -2653,7 +2653,7 @@ test_47g() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
        sync
        sync_all_data
-       cancel_lru_locks mdc
+       pdo_lru_clear
 #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 &
@@ -4355,6 +4355,31 @@ test_83() {
 }
 run_test 83 "access striped directory while it is being created/unlinked"
 
+test_84() {
+       [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
+               skip "lustre < 2.12.55 does not contain LU-12485 fix"
+
+       local mtime
+
+       $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
+               error "create $tfile failed"
+       mtime=$(stat -c%Y $DIR/$tfile)
+       mtime=$((mtime + 200))
+
+       #define OBD_FAIL_OBD_0NLINK_RACE  0x60b
+       do_facet mds1 $LCTL set_param fail_loc=0x8000060b
+
+       touch -c -m $mtime $DIR/$tfile &
+       setattr_pid=$!
+       # sleep a while to let 'touch' run first
+       sleep 5
+       rm -f $DIR2/$tfile || error "unlink $tfile failed"
+
+       # touch may fail
+       wait $setattr_pid || true
+}
+run_test 84 "0-nlink race in lu_object_find()"
+
 test_90() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
        local pid1
@@ -4459,12 +4484,12 @@ test_93() {
 
        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
+       local old_rr=$(do_facet $SINGLEMDS "$LCTL get_param -n \
+               lod.$FSNAME-MDT0000-*/qos_threshold_rr" | sed -e 's/%//')
+       do_facet $SINGLEMDS "$LCTL set_param -n \
+               lod.$FSNAME-MDT0000-*/qos_threshold_rr=100"
        #define OBD_FAIL_MDS_LOV_CREATE_RACE     0x163
-       do_facet $SINGLEMDS "lctl set_param fail_loc=0x00000163"
+       do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x00000163"
 
        $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
        local PID1=$!
@@ -4473,9 +4498,9 @@ test_93() {
        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"
+       do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
+       do_facet $SINGLEMDS "$LCTL set_param -n \
+               lod.$FSNAME-MDT0000-*/qos_threshold_rr=$old_rr"
 
        $LFS getstripe $DIR1/$tfile-1/file1
        rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
@@ -4489,11 +4514,47 @@ test_93() {
 }
 run_test 93 "alloc_rr should not allocate on same ost"
 
+test_94() {
+       $LCTL set_param osc.*.idle_timeout=0
+       dd if=/dev/zero of=$DIR2/$tfile bs=4k count=2 conv=fsync
+
+       local before=$(date +%s)
+       local evict
+
+       $LCTL mark write
+#define OBD_FAIL_LDLM_PAUSE_CANCEL       0x312
+       $LCTL set_param fail_val=5 fail_loc=0x80000312
+       dd if=/dev/zero of=$DIR/$tfile conv=notrunc oflag=append bs=4k count=1 &
+       local pid=$!
+       sleep 2
+
+#define OBD_FAIL_LDLM_PAUSE_CANCEL_LOCAL 0x329
+       $LCTL set_param fail_val=6 fail_loc=0x80000329
+       $LCTL mark kill $pid
+       kill -ALRM $pid
+
+       dd if=/dev/zero of=$DIR2/$tfile conv=notrunc oflag=append bs=4k count=1
+
+       wait $pid
+       dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 conv=fsync
+
+       evict=$(do_facet client $LCTL get_param \
+               osc.$FSNAME-OST*-osc-*/state |
+           awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
+
+       [ -z "$evict" ] || [[ $evict -le $before ]] ||
+               (do_facet client $LCTL get_param \
+                       osc.$FSNAME-OST*-osc-*/state;
+                   error "eviction happened: $evict before:$before")
+       $LCTL set_param osc.*.idle_timeout=debug
+}
+run_test 94 "signal vs CP callback race"
+
 # 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
+               skip "Need MDS version at least 2.10.55"
 
        mkdir -p $DIR/$tdir
 
@@ -4517,7 +4578,7 @@ 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
+               skip "Need MDS version at least 2.10.55"
 
        mkdir -p $DIR/$tdir
 
@@ -4540,7 +4601,7 @@ 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
+               skip "Need MDS version at least 2.10.55"
 
        mkdir -p $DIR/$tdir
 
@@ -4563,7 +4624,7 @@ 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
+               skip "Need MDS version at least 2.10.55"
 
        mkdir -p $DIR/$tdir
 
@@ -4586,6 +4647,28 @@ test_100d() {
 }
 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
 
+test_100e() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.50) ] &&
+               skip "Need MDS version at least 2.11.50"
+
+       local dom=$DIR/$tdir/dom
+       local dom2=$DIR2/$tdir/dom
+       mkdir -p $DIR/$tdir
+
+       $LFS setstripe -E 1024K -L mdt $DIR/$tdir
+
+       cancel_lru_locks mdc
+       dd if=/dev/urandom of=$dom bs=12000 count=1
+       $TRUNCATE $dom2 6000
+       cancel_lru_locks mdc
+       lctl set_param -n mdc.*.stats=clear
+       # expect read-on-open to return all data before write
+       cat /etc/hosts >> $dom
+       local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
+       [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
+}
+run_test 100e "DoM: read on open and file size"
+
 test_101a() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
                skip "Need MDS version at least 2.10.55" && return
@@ -4682,6 +4765,154 @@ test_102() {
 }
 run_test 102 "Test open by handle of unlinked file"
 
+# Compare file size between first & second mount, ensuring the client correctly
+# glimpses even with unused speculative locks - LU-11670
+test_103() {
+       [ $(lustre_version_code $ost1) -lt $(version_code 2.10.50) ] &&
+               skip "Lockahead needs OST version at least 2.10.50"
+
+       local testnum=23
+
+       test_mkdir -p $DIR/$tdir
+
+       # Force file on to OST0
+       $LFS setstripe -i 0 $DIR/$tdir
+
+       # Do not check multiple locks on glimpse
+       # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
+       $LCTL set_param fail_loc=0x415
+
+       # Delay write commit by 2 seconds to guarantee glimpse wins race
+       # The same fail_loc is used on client & server so it can work in the
+       # single node sanity setup
+       do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
+
+       echo "Incorrect size expected (no glimpse fix):"
+       lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $testnum -f $tfile
+       rc=$?
+       if [ $rc -eq 0 ]; then
+               echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
+       fi
+
+       # guarantee write commit timeout has expired
+       sleep 2
+
+       # Clear fail_loc on client
+       $LCTL set_param fail_loc=0
+
+       # Delay write commit by 2 seconds to guarantee glimpse wins race
+       # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
+       do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
+
+       # Write commit is still delayed by 2 seconds
+       lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $testnum -f $tfile
+       rc=$?
+       [ $rc -eq 0 ] || error "Lockahead test${testnum} failed, ${rc}"
+
+       # guarantee write commit timeout has expired
+       sleep 2
+
+       rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
+}
+run_test 103 "Test size correctness with lockahead"
+
+get_stat_xtimes()
+{
+       local xtimes
+
+       xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
+
+       echo ${xtimes[*]}
+}
+
+get_mdt_xtimes()
+{
+       local mdtdev=$1
+       local output
+       local xtimes
+
+       output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
+       ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
+       ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
+       ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
+
+       echo ${xtimes[*]}
+}
+
+check_mdt_xtimes()
+{
+       local mdtdev=$1
+       local xtimes=($(get_stat_xtimes))
+       local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
+
+       echo "STAT a|m|ctime ${xtimes[*]}"
+       echo "MDT a|m|ctime ${xtimes[*]}"
+       [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
+               error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
+       [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
+               error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
+       [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
+               error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
+}
+
+test_104() {
+       [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
+       [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
+               skip "Need MDS version at least 2.12.4"
+
+       local pid
+       local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
+       local atime_diff=$(do_facet $SINGLEMDS \
+               lctl get_param -n mdd.*MDT0000*.atime_diff)
+
+       do_facet $SINGLEMDS \
+               lctl set_param -n mdd.*MDT0000*.atime_diff=0
+
+       stack_trap "do_facet $SINGLEMDS \
+               lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
+
+       dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
+       check_mdt_xtimes $mdtdev
+       sleep 2
+
+       dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
+       check_mdt_xtimes $mdtdev
+       sleep 2
+       $MULTIOP $DIR2/$tfile Oz8192w8192_c &
+       pid=$!
+       sleep 2
+       dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
+       sleep 2
+       kill -USR1 $pid && wait $pid || error "multiop failure"
+       check_mdt_xtimes $mdtdev
+
+       local xtimes
+       local mdt_xtimes
+
+       # Verify mtime/ctime is NOT upated on MDS when there is no modification
+       # on the client side
+       xtimes=($(get_stat_xtimes))
+       $MULTIOP $DIR/$tfile O_c &
+       pid=$!
+       sleep 2
+       kill -USR1 $pid && wait $pid || error "multiop failure"
+       mdt_xtimes=($(get_mdt_xtimes $mdtdev))
+       [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
+               error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
+       [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
+               error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
+       check_mdt_xtimes $mdtdev
+
+       sleep 2
+       # Change ctime via chmod
+       $MULTIOP $DIR/$tfile o_tc &
+       pid=$!
+       sleep 2
+       kill -USR1 $pid && wait $pid || error "multiop failure"
+       check_mdt_xtimes $mdtdev
+}
+run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
+
 log "cleanup: ======================================================"
 
 # kill and wait in each test only guarentee script finish, but command in script