X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fsanity-pfl.sh;h=35640cfe1e566ea43eb4ffcdff91728877b33a2a;hb=37d6d157a2a94e022f2e153c9191aa559daec321;hp=f1c7f8f6f69c8a40fccbb9172b91199c3d2585b2;hpb=183f0a19969ce1fc10b8bf5156beaa1fc29bbd0b;p=fs%2Flustre-release.git diff --git a/lustre/tests/sanity-pfl.sh b/lustre/tests/sanity-pfl.sh index f1c7f8f..35640cf 100644 --- a/lustre/tests/sanity-pfl.sh +++ b/lustre/tests/sanity-pfl.sh @@ -4,54 +4,49 @@ # 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! - -[ "$ALWAYS_EXCEPT$EXCEPT" ] && - echo "Skipping tests: $ALWAYS_EXCEPT $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" && exit + skip_env "Need MDS version at least 2.9.51" fi -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 -test_0() { - [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return +assert_DIR +rm -rf $DIR/[Rdfs][0-9]* + +test_0a() { + [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" - local comp_file=$DIR/$tfile + local comp_file=$DIR/$tdir/$tfile local rw_len=$((3 * 1024 * 1024)) # 3M + test_mkdir $DIR/$tdir rm -f $comp_file $LFS setstripe -E 1m -S 1M -c 1 -E -1 -c 1 $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=1k + dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k - local ost_idx1=$($LFS getstripe -I 1 -i $comp_file) - local ost_idx2=$($LFS getstripe -I 2 -i $comp_file) + local ost_idx1=$($LFS getstripe -I1 -i $comp_file) + local ost_idx2=$($LFS getstripe -I2 -i $comp_file) [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2" @@ -59,22 +54,48 @@ test_0() { 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() { - local comp_file=$DIR/$tfile +test_1a() { + local comp_file=$DIR/$tdir/$tfile local rw_len=$((3 * 1024 * 1024)) # 3M + test_mkdir $DIR/$tdir rm -f $comp_file $LFS setstripe -E 1m -S 1m -o 0 -E -1 -o 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=1k + dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k - local ost_idx1=$($LFS getstripe -I 1 -i $comp_file) - local ost_idx2=$($LFS getstripe -I 2 -i $comp_file) + local ost_idx1=$($LFS getstripe -I1 -i $comp_file) + local ost_idx2=$($LFS getstripe -I2 -i $comp_file) [ $ost_idx1 -ne $ost_idx2 ] && error "$ost_idx1 != $ost_idx2" @@ -82,12 +103,82 @@ test_1() { 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/$tfile + local comp_file=$DIR/$tdir/$tfile local rw_len=$((5 * 1024 * 1024)) # 5M + test_mkdir $DIR/$tdir rm -f $comp_file $LFS setstripe -E 1m -S 1m $comp_file || @@ -106,7 +197,7 @@ test_2() { dd if=$comp_file of=/dev/null bs=1M count=2 > /dev/null 2>&1 || error "Read beyond component should short read, not fail" - $LFS setstripe --component-add -E 2M -c 1 $comp_file || + $LFS setstripe --component-add -E 2M -S 1M -c 1 $comp_file || error "Add component to $comp_file failed" comp_cnt=$($LFS getstripe --component-count $comp_file) @@ -130,12 +221,12 @@ del_comp_and_verify() { local left=$3 local size=$4 - local opt="-I" - if [ $id == "init" ]; then - opt="--component-flags" + local opt="-I " + if [ $id == "init" -o $id == "^init" ]; then + opt="--component-flags=" fi - $LFS setstripe --component-del $opt $id $comp_file || + $LFS setstripe --component-del $opt$id $comp_file || error "Delete component $id from $comp_file failed" local comp_cnt=$($LFS getstripe --component-count $comp_file) @@ -148,11 +239,12 @@ del_comp_and_verify() { } test_3() { - local comp_file=$DIR/$tfile + local comp_file=$DIR/$tdir/$tfile + test_mkdir $DIR/$tdir rm -f $comp_file - $LFS setstripe -E 1M -E 64M -c 2 -E -1 -c 3 $comp_file || + $LFS setstripe -E 1M -S 1M -E 64M -c 2 -E -1 -c 3 $comp_file || error "Create $comp_file failed" local comp_cnt=$($LFS getstripe --component-count $comp_file) @@ -169,19 +261,18 @@ test_3() { rm -f $comp_file || error "Delete $comp_file failed" - $LFS setstripe -E 1M -E 16M -E -1 $comp_file || + $LFS setstripe -E 1M -S 1M -E 16M -E -1 $comp_file || error "Create second $comp_file failed" - #instantiate all components, so that objs are allocted - dd if=/dev/zero of=$comp_file bs=1k count=1 seek=16k - + del_comp_and_verify $comp_file "^init" 1 0 del_comp_and_verify $comp_file "init" 0 0 rm -f $comp_file || error "Delete second $comp_file failed" + } run_test 3 "Delete component from existing file" test_4() { - skip "Not supported in PFL" && return + skip "Not supported in PFL" # In PFL project, only LCME_FL_INIT is supported, and it can't # be altered by application. } @@ -193,7 +284,7 @@ test_5() { local subdir=$parent/subdir rm -fr $parent - mkdir -p $parent || error "Create dir $parent failed" + test_mkdir $parent # set default layout to parent directory $LFS setstripe -E 64M -c 2 -i 0 -E -1 -c 4 -i 0 $parent || @@ -205,13 +296,13 @@ test_5() { [ $comp_cnt -ne 2 ] && error "file $comp_cnt != 2" #instantiate all components, so that objs are allocted - dd if=/dev/zero of=$comp_file bs=1k count=1 seek=64k + dd if=/dev/zero of=$comp_file bs=1k count=1 seek=65k - local ost_idx=$($LFS getstripe -I 1 -i $comp_file) + local ost_idx=$($LFS getstripe -I1 -i $comp_file) [ $ost_idx -ne 0 ] && error "component 1 ost_idx $ost_idx != 0" - ost_idx=$($LFS getstripe -I 2 -i $comp_file) + ost_idx=$($LFS getstripe -I2 -i $comp_file) [ $ost_idx -ne 0 ] && error "component 2 ost_idx $ost_idx != 0" @@ -232,7 +323,7 @@ test_5() { error "Delete default layout from $parent failed" comp_cnt=$($LFS getstripe -d --component-count $parent) - [ ! -z "$comp_cnt" ] && error "$comp_cnt isn't empty" + [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0" rm -f $comp_file || error "Delete $comp_file failed" rm -f $subdir/$tfile || error "Delete $subdir/$tfile failed" @@ -242,15 +333,16 @@ test_5() { run_test 5 "Inherit composite layout from parent directory" test_6() { - local comp_file=$DIR/$tfile + local comp_file=$DIR/$tdir/$tfile + test_mkdir $DIR/$tdir rm -f $DIR/$tfile $LFS setstripe -c 1 -S 128K $comp_file || error "Create v1 $comp_file failed" local comp_cnt=$($LFS getstripe --component-count $comp_file) - [ ! -z "$comp_cnt" ] && error "Wrong component count $comp_cnt" + [ $comp_cnt -ne 0 ] && error "Wrong component count $comp_cnt" dd if=/dev/urandom of=$comp_file bs=1M count=5 oflag=sync || error "Write to v1 $comp_file failed" @@ -285,7 +377,7 @@ test_6() { error "Migrate(composite -> v1) $comp_file failed" comp_cnt=$($LFS getstripe --component-count $comp_file) - [ ! -z "$comp_cnt" ] && error "$comp_cnt isn't empty" + [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0" chksum=$(md5sum $comp_file) [ "$old_chksum" != "$chksum" ] && @@ -296,11 +388,11 @@ test_6() { run_test 6 "Migrate composite file" test_7() { - mkdir -p $DIR/$tdir || error "mkdir failed" + test_mkdir $DIR/$tdir chmod 0777 $DIR/$tdir || error "chmod $tdir failed" local comp_file=$DIR/$tdir/$tfile - $RUNAS $LFS setstripe -E 1M -c 1 $comp_file || + $RUNAS $LFS setstripe -E 1M -S 1M -c 1 $comp_file || error "Create composite file $comp_file failed" $RUNAS $LFS setstripe --component-add -E 64M -c 4 $comp_file || @@ -320,24 +412,25 @@ test_8() { local parent=$DIR/$tdir rm -fr $parent - mkdir -p $parent || error "Create dir $parent failed" + test_mkdir $parent $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c 2 -S 2M \ -E -1 -c 4 -S 4M $parent || error "Set default layout to $parent failed" - sh rundbench -C -D $parent 2 || error "debench failed" + sh rundbench -C -D $parent 2 || error "dbench failed" rm -fr $parent || error "Delete dir $parent failed" } -run_test 8 "Run debench over composite files" +run_test 8 "Run dbench over composite files" test_9() { - local comp_file=$DIR/$tfile + 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) @@ -346,17 +439,17 @@ test_9() { replay_barrier $SINGLEMDS # instantiate the 2nd component - dd if=/dev/zero of=$comp_file bs=1k count=1 seek=1k + dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k - local f1=$($LFS getstripe -I 2 $comp_file | + local f1=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}') echo "before MDS recovery, the ost fid of 2nd component is $f1" fail $SINGLEMDS - local f2=$($LFS getstripe -I 2 $comp_file | + local f2=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}') echo "after MDS recovery, the ost fid of 2nd component is $f2" - [ $f1 == $f2 ] || error "$f1 != $f2" + [ "x$f1" == "x$f2" ] || error "$f1 != $f2" } run_test 9 "Replay layout extend object instantiation" @@ -369,17 +462,32 @@ component_dump() { test_10() { local parent=$DIR/$tdir - local root_layout=$(get_layout_param $MOUNT) + 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" - mkdir -p $parent || error "Create dir $parent 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 || error "set $parent layout failed" @@ -408,53 +516,56 @@ test_10() { [ x$f2_expect != x$f2_entry ] && error "$parent/file2 does not inherite root layout" - $LFS setstripe $root_layout $MOUNT return 0 } run_test 10 "Inherit composite template from root" test_11() { - local comp_file=$DIR/$tfile + local comp_file=$DIR/$tdir/$tfile + test_mkdir $DIR/$tdir rm -f $comp_file # only 1st component instantiated - $LFS setstripe -E 1m -E 2m -E 3m -E -1 $comp_file || + $LFS setstripe -E 1M -S 1M -E 2M -E 3M -E -1 $comp_file || error "Create $comp_file failed" - local f1=$($LFS getstripe -I 1 $comp_file | grep "l_fid") + local f1=$($LFS getstripe -I1 $comp_file | grep "l_fid") [[ -z $f1 ]] && error "1: 1st component uninstantiated" - local f2=$($LFS getstripe -I 2 $comp_file | grep "l_fid") + local f2=$($LFS getstripe -I2 $comp_file | grep "l_fid") [[ -n $f2 ]] && error "1: 2nd component instantiated" - local f3=$($LFS getstripe -I 3 $comp_file | grep "l_fid") + local f3=$($LFS getstripe -I3 $comp_file | grep "l_fid") [[ -n $f3 ]] && error "1: 3rd component instantiated" - local f4=$($LFS getstripe -I 4 $comp_file | grep "l_fid") + local f4=$($LFS getstripe -I4 $comp_file | grep "l_fid") [[ -n $f4 ]] && error "1: 4th component instantiated" # the first 2 components instantiated $TRUNCATE $comp_file $((1024*1024*1+1)) - f2=$($LFS getstripe -I 2 $comp_file | grep "l_fid") + f2=$($LFS getstripe -I2 $comp_file | grep "l_fid") [[ -z $f2 ]] && error "2: 2nd component uninstantiated" - f3=$($LFS getstripe -I 3 $comp_file | grep "l_fid") + f3=$($LFS getstripe -I3 $comp_file | grep "l_fid") [[ -n $f3 ]] && error "2: 3rd component instantiated" - f4=$($LFS getstripe -I 4 $comp_file | grep "l_fid") + f4=$($LFS getstripe -I4 $comp_file | grep "l_fid") [[ -n $f4 ]] && error "2: 4th component instantiated" # the first 3 components instantiated $TRUNCATE $comp_file $((1024*1024*3)) $TRUNCATE $comp_file $((1024*1024*1+1)) - f2=$($LFS getstripe -I 2 $comp_file | grep "l_fid") - [[ -z $f2 ]] && error "2: 2nd component uninstantiated" - f3=$($LFS getstripe -I 3 $comp_file | grep "l_fid") + f2=$($LFS getstripe -I2 $comp_file | grep "l_fid") + [[ -z $f2 ]] && error "3: 2nd component uninstantiated" + f3=$($LFS getstripe -I3 $comp_file | grep "l_fid") [[ -z $f3 ]] && error "3: 3rd component uninstantiated" - f4=$($LFS getstripe -I 4 $comp_file | grep "l_fid") + f4=$($LFS getstripe -I4 $comp_file | grep "l_fid") [[ -n $f4 ]] && error "3: 4th component instantiated" - # all 4 components instantiated - dd if=/dev/zero of=$comp_file bs=1k count=1 seek=3k + # all 4 components instantiated, using append write + dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k + ls -l $comp_file + rwv -f $comp_file -w -a -n 2 $((1024*1023)) 1 + ls -l $comp_file - f4=$($LFS getstripe -I 4 $comp_file | grep "l_fid") + f4=$($LFS getstripe -I4 $comp_file | grep "l_fid") [[ -z $f4 ]] && error "4: 4th component uninstantiated" return 0 @@ -462,15 +573,22 @@ test_11() { run_test 11 "Verify component instantiation with write/truncate" test_12() { - [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs" && return + [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs" - local file=$DIR/$tfile + local file=$DIR/$tdir/$tfile + test_mkdir $DIR/$tdir rm -f $file # specify ost list for component - $LFS setstripe -E1m -c2 -o0,1 -E2m -c2 -o1,2 -E3m -c2 -o2,1 \ - -E4m -c2 -o2,0 -E-1 $file || + $LFS setstripe -E 1M -S 1M -c 2 -o 0,1 -E 2M -c 2 -o 1,2 \ + -E 3M -c 2 -o 2,1 -E 4M -c 1 -i 2 -E -1 $file || error "Create $file failed" + + # clear lod component cache + stop $SINGLEMDS || error "stop MDS" + local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/}) + start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "start MDS" + # instantiate all components $TRUNCATE $file $((1024*1024*4+1)) @@ -489,12 +607,355 @@ test_12() { local o4=$($LFS getstripe -I4 $file | awk '/l_ost_idx:/ {printf("%d",$5)}') - [[ $o4 != "20" ]] && error "$o4 is not 20" + [[ $o4 != "2" ]] && error "$o4 is not 2" return 0 } run_test 12 "Verify ost list specification" +test_13() { # LU-9311 + [ $OSTCOUNT -lt 8 ] && skip "needs >= 8 OSTs" + + local file=$DIR/$tfile + local dd_count=4 + local dd_size=$(($dd_count * 1024 * 1024)) + local real_size + + rm -f $file + $LFS setstripe -E 1M -S 1M -c 1 -E 2M -c 2 -E -1 -c -1 -i 1 $file || + error "Create $file failed" + dd if=/dev/zero of=$file bs=1M count=$dd_count + real_size=$(stat -c %s $file) + [ $real_size -eq $dd_size ] || + error "dd actually wrote $real_size != $dd_size bytes" + + rm -f $file +} +run_test 13 "shouldn't reprocess granted resent request" + +test_14() { + [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" + local file=$DIR/$tdir/$tfile + test_mkdir -p $DIR/$tdir + rm -f $file + + $LFS setstripe -E1m -c1 -S1m --pool="pool1" -E2m \ + -E4m -c2 -S2m --pool="pool2" -E-1 $file || + error "Create $file failed" + + # check --pool inheritance + local pool + pool="$($LFS getstripe -I2 --pool $file)" + [ x"$pool" != "xpool1" ] && $LFS getstripe -I2 $file && + error "$file: component 2 doesn't have poolname pool1" + pool="$($LFS getstripe -I4 --pool $file)" + [ x"$pool" != "xpool2" ] && $LFS getstripe -I4 $file && + error "$file: component 4 doesn't have poolname pool2" + + #check --stripe-count inheritance + local count + count="$($LFS getstripe -I2 -c $file)" + [ $count -ne 1 ] && $LFS getstripe -I2 $file && + error "$file: component 2 doesn't have 1 stripe_count" + count="$($LFS getstripe -I4 -c $file)" + [ $count -ne 2 ] && $LFS getstripe -I4 $file && + error "$file: component 4 doesn't have 2 stripe_count" + + #check --stripe-size inheritance + local size + size="$($LFS getstripe -I2 -S $file)" + [ $size -ne $((1024*1024)) ] && $LFS getstripe -I2 $file && + error "$file: component 2 doesn't have 1M stripe_size" + size="$($LFS getstripe -I4 -S $file)" + [ $size -ne $((1024*1024*2)) ] && $LFS getstripe -I4 $file && + error "$file: component 4 doesn't have 2M stripe_size" + + return 0 +} +run_test 14 "Verify setstripe poolname/stripe_count/stripe_size inheritance" + +test_15() { + local parent=$DIR/$tdir + + rm -fr $parent + test_mkdir $parent + + $LFS setstripe -d $parent || error "delete default layout" + + $LFS setstripe -E 1M -S 1M -E 10M -E eof $parent/f1 || error "create f1" + $LFS setstripe -E 4M -E 20M -E eof $parent/f2 || error "create f2" + test_mkdir $parent/subdir + $LFS setstripe -E 6M -S 1M -E 30M -E eof $parent/subdir || + error "setstripe to subdir" + $LFS setstripe -E 8M -E eof $parent/subdir/f3 || error "create f3" + $LFS setstripe -c 1 $parent/subdir/f4 || error "create f4" + + # none + local found=$($LFS find --component-start +2M -E -15M $parent | wc -l) + [ $found -eq 0 ] || error "start+2M, end-15M, $found != 0" + + # f2, f3 + found=$($LFS find --component-start +2M -E -35M $parent | wc -l) + [ $found -eq 2 ] || error "start+2M, end-35M, $found != 2" + + # subdir + found=$($LFS find --component-start +4M -E -eof $parent | wc -l) + [ $found -eq 1 ] || error "start+4M, end-eof, $found != 1" + + local flg_opts="--component-flags init" + # none + found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l) + [ $found -eq 0 ] || + error "before write: start=1M, end=10M, flag=init, $found != 0" + + dd if=/dev/zero of=$parent/f1 bs=1M count=2 || + error "dd $parent/f1 failed" + + # f1 + found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l) + [ $found -eq 1 ] || + error "after write: start=1M, end=10M, flag=init, $found != 1" + + local ext_opts="--component-start -1M -E +5M" + # parent, subdir, f3, f4 + found=$($LFS find $ext_opts $parent | wc -l) + [ $found -eq 4 ] || error "start-1M, end+5M, $found != 4" + + local cnt_opts="--component-count +2" + # subdir + found=$($LFS find $ext_opts $cnt_opts $parent | wc -l) + [ $found -eq 1 ] || error "start-1M, end+5M, count+2, $found != 1" + + # none + found=$($LFS find $ext_opts $cnt_opts $flg_opts $parent | wc -l) + [ $found -eq 0 ] || + error "start-1M, end+5M, count+2, flag=init, $found != 0" + + # f3, f4 + found=$($LFS find $ext_opts ! $cnt_opts $flg_opts $parent | wc -l) + [ $found -eq 2 ] || + error "start-1M, end+5M, !count+2, flag=init, $found != 2" +} +run_test 15 "Verify component options for lfs find" + +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 + local temp=$DIR/$tdir/template + rm -rf $DIR/$tdir + test_mkdir $DIR/$tdir + + ##################################################################### + # 1. PFL file + # set stripe for source file + $LFS setstripe -E1m -S 1M -c2 -o0,1 -E2m -c2 -E3m -o1,0 -E4m -c1 -E-1 \ + $file || error "Create $file failed" + + echo "1. PFL file" + verify_yaml_layout $file $file.copy $temp "1. PFL file" + + ##################################################################### + # 2. plain file + # set stripe for source file + rm -f $file + $LFS setstripe -c2 -o0,1 -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 + # set stripe for source dir + test_mkdir $dir + $LFS setstripe -E1m -S 1M -c2 -E2m -c1 -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 + # set stripe for source dir + $LFS setstripe -c2 -i-1 $dir || error "setstripe $dir failed" + + echo "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 16b "Verify setstripe/getstripe with YAML config file + overstriping" + +test_17() { + [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" + local file=$DIR/$tdir/$tfile + test_mkdir -p $DIR/$tdir + rm -f $file + + $LFS setstripe -E 1M -S 1M -E 2M -c 2 -E -1 -c -1 $file || + error "Create $file failed" + + local s1=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}') + local s2=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}') + local s3=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}') + echo "1st init: comp size 1:$s1 2:$s2 3:$s3" + + # init 2nd component + $TRUNCATE $file $((1024*1024+1)) + local s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}') + local s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}') + echo "2nd init: comp size 1:$s1n 2:$s2n 3:$s3" + + [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n" + [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n" + + # init 3rd component + $TRUNCATE $file $((1024*1024*2+1)) + s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}') + s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}') + local s3n=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}') + echo "3rd init: comp size 1:$s1n 2:$s2n 3:$s3n" + + [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n" + [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n" + [ $s3 -lt $s3n ] || error "3rd comp size $s3 should < $s3n" +} +run_test 17 "Verify LOVEA grows with more component inited" + +check_distribution() { + local file=$1 + local objs + local ave + local obj_min_one=$((OSTCOUNT - 1)) + + objs=$($LFS getstripe $file | + awk '/l_ost_idx:/ { print $5 }' | wc -l) + let ave=$((objs / OSTCOUNT)) + + # collect objects per OST distribution + $LFS getstripe $file | awk '/l_ost_idx:/ { print $5 }' | tr -d "," | + (inuse=( $(for i in $(seq 0 $obj_min_one); do echo 0; done) ) + while read O; do + let inuse[$O]=$((1 + ${inuse[$O]})) + done; + + # verify object distribution varies no more than +-1 + for idx in $(seq 0 $obj_min_one); do + let dif=$((${inuse[$idx]} - ave)) + let dif=${dif#-} + if [ "$dif" -gt 1 ]; then + echo "OST${idx}: ${inuse[$idx]} objects" + error "bad distribution on OST${idx}" + fi + done) +} + +test_18() { + local file1=$DIR/${tfile}-1 + local file2=$DIR/${tfile}-2 + local file3=$DIR/${tfile}-3 + + rm -f $file1 $file2 $file3 + + $LFS setstripe -E 1m -S 1m $file1 || + error "Create $file1 failed" + $LFS setstripe -E 1m -S 1m $file2 || + error "Create $file2 failed" + $LFS setstripe -E 1m -S 1m $file3 || + error "Create $file3 failed" + + local objs=$((OSTCOUNT+1)) + for comp in $(seq 1 $OSTCOUNT); do + $LFS setstripe --component-add -E $((comp+1))M -c 1 $file1 || + error "Add component to $file1 failed 2" + $LFS setstripe --component-add -E $((comp+1))M -c 1 $file2 || + error "Add component to $file2 failed 2" + $LFS setstripe --component-add -E $((comp+1))M -c 1 $file3 || + error "Add component to $file3 failed 2" + done + + $LFS setstripe --component-add -E -1 -c -1 $file1 || + error "Add component to $file1 failed 3" + $LFS setstripe --component-add -E -1 -c -1 $file2 || + error "Add component to $file2 failed 3" + $LFS setstripe --component-add -E -1 -c -1 $file3 || + error "Add component to $file3 failed 3" + + # Instantiate all components + dd if=/dev/urandom of=$file1 bs=1M count=$((objs+1)) || + error "dd failed for $file1" + dd if=/dev/urandom of=$file2 bs=1M count=$((objs+1)) || + error "dd failed for $file2" + dd if=/dev/urandom of=$file3 bs=1M count=$((objs+1)) || + error "dd failed for $file3" + + check_distribution $file1 + check_distribution $file2 + check_distribution $file3 + +} +run_test 18 "check component distribution" + complete $SECONDS check_and_cleanup_lustre exit_status