# Skip specific tests by setting EXCEPT.
set -e
-SRCDIR=$(dirname $0)
-export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
-
ONLY=${ONLY:-"$*"}
-# Bug number for skipped test:
-ALWAYS_EXCEPT="$SANITY_PFL_EXCEPT"
-# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
-
-TMP=${TMP:-/tmp}
-CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
-LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
+LUSTRE=${LUSTRE:-$(dirname $0)/..}
. $LUSTRE/tests/test-framework.sh
init_test_env $@
-. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
init_logging
+# bug number for skipped test:
+ALWAYS_EXCEPT="$SANITY_PFL_EXCEPT"
+# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
+
+build_test_filter
+
check_and_setup_lustre
if [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.51) ]]; then
skip_env "Need MDS version at least 2.9.51"
fi
-if [ $MDSCOUNT -eq 1 ]; then
- # Bug number: LU-10686
- ALWAYS_EXCEPT+=" 9"
-fi
-
-[ "$ALWAYS_EXCEPT$EXCEPT" ] &&
- echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
-
-build_test_filter
-
[ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
error "\$RUNAS_ID set to 0, but \$UID is also 0!"
check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
assert_DIR
rm -rf $DIR/[Rdfs][0-9]*
-test_0() {
+test_0a() {
[ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
local comp_file=$DIR/$tdir/$tfile
rm -f $comp_file || error "Delete $comp_file failed"
}
-run_test 0 "Create full components file, no reused OSTs"
+run_test 0a "Create full components file, no reused OSTs"
+
+test_0b() {
+ [[ $($LCTL get_param mdc.*.import |
+ grep "connect_flags:.*overstriping") ]] ||
+ skip "server does not support overstriping"
+ large_xattr_enabled || skip_env "no large xattr support"
+
+ local comp_file=$DIR/$tdir/$tfile
+
+ test_mkdir $DIR/$tdir
+
+ # Create file with 1.1*LOV_MAX_STRIPE_COUNT stripes should succeed
+ $LFS setstripe -E 1m -C $((LOV_MAX_STRIPE_COUNT / 10)) -E -1 \
+ -C $LOV_MAX_STRIPE_COUNT $comp_file ||
+ error "Create $comp_file failed"
+
+ rm -f $comp_file || error "Delete $comp_file failed"
+
+ # Create file with 2*LOV_MAX_STRIPE_COUNT stripes should fail
+ $LFS setstripe -E 1m -C $LOV_MAX_STRIPE_COUNT -E -1 -C $LOV_MAX_STRIPE_COUNT \
+ $comp_file && error "Create $comp_file succeeded"
+
+ rm -f $comp_file || error "Delete $comp_file failed"
+}
+run_test 0b "Verify comp stripe count limits"
-test_1() {
+test_1a() {
local comp_file=$DIR/$tdir/$tfile
local rw_len=$((3 * 1024 * 1024)) # 3M
rm -f $comp_file || error "Delete $comp_file failed"
}
-run_test 1 "Create full components file, reused OSTs"
+run_test 1a "Create full components file, reused OSTs"
+
+# test overstriping (>1 stripe/OST within a component)
+test_1b() {
+ [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
+ [[ $($LCTL get_param mdc.*.import |
+ grep "connect_flags:.*overstriping") ]] ||
+ skip "server does not support overstriping"
+
+ local comp_file=$DIR/$tdir/$tfile
+ local rw_len=$((3 * 1024 * 1024)) # 3M
+
+ test_mkdir $DIR/$tdir
+
+ $LFS setstripe -E 1m -S 1m -o 0,0 -E -1 -o 1,1,0,0 $comp_file ||
+ error "Create $comp_file failed"
+
+ #instantiate all components, so that objs are allocted
+ dd if=/dev/zero of=$comp_file bs=1k count=1 seek=1M
+
+ $LFS getstripe $comp_file
+ local OSTS_1=$($LFS getstripe -I1 $comp_file | grep -o 'l_ost_idx.*' |
+ awk -e '{print $2}' | tr "\n" "\0")
+ local OSTS_2=$($LFS getstripe -I2 $comp_file | grep -o 'l_ost_idx.*' |
+ awk -e '{print $2}' | tr "\n" "\0")
+
+ echo ":"$OSTS_1":"
+ echo ":"$OSTS_2":"
+ [ "$OSTS_1" = "0,0," ] || error "incorrect OSTs($OSTS_1) in component 1"
+ [ "$OSTS_2" = "1,1,0,0," ] ||
+ error "incorrect OSTs($OSTS_2) in component 2"
+
+ small_write $comp_file $rw_len || error "Verify RW failed"
+
+ rm -f $comp_file || error "Delete $comp_file failed"
+}
+run_test 1b "Create full components file, overstriping in components"
+
+# test overstriping with max stripe count
+test_1c() {
+ [[ $($LCTL get_param mdc.*.import |
+ grep "connect_flags:.*overstriping") ]] ||
+ skip "server does not support overstriping"
+ large_xattr_enabled || skip_env "no large xattr support"
+
+ local comp_file=$DIR/$tdir/$tfile
+ local rw_len=$((3 * 1024 * 1024)) # 3M
+
+ test_mkdir $DIR/$tdir
+
+ $LFS setstripe -E 1m -C 10 -E 10M -C 100 -E -1 \
+ -C $LOV_MAX_STRIPE_COUNT $comp_file ||
+ error "Create $comp_file failed"
+
+ # Seek & write in to last component so all objects are allocated
+ dd if=/dev/zero of=$comp_file bs=1k count=1 seek=20000
+
+ local count=$($LFS getstripe -c -I1 $DIR/$tdir/$tfile)
+ [ $count -eq 10 ] || error "comp1 stripe count $count, should be 10"
+ count=$($LFS getstripe -c -I2 $DIR/$tdir/$tfile)
+ [ $count -eq 100 ] || error "comp2 stripe count $count, should be 100"
+ count=$($LFS getstripe -c -I3 $DIR/$tdir/$tfile)
+ [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
+ error "comp4 stripe count $count != $LOV_MAX_STRIPE_COUNT"
+
+ small_write $comp_file $rw_len || error "Verify RW failed"
+
+ rm -f $comp_file || error "Delete $comp_file failed"
+}
+run_test 1c "Test overstriping w/max stripe count"
test_2() {
local comp_file=$DIR/$tdir/$tfile
test_mkdir $DIR/$tdir
rm -f $comp_file
- $LFS setstripe -E 1M -S 1M -E 2M -c 1 $comp_file ||
+ $LFS setstripe -E 1M -S 1M -E -1 -c 1 $comp_file ||
error "Create $comp_file failed"
local comp_cnt=$($LFS getstripe --component-count $comp_file)
test_10() {
local parent=$DIR/$tdir
+ local root=$MOUNT
save_layout_restore_at_exit $MOUNT
rm -rf $parent
- $LFS setstripe -d $MOUNT || error "clear root layout"
+
+ # mount root on $MOUNT2 if FILESET is set
+ if [ -n "$FILESET" ]; then
+ FILESET="" mount_client $MOUNT2 ||
+ error "mount $MOUNT2 fail"
+ root=$MOUNT2
+ fi
+
+ $LFS setstripe -d $root || error "clear root layout"
# set root composite layout
$LFS setstripe -E 2M -c 1 -S 1M -E 16M -c2 -S 2M \
- -E -1 -c 4 -S 4M $MOUNT ||
+ -E -1 -c 4 -S 4M $root ||
error "Set root layout failed"
+ if [ "$root" == "$MOUNT2" ]; then
+ umount_client $MOUNT2 ||
+ error "umount $MOUNT2 fail"
+ fi
+
test_mkdir $parent
# set a different layout for parent
$LFS setstripe -E -1 -c 1 -S 1M $parent ||
}
run_test 15 "Verify component options for lfs find"
-verify_16() {
- local src=$1
- local dst=$2
- local temp=$3
- local msg_prefix=$4
-
- echo "getstripe --yaml $src"
- $LFS getstripe --yaml $src > $temp || error "getstripe $src failed"
- echo "setstripe --yaml=$temp $dst"
- $LFS setstripe --yaml=$temp $dst|| error "setstripe $dst failed"
-
- echo "compare"
- local layout1=$(get_layout_param $src)
- local layout2=$(get_layout_param $dst)
- # compare their layout info
- [ "$layout1" == "$layout2" ] ||
- error "$msg_prefix $src/$dst layouts are not equal"
-}
-
-test_16() {
+test_16a() {
[ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
+ large_xattr_enabled || skip_env "ea_inode feature disabled"
local file=$DIR/$tdir/$tfile
local dir=$DIR/$tdir/dir
$file || error "Create $file failed"
echo "1. PFL file"
- verify_16 $file $file.copy $temp "1. PFL file"
+ verify_yaml_layout $file $file.copy $temp "1. PFL file"
#####################################################################
# 2. plain file
rm -f $file.copy
echo "2. plain file"
- verify_16 $file $file.copy $temp "2. plain file"
+ verify_yaml_layout $file $file.copy $temp "2. plain file"
#####################################################################
# 3. PFL dir
test_mkdir $dir.copy
echo "3. PFL dir"
- verify_16 $dir $dir.copy $temp.dir "3. PFL dir"
+ verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
#####################################################################
# 4. plain dir
$LFS setstripe -c2 -i-1 $dir || error "setstripe $dir failed"
echo "4. plain dir"
- verify_16 $dir $dir.copy $temp.dir "4. plain dir"
+ verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
+}
+run_test 16a "Verify setstripe/getstripe with YAML config file"
+
+test_16b() {
+ [[ $($LCTL get_param mdc.*.import |
+ grep "connect_flags:.*overstriping") ]] ||
+ skip "server does not support overstriping"
+ [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
+ [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
+ skip_env "too many osts, skipping"
+ large_xattr_enabled || skip_env "ea_inode feature disabled"
+
+ local file=$DIR/$tdir/$tfile
+ local dir=$DIR/$tdir/dir
+ local temp=$DIR/$tdir/template
+ # We know OSTCOUNT < (LOV_MAX_STRIPE_COUNT / 2), so this is overstriping
+ local large_count=$((LOV_MAX_STRIPE_COUNT / 2 + 10))
+
+ rm -rf $DIR/$tdir
+ test_mkdir $DIR/$tdir
+
+ #####################################################################
+ # 1. PFL file, overstriping in first comps
+ # set stripe for source file
+ $LFS setstripe -E1m -S 1M -o0,0 -E2m -o1,1 -E3m -C $large_count -E-1 \
+ $file || error "Create $file failed"
+
+ echo "1. PFL file"
+ verify_yaml_layout $file $file.copy $temp "1. PFL file"
+
+ #####################################################################
+ # 2. plain file + overstriping
+ # set stripe for source file
+ rm -f $file
+ $LFS setstripe -C $large_count -i1 $file || error "Create $file failed"
+
+ rm -f $file.copy
+ echo "2. plain file"
+ verify_yaml_layout $file $file.copy $temp "2. plain file"
+
+ #####################################################################
+ # 3. PFL dir + overstriping
+ # set stripe for source dir
+ test_mkdir $dir
+ $LFS setstripe -E1m -S 1M -o 0,0 -E2m -C $large_count -E-1 $dir ||
+ error "setstripe $dir failed"
+
+ test_mkdir $dir.copy
+ echo "3. PFL dir"
+ verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
+
+ #####################################################################
+ # 4. plain dir + overstriping
+ # set stripe for source dir
+ $LFS setstripe -C $large_count $dir || error "setstripe $dir failed"
+
+ echo "4. plain dir"
+ verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
}
-run_test 16 "Verify setstripe/getstripe with YAML config file"
+run_test 16b "Verify setstripe/getstripe with YAML config file + overstriping"
test_17() {
[ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"