Whamcloud - gitweb
LU-9899 tests: mount client on MGS for tests with pools
[fs/lustre-release.git] / lustre / tests / sanity.sh
index f3ce898..4859d9e 100755 (executable)
@@ -12,8 +12,8 @@ ONLY=${ONLY:-"$*"}
 ALWAYS_EXCEPT="                42a    42b      42c     45   68b $SANITY_EXCEPT"
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
-# skipped tests: LU-2036 LU-8411 LU-9096 LU-9054
-ALWAYS_EXCEPT="  76     407     253     312 $ALWAYS_EXCEPT"
+# skipped tests: LU-8411 LU-9096 LU-9054 LU-10199
+ALWAYS_EXCEPT="  407     253     312     56xb     $ALWAYS_EXCEPT"
 
 # Check Grants after these tests
 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c"
@@ -1713,10 +1713,10 @@ test_27w() { # bug 10997
        $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
        [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
                error "stripe size $size != 65536" || true
-       [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
-               error "$LFS getstripe -d $DIR/$tdir failed" || true
+       [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
+               error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
 }
-run_test 27w "check $LFS setstripe -S option"
+run_test 27w "check $LFS setstripe -S and getstrip -d options"
 
 test_27wa() {
        [[ $OSTCOUNT -lt 2 ]] &&
@@ -2059,6 +2059,10 @@ test_27D() {
        local ost_list=$(seq $first_ost $ost_step $last_ost)
        local ost_range="$first_ost $last_ost $ost_step"
 
+       if ! combined_mgs_mds ; then
+               mount_mgs_client
+       fi
+
        test_mkdir $DIR/$tdir
        pool_add $POOL || error "pool_add failed"
        pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
@@ -2073,6 +2077,10 @@ test_27D() {
                error "llapi_layout_test failed"
 
        destroy_test_pools || error "destroy test pools failed"
+
+       if ! combined_mgs_mds ; then
+               umount_mgs_client
+       fi
 }
 run_test 27D "validate llapi_layout API"
 
@@ -4154,11 +4162,13 @@ test_51b() {
        [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)" &&
                return
 
-       trap cleanup_print_lfsdf EXIT
+       trap cleanup_print_lfs_df EXIT
 
        # create files
-       createmany -d $dir/d $nrdirs ||
+       createmany -d $dir/d $nrdirs || {
+               unlinkmany $dir/d $nrdirs
                error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
+       }
 
        # really created :
        nrdirs=$(ls -U $dir | wc -l)
@@ -4267,8 +4277,10 @@ test_51f() {
                echo "left ulimit at $ulimit_old"
        fi
 
-       createmany -o -k -t 120 $DIR/$tdir/f $numfree ||
+       createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
+               unlinkmany $DIR/$tdir/f $numfree
                error "create+open $numfree files in $DIR/$tdir failed"
+       }
        ulimit -n $ulimit_old
 
        # if createmany exits at 120s there will be fewer than $numfree files
@@ -5151,16 +5163,15 @@ test_56x() {
        check_swap_layouts_support && return 0
        [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
 
-       local dir0=$DIR/$tdir/$testnum
-       test_mkdir -p $dir0
-
+       local dir0=$DIR/$tdir
        local ref1=/etc/passwd
        local file1=$dir0/file1
 
-       $SETSTRIPE -c 2 $file1
+       test_mkdir $dir0 || error "creating dir $dir0"
+       $LFS setstripe -c 2 $file1
        cp $ref1 $file1
        $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
-       stripe=$($GETSTRIPE -c $file1)
+       stripe=$($LFS getstripe -c $file1)
        [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
        cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
 
@@ -5179,10 +5190,10 @@ test_56xa() {
        local ref1=/etc/passwd
        local file1=$dir0/file1
 
-       $SETSTRIPE -c 2 $file1
+       $LFS setstripe -c 2 $file1
        cp $ref1 $file1
        $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
-       local stripe=$($GETSTRIPE -c $file1)
+       local stripe=$($LFS getstripe -c $file1)
        [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
        cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
 
@@ -5191,6 +5202,110 @@ test_56xa() {
 }
 run_test 56xa "lfs migration --block support"
 
+check_migrate_links() {
+       local dir="$1"
+       local file1="$dir/file1"
+       local begin="$2"
+       local count="$3"
+       local total_count=$(($begin + $count - 1))
+       local symlink_count=10
+       local uniq_count=10
+
+       if [ ! -f "$file1" ]; then
+               echo -n "creating initial file..."
+               $LFS setstripe -c 1 -S "512k" "$file1" ||
+                       error "cannot setstripe initial file"
+               echo "done"
+
+               echo -n "creating symlinks..."
+               for s in $(seq 1 $symlink_count); do
+                       ln -s "$file1" "$dir/slink$s" ||
+                               error "cannot create symlinks"
+               done
+               echo "done"
+
+               echo -n "creating nonlinked files..."
+               createmany -o "$dir/uniq" 1 10 &> /dev/null ||
+                       error "cannot create nonlinked files"
+               echo "done"
+       fi
+
+       # create hard links
+       if [ ! -f "$dir/file$total_count" ]; then
+               echo -n "creating hard links $begin:$total_count..."
+               createmany -l"$file1" "$dir/file" "$begin" "$count" &>  \
+                       /dev/null || error "cannot create hard links"
+               echo "done"
+       fi
+
+       echo -n "checking number of hard links listed in xattrs..."
+       local fid=$($LFS getstripe -F "$file1")
+       local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
+
+       echo "${#paths[*]}"
+       if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2  ]; then
+                       echo "hard link list has unexpected size, skipping test"
+                       return 0
+       fi
+       if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2  ]; then
+                       error "link names should exceed xattrs size"
+       fi
+
+       echo -n "migrating files..."
+       local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
+       local rc=$?
+       [ $rc -eq 0 ] || error "migrate failed rc = $rc"
+       echo "done"
+
+       # make sure all links have been properly migrated
+       echo -n "verifying files..."
+       fid=$($LFS getstripe -F "$file1") ||
+               error "cannot get fid for file $file1"
+       for i in $(seq 2 $total_count); do
+               local fid2=$($LFS getstripe -F $dir/file$i)
+               [ "$fid2" == "$fid" ] ||
+                       error "migrated hard link has mismatched FID"
+       done
+
+       # make sure hard links were properly detected, and migration was
+       # performed only once for the entire link set; nonlinked files should
+       # also be migrated
+       local actual=$(grep -c 'done migrate' <<< "$migrate_out")
+       local expected=$(($uniq_count + 1))
+       [ "$actual" -eq  "$expected" ] ||
+               error "hard links individually migrated ($actual != $expected)"
+
+       # make sure the correct number of hard links are present
+       local hardlinks=$(stat -c '%h' "$file1")
+       [ $hardlinks -eq $total_count ] ||
+               error "num hard links $hardlinks != $total_count"
+       echo "done"
+
+       return 0
+}
+
+test_56xb() {
+       local dir0="$DIR/$tdir"
+
+       test_mkdir "$dir0" || error "cannot create dir $dir0"
+
+       echo "testing lfs migrate mode when all links fit within xattrs"
+       LFS_MIGRATE_RSYNC=false check_migrate_links "$dir0" 2 99
+
+       echo "testing rsync mode when all links fit within xattrs"
+       LFS_MIGRATE_RSYNC=true check_migrate_links "$dir0" 2 99
+
+       echo "testing lfs migrate mode when all links do not fit within xattrs"
+       LFS_MIGRATE_RSYNC=false check_migrate_links "$dir0" 101 100
+
+       echo "testing rsync mode when all links do not fit within xattrs"
+       LFS_MIGRATE_RSYNC=true check_migrate_links "$dir0" 101 100
+
+       # clean up
+       rm -rf $dir0
+}
+run_test 56xb "lfs migration hard link support"
+
 test_56y() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
                skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
@@ -5259,6 +5374,68 @@ test_56aa() { # LU-5937
 }
 run_test 56aa "lfs find --size under striped dir"
 
+test_56ba() {
+       # Create composite files with one component
+       TDIR=$DIR/$tdir/1Mfiles
+       setup_56 5 1 "--component-end 1M"
+       # Create composite files with three components
+       TDIR=$DIR/$tdir/2Mfiles
+       setup_56 5 2 "-E 2M -E 4M -E 6M"
+       TDIR=$DIR/$tdir
+       # Create non-composite files
+       createmany -o $TDIR/${tfile}- 10
+
+       local nfiles=$($LFIND --component-end 1M --type f $TDIR | wc -l)
+       [[ $nfiles == 10 ]] ||
+               error "lfs find -E 1M found $nfiles != 10 files"
+
+       nfiles=$($LFIND ! -E 1M --type f $TDIR | wc -l)
+       [[ $nfiles == 25 ]] ||
+               error "lfs find ! -E 1M found $nfiles != 25 files"
+
+       # All files have a component that starts at 0
+       local nfiles=$($LFIND --component-start 0 --type f $TDIR | wc -l)
+       [[ $nfiles == 35 ]] ||
+               error "lfs find --component-start 0 found $nfiles != 35 files"
+
+       nfiles=$($LFIND --component-start 2M --type f $TDIR | wc -l)
+       [[ $nfiles == 15 ]] ||
+               error "$LFIND --component-start 2M found $nfiles != 15 files"
+
+       # All files created here have a componenet that does not starts at 2M
+       nfiles=$($LFIND ! --component-start 2M --type f $TDIR | wc -l)
+       [[ $nfiles == 35 ]] ||
+               error "$LFIND ! --component-start 2M found $nfiles != 35 files"
+
+       # Find files with a specified number of components
+       local nfiles=$($LFIND --component-count 3 --type f $TDIR | wc -l)
+       [[ $nfiles == 15 ]] ||
+               error "lfs find --component-count 3 found $nfiles != 15 files"
+
+       # Remember non-composite files have a component count of zero
+       local nfiles=$($LFIND --component-count 0 --type f $TDIR | wc -l)
+       [[ $nfiles == 10 ]] ||
+               error "lfs find --component-count 0 found $nfiles != 10 files"
+
+       nfiles=$($LFIND ! --component-count 3 --type f $TDIR | wc -l)
+       [[ $nfiles == 20 ]] ||
+               error "$LFIND ! --component-count 3 found $nfiles != 20 files"
+
+       # All files have a flag called "init"
+       local nfiles=$($LFIND --component-flags init --type f $TDIR | wc -l)
+       [[ $nfiles == 35 ]] ||
+               error "$LFIND --component-flags init found $nfiles != 35 files"
+
+       # Multi-component files will have a component not initialized
+       local nfiles=$($LFIND ! --component-flags init --type f $TDIR | wc -l)
+       [[ $nfiles == 15 ]] ||
+               error "$LFIND !--component-flags init found $nfiles != 15 files"
+
+       rm -rf $TDIR
+
+}
+run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
+
 test_57a() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
        # note test will not do anything if MDS is not local
@@ -6008,21 +6185,9 @@ num_inodes() {
        awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
 }
 
-get_inode_slab_tunables() {
-       awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
-}
-
-set_inode_slab_tunables() {
-       echo "lustre_inode_cache $1" > /proc/slabinfo
-}
-
 test_76() { # Now for bug 20433, added originally in bug 1443
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       local SLAB_SETTINGS=$(get_inode_slab_tunables)
        local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
-       # we cannot set limit below 1 which means 1 inode in each
-       # per-cpu cache is still allowed
-       set_inode_slab_tunables "1 1 0"
        cancel_lru_locks osc
        BEFORE_INODES=$(num_inodes)
        echo "before inodes: $BEFORE_INODES"
@@ -6045,7 +6210,6 @@ test_76() { # Now for bug 20433, added originally in bug 1443
                        error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
                fi
        done
-       set_inode_slab_tunables "$SLAB_SETTINGS"
 }
 run_test 76 "confirm clients recycle inodes properly ===="
 
@@ -6933,7 +7097,7 @@ setup_test102() {
        done
 
        cd $DIR
-       $1 $TAR cf $TMP/f102.tar $tdir --xattrs
+       $1 tar cf $TMP/f102.tar $tdir --xattrs
 }
 
 cleanup_test102() {
@@ -7092,20 +7256,17 @@ compare_stripe_info1() {
        return 0
 }
 
-find_lustre_tar() {
-       [ -n "$(which tar 2>/dev/null)" ] &&
-               strings $(which tar) | grep -q "lustre" && echo tar
+have_xattrs_include() {
+       tar --help | grep -q xattrs-include &&
+               echo --xattrs-include="lustre.*"
 }
 
 test_102d() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       # b10930: tar test for trusted.lov xattr
-       TAR=$(find_lustre_tar)
-       [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
        [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+       XINC=$(have_xattrs_include)
        setup_test102
-       test_mkdir $DIR/$tdir
-       $TAR xf $TMP/$tfile.tar -C $DIR/$tdir --xattrs
+       tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
        cd $DIR/$tdir/$tdir
        compare_stripe_info1
 }
@@ -7113,14 +7274,13 @@ run_test 102d "tar restore stripe info from tarfile,not keep osts"
 
 test_102f() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       # b10930: tar test for trusted.lov xattr
-       TAR=$(find_lustre_tar)
-       [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
        [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+       XINC=$(have_xattrs_include)
        setup_test102
        test_mkdir $DIR/$tdir.restore
        cd $DIR
-       $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/$tdir.restore
+       tar cf - --xattrs $tdir | tar xf - \
+               -C $DIR/$tdir.restore --xattrs $XINC
        cd $DIR/$tdir.restore/$tdir
        compare_stripe_info1
 }
@@ -7194,13 +7354,11 @@ run_test 102i "lgetxattr test on symbolic link ============"
 
 test_102j() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       TAR=$(find_lustre_tar)
-       [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
        [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+       XINC=$(have_xattrs_include)
        setup_test102 "$RUNAS"
-       test_mkdir $DIR/$tdir
        chown $RUNAS_ID $DIR/$tdir
-       $RUNAS $TAR xf $TMP/f102.tar -C $DIR/$tdir --xattrs
+       $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
        cd $DIR/$tdir/$tdir
        compare_stripe_info1 "$RUNAS"
 }
@@ -12143,8 +12301,12 @@ test_200() {
        local test_path=$POOL_ROOT/$POOL_DIR_NAME
        local file_dir=$POOL_ROOT/file_tst
        local subdir=$test_path/subdir
-
        local rc=0
+
+       if ! combined_mgs_mds ; then
+               mount_mgs_client
+       fi
+
        while : ; do
                # former test_200a test_200b
                pool_add $POOL                          || { rc=$? ; break; }
@@ -12164,7 +12326,7 @@ test_200() {
                pool_create_files $POOL $file_dir $files "$ost_list" \
                                                        || { rc=$? ; break; }
                # former test_200g test_200h
-               pool_lfs_df $POOL                       || { rc=$? ; break; }
+               pool_lfs_df $POOL                       || { rc=$? ; break; }
                pool_file_rel_path $POOL $test_path     || { rc=$? ; break; }
 
                # former test_201a test_201b test_201c
@@ -12172,11 +12334,15 @@ test_200() {
 
                local f=$test_path/$tfile
                pool_remove_all_targets $POOL $f        || { rc=$? ; break; }
-               pool_remove $POOL $f                    || { rc=$? ; break; }
+               pool_remove $POOL $f                    || { rc=$? ; break; }
                break
        done
 
        destroy_test_pools
+
+       if ! combined_mgs_mds ; then
+               umount_mgs_client
+       fi
        return $rc
 }
 run_test 200 "OST pools"
@@ -12617,16 +12783,12 @@ run_test 214 "hash-indexed directory test - bug 20133"
 
 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
 create_lnet_proc_files() {
-       lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
-       sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
-
-       sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
-       rm -f "$TMP/lnet_$1.sys_tmp"
+       lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
 }
 
 # counterpart of create_lnet_proc_files
 remove_lnet_proc_files() {
-       rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
+       rm -f $TMP/lnet_$1.sys
 }
 
 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
@@ -12736,7 +12898,6 @@ test_215() { # for bugs 18102, 21079, 21517
 
        # can we successfully write to lnet.stats?
        lctl set_param -n stats=0 || error "cannot write to lnet.stats"
-       sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
 }
 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
 
@@ -12859,6 +13020,10 @@ test_220() { #LU-325
 
        $LFS df -i
 
+       if ! combined_mgs_mds ; then
+               mount_mgs_client
+       fi
+
        do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
        #define OBD_FAIL_OST_ENOINO              0x229
        do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
@@ -12889,10 +13054,16 @@ test_220() { #LU-325
        do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
        do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
 
-       do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
-       do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
+       do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
+               error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
+       do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
+               error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
        echo "unlink $MDSOBJS files @$next_id..."
-       unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
+       unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
+
+       if ! combined_mgs_mds ; then
+               umount_mgs_client
+       fi
 }
 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
 
@@ -13064,8 +13235,6 @@ test_225b () {
              skip_env "Need to mount OST to test" && return
        fi
 
-       [ $MDSCOUNT -ge 2 ] &&
-               skip "skipping now for more than one MDT" && return
        local mds=$(facet_host $SINGLEMDS)
        local target=$(do_nodes $mds 'lctl dl' | \
                       awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
@@ -13972,9 +14141,10 @@ test_239() {
        mkdir -p $DIR/$tdir
        createmany -o $DIR/$tdir/f- 5000
        unlinkmany $DIR/$tdir/f- 5000
-       do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
-       changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
-                       osc.*MDT*.sync_in_flight" | calc_sum)
+       [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.10.53) ] &&
+               do_nodes $list "lctl set_param -n osp.*.force_sync=1"
+       changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
+                       osp.*MDT*.sync_in_flight" | calc_sum)
        [ "$changes" -eq 0 ] || error "$changes not synced"
 }
 run_test 239 "osp_sync test"
@@ -14415,6 +14585,9 @@ test_253() {
                        osp.$mdtosc_proc1.reserved_mb_low)
        echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
 
+       if ! combined_mgs_mds ; then
+               mount_mgs_client
+       fi
        create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
        do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
                error "Adding $ost_name to pool failed"
@@ -14479,6 +14652,10 @@ test_253() {
                error "Remove $ost_name from pool failed"
        do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
                error "Pool destroy fialed"
+
+       if ! combined_mgs_mds ; then
+               umount_mgs_client
+       fi
 }
 run_test 253 "Check object allocation limit"
 
@@ -14903,11 +15080,12 @@ test_256() {
 
        #after mount new plainllog is used
        touch $DIR/$tdir/{11..19}
-       local TEMP256FILE=$(mktemp TEMP256XXXXXX)
+       do_facet mds1 sync
+       local TEMP256FILE=$(mktemp -u TEMP256XXXXXX)
        cat_sl=$(do_facet mds1 \
        "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
         llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
-       rm $TEMP256FILE
+       do_facet mds1 rm $TEMP256FILE
 
        if (( cat_sl != 2 )); then
                do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
@@ -14916,11 +15094,12 @@ test_256() {
 
        $LFS changelog_clear $MDT0 $cl_user 0
 
-       TEMP256FILE=$(mktemp TEMP256XXXXXX)
+       do_facet mds1 sync
+       TEMP256FILE=$(mktemp -u TEMP256XXXXXX)
        cat_sl=$(do_facet mds1 \
        "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
         llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
-       rm $TEMP256FILE
+       do_facet mds1 rm $TEMP256FILE
 
        do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
 
@@ -15006,18 +15185,18 @@ test_270a() {
        mkdir -p $DIR/$tdir
 
        # basic checks for DoM component creation
-       $SETSTRIPE -E 1024K -E 1024K -L mdt $dom 2>/dev/null &&
+       $LFS setstripe -E 1024K -E 1024K -L mdt $dom 2>/dev/null &&
                error "Can set MDT layout to non-first entry"
 
-       $SETSTRIPE -E 1024K -L mdt -E 1024K -L mdt $dom 2>/dev/null &&
+       $LFS setstripe -E 1024K -L mdt -E 1024K -L mdt $dom 2>/dev/null &&
                error "Can define multiple entries as MDT layout"
 
-       $SETSTRIPE -E 1M -L mdt $dom ||
+       $LFS setstripe -E 1M -L mdt $dom ||
                error "Can't create DoM layout"
 
-       [ $($GETSTRIPE -L $dom) == 100 ] || error "bad pattern"
-       [ $($GETSTRIPE -c $dom) == 0 ] || error "bad stripe count"
-       [ $($GETSTRIPE -S $dom) == 1048576 ] || error "bad stripe size"
+       [ $($LFS getstripe -L $dom) == 100 ] || error "bad pattern"
+       [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
+       [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
 
        local mdtidx=$($GETSTRIPE -M $dom)
        local mdtname=MDT$(printf %04x $mdtidx)
@@ -15077,7 +15256,7 @@ test_270a() {
        fi
 
        # combined striping
-       $SETSTRIPE -E 1024K -L mdt -E EOF $dom ||
+       $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
                error "Can't create DoM + OST striping"
 
        dd if=/dev/urandom of=$tmp bs=1024 count=2000
@@ -15098,7 +15277,7 @@ test_270b() {
        local max_size=1048576
 
        mkdir -p $DIR/$tdir
-       $SETSTRIPE -E $max_size -L mdt $dom
+       $LFS setstripe -E $max_size -L mdt $dom
 
        # truncate over the limit
        $TRUNCATE $dom $(($max_size + 1)) &&
@@ -15117,25 +15296,25 @@ run_test 270b "DoM: maximum size overflow checks for DoM-only file"
 
 test_270c() {
        mkdir -p $DIR/$tdir
-       $SETSTRIPE -E 1024K -L mdt $DIR/$tdir
+       $LFS setstripe -E 1024K -L mdt $DIR/$tdir
 
        # check files inherit DoM EA
        touch $DIR/$tdir/first
        [ $($GETSTRIPE -L $DIR/$tdir/first) == 100 ] ||
                error "bad pattern"
-       [ $($GETSTRIPE -c $DIR/$tdir/first) == 0 ] ||
+       [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
                error "bad stripe count"
-       [ $($GETSTRIPE -S $DIR/$tdir/first) == 1048576 ] ||
+       [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
                error "bad stripe size"
 
        # check directory inherits DoM EA and uses it as default
        mkdir $DIR/$tdir/subdir
        touch $DIR/$tdir/subdir/second
-       [ $($GETSTRIPE -L $DIR/$tdir/subdir/second) == 100 ] ||
+       [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == 100 ] ||
                error "bad pattern in sub-directory"
-       [ $($GETSTRIPE -c $DIR/$tdir/subdir/second) == 0 ] ||
+       [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
                error "bad stripe count in sub-directory"
-       [ $($GETSTRIPE -S $DIR/$tdir/subdir/second) == 1048576 ] ||
+       [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
                error "bad stripe size in sub-directory"
        return 0
 }
@@ -15143,18 +15322,18 @@ run_test 270c "DoM: DoM EA inheritance tests"
 
 test_270d() {
        mkdir -p $DIR/$tdir
-       $SETSTRIPE -E 1024K -L mdt $DIR/$tdir
+       $LFS setstripe -E 1024K -L mdt $DIR/$tdir
 
        # inherit default DoM striping
        mkdir $DIR/$tdir/subdir
        touch $DIR/$tdir/subdir/f1
 
        # change default directory striping
-       $SETSTRIPE -c 1 $DIR/$tdir/subdir
+       $LFS setstripe -c 1 $DIR/$tdir/subdir
        touch $DIR/$tdir/subdir/f2
-       [ $($GETSTRIPE -c $DIR/$tdir/subdir/f2) == 1 ] ||
+       [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
                error "wrong default striping in file 2"
-       [ $($GETSTRIPE -L $DIR/$tdir/subdir/f2) == 1 ] ||
+       [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == 1 ] ||
                error "bad pattern in file 2"
        return 0
 }
@@ -15165,8 +15344,8 @@ test_270e() {
        mkdir -p $DIR/$tdir/norm
        DOMFILES=20
        NORMFILES=10
-       $SETSTRIPE -E 1M -L mdt $DIR/$tdir/dom
-       $SETSTRIPE -i 0 -S 2M $DIR/$tdir/norm
+       $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
+       $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
 
        createmany -o $DIR/$tdir/dom/dom- $DOMFILES
        createmany -o $DIR/$tdir/norm/norm- $NORMFILES
@@ -15212,12 +15391,12 @@ test_270f() {
                error "Cannot change per-MDT DoM stripe limit to $dom_limit"
 
        $LFS mkdir -i 0 -c 1 $DIR/$tdir
-       $SETSTRIPE -d $DIR/$tdir
-       $SETSTRIPE -E $dom_limit -L mdt $DIR/$tdir ||
+       $LFS setstripe -d $DIR/$tdir
+       $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
                error "Can't set directory default striping"
 
        # exceed maximum stripe size
-       $SETSTRIPE -E $(($dom_limit * 2)) -L mdt $dom &&
+       $LFS setstripe -E $(($dom_limit * 2)) -L mdt $dom &&
                error "Able to create DoM component size more than LOD limit"
 
        do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
@@ -15242,11 +15421,11 @@ test_270f() {
 
        do_facet mds1 $LCTL set_param -n \
                                lod.$mdtname.dom_stripesize=$((dom_limit * 2))
-       $SETSTRIPE -E $((dom_limit * 2)) -L mdt $dom ||
+       $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
                error "Can't create DoM component size after limit change"
        do_facet mds1 $LCTL set_param -n \
                                lod.$mdtname.dom_stripesize=$((dom_limit / 2))
-       $SETSTRIPE -E $dom_limit -L mdt ${dom}_big &&
+       $LFS setstripe -E $dom_limit -L mdt ${dom}_big &&
                error "Can create big DoM component after limit decrease"
        touch ${dom}_def ||
                error "Can't create file with old default layout"
@@ -15261,19 +15440,106 @@ test_271a() {
 
        mkdir -p $DIR/$tdir
 
-       $SETSTRIPE -E 1024K -L mdt $dom
+       $LFS setstripe -E 1024K -L mdt $dom
 
        lctl set_param -n mdc.*.stats=clear
        dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
        cat $dom > /dev/null
-       local reads=$(lctl get_param -n mdc.*.stats | \
-               awk '/ost_read/ {print $2}')
+       local reads=$(lctl get_param -n mdc.*.stats |
+                       awk '/ost_read/ {print $2}')
        [ -z $reads ] || error "Unexpected $reads READ RPCs"
        ls $dom
        rm -f $dom
 }
 run_test 271a "DoM: data is cached for read after write"
 
+test_271b() {
+       local dom=$DIR/$tdir/dom
+
+       mkdir -p $DIR/$tdir
+
+       $LFS setstripe -E 1024K -L mdt -E EOF $dom
+
+       lctl set_param -n mdc.*.stats=clear
+       dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
+       cancel_lru_locks mdc
+       $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
+       # second stat to check size is cached on client
+       $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
+       local gls=$(lctl get_param -n mdc.*.stats |
+                       awk '/ldlm_glimpse/ {print $2}')
+       [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
+       rm -f $dom
+}
+run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
+
+test_271ba() {
+       local dom=$DIR/$tdir/dom
+
+       mkdir -p $DIR/$tdir
+
+       $LFS setstripe -E 1024K -L mdt -E EOF $dom
+
+       lctl set_param -n mdc.*.stats=clear
+       lctl set_param -n osc.*.stats=clear
+       dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
+       cancel_lru_locks mdc
+       $CHECKSTAT -t file -s 2097152 $dom || error "stat"
+       # second stat to check size is cached on client
+       $CHECKSTAT -t file -s 2097152 $dom || error "stat"
+       local gls=$(lctl get_param -n mdc.*.stats |
+                       awk '/ldlm_glimpse/ {print $2}')
+       [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
+       local gls=$(lctl get_param -n osc.*.stats |
+                       awk '/ldlm_glimpse/ {print $2}')
+       [ -z $gls ] || error "Unexpected $gls OSC glimpse RPCs"
+       rm -f $dom
+}
+run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
+
+test_271c() {
+       # test to be enabled with lock_convert
+       skip "skipped until lock convert will be implemented" && return
+
+       local dom=$DIR/$tdir/dom
+
+       mkdir -p $DIR/$tdir
+
+       $LFS setstripe -E 1024K -L mdt $DIR/$tdir
+
+       local mdtidx=$($LFS getstripe -M $DIR/$tdir)
+       local facet=mds$((mdtidx + 1))
+
+       cancel_lru_locks mdc
+       do_facet $facet lctl set_param -n mdt.*.dom_lock=0
+       createmany -o $dom 1000
+       lctl set_param -n mdc.*.stats=clear
+       smalliomany -w $dom 1000 200
+       lctl get_param -n mdc.*.stats
+       local enq=$(lctl get_param -n mdc.*.stats |
+                       awk '/ldlm_ibits_enqueue/ {print $2}')
+       # Each file has 1 open, 1 IO enqueues, total 2000
+       # but now we have also +1 getxattr for security.capability, total 3000
+       [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
+       unlinkmany $dom 1000
+
+       cancel_lru_locks mdc
+       do_facet $facet lctl set_param -n mdt.*.dom_lock=1
+       createmany -o $dom 1000
+       lctl set_param -n mdc.*.stats=clear
+       smalliomany -w $dom 1000 200
+       lctl get_param -n mdc.*.stats
+       local enq_2=$(lctl get_param -n mdc.*.stats |
+                       awk '/ldlm_ibits_enqueue/ {print $2}')
+       # Expect to see reduced amount of RPCs by 1000 due to single enqueue
+       # for OPEN and IO lock.
+       [ $((enq - enq_2)) -ge 1000 ] ||
+               error "Too many enqueues $enq_2, expected about $((enq - 1000))"
+       unlinkmany $dom 1000
+       return 0
+}
+run_test 271c "DoM: IO lock at open saves enqueue RPCs"
+
 cleanup_test_300() {
        trap 0
        umask $SAVE_UMASK
@@ -15598,17 +15864,17 @@ test_300g() {
        $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
                error "create striped_dir failed"
 
+       $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
+               error "create dir0 fails"
+       stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
+       [ $stripe_index -eq 0 ] ||
+               error "dir0 expect index 0 got $stripe_index"
+
        mkdir $DIR/$tdir/striped_dir/dir1 ||
                error "create dir1 fails"
        stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
        [ $stripe_index -eq 1 ] ||
-               error "dir1 expect 1 got $stripe_index"
-
-       $LFS setdirstripe -i2 $DIR/$tdir/striped_dir/dir2 ||
-               error "create dir2 fails"
-       stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir2)
-       [ $stripe_index -eq 2 ] ||
-               error "dir2 expect 2 got $stripe_index"
+               error "dir1 expect index 1 got $stripe_index"
 
        #check default stripe count/stripe index
        test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
@@ -16529,8 +16795,11 @@ test_406() {
        local def_stripe_size=$($GETSTRIPE -S $MOUNT)
        local def_stripe_offset=$($GETSTRIPE -i $MOUNT)
        local def_pool=$($GETSTRIPE -p $MOUNT)
-
        local test_pool=$TESTNAME
+
+       if ! combined_mgs_mds ; then
+               mount_mgs_client
+       fi
        pool_add $test_pool || error "pool_add failed"
        pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
                error "pool_add_targets failed"
@@ -16592,6 +16861,10 @@ test_406() {
        local f=$DIR/$tdir/$tfile
        pool_remove_all_targets $test_pool $f
        pool_remove $test_pool $f
+
+       if ! combined_mgs_mds ; then
+               umount_mgs_client
+       fi
 }
 run_test 406 "DNE support fs default striping"