Whamcloud - gitweb
LU-7660 dne: support fs default stripe
[fs/lustre-release.git] / lustre / tests / sanity.sh
index dfc8ba7..6618b42 100644 (file)
@@ -13162,7 +13162,7 @@ test_230f() {
 
        # a should be migrated to MDT1, since no other links on MDT0
        $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
-               error "migrate dir fails"
+               error "#1 migrate dir fails"
        mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
        [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
        mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
@@ -13170,12 +13170,12 @@ test_230f() {
 
        # a should stay on MDT1, because it is a mulitple link file
        $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
-               error "migrate dir fails"
+               error "#2 migrate dir fails"
        mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
        [ $mdt_index == 1 ] || error "a is not on MDT1"
 
        $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
-               error "migrate dir fails"
+               error "#3 migrate dir fails"
 
        a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
        ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
@@ -13186,7 +13186,7 @@ test_230f() {
 
        # a should be migrated to MDT0, since no other links on MDT1
        $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
-               error "migrate dir fails"
+               error "#4 migrate dir fails"
        mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
        [ $mdt_index == 0 ] || error "a is not on MDT0"
 
@@ -14901,6 +14901,84 @@ test_405() {
 }
 run_test 405 "Various layout swap lock tests"
 
+test_406() {
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
+       [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] &&
+               skip "Need MDS version at least 2.8.50" && return
+
+       local def_stripenr=$($GETSTRIPE -c $MOUNT)
+       local def_stripe_size=$($GETSTRIPE -S $MOUNT)
+       local def_stripe_offset=$($GETSTRIPE -i $MOUNT)
+       local def_pool=$($GETSTRIPE -p $MOUNT)
+
+       local test_pool=$TESTNAME
+       pool_add $test_pool || error "pool_add failed"
+       pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
+               error "pool_add_targets failed"
+
+       # 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 ||
+               error "setstripe $MOUNT failed"
+       $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
+       $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)
+               [ $count -eq $OSTCOUNT ] ||
+                       error "$f stripe count $count != $OSTCOUNT"
+               local offset=$($GETSTRIPE -i $f)
+               [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
+               local size=$($GETSTRIPE -S $f)
+               [ $size -eq $((def_stripe_size * 2)) ] ||
+                       error "$f stripe size $size != $((def_stripe_size * 2))"
+               local pool=$($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 ||
+               error "change $MOUNT default stripe failed"
+       $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)
+               [ $count -eq 1 ] || error "$f stripe count $count != 1"
+               local offset=$($GETSTRIPE -i $f)
+               [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
+               local size=$($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"
+
+       done
+
+       unlinkmany $DIR/$tdir/$tfile. 1 20
+
+       # restore FS default striping
+       if [ -z $def_pool ]; then
+               $SETSTRIPE -c $def_stripenr -S $def_stripe_size \
+                       -i $def_stripe_offset $MOUNT ||
+                       error "restore default striping failed"
+       else
+               $SETSTRIPE -c $def_stripenr -S $def_stripe_size -p $def_pool \
+                       -i $def_stripe_offset $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
+}
+run_test 406 "DNE support fs default striping"
+
 #
 # tests that do cleanup/setup should be run at the end
 #