Whamcloud - gitweb
LU-10650 obd: add check to obd_statfs
[fs/lustre-release.git] / lustre / tests / sanity.sh
index be29031..62f31a9 100755 (executable)
@@ -18,24 +18,6 @@ ALWAYS_EXCEPT="  407     253     312     $ALWAYS_EXCEPT"
 # Check Grants after these tests
 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c"
 
-is_sles11()                                            # LU-4341
-{
-       if [ -r /etc/SuSE-release ]
-       then
-               local vers=$(grep VERSION /etc/SuSE-release | awk '{print $3}')
-               local patchlev=$(grep PATCHLEVEL /etc/SuSE-release |
-                       awk '{ print $3 }')
-               if [ $vers -eq 11 ] && [ $patchlev -ge 3 ]; then
-                       return 0
-               fi
-       fi
-       return 1
-}
-
-if is_sles11; then                                     # LU-4341
-       ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
-fi
-
 SRCDIR=$(cd $(dirname $0); echo $PWD)
 export PATH=$PATH:/sbin
 
@@ -87,6 +69,30 @@ if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
        [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
 fi
 
+# Get the SLES version so we can make decisions on if a test should be run
+#
+# Returns a version string that should only be used in comparing
+# strings returned by version_code()
+
+sles_version_code()
+{
+       local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
+
+       # All SuSE Linux versions have one decimal. version_code expects two
+       local sles_version=$version.0
+       version_code $sles_version
+}
+
+if [ -r /etc/SuSE-release ]; then
+       sles_version=$(sles_version_code)
+       [ $sles_version -lt $(version_code 11.4.0) ] &&
+               # bug number for skipped test: LU-4341
+               ALWAYS_EXCEPT="$ALWAYS_EXCEPT  170"
+       [ $sles_version -lt $(version_code 12.0.0) ] &&
+               # bug number for skipped test: LU-3703
+               ALWAYS_EXCEPT="$ALWAYS_EXCEPT  234"
+fi
+
 FAIL_ON_ERROR=false
 
 cleanup() {
@@ -164,6 +170,45 @@ test_0c() {
 }
 run_test 0c "check import proc"
 
+test_0d() { # LU-3397
+       [ $(lustre_version_code mgs) -lt $(version_code 2.10.57) ] &&
+               skip "proc exports not supported before 2.10.57" && return
+
+       local mgs_exp="mgs.MGS.exports"
+       local client_uuid=$($LCTL get_param -n mgc.*.uuid)
+       local exp_client_nid
+       local exp_client_version
+       local exp_val
+       local imp_val
+       local temp_imp=$DIR/$tfile.import
+       local temp_exp=$DIR/$tfile.export
+
+       # save mgc import file to $temp_imp
+       $LCTL get_param mgc.*.import | tee $temp_imp
+       # Check if client uuid is found in MGS export
+       for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
+               [ $(do_facet mgs $LCTL get_param $exp_client_nid.uuid) == \
+                       $client_uuid ] &&
+                       break;
+       done
+       # save mgs export file to $temp_exp
+       do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
+
+       # Compare the value of field "connect_flags"
+       imp_val=$(grep "connect_flags" $temp_imp)
+       exp_val=$(grep "connect_flags" $temp_exp)
+       [ "$exp_val" == "$imp_val" ] ||
+               error "export flags '$exp_val' != import flags '$imp_val'"
+
+       # Compare the value of client version
+       exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
+       exp_val=$(version_code $exp_client_version)
+       imp_val=$(lustre_version_code client)
+       [ "$exp_val" == "$imp_val" ] ||
+               error "export client version '$exp_val' != '$imp_val'"
+}
+run_test 0d "check export proc ============================="
+
 test_1() {
        test_mkdir $DIR/$tdir
        test_mkdir $DIR/$tdir/d2
@@ -813,6 +858,38 @@ test_23b() { # bug 18988
 }
 run_test 23b "O_APPEND check"
 
+# LU-9409, size with O_APPEND and tiny writes
+test_23c() {
+       local file=$DIR/$tfile
+
+       # single dd
+       dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
+       $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
+       rm -f $file
+
+       # racing tiny writes
+       dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
+       dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
+       wait
+       $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
+       rm -f $file
+
+       #racing tiny & normal writes
+       dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
+       dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
+       wait
+       $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
+       rm -f $file
+
+       #racing tiny & normal writes 2, ugly numbers
+       dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
+       dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
+       wait
+       $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
+       rm -f $file
+}
+run_test 23c "O_APPEND size checks for tiny writes"
+
 # rename sanity
 test_24a() {
        echo '-- same directory rename'
@@ -857,8 +934,8 @@ test_24e() {
        test_mkdir $DIR/R5b
        touch $DIR/R5a/f
        mv $DIR/R5a/f $DIR/R5b/g
-       $CHECKSTAT -a $DIR/R5a/f || error
-       $CHECKSTAT -t file $DIR/R5b/g || error
+       $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
+       $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
 }
 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
 
@@ -867,8 +944,8 @@ test_24f() {
        test_mkdir $DIR/R6b
        touch $DIR/R6a/f $DIR/R6b/g
        mv $DIR/R6a/f $DIR/R6b/g
-       $CHECKSTAT -a $DIR/R6a/f || error
-       $CHECKSTAT -t file $DIR/R6b/g || error
+       $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
+       $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
 }
 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
 
@@ -877,8 +954,8 @@ test_24g() {
        test_mkdir $DIR/R7b
        test_mkdir $DIR/R7a/d
        mv $DIR/R7a/d $DIR/R7b/e
-       $CHECKSTAT -a $DIR/R7a/d || error
-       $CHECKSTAT -t dir $DIR/R7b/e || error
+       $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
+       $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
 }
 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
 
@@ -888,8 +965,8 @@ test_24h() {
        test_mkdir -c1 $DIR/R8a/d
        test_mkdir -c1 $DIR/R8b/e
        mrename $DIR/R8a/d $DIR/R8b/e
-       $CHECKSTAT -a $DIR/R8a/d || error
-       $CHECKSTAT -t dir $DIR/R8b/e || error
+       $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
+       $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
 }
 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
 
@@ -899,18 +976,18 @@ test_24i() {
        test_mkdir $DIR/R9/a
        touch $DIR/R9/f
        mrename $DIR/R9/f $DIR/R9/a
-       $CHECKSTAT -t file $DIR/R9/f || error
-       $CHECKSTAT -t dir  $DIR/R9/a || error
-       $CHECKSTAT -a $DIR/R9/a/f || error
+       $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
+       $CHECKSTAT -t dir  $DIR/R9/a || error "$DIR/R9/a not dir type"
+       $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
 }
 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
 
 test_24j() {
        test_mkdir $DIR/R10
        mrename $DIR/R10/f $DIR/R10/g
-       $CHECKSTAT -t dir $DIR/R10 || error
-       $CHECKSTAT -a $DIR/R10/f || error
-       $CHECKSTAT -a $DIR/R10/g || error
+       $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
+       $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
+       $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
 }
 run_test 24j "source does not exist ============================"
 
@@ -919,15 +996,15 @@ test_24k() {
        test_mkdir $DIR/R11a/d
        touch $DIR/R11a/f
        mv $DIR/R11a/f $DIR/R11a/d
-        $CHECKSTAT -a $DIR/R11a/f || error
-        $CHECKSTAT -t file $DIR/R11a/d/f || error
+       $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
+       $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
 }
 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
 
 # bug 2429 - rename foo foo foo creates invalid file
 test_24l() {
        f="$DIR/f24l"
-       $MULTIOP $f OcNs || error
+       $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
 }
 run_test 24l "Renaming a file to itself ========================"
 
@@ -945,10 +1022,10 @@ test_24n() {
     f="$DIR/f24n"
     # this stats the old file after it was renamed, so it should fail
     touch ${f}
-    $CHECKSTAT ${f}
+    $CHECKSTAT ${f} || error "${f} missing"
     mv ${f} ${f}.rename
-    $CHECKSTAT ${f}.rename
-    $CHECKSTAT -a ${f}
+    $CHECKSTAT ${f}.rename || error "${f}.rename missing"
+    $CHECKSTAT -a ${f} || error "${f} exists"
 }
 run_test 24n "Statting the old file after renaming (Posix rename 2)"
 
@@ -963,8 +1040,8 @@ test_24p() {
        test_mkdir $DIR/R12b
        DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
        mrename $DIR/R12a $DIR/R12b
-       $CHECKSTAT -a $DIR/R12a || error
-       $CHECKSTAT -t dir $DIR/R12b || error
+       $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
+       $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
        DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
        [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
 }
@@ -1023,7 +1100,7 @@ test_24t() {
 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
 
 test_24u() { # bug12192
-       $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
+       $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
        $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
 }
 run_test 24u "create stripe file"
@@ -1284,13 +1361,14 @@ test_25a() {
 
        test_mkdir $DIR/d25
        ln -s d25 $DIR/s25
-       touch $DIR/s25/foo || error
+       touch $DIR/s25/foo ||
+               error "File creation in symlinked directory failed"
 }
 run_test 25a "create file in symlinked directory ==============="
 
 test_25b() {
        [ ! -d $DIR/d25 ] && test_25a
-       $CHECKSTAT -t file $DIR/s25/foo || error
+       $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
 }
 run_test 25b "lookup file in symlinked directory ==============="
 
@@ -1298,14 +1376,14 @@ test_26a() {
        test_mkdir $DIR/d26
        test_mkdir $DIR/d26/d26-2
        ln -s d26/d26-2 $DIR/s26
-       touch $DIR/s26/foo || error
+       touch $DIR/s26/foo || error "File creation failed"
 }
 run_test 26a "multiple component symlink ======================="
 
 test_26b() {
        test_mkdir -p $DIR/$tdir/d26-2
        ln -s $tdir/d26-2/foo $DIR/s26-2
-       touch $DIR/s26-2 || error
+       touch $DIR/s26-2 || error "File creation failed"
 }
 run_test 26b "multiple component symlink at end of lookup ======"
 
@@ -1354,7 +1432,7 @@ test_27a() {
        $LFS getstripe $DIR/$tdir
        $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
        $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
-       cp /etc/hosts $DIR/$tdir/$tfile || error
+       cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
 }
 run_test 27a "one stripe file"
 
@@ -1546,8 +1624,8 @@ test_27n() {
        reset_enospc
        rm -f $DIR/$tdir/$tfile
        exhaust_precreations 0 0x80000215
-       $LFS setstripe -c -1 $DIR/$tdir
-       touch $DIR/$tdir/$tfile || error
+       $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
+       touch $DIR/$tdir/$tfile || error "touch failed"
        $LFS getstripe $DIR/$tdir/$tfile
        reset_enospc
 }
@@ -1627,7 +1705,7 @@ test_27r() {
        rm -f $DIR/$tdir/$tfile
        exhaust_precreations 0 0x80000215
 
-       $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile # && error
+       $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
 
        reset_enospc
 }
@@ -1971,9 +2049,9 @@ run_test 27z "check SEQ/OID on the MDT and OST filesystems"
 
 test_27A() { # b=19102
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        local restore_size=$($GETSTRIPE -S $MOUNT)
-        local restore_count=$($GETSTRIPE -c $MOUNT)
-        local restore_offset=$($GETSTRIPE -i $MOUNT)
+
+       save_layout_restore_at_exit $MOUNT
+
         $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
         wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/  *//g'" "1" 20 ||
                 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
@@ -1983,7 +2061,6 @@ test_27A() { # b=19102
         [ $default_size -eq $dsize ] ||
                 error "stripe size $default_size != $dsize"
         [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
-        $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
 }
 run_test 27A "check filesystem-wide default LOV EA values"
 
@@ -2069,10 +2146,10 @@ test_27D() {
 
        local skip27D
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ] &&
-               skip27D += "-s 29"
+               skip27D+="-s 29"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.55) -o \
          $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
-               skip27D += "-s 30,31"
+               skip27D+=" -s 30,31"
        llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
                error "llapi_layout_test failed"
 
@@ -2158,7 +2235,7 @@ run_test 27F "Client resend delayed layout creation with non-zero size"
 # then visible correctly (#2091)
 test_28() { # bug 2091
        test_mkdir $DIR/d28
-       $CREATETEST $DIR/d28/ct || error
+       $CREATETEST $DIR/d28/ct || error "createtest failed"
 }
 run_test 28 "create/mknod/mkdir with bad file types ============"
 
@@ -2214,7 +2291,7 @@ run_test 29 "IT_GETATTR regression  ============================"
 
 test_30a() { # was test_30
        cp $(which ls) $DIR || cp /bin/ls $DIR
-       $DIR/ls / || error
+       $DIR/ls / || error "Can't execute binary from lustre"
        rm $DIR/ls
 }
 run_test 30a "execute binary from Lustre (execve) =============="
@@ -2222,7 +2299,7 @@ run_test 30a "execute binary from Lustre (execve) =============="
 test_30b() {
        cp `which ls` $DIR || cp /bin/ls $DIR
        chmod go+rx $DIR/ls
-       $RUNAS $DIR/ls / || error
+       $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
        rm $DIR/ls
 }
 run_test 30b "execute binary from Lustre as non-root ==========="
@@ -2233,29 +2310,30 @@ test_30c() { # b=22376
        chmod a-rw $DIR/ls
        cancel_lru_locks mdc
        cancel_lru_locks osc
-       $RUNAS $DIR/ls / || error
+       $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
        rm -f $DIR/ls
 }
 run_test 30c "execute binary from Lustre without read perms ===="
 
 test_31a() {
-       $OPENUNLINK $DIR/f31 $DIR/f31 || error
-       $CHECKSTAT -a $DIR/f31 || error
+       $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
+       $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
 }
 run_test 31a "open-unlink file =================================="
 
 test_31b() {
-       touch $DIR/f31 || error
-       ln $DIR/f31 $DIR/f31b || error
-       $MULTIOP $DIR/f31b Ouc || error
-       $CHECKSTAT -t file $DIR/f31 || error
+       touch $DIR/f31 || error "touch $DIR/f31 failed"
+       ln $DIR/f31 $DIR/f31b || error "ln failed"
+       $MULTIOP $DIR/f31b Ouc || error "multiop failed"
+       $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
 }
 run_test 31b "unlink file with multiple links while open ======="
 
 test_31c() {
-       touch $DIR/f31 || error
-       ln $DIR/f31 $DIR/f31c || error
-       multiop_bg_pause $DIR/f31 O_uc || return 1
+       touch $DIR/f31 || error "touch $DIR/f31 failed"
+       ln $DIR/f31 $DIR/f31c || error "ln failed"
+       multiop_bg_pause $DIR/f31 O_uc ||
+               error "multiop_bg_pause for $DIR/f31 failed"
        MULTIPID=$!
        $MULTIOP $DIR/f31c Ouc
        kill -USR1 $MULTIPID
@@ -2264,13 +2342,13 @@ test_31c() {
 run_test 31c "open-unlink file with multiple links ============="
 
 test_31d() {
-       opendirunlink $DIR/d31d $DIR/d31d || error
-       $CHECKSTAT -a $DIR/d31d || error
+       opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
+       $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
 }
 run_test 31d "remove of open directory ========================="
 
 test_31e() { # bug 2904
-       openfilleddirunlink $DIR/d31e || error
+       openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
 }
 run_test 31e "remove of open non-empty directory ==============="
 
@@ -2431,7 +2509,7 @@ test_31p() {
 
        test_mkdir $DIR/$tdir
        $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
-       $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
+       $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
 
        opendirunlink $DIR/$tdir/striped_dir/test1 ||
                error "open unlink test1 failed"
@@ -2461,8 +2539,10 @@ test_32a() {
        [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
        trap cleanup_test32_mount EXIT
        test_mkdir -p $DIR/$tdir/ext2-mountpoint
-       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
-       $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
+       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
+               error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
+       $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
+               error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
        cleanup_test32_mount
 }
 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
@@ -2472,8 +2552,10 @@ test_32b() {
        [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
        trap cleanup_test32_mount EXIT
        test_mkdir -p $DIR/$tdir/ext2-mountpoint
-       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
-       ls -al $DIR/$tdir/ext2-mountpoint/.. || error
+       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
+               error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
+       ls -al $DIR/$tdir/ext2-mountpoint/.. ||
+               error "Can't list $DIR/$tdir/ext2-mountpoint/.."
        cleanup_test32_mount
 }
 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
@@ -2483,9 +2565,11 @@ test_32c() {
        [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
        trap cleanup_test32_mount EXIT
        test_mkdir -p $DIR/$tdir/ext2-mountpoint
-       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
+       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
+               error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
        test_mkdir -p $DIR/$tdir/d2/test_dir
-       $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
+       $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
+               error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
        cleanup_test32_mount
 }
 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
@@ -2495,9 +2579,11 @@ test_32d() {
        [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
        trap cleanup_test32_mount EXIT
        test_mkdir -p $DIR/$tdir/ext2-mountpoint
-       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
+       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
+               error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
        test_mkdir -p $DIR/$tdir/d2/test_dir
-       ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
+       ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
+               error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
        cleanup_test32_mount
 }
 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
@@ -2554,9 +2640,11 @@ test_32i() {
        [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
        trap cleanup_test32_mount EXIT
        test_mkdir -p $DIR/$tdir/ext2-mountpoint
-       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
+       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
+               error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
        touch $DIR/$tdir/test_file
-       $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
+       $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
+               error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
        cleanup_test32_mount
 }
 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
@@ -2566,9 +2654,11 @@ test_32j() {
        [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
        trap cleanup_test32_mount EXIT
        test_mkdir -p $DIR/$tdir/ext2-mountpoint
-       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
+       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
+               error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
        touch $DIR/$tdir/test_file
-       cat $DIR/$tdir/ext2-mountpoint/../test_file || error
+       cat $DIR/$tdir/ext2-mountpoint/../test_file ||
+               error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
        cleanup_test32_mount
 }
 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
@@ -2578,10 +2668,12 @@ test_32k() {
        rm -fr $DIR/$tdir
        trap cleanup_test32_mount EXIT
        test_mkdir -p $DIR/$tdir/ext2-mountpoint
-       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
+       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
+               error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
        test_mkdir -p $DIR/$tdir/d2
-       touch $DIR/$tdir/d2/test_file || error
-       $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
+       touch $DIR/$tdir/d2/test_file || error "touch failed"
+       $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
+               error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
        cleanup_test32_mount
 }
 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
@@ -2591,10 +2683,12 @@ test_32l() {
        rm -fr $DIR/$tdir
        trap cleanup_test32_mount EXIT
        test_mkdir -p $DIR/$tdir/ext2-mountpoint
-       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
+       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
+               error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
        test_mkdir -p $DIR/$tdir/d2
-       touch $DIR/$tdir/d2/test_file
-       cat  $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
+       touch $DIR/$tdir/d2/test_file || error "touch failed"
+       cat  $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
+               error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
        cleanup_test32_mount
 }
 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
@@ -2605,8 +2699,10 @@ test_32m() {
        TMP_DIR=$DIR/d32m/tmp
        ln -s $DIR $TMP_DIR/symlink11
        ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
-       $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
-       $CHECKSTAT -t link $DIR/d32m/symlink01 || error
+       $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
+               error "symlink11 not a link"
+       $CHECKSTAT -t link $DIR/d32m/symlink01 ||
+               error "symlink01 not a link"
 }
 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
 
@@ -2616,8 +2712,8 @@ test_32n() {
        TMP_DIR=$DIR/d32n/tmp
        ln -s $DIR $TMP_DIR/symlink11
        ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
-       ls -l $DIR/d32n/tmp/symlink11  || error
-       ls -l $DIR/d32n/symlink01 || error
+       ls -l $DIR/d32n/tmp/symlink11  || error "listing symlink11"
+       ls -l $DIR/d32n/symlink01 || error "listing symlink01"
 }
 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
 
@@ -2627,10 +2723,13 @@ test_32o() {
        TMP_DIR=$DIR/d32o/tmp
        ln -s $DIR/$tfile $TMP_DIR/symlink12
        ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
-       $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
-       $CHECKSTAT -t link $DIR/d32o/symlink02 || error
-       $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
-       $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
+       $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
+               error "symlink12 not a link"
+       $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
+       $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
+               error "$DIR/d32o/tmp/symlink12 not file type"
+       $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
+               error "$DIR/d32o/symlink02 not file type"
 }
 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
 
@@ -2650,9 +2749,10 @@ test_32p() {
        log 32p_7
        ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
        log 32p_8
-       cat $DIR/d32p/tmp/symlink12 || error
+       cat $DIR/d32p/tmp/symlink12 ||
+               error "Can't open $DIR/d32p/tmp/symlink12"
        log 32p_9
-       cat $DIR/d32p/symlink02 || error
+       cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
        log 32p_10
 }
 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
@@ -2662,8 +2762,9 @@ test_32q() {
        [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
        trap cleanup_test32_mount EXIT
        test_mkdir -p $DIR/$tdir/ext2-mountpoint
-       touch $DIR/$tdir/ext2-mountpoint/under_the_mount
-       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
+       touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
+       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
+               error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
        ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
        cleanup_test32_mount
 }
@@ -2674,8 +2775,9 @@ test_32r() {
        [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
        trap cleanup_test32_mount EXIT
        test_mkdir -p $DIR/$tdir/ext2-mountpoint
-       touch $DIR/$tdir/ext2-mountpoint/under_the_mount
-       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
+       touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
+       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
+               error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
        ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
        cleanup_test32_mount
 }
@@ -2890,47 +2992,59 @@ run_test 33g "nonroot user create already existing root created file"
 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
 test_34a() {
        rm -f $DIR/f34
-       $MCREATE $DIR/f34 || error
-       $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
-       $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
-       $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
+       $MCREATE $DIR/f34 || error "mcreate failed"
+       $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
+               error "getstripe failed"
+       $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
+       $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
+               error "getstripe failed"
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
+               error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
 }
 run_test 34a "truncate file that has not been opened ==========="
 
 test_34b() {
        [ ! -f $DIR/f34 ] && test_34a
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
+               error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
        $OPENFILE -f O_RDONLY $DIR/f34
-       $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
+       $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
+               error "getstripe failed"
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
+               error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
 }
 run_test 34b "O_RDONLY opening file doesn't create objects ====="
 
 test_34c() {
        [ ! -f $DIR/f34 ] && test_34a
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
+               error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
        $OPENFILE -f O_RDWR $DIR/f34
        $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
+               error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
 }
 run_test 34c "O_RDWR opening file-with-size works =============="
 
 test_34d() {
        [ ! -f $DIR/f34 ] && test_34a
-       dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
+       dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
+               error "dd failed"
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
+               error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
        rm $DIR/f34
 }
 run_test 34d "write to sparse file ============================="
 
 test_34e() {
        rm -f $DIR/f34e
-       $MCREATE $DIR/f34e || error
-       $TRUNCATE $DIR/f34e 1000 || error
-       $CHECKSTAT -s 1000 $DIR/f34e || error
+       $MCREATE $DIR/f34e || error "mcreate failed"
+       $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
+       $CHECKSTAT -s 1000 $DIR/f34e ||
+               error "Size of $DIR/f34e not equal to 1000 bytes"
        $OPENFILE -f O_RDWR $DIR/f34e
-       $CHECKSTAT -s 1000 $DIR/f34e || error
+       $CHECKSTAT -s 1000 $DIR/f34e ||
+               error "Size of $DIR/f34e not equal to 1000 bytes"
 }
 run_test 34e "create objects, some with size and some without =="
 
@@ -2938,7 +3052,7 @@ test_34f() { # bug 6242, 6243
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
        SIZE34F=48000
        rm -f $DIR/f34f
-       $MCREATE $DIR/f34f || error
+       $MCREATE $DIR/f34f || error "mcreate failed"
        $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
        dd if=$DIR/f34f of=$TMP/f34f
        $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
@@ -2951,18 +3065,20 @@ run_test 34f "read from a file with no objects until EOF ======="
 
 test_34g() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
-       $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
-       $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
+       dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
+               error "dd failed"
+       $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
+       $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
+               error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
        cancel_lru_locks osc
-       $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
+       $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
                error "wrong size after lock cancel"
 
-       $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
+       $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
                error "expanding truncate failed"
        cancel_lru_locks osc
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
                error "wrong expanded size after lock cancel"
 }
 run_test 34g "truncate long file ==============================="
@@ -2972,7 +3088,7 @@ test_34h() {
        local gid=10
        local sz=1000
 
-       dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
+       dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
        sync # Flush the cache so that multiop below does not block on cache
             # flush when getting the group lock
        $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
@@ -3006,13 +3122,13 @@ run_test 35a "exec file with mode 444 (should return and not leak)"
 
 test_36a() {
        rm -f $DIR/f36
-       utime $DIR/f36 || error
+       utime $DIR/f36 || error "utime failed for MDS"
 }
 run_test 36a "MDS utime check (mknod, utime)"
 
 test_36b() {
        echo "" > $DIR/f36
-       utime $DIR/f36 || error
+       utime $DIR/f36 || error "utime failed for OST"
 }
 run_test 36b "OST utime check (open, utime)"
 
@@ -3020,14 +3136,14 @@ test_36c() {
        rm -f $DIR/d36/f36
        test_mkdir $DIR/d36
        chown $RUNAS_ID $DIR/d36
-       $RUNAS utime $DIR/d36/f36 || error
+       $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
 }
 run_test 36c "non-root MDS utime check (mknod, utime)"
 
 test_36d() {
        [ ! -d $DIR/d36 ] && test_36c
        echo "" > $DIR/d36/f36
-       $RUNAS utime $DIR/d36/f36 || error
+       $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
 }
 run_test 36d "non-root OST utime check (open, utime)"
 
@@ -5200,9 +5316,7 @@ test_56wb() {
        echo "done."
 
        echo -n "Detecting existing pools..."
-       while IFS='' read thispool; do
-               pool_list+=("$thispool")
-       done < <($LFS pool_list $MOUNT | awk -F '.' 'NR>=2 { print $2 }')
+       pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
 
        if [ ${#pool_list[@]} -gt 0 ]; then
                echo "${pool_list[@]}"
@@ -5688,6 +5802,80 @@ test_56ba() {
 }
 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
 
+test_56ca() {
+       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.57) ]] ||
+               { skip "Need MDS version at least 2.10.57"; return 0; }
+
+       local td=$DIR/$tdir
+       local tf=$td/$tfile
+       local dir
+       local nfiles
+       local cmd
+       local i
+       local j
+
+       # create mirrored directories and mirrored files
+       mkdir $td || error "mkdir $td failed"
+       $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
+       createmany -o $tf- 10 || error "create $tf- failed"
+
+       for i in $(seq 2); do
+               dir=$td/dir$i
+               mkdir $dir || error "mkdir $dir failed"
+               $LFS mirror create -N$((3 + i)) $dir ||
+                       error "create mirrored dir $dir failed"
+               createmany -o $dir/$tfile- 10 ||
+                       error "create $dir/$tfile- failed"
+       done
+
+       # change the states of some mirrored files
+       echo foo > $tf-6
+       for i in $(seq 2); do
+               dir=$td/dir$i
+               for j in $(seq 4 9); do
+                       echo foo > $dir/$tfile-$j
+               done
+       done
+
+       # find mirrored files with specific mirror count
+       cmd="$LFS find --mirror-count 3 --type f $td"
+       nfiles=$($cmd | wc -l)
+       [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
+
+       cmd="$LFS find ! --mirror-count 3 --type f $td"
+       nfiles=$($cmd | wc -l)
+       [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
+
+       cmd="$LFS find --mirror-count +2 --type f $td"
+       nfiles=$($cmd | wc -l)
+       [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
+
+       cmd="$LFS find --mirror-count -6 --type f $td"
+       nfiles=$($cmd | wc -l)
+       [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
+
+       # find mirrored files with specific file state
+       cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
+       [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
+
+       cmd="$LFS find --mirror-state=ro --type f $td"
+       nfiles=$($cmd | wc -l)
+       [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
+
+       cmd="$LFS find ! --mirror-state=ro --type f $td"
+       nfiles=$($cmd | wc -l)
+       [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
+
+       cmd="$LFS find --mirror-state=wp --type f $td"
+       nfiles=$($cmd | wc -l)
+       [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
+
+       cmd="$LFS find ! --mirror-state=sp --type f $td"
+       nfiles=$($cmd | wc -l)
+       [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
+}
+run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
+
 test_57a() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
        # note test will not do anything if MDS is not local
@@ -6226,40 +6414,38 @@ test_65h() {
 }
 run_test 65h "directory stripe info inherit ===================="
 
-test_65i() { # bug6367
+test_65i() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        $SETSTRIPE -S 65536 -c -1 $MOUNT
-}
-run_test 65i "set non-default striping on root directory (bug 6367)="
 
-test_65ia() { # bug12836
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
-}
-run_test 65ia "getstripe on -1 default directory striping"
+       save_layout_restore_at_exit $MOUNT
 
-test_65ib() { # bug12836
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
-}
-run_test 65ib "getstripe -v on -1 default directory striping"
+       # bug6367: set non-default striping on root directory
+       $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
 
-test_65ic() { # bug12836
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       # bug12836: getstripe on -1 default directory striping
+       $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
+
+       # bug12836: getstripe -v on -1 default directory striping
+       $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
+
+       # bug12836: new find on -1 default directory striping
        $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
 }
-run_test 65ic "new find on -1 default directory striping"
+run_test 65i "various tests to set root directory striping"
 
 test_65j() { # bug6367
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $($LFS getstripe --component-count $MOUNT) -gt 1 ] &&
-               skip "don't delete default PFL layout" && return
+
        sync; sleep 1
+
        # if we aren't already remounting for each test, do so for this test
        if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
                cleanup || error "failed to unmount"
                setup
        fi
+
+       save_layout_restore_at_exit $MOUNT
+
        $SETSTRIPE -d $MOUNT || error "setstripe failed"
 }
 run_test 65j "set default striping on root directory (bug 6367)="
@@ -6334,7 +6520,11 @@ test_65l() { # bug 12836
 run_test 65l "lfs find on -1 stripe dir ========================"
 
 test_65m() {
-       $RUNAS $SETSTRIPE -c 2 $MOUNT && error "setstripe should fail"
+       local layout=$(save_layout $MOUNT)
+       $RUNAS $SETSTRIPE -c 2 $MOUNT && {
+               restore_layout $MOUNT $layout
+               error "setstripe should fail by non-root users"
+       }
        true
 }
 run_test 65m "normal user can't set filesystem default stripe"
@@ -10033,6 +10223,27 @@ test_130e() {
 }
 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
 
+test_130f() {
+       filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
+       [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
+               return
+
+       local fm_file=$DIR/$tfile
+       $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
+               error "multiop create with lov_delay_create on $fm_file"
+
+       filefrag -ves $fm_file || error "filefrag $fm_file failed"
+       filefrag_extents=$(filefrag -vek $fm_file |
+                          awk '/extents? found/ { print $2 }')
+       if [[ "$filefrag_extents" != "0" ]]; then
+               error "FIEMAP on $fm_file failed; " \
+                     "returned $filefrag_extents expected 0"
+       fi
+
+       rm -f $fm_file
+}
+run_test 130f "FIEMAP (unstriped file)"
+
 # Test for writev/readv
 test_131a() {
        rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
@@ -10974,6 +11185,8 @@ test_154a() {
        dot_lustre_fid_permission_check "$fid" $DIR ||
                error "dot lustre permission check $fid failed"
 
+       ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
+
        rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
 
        touch $MOUNT/.lustre/file &&
@@ -12236,7 +12449,7 @@ test_162b() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
 
        mkdir $DIR/$tdir
-       $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
+       $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
                                error "create striped dir failed"
 
        local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
@@ -12311,16 +12524,17 @@ run_test 169 "parallel read and truncate should not deadlock"
 
 test_170() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        $LCTL clear    # bug 18514
-        $LCTL debug_daemon start $TMP/${tfile}_log_good
-        touch $DIR/$tfile
-        $LCTL debug_daemon stop
-        sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
-               error "sed failed to read log_good"
 
-        $LCTL debug_daemon start $TMP/${tfile}_log_good
-        rm -rf $DIR/$tfile
-        $LCTL debug_daemon stop
+       $LCTL clear     # bug 18514
+       $LCTL debug_daemon start $TMP/${tfile}_log_good
+       touch $DIR/$tfile
+       $LCTL debug_daemon stop
+       sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
+               error "sed failed to read log_good"
+
+       $LCTL debug_daemon start $TMP/${tfile}_log_good
+       rm -rf $DIR/$tfile
+       $LCTL debug_daemon stop
 
         $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
                error "lctl df log_bad failed"
@@ -14614,17 +14828,8 @@ test_234() {
        touch $DIR/$tdir/$tfile || error "touch failed"
        # OBD_FAIL_LLITE_XATTR_ENOMEM
        $LCTL set_param fail_loc=0x1405
-       # output of the form: attr 2 4 44 3 fc13 x86_64
-       V=($(IFS=".-" rpm -q attr))
-       if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
-             ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
-               # attr pre-2.4.44-7 had a bug with rc
-               # LU-3703 - SLES 11 and FC13 clients have older attr
-               getfattr -n user.attr $DIR/$tdir/$tfile &&
-                       error "getfattr should have failed with ENOMEM"
-       else
-               skip "LU-3703: attr version $(getfattr --version) too old"
-       fi
+       getfattr -n user.attr $DIR/$tdir/$tfile &&
+               error "getfattr should have failed with ENOMEM"
        $LCTL set_param fail_loc=0x0
        rm -rf $DIR/$tdir
 
@@ -15493,6 +15698,8 @@ facet_meminfo() {
 }
 
 test_255b() {
+       [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
+               skip "lustre < 2.8.54 does not support ladvise " && return
        remote_ost_nodsh && skip "remote OST with nodsh" && return
 
        lfs setstripe -c 1 -i 0 $DIR/$tfile
@@ -15568,7 +15775,7 @@ test_255c() {
 
        #test 10 returns only success/failure
        i=10
-       lockahead_test -d $DIR/$tdir -t $i
+       lockahead_test -d $DIR/$tdir -t $i -f $tfile
        rc=$?
        if [ $rc -eq 255 ]; then
                error "Ladvise test${i} failed, ${rc}"
@@ -15580,7 +15787,7 @@ test_255c() {
                $LCTL get_param -n ost.OSS.ost.stats)
        count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
 
-       lockahead_test -d $DIR/$tdir -t $i
+       lockahead_test -d $DIR/$tdir -t $i -f $tfile
        rc=$?
        if [ $rc -eq 255 ]; then
                error "Ladvise test${i} failed, ${rc}"
@@ -15606,7 +15813,7 @@ test_255c() {
                count=$($LCTL get_param -n \
                       ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
 
-               lockahead_test -d $DIR/$tdir -t $i
+               lockahead_test -d $DIR/$tdir -t $i -f $tfile
                rc=$?
                if [ $rc -eq 255 ]; then
                        error "Ladvise test ${i} failed, ${rc}"
@@ -15629,12 +15836,11 @@ test_255c() {
 
        #test 22 returns only success/failure
        i=22
-       lockahead_test -d $DIR/$tdir -t $i
+       lockahead_test -d $DIR/$tdir -t $i -f $tfile
        rc=$?
        if [ $rc -eq 255 ]; then
                error "Ladvise test${i} failed, ${rc}"
        fi
-
 }
 run_test 255c "suite of ladvise lockahead tests"
 
@@ -16167,6 +16373,25 @@ test_271c() {
 }
 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
 
+test_276() {
+       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       local pid
+
+       do_facet ost1 "(while true; do \
+               $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
+               done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
+       pid=$!
+
+       for LOOP in $(seq 20); do
+               stop ost1
+               start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
+       done
+       kill -9 $pid
+       do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
+               rm $TMP/sanity_276_pid"
+}
+run_test 276 "Race between mount and obd_statfs"
+
 cleanup_test_300() {
        trap 0
        umask $SAVE_UMASK
@@ -16181,7 +16406,7 @@ test_striped_dir() {
        SAVE_UMASK=$(umask)
        trap cleanup_test_300 RETURN EXIT
 
-       $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
+       $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
                                                $DIR/$tdir/striped_dir ||
                error "set striped dir error"
 
@@ -16260,23 +16485,19 @@ test_300b() {
        local mtime2
        local mtime3
 
-       test_mkdir $DIR/$tdir
-       $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
+       test_mkdir $DIR/$tdir || error "mkdir fail"
+       $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
                error "set striped dir error"
-       for ((i=0; i<10; i++)); do
+       for i in {0..9}; do
                mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
                sleep 1
-               touch $DIR/$tdir/striped_dir/file_$i ||
-                                       error "touch error $i"
+               touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
                mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
-               [ $mtime1 -eq $mtime2 ] &&
-                       error "mtime not change after create"
+               [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
                sleep 1
-               rm -f $DIR/$tdir/striped_dir/file_$i ||
-                                       error "unlink error $i"
+               rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
                mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
-               [ $mtime2 -eq $mtime3 ] &&
-                       error "mtime did not change after unlink"
+               [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
        done
        true
 }
@@ -16319,7 +16540,7 @@ test_300d() {
        $SETSTRIPE -c 2 $DIR/$tdir
 
        #local striped directory
-       $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
+       $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
                error "set striped dir error"
        createmany -o $DIR/$tdir/striped_dir/f 10 ||
                error "create 10 files failed"
@@ -16350,7 +16571,7 @@ test_300e() {
 
        mkdir -p $DIR/$tdir
 
-       $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
+       $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
                error "set striped dir error"
 
        touch $DIR/$tdir/striped_dir/a
@@ -16361,13 +16582,13 @@ test_300e() {
        mkdir $DIR/$tdir/striped_dir/dir_b
        mkdir $DIR/$tdir/striped_dir/dir_c
 
-       $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
+       $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
                error "set striped adir under striped dir error"
 
        $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
                error "set striped bdir under striped dir error"
 
-       $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
+       $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
                error "set striped cdir under striped dir error"
 
        mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
@@ -16397,10 +16618,10 @@ test_300f() {
        rm -rf $DIR/$tdir
        mkdir -p $DIR/$tdir
 
-       $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
+       $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
                error "set striped dir error"
 
-       $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
+       $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
                error "set striped dir error"
 
        touch $DIR/$tdir/striped_dir/a
@@ -16534,8 +16755,7 @@ test_300h() {
        local stripe_count
 
        mkdir $DIR/$tdir
-       $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
-                                       $DIR/$tdir/striped_dir ||
+       $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
                error "set striped dir error"
 
        test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
@@ -16566,7 +16786,7 @@ test_300i() {
 
        mkdir $DIR/$tdir
 
-       $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
+       $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
                error "set striped dir error"
 
        createmany -o $DIR/$tdir/striped_dir/f- 10 ||
@@ -16622,7 +16842,7 @@ test_300j() {
 
        #define OBD_FAIL_SPLIT_UPDATE_REC       0x1702
        $LCTL set_param fail_loc=0x1702
-       $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
+       $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
                error "set striped dir error"
 
        createmany -o $DIR/$tdir/striped_dir/f- 10 ||
@@ -16850,7 +17070,8 @@ prepare_remote_file() {
        mkdir $DIR/$tdir/src_dir ||
                error "create remote source failed"
 
-       cp /etc/hosts $DIR/$tdir/src_dir/a || error
+       cp /etc/hosts $DIR/$tdir/src_dir/a ||
+                error "cp to remote source failed"
        touch $DIR/$tdir/src_dir/a
 
        $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
@@ -16881,8 +17102,9 @@ test_310a() {
        prepare_remote_file || error "prepare remote file failed"
 
        #open-unlink file
-       $OPENUNLINK $remote_file $remote_file || error
-       $CHECKSTAT -a $remote_file || error
+       $OPENUNLINK $remote_file $remote_file ||
+               error "openunlink $remote_file failed"
+       $CHECKSTAT -a $remote_file || error "$remote_file exists"
 }
 run_test 310a "open unlink remote file"
 
@@ -17445,10 +17667,7 @@ test_406() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] &&
                skip "Need MDS version at least 2.8.50" && return
 
-       local def_stripe_count=$($GETSTRIPE -c $MOUNT)
-       local def_stripe_size=$($GETSTRIPE -S $MOUNT)
-       local def_stripe_offset=$($GETSTRIPE -i $MOUNT)
-       local def_pool=$($GETSTRIPE -p $MOUNT)
+       local def_stripe_size=$($LFS getstripe -S $MOUNT)
        local test_pool=$TESTNAME
 
        if ! combined_mgs_mds ; then
@@ -17458,60 +17677,51 @@ test_406() {
        pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
                error "pool_add_targets failed"
 
+       save_layout_restore_at_exit $MOUNT
+
        # parent set default stripe count only, child will stripe from both
        # parent and fs default
-       $SETSTRIPE -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
+       $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
                error "setstripe $MOUNT failed"
        $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
-       $SETSTRIPE -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
+       $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
        for i in $(seq 10); do
                local f=$DIR/$tdir/$tfile.$i
                touch $f || error "touch failed"
-               local count=$($GETSTRIPE -c $f)
+               local count=$($LFS getstripe -c $f)
                [ $count -eq $OSTCOUNT ] ||
                        error "$f stripe count $count != $OSTCOUNT"
-               local offset=$($GETSTRIPE -i $f)
+               local offset=$($LFS getstripe -i $f)
                [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
-               local size=$($GETSTRIPE -S $f)
+               local size=$($LFS getstripe -S $f)
                [ $size -eq $((def_stripe_size * 2)) ] ||
                        error "$f stripe size $size != $((def_stripe_size * 2))"
-               local pool=$($GETSTRIPE -p $f)
+               local pool=$($LFS getstripe -p $f)
                [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
        done
 
        # change fs default striping, delete parent default striping, now child
        # will stripe from new fs default striping only
-       $SETSTRIPE -c 1 -S $def_stripe_size -i 0 $MOUNT ||
+       $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
                error "change $MOUNT default stripe failed"
-       $SETSTRIPE -c 0 $DIR/$tdir || error "delete $tdir default stripe failed"
+       $LFS setstripe -c 0 $DIR/$tdir ||
+               error "delete $tdir default stripe failed"
        for i in $(seq 11 20); do
                local f=$DIR/$tdir/$tfile.$i
                touch $f || error "touch $f failed"
-               local count=$($GETSTRIPE -c $f)
+               local count=$($LFS getstripe -c $f)
                [ $count -eq 1 ] || error "$f stripe count $count != 1"
-               local offset=$($GETSTRIPE -i $f)
+               local offset=$($LFS getstripe -i $f)
                [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
-               local size=$($GETSTRIPE -S $f)
+               local size=$($LFS getstripe -S $f)
                [ $size -eq $def_stripe_size ] ||
                        error "$f stripe size $size != $def_stripe_size"
-               local pool=$($GETSTRIPE -p $f)
-               [ "#$pool" == "#" ] || error "$f pool $pool is set"
-
+               local pool=$($LFS getstripe -p $f)
+               [ $pool == $test_pool ] || error "$f pool $pool isn't set"
        done
 
        unlinkmany $DIR/$tdir/$tfile. 1 20
 
-       # restore FS default striping
-       if [ -z $def_pool ]; then
-               $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
-                       -i $def_stripe_offset $MOUNT ||
-                       error "restore default striping failed"
-       else
-               $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
-                       -i $def_stripe_offset -p $def_pool $MOUNT ||
-                       error "restore default striping with $def_pool failed"
-       fi
-
        local f=$DIR/$tdir/$tfile
        pool_remove_all_targets $test_pool $f
        pool_remove $test_pool $f
@@ -17954,7 +18164,7 @@ test_803() {
                        error "Fail to create $DIR/$tdir/dir${idx}"
        done
 
-       sync; sleep 5
+       sync; sleep 3
        echo "before create:"
        $LFS df -i $MOUNT
        local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
@@ -17964,7 +18174,7 @@ test_803() {
                        error "Fail to create $DIR/$tdir/foo$i"
        done
 
-       sync; sleep 5
+       sync; sleep 3
        echo "after create:"
        $LFS df -i $MOUNT
        local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
@@ -17977,6 +18187,7 @@ test_803() {
                        error "Fail to remove $DIR/$tdir/foo$i"
        done
 
+       sleep 3 # avoid MDT return cached statfs
        wait_delete_completed
        echo "after unlink:"
        $LFS df -i $MOUNT
@@ -18072,6 +18283,52 @@ test_804() {
 }
 run_test 804 "verify agent entry for remote entry"
 
+cleanup_805() {
+       do_facet $SINGLEMDS zfs set quota=$old $fsset
+       unlinkmany $DIR/$tdir/f- 1000000
+       trap 0
+}
+
+test_805() {
+       local zfs_version=$(do_node $SINGLEMDS cat /sys/module/zfs/version)
+       [ "$(facet_fstype mds1)" != "zfs" ] &&
+               skip "ZFS specific test" && return
+       [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
+               skip "netfree not implemented before 0.7" && return
+       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.57) ]] ||
+               { skip "Need MDS version at least 2.10.57" && return 0; }
+
+       local fsset
+       local freekb
+       local usedkb
+       local old
+       local quota
+       local pref="osd-zfs.lustre-MDT0000."
+
+       # limit available space on MDS dataset to meet nospace issue
+       # quickly. then ZFS 0.7.2 can use reserved space if asked
+       # properly (using netfree flag in osd_declare_destroy()
+       fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
+       old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
+               gawk '{print $3}')
+       freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
+       usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
+       let "usedkb=usedkb-freekb"
+       let "freekb=freekb/2"
+       if let "freekb > 5000"; then
+               let "freekb=5000"
+       fi
+       do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
+       trap cleanup_805 EXIT
+       mkdir $DIR/$tdir
+       $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
+       createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
+       rm -rf $DIR/$tdir || error "not able to remove"
+       do_facet $SINGLEMDS zfs set quota=$old $fsset
+       trap 0
+}
+run_test 805 "ZFS can remove from full fs"
+
 #
 # tests that do cleanup/setup should be run at the end
 #