+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"
+
+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() {
+ [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
+
+ 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_16 $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_16 $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_16 $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_16 $dir $dir.copy $temp.dir "4. plain dir"
+}
+run_test 16 "Verify setstripe/getstripe with YAML config file"
+
+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"
+