3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
9 LUSTRE=${LUSTRE:-$(dirname $0)/..}
10 . $LUSTRE/tests/test-framework.sh
14 # bug number for skipped test:
15 ALWAYS_EXCEPT="$SANITY_PFL_EXCEPT "
16 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
18 # Skip tests for PPC that fail frequently
19 if [[ $(uname -m) = ppc64 ]]; then
20 # bug number: LU-13186 LU-13205 LU-13207 LU-13186
21 ALWAYS_EXCEPT+=" 14 16a 16b 17"
24 if [[ "$ost1_FSTYPE" == "zfs" ]]; then
30 check_and_setup_lustre
32 if [[ "$MDS1_VERSION" -lt $(version_code 2.9.51) ]]; then
33 skip_env "Need MDS version at least 2.9.51"
36 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
37 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
38 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
41 rm -rf $DIR/[Rdfs][0-9]*
46 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
48 local comp_file=$DIR/$tdir/$tfile
49 local rw_len=$((3 * 1024 * 1024)) # 3M
54 $LFS setstripe -E 1m -S 1M -c 1 -E -1 -c 1 $comp_file ||
55 error "Create $comp_file failed"
57 #instantiate all components, so that objs are allocted
58 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
60 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
61 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
63 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
65 small_write $comp_file $rw_len || error "Verify RW failed"
67 rm -f $comp_file || error "Delete $comp_file failed"
69 run_test 0a "Create full components file, no reused OSTs"
72 [[ $($LCTL get_param mdc.*.import |
73 grep "connect_flags:.*overstriping") ]] ||
74 skip "server does not support overstriping"
75 large_xattr_enabled || skip_env "no large xattr support"
79 local comp_file=$DIR/$tdir/$tfile
83 $LFS setstripe -E -1 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
84 error "Create $comp_file failed"
86 local count=$($LFS getstripe -I1 -c $comp_file)
87 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
88 error "stripe count of first component is shrinked to $count"
90 rm -f $comp_file || error "Delete $comp_file failed"
92 # Create file with 1.1*LOV_MAX_STRIPE_COUNT stripes should succeed
93 $LFS setstripe -E 1m -C $((LOV_MAX_STRIPE_COUNT / 10)) -E -1 \
94 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
95 error "Create $comp_file failed"
97 local count=$($LFS getstripe -I2 -c $comp_file)
98 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
99 error "stripe count of second component is shrinked to $count"
101 rm -f $comp_file || error "Delete $comp_file failed"
103 # Create file with 3*LOV_MAX_STRIPE_COUNT stripes should fail
104 $LFS setstripe -E 200G -C $LOV_MAX_STRIPE_COUNT \
105 -E 500G -C $LOV_MAX_STRIPE_COUNT \
106 -E -1 -C $LOV_MAX_STRIPE_COUNT $comp_file &&
107 error "Create $comp_file succeeded"
109 rm -f $comp_file || error "Delete $comp_file failed"
111 run_test 0b "Verify comp stripe count limits"
114 [[ $($LCTL get_param mdc.*.import |
115 grep "connect_flags:.*overstriping") ]] ||
116 skip "server does not support overstriping"
117 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code $SEL_VER) ] &&
118 skip "skipped for lustre < $SEL_VER"
120 large_xattr_enabled || skip_env "no large xattr support"
124 local comp_file=$DIR/$tdir/$tfile
126 test_mkdir $DIR/$tdir
128 # extension size aligned to 64M and limit to 1G
129 $LFS setstripe -E-1 -S64K -C $LOV_MAX_STRIPE_COUNT \
130 -z $((64*1024*((LOV_MAX_STRIPE_COUNT+1023)>>10<<10))) \
131 $comp_file || error "Create $comp_file failed"
133 local count=$($LFS getstripe -I1 -c $comp_file)
134 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
135 error "stripe count is shrinked to $count"
137 run_test 0c "Verify SEL comp stripe count limits"
140 (( $MDS1_VERSION > $(version_code 2.14.50.115) )) ||
141 skip_env "Need MDS version at least 2.14.50.115"
148 # Create parent directory
151 # Component end must be a multiple of stripe size
152 # and a multiple of 64KiB to align with the minimum
154 # Values below 4096 are assumed to be in KiB units.
155 $LFS setstripe -E 127 $tf-1 > /dev/null 2>&1 &&
156 error "creating $tf-1 with '-E 127' should fail"
158 $LFS setstripe -E 128 -S 512 $tf-1 > /dev/null 2>&1 &&
159 error "creating $tf-1 with '-E 128 -S 512' should fail"
161 $LFS setstripe -E 128 $tf-1 ||
162 error "creating $tf-1 failed"
164 yes | dd bs=1K count=129 iflag=fullblock of=$tf-1 &&
165 error "writing to $tf-1 should fail"
167 yes | dd bs=1K count=128 iflag=fullblock of=$tf-1 ||
168 error "writing to $tf-1 failed"
170 comp_end=$($LFS getstripe -I1 -E $tf-1)
171 stripe_size=$($LFS getstripe -I1 -S $tf-1)
173 [[ $comp_end == $((128 * 1024)) ]] ||
174 error "incorrect component end '$comp_end' for $tf-1"
176 [[ $stripe_size == $((128 * 1024)) ]] ||
177 error "incorrect stripe size '$stripe_size' for $tf-1"
179 rm $tf-1 || error "removing $tf-1 failed"
181 # The stripe size must be a multiple of 64KiB.
182 # Values below 4096 are assumed to be in KiB units.
183 $LFS setstripe -E -1 -S 2047 $tf-2 > /dev/null 2>&1 &&
184 error "creating $tf-2 with '-S 2047' should fail"
186 $LFS setstripe -E -1 -S 2048 $tf-2 ||
187 error "creating $tf-2 failed"
189 stripe_size=$($LFS getstripe -I1 -S $tf-2)
190 [[ $stripe_size == $((2048 * 1024)) ]] ||
191 error "incorrect stripe size '$stripe_size' for $tf-2"
193 rm $tf-2 || error "removing $tf-2 failed"
195 run_test 0d "Verify comp end and stripe size"
198 (( $MDS1_VERSION >= $(version_code 2.15.56.112) )) ||
199 skip "Need MDS version at least 2.15.56.112"
201 (( OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
208 # component size 1M can only utilize 1 stripe
209 $LFS setstripe -E1M -S1M -c2 -Eeof -S1M -c2 $tf ||
210 error "failed to setstripe $tf"
212 local sc=$($LFS getstripe -I1 -c $tf)
215 error "expect 1 stripe count instread of $sc"
217 sc=$($LFS getstripe -I2 -c $tf)
220 error "expect 2 stripe count instread of $sc"
223 (( OSTCOUNT >= 3 )) || skip "needs >= 3 OSTs"
226 # component size 2M can only utilize 2 stripes
227 $LFS setstripe -E2M -S1M -c3 -Eeof -S1M -c3 $tf ||
228 error "failed to setstripe $tf"
229 sc=$($LFS getstripe -I1 -c $tf)
232 error "expect 2 stripe count instread of $sc"
234 sc=$($LFS getstripe -I2 -c $tf)
237 error "expect 3 stripe count instread of $sc"
241 # 2nd component size 11M and stripe_size 4M should cross 3 stripes
242 $LFS setstripe -E1M -S1M -c3 -E12M -S4M -c3 $tf ||
243 error "failed to setstripe $tf"
244 sc=$($LFS getstripe -I1 -c $tf)
247 error "expect 1 stripe count instread of $sc"
249 sc=$($LFS getstripe -I2 -c $tf)
252 error "expect 3 stripe count instread of $sc"
255 run_test 0e "lfs setstripe should limite stripe count for component size"
258 local comp_file=$DIR/$tdir/$tfile
259 local rw_len=$((3 * 1024 * 1024)) # 3M
261 test_mkdir $DIR/$tdir
264 $LFS setstripe -E 1m -S 1m -o 0 -E -1 -o 0 $comp_file ||
265 error "Create $comp_file failed"
267 #instantiate all components, so that objs are allocted
268 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
270 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
271 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
273 [ $ost_idx1 -ne $ost_idx2 ] && error "$ost_idx1 != $ost_idx2"
275 small_write $comp_file $rw_len || error "Verify RW failed"
277 rm -f $comp_file || error "Delete $comp_file failed"
279 run_test 1a "Create full components file, reused OSTs"
281 # test overstriping (>1 stripe/OST within a component)
283 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
284 [[ $($LCTL get_param mdc.*.import |
285 grep "connect_flags:.*overstriping") ]] ||
286 skip "server does not support overstriping"
288 local comp_file=$DIR/$tdir/$tfile
289 local rw_len=$((3 * 1024 * 1024)) # 3M
291 test_mkdir $DIR/$tdir
293 $LFS setstripe -E 2m -S 1m -o 0,0 -E -1 -o 1,1,0,0 $comp_file ||
294 error "Create $comp_file failed"
296 #instantiate all components, so that objs are allocted
297 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=1M
299 $LFS getstripe $comp_file
300 local OSTS_1=$($LFS getstripe -I1 $comp_file | grep -o 'l_ost_idx.*' |
301 awk -e '{print $2}' | tr "\n" "\0")
302 local OSTS_2=$($LFS getstripe -I2 $comp_file | grep -o 'l_ost_idx.*' |
303 awk -e '{print $2}' | tr "\n" "\0")
307 [ "$OSTS_1" = "0,0," ] || error "incorrect OSTs($OSTS_1) in component 1"
308 [ "$OSTS_2" = "1,1,0,0," ] ||
309 error "incorrect OSTs($OSTS_2) in component 2"
311 small_write $comp_file $rw_len || error "Verify RW failed"
313 rm -f $comp_file || error "Delete $comp_file failed"
315 run_test 1b "Create full components file, overstriping in components"
317 # test overstriping with max stripe count
319 [[ $($LCTL get_param mdc.*.import |
320 grep "connect_flags:.*overstriping") ]] ||
321 skip "server does not support overstriping"
322 large_xattr_enabled || skip_env "no large xattr support"
326 local comp_file=$DIR/$tdir/$tfile
327 local rw_len=$((3 * 1024 * 1024)) # 3M
329 test_mkdir $DIR/$tdir
331 $LFS setstripe -E 10m -C 10 -E 110M -C 100 -E -1 \
332 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
333 error "Create $comp_file failed"
335 # Seek & write in to last component so all objects are allocated
336 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=20000
338 local ssize=$($LFS getstripe -S -I1 $DIR/$tdir/$tfile)
339 local count=$($LFS getstripe -c -I1 $DIR/$tdir/$tfile)
340 count=$((count * ssize / 1048576))
341 [ $count -eq 10 ] || error "comp1 stripe count $count, should be 10"
342 ssize=$($LFS getstripe -S -I2 $DIR/$tdir/$tfile)
343 count=$($LFS getstripe -c -I2 $DIR/$tdir/$tfile)
344 count=$((count * ssize / 1048576))
345 [ $count -eq 100 ] || error "comp2 stripe count $count, should be 100"
346 ssize=$($LFS getstripe -S -I3 $DIR/$tdir/$tfile)
347 count=$($LFS getstripe -c -I3 $DIR/$tdir/$tfile)
348 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
349 echo "comp4 stripe count $count != $LOV_MAX_STRIPE_COUNT"
351 small_write $comp_file $rw_len || error "Verify RW failed"
353 rm -f $comp_file || error "Delete $comp_file failed"
355 run_test 1c "Test overstriping w/max stripe count"
358 local comp_file=$DIR/$tdir/$tfile
359 local rw_len=$((5 * 1024 * 1024)) # 5M
362 test_mkdir $DIR/$tdir
365 multiop $comp_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
366 error "create failed $comp_file"
368 $LFS setstripe --component-add $params $comp_file ||
369 error "Add component to $comp_file failed"
371 check_component_count $comp_file 1
373 dd if=/dev/zero of=$comp_file bs=1M count=1 > /dev/null 2>&1 ||
374 error "Write first component failed"
375 dd if=$comp_file of=/dev/null bs=1M count=1 > /dev/null 2>&1 ||
376 error "Read first component failed"
378 dd if=/dev/zero of=$comp_file bs=1M count=2 > /dev/null 2>&1 &&
379 error "Write beyond component should fail"
380 dd if=$comp_file of=/dev/null bs=1M count=2 > /dev/null 2>&1 ||
381 error "Read beyond component should short read, not fail"
383 $LFS setstripe --component-add -E 2M -S 1M -c 1 $comp_file ||
384 error "Add component to $comp_file failed"
386 check_component_count $comp_file 2
388 $LFS setstripe --component-add -E -1 -c 3 $comp_file ||
389 error "Add last component to $comp_file failed"
391 check_component_count $comp_file 3
393 small_write $comp_file $rw_len || error "Verify RW failed"
395 rm -f $comp_file || error "Delete $comp_file failed"
399 base_test_2 "-E 1m -S 1m"
401 run_test 2a "Add components to existing file"
404 base_test_2 "-E 1m -L mdt"
406 run_test 2b "Add components w/DOM to existing file"
408 del_comp_and_verify() {
415 if [ $id == "init" -o $id == "^init" ]; then
416 opt="--component-flags="
419 $LFS setstripe --component-del $opt$id $comp_file ||
420 error "Delete component $id from $comp_file failed"
422 local comp_cnt=$($LFS getstripe --component-count $comp_file)
423 if grep -q "has no stripe info" <<< "$comp_cnt" ; then
426 [ $comp_cnt -ne $left ] && error "$comp_cnt != $left"
428 $CHECKSTAT -s $size $comp_file || error "size != $size"
432 local comp_file=$DIR/$tdir/$tfile
435 test_mkdir $DIR/$tdir
438 $LFS setstripe $params $comp_file || error "Create $comp_file failed"
440 check_component_count $comp_file 3
442 dd if=/dev/zero of=$comp_file bs=1M count=2
444 $LFS setstripe --component-del -I 2 $comp_file &&
445 error "Component deletion makes hole"
447 del_comp_and_verify $comp_file 3 2 $((2 * 1024 * 1024))
448 del_comp_and_verify $comp_file 2 1 $((1 * 1024 * 1024))
449 del_comp_and_verify $comp_file 1 0 0
451 rm -f $comp_file || error "Delete $comp_file failed"
453 $LFS setstripe -E 1M -S 1M -E 16M -E -1 $comp_file ||
454 error "Create second $comp_file failed"
456 del_comp_and_verify $comp_file "^init" 1 0
457 del_comp_and_verify $comp_file "init" 0 0
458 rm -f $comp_file || error "Delete second $comp_file failed"
462 base_test_3 "-E 1M -S 1M -E 64M -c 2 -E -1 -c 3"
464 run_test 3a "Delete components from existing file"
467 base_test_3 "-E 1M -L mdt -E 64M -S 1M -c 2 -E -1 -c 3"
469 run_test 3b "Delete components w/DOM from existing file"
472 skip "Not supported in PFL"
473 # In PFL project, only LCME_FL_INIT is supported, and it can't
474 # be altered by application.
476 run_test 4 "Modify component flags in existing file"
479 local parent=$DIR/$tdir
480 local comp_file=$DIR/$tdir/$tfile
481 local subdir=$parent/subdir
486 # set default layout to parent directory
487 $LFS setstripe -E 64M -c 2 -i 0 -E -1 -c 4 -i 0 $parent ||
488 error "Set default layout to $parent failed"
490 # create file under parent
491 touch $comp_file || error "Create $comp_file failed"
492 check_component_count $comp_file 2
494 #instantiate all components, so that objs are allocted
495 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=65k
497 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
498 [ $ost_idx -ne 0 ] &&
499 error "component 1 ost_idx $ost_idx != 0"
501 ost_idx=$($LFS getstripe -I2 -i $comp_file)
502 [ $ost_idx -ne 0 ] &&
503 error "component 2 ost_idx $ost_idx != 0"
505 # create subdir under parent
506 mkdir -p $subdir || error "Create subdir $subdir failed"
508 comp_cnt=$($LFS getstripe -d --component-count $subdir)
509 [ $comp_cnt -ne 2 ] && error "subdir $comp_cnt != 2"
511 # create file under subdir
512 touch $subdir/$tfile || error "Create $subdir/$tfile failed"
514 check_component_count $subdir/$tfile 2
516 # delete default layout setting from parent
517 $LFS setstripe -d $parent ||
518 error "Delete default layout from $parent failed"
520 comp_cnt=$($LFS getstripe -d --component-count $parent)
521 [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0"
523 rm -f $comp_file || error "Delete $comp_file failed"
524 rm -f $subdir/$tfile || error "Delete $subdir/$tfile failed"
525 rm -r $subdir || error "Delete subdir $subdir failed"
526 rmdir $parent || error "Delete dir $parent failed"
528 run_test 5 "Inherit composite layout from parent directory"
531 local comp_file=$DIR/$tdir/$tfile
533 test_mkdir $DIR/$tdir
536 $LFS setstripe -c 1 -S 128K $comp_file ||
537 error "Create v1 $comp_file failed"
539 check_component_count $comp_file 0
541 dd if=/dev/urandom of=$comp_file bs=1M count=5 oflag=sync ||
542 error "Write to v1 $comp_file failed"
544 local old_chksum=$(md5sum $comp_file)
546 # Migrate v1 to composite
547 $LFS migrate -E 1M -S 512K -c 1 -E -1 -S 1M -c 2 $comp_file ||
548 error "Migrate(v1 -> composite) $comp_file failed"
550 check_component_count $comp_file 2
552 local chksum=$(md5sum $comp_file)
553 [ "$old_chksum" != "$chksum" ] &&
554 error "(v1 -> compsoite) $old_chksum != $chksum"
556 # Migrate composite to composite
557 $LFS migrate -E 1M -S 1M -c 2 -E 4M -S 1M -c 2 \
558 -E -1 -S 3M -c 3 $comp_file ||
559 error "Migrate(compsoite -> composite) $comp_file failed"
561 check_component_count $comp_file 3
563 chksum=$(md5sum $comp_file)
564 [ "$old_chksum" != "$chksum" ] &&
565 error "(composite -> compsoite) $old_chksum != $chksum"
567 # Migrate composite to v1
568 $LFS migrate -c 2 -S 2M $comp_file ||
569 error "Migrate(composite -> v1) $comp_file failed"
571 check_component_count $comp_file 0
573 chksum=$(md5sum $comp_file)
574 [ "$old_chksum" != "$chksum" ] &&
575 error "(composite -> v1) $old_chksum != $chksum"
577 rm -f $comp_file || error "Delete $comp_file failed"
579 run_test 6 "Migrate composite file"
582 test_mkdir $DIR/$tdir
583 chmod 0777 $DIR/$tdir || error "chmod $tdir failed"
585 local comp_file=$DIR/$tdir/$tfile
586 $RUNAS $LFS setstripe -E 1M -S 1M -c 1 $comp_file ||
587 error "Create composite file $comp_file failed"
589 $RUNAS $LFS setstripe --component-add -E 64M -c 4 $comp_file ||
590 error "Add component to $comp_file failed"
592 $RUNAS $LFS setstripe --component-del -I 2 $comp_file ||
593 error "Delete component from $comp_file failed"
595 $RUNAS $LFS setstripe --component-add -E -1 -c 5 $comp_file ||
596 error "Add last component to $comp_file failed"
598 rm $comp_file || error "Delete composite failed"
600 run_test 7 "Add/Delete/Create composite file by non-privileged user"
603 local parent=$DIR/$tdir
606 mkdir_on_mdt0 $parent
608 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c 2 -S 2M \
609 -E -1 -c 4 -S 4M $parent ||
610 error "Set default layout to $parent failed"
612 bash rundbench -C -D $parent 2 || error "dbench failed"
614 rm -fr $parent || error "Delete dir $parent failed"
616 run_test 8 "Run dbench over composite files"
619 local comp_file=$DIR/$tdir/$tfile
621 test_mkdir $DIR/$tdir
624 $LFS setstripe -E 1M -S 1M -E -1 -c 1 $comp_file ||
625 error "Create $comp_file failed"
627 check_component_count $comp_file 2
629 replay_barrier $SINGLEMDS
631 # instantiate the 2nd component
632 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
634 local f1=$($LFS getstripe -I2 $comp_file |
635 awk '/l_fid:/ {print $7}')
636 echo "before MDS recovery, the ost fid of 2nd component is $f1"
639 local f2=$($LFS getstripe -I2 $comp_file |
640 awk '/l_fid:/ {print $7}')
641 echo "after MDS recovery, the ost fid of 2nd component is $f2"
642 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
644 run_test 9 "Replay layout extend object instantiation"
647 echo $($LFS getstripe $1 |
648 awk '$1 == "lcm_entry_count:" { printf("%d", $2) }
649 $1 == "lcme_extent.e_start:" { printf("[%#lx", $2) }
650 $1 == "lcme_extent.e_end:" { printf(",%s]", $2) }')
654 local parent=$DIR/$tdir
657 save_layout_restore_at_exit $MOUNT
661 # mount root on $MOUNT2 if FILESET is set
662 if [ -n "$FILESET" ]; then
663 FILESET="" mount_client $MOUNT2 ||
664 error "mount $MOUNT2 fail"
668 $LFS setstripe -d $root || error "clear root layout"
670 # set root composite layout
671 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c2 -S 2M \
672 -E -1 -c 4 -S 4M $root ||
673 error "Set root layout failed"
675 if [ "$root" == "$MOUNT2" ]; then
676 umount_client $MOUNT2 ||
677 error "umount $MOUNT2 fail"
681 # set a different layout for parent
682 $LFS setstripe -E -1 -c 1 -S 1M $parent ||
683 error "set $parent layout failed"
686 local f1_entry=$(component_dump $parent/file1)
688 # delete parent's layout
689 $LFS setstripe -d $parent || error "Clear $parent layout failed"
692 local f2_entry=$(component_dump $parent/file2)
694 # verify layout inheritance
696 local f1_expect="1[0,EOF]"
697 local f2_expect="3[0,2097152][0x200000,16777216][0x1000000,EOF]"
699 echo "f1 expect=$f1_expect"
700 echo "f1 get =$f1_entry"
701 echo "f2 expect=$f2_expect"
702 echo "f2 get =$f2_entry"
704 [ x$f1_expect != x$f1_entry ] &&
705 error "$parent/file1 does not inherite parent layout"
706 [ x$f2_expect != x$f2_entry ] &&
707 error "$parent/file2 does not inherite root layout"
711 run_test 10 "Inherit composite template from root"
714 local comp_file=$DIR/$tdir/$tfile
715 test_mkdir $DIR/$tdir
718 # only 1st component instantiated
719 $LFS setstripe -E 1M -S 1M -E 2M -E 3M -E -1 $comp_file ||
720 error "Create $comp_file failed"
722 local f1=$($LFS getstripe -I1 $comp_file | grep "l_fid")
723 [[ -z $f1 ]] && error "1: 1st component uninstantiated"
724 local f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
725 [[ -n $f2 ]] && error "1: 2nd component instantiated"
726 local f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
727 [[ -n $f3 ]] && error "1: 3rd component instantiated"
728 local f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
729 [[ -n $f4 ]] && error "1: 4th component instantiated"
731 # the first 2 components instantiated
732 # Truncate to exact start of new component - LU-12586
733 $TRUNCATE $comp_file $((1024*1024*1))
735 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
736 [[ -z $f2 ]] && error "2: 2nd component uninstantiated"
737 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
738 [[ -n $f3 ]] && error "2: 3rd component instantiated"
739 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
740 [[ -n $f4 ]] && error "2: 4th component instantiated"
742 # the first 3 components instantiated
743 $TRUNCATE $comp_file $((1024*1024*3 - 1))
744 $TRUNCATE $comp_file $((1024*1024*1+1))
746 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
747 [[ -z $f2 ]] && error "3: 2nd component uninstantiated"
748 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
749 [[ -z $f3 ]] && error "3: 3rd component uninstantiated"
750 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
751 [[ -n $f4 ]] && error "3: 4th component instantiated"
753 # all 4 components instantiated, using append write
754 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
756 rwv -f $comp_file -w -a -n 2 $((1024*1023)) 1
759 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
760 [[ -z $f4 ]] && error "4: 4th component uninstantiated"
764 run_test 11a "Verify component instantiation with write/truncate"
767 [ $OSTCOUNT -lt 4 ] && skip "needs >= 4 OSTs"
769 local file=$DIR/$tdir/$tfile
771 test_mkdir $DIR/$tdir
774 $LFS setstripe -E 1m -E 1g -c 4 -E eof $DIR/$tdir ||
775 error "setstripe dir $DIR/$tdir failed"
776 expand_truncate_test $file ||
777 error "expand_truncate_test failed on $file"
779 run_test 11b "truncate file set file size correctly"
782 [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs"
784 local file=$DIR/$tdir/$tfile
785 test_mkdir $DIR/$tdir
788 # specify ost list for component
789 $LFS setstripe -E 2M -S 1M -c 2 -o 0,1 -E 4M -c 2 -o 1,2 \
790 -E 6M -c 2 -o 2,1 -E 8M -c 1 -i 2 -E -1 $file ||
791 error "Create $file failed"
793 # clear lod component cache
794 stop $SINGLEMDS || error "stop MDS"
795 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
796 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "start MDS"
798 # instantiate all components
799 $TRUNCATE $file $((1024*1024*8+1))
801 #verify object alloc order
802 local o1=$($LFS getstripe -I1 $file |
803 awk '/l_ost_idx:/ {printf("%d",$5)}')
804 [[ $o1 != "01" ]] && error "$o1 is not 01"
806 local o2=$($LFS getstripe -I2 $file |
807 awk '/l_ost_idx:/ {printf("%d",$5)}')
808 [[ $o2 != "12" ]] && error "$o2 is not 12"
810 local o3=$($LFS getstripe -I3 $file |
811 awk '/l_ost_idx:/ {printf("%d",$5)}')
812 [[ $o3 != "21" ]] && error "$o3 is not 21"
814 local o4=$($LFS getstripe -I4 $file |
815 awk '/l_ost_idx:/ {printf("%d",$5)}')
816 [[ $o4 != "2" ]] && error "$o4 is not 2"
820 run_test 12 "Verify ost list specification"
822 test_13() { # LU-9311
823 [ $OSTCOUNT -lt 8 ] && skip "needs >= 8 OSTs"
825 local file=$DIR/$tfile
827 local dd_size=$(($dd_count * 1024 * 1024))
831 $LFS setstripe -E 1M -S 1M -c 1 -E 2M -c 2 -E -1 -c -1 -i 1 $file ||
832 error "Create $file failed"
833 dd if=/dev/zero of=$file bs=1M count=$dd_count
834 real_size=$(stat -c %s $file)
835 [ $real_size -eq $dd_size ] ||
836 error "dd actually wrote $real_size != $dd_size bytes"
840 run_test 13 "shouldn't reprocess granted resent request"
843 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
844 local file=$DIR/$tdir/$tfile
845 test_mkdir -p $DIR/$tdir
850 create_pool $FSNAME.$p1 || error "create_pool $FSNAME.$p1 failed"
851 create_pool $FSNAME.$p2 || error "create_pool $FSNAME.$p2 failed"
852 $LFS setstripe -E1m -c1 -S1m --pool=$p1 -E2m \
853 -E4m -c2 -S2m --pool=$p2 -E-1 $file ||
854 error "Create $file failed"
856 # check --pool inheritance
858 pool="$($LFS getstripe -I2 --pool $file)"
859 [ x"$pool" != "xpool1" ] && $LFS getstripe -I2 $file &&
860 error "$file: component 2 doesn't have poolname pool1"
861 pool="$($LFS getstripe -I4 --pool $file)"
862 [ x"$pool" != "xpool2" ] && $LFS getstripe -I4 $file &&
863 error "$file: component 4 doesn't have poolname pool2"
865 #check --stripe-count inheritance
867 count="$($LFS getstripe -I2 -c $file)"
868 [ $count -ne 1 ] && $LFS getstripe -I2 $file &&
869 error "$file: component 2 doesn't have 1 stripe_count"
870 count="$($LFS getstripe -I4 -c $file)"
871 [ $count -ne 2 ] && $LFS getstripe -I4 $file &&
872 error "$file: component 4 doesn't have 2 stripe_count"
874 #check --stripe-size inheritance
876 size="$($LFS getstripe -I2 -S $file)"
877 [ $size -ne $((1024*1024)) ] && $LFS getstripe -I2 $file &&
878 error "$file: component 2 doesn't have 1M stripe_size"
879 size="$($LFS getstripe -I4 -S $file)"
880 [ $size -ne $((1024*1024*2)) ] && $LFS getstripe -I4 $file &&
881 error "$file: component 4 doesn't have 2M stripe_size"
885 run_test 14 "Verify setstripe poolname/stripe_count/stripe_size inheritance"
888 local parent=$DIR/$tdir
893 $LFS setstripe -d $parent || error "delete default layout"
895 $LFS setstripe -E 1M -S 1M -E 10M -E eof $parent/f1 || error "create f1"
896 $LFS setstripe -E 4M -E 20M -E eof $parent/f2 || error "create f2"
897 test_mkdir $parent/subdir
898 $LFS setstripe -E 6M -S 1M -c1 -E 30M -c4 -E eof -c $OSTCOUNT \
899 $parent/subdir || error "setstripe to subdir"
900 $LFS setstripe -E 8M -E eof $parent/subdir/f3 || error "create f3"
901 $LFS setstripe -c 1 $parent/subdir/f4 || error "create f4"
904 local found=$($LFS find --component-start +2M -E -15M $parent | wc -l)
905 [ $found -eq 0 ] || error "start+2M, end-15M, $found != 0"
908 found=$($LFS find --component-start +2M -E -35M $parent | wc -l)
909 [ $found -eq 2 ] || error "start+2M, end-35M, $found != 2"
912 found=$($LFS find --component-start +4M -E -eof $parent | wc -l)
913 [ $found -eq 1 ] || error "start+4M, end-eof, $found != 1"
915 local flg_opts="--component-flags init"
917 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
919 error "before write: start=1M, end=10M, flag=init, $found != 0"
921 dd if=/dev/zero of=$parent/f1 bs=1M count=2 ||
922 error "dd $parent/f1 failed"
925 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
927 error "after write: start=1M, end=10M, flag=init, $found != 1"
929 local ext_opts="--component-start -1M -E +5M"
930 # parent, subdir, f3, f4
931 found=$($LFS find $ext_opts $parent | wc -l)
932 [ $found -eq 4 ] || error "start-1M, end+5M, $found != 4"
934 local cnt_opts="--component-count +2"
936 found=$($LFS find $ext_opts $cnt_opts $parent | wc -l)
937 [ $found -eq 1 ] || error "start-1M, end+5M, count+2, $found != 1"
940 found=$($LFS find $ext_opts $cnt_opts $flg_opts $parent | wc -l)
942 error "start-1M, end+5M, count+2, flag=init, $found != 0"
945 found=$($LFS find $ext_opts ! $cnt_opts $flg_opts $parent | wc -l)
947 error "start-1M, end+5M, !count+2, flag=init, $found != 2"
949 # check last component stripe count
950 if [ $OSTCOUNT -gt 1 ]; then
951 touch $parent/subdir/f5
952 $TRUNCATE $parent/subdir/f5 $((32*1024*1024))
953 found=$($LFS find $parent/subdir -c $OSTCOUNT)
954 [[ "$found" == "$parent/subdir/f5" ]] ||
955 error "got '$found' with stripe_count=$OSTCOUNT, not f5"
958 run_test 15 "Verify component options for lfs find"
961 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
962 large_xattr_enabled || skip_env "ea_inode feature disabled"
964 local file=$DIR/$tdir/$tfile
965 local dir=$DIR/$tdir/dir
966 local temp=$DIR/$tdir/template
968 test_mkdir $DIR/$tdir
970 #####################################################################
972 # set stripe for source file
973 $LFS setstripe -E1m -S 1M -c2 -o0,1 -E2m -c2 -E3m -o1,0 -E4m -c1 -E-1 \
974 $file || error "Create $file failed"
977 verify_yaml_layout $file $file.copy $temp "1. PFL file"
979 #####################################################################
981 # set stripe for source file
983 $LFS setstripe -c2 -o0,1 -i1 $file || error "Create $file failed"
987 verify_yaml_layout $file $file.copy $temp "2. plain file"
989 #####################################################################
991 # set stripe for source dir
993 $LFS setstripe -E1m -S 1M -c2 -E2m -c1 -E-1 $dir ||
994 error "setstripe $dir failed"
998 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
1000 #####################################################################
1002 # set stripe for source dir
1003 $LFS setstripe -c2 -i-1 $dir || error "setstripe $dir failed"
1006 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
1008 run_test 16a "Verify setstripe/getstripe with YAML config file"
1011 [[ $($LCTL get_param mdc.*.import |
1012 grep "connect_flags:.*overstriping") ]] ||
1013 skip "server does not support overstriping"
1014 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1015 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1016 skip_env "too many osts, skipping"
1017 large_xattr_enabled || skip_env "ea_inode feature disabled"
1021 local file=$DIR/$tdir/$tfile
1022 local dir=$DIR/$tdir/dir
1023 local temp=$DIR/$tdir/template
1024 # We know OSTCOUNT < (LOV_MAX_STRIPE_COUNT / 2), so this is overstriping
1025 local large_count=$((LOV_MAX_STRIPE_COUNT / 2 + 10))
1028 test_mkdir $DIR/$tdir
1030 #####################################################################
1031 # 1. PFL file, overstriping in first comps
1032 # set stripe for source file
1033 $LFS setstripe -E1m -S 1M -o0,0 -E2m -o1,1 -E3m -C $large_count -E-1 \
1034 $file || error "Create $file failed"
1037 verify_yaml_layout $file $file.copy $temp "1. PFL file"
1039 #####################################################################
1040 # 2. plain file + overstriping
1041 # set stripe for source file
1043 $LFS setstripe -C $large_count -i1 $file || error "Create $file failed"
1046 echo "2. plain file"
1047 verify_yaml_layout $file $file.copy $temp "2. plain file"
1049 #####################################################################
1050 # 3. PFL dir + overstriping
1051 # set stripe for source dir
1053 $LFS setstripe -E1m -S 1M -o 0,0 -E2m -C $large_count -E-1 $dir ||
1054 error "setstripe $dir failed"
1056 test_mkdir $dir.copy
1058 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
1060 #####################################################################
1061 # 4. plain dir + overstriping
1062 # set stripe for source dir
1063 $LFS setstripe -C $large_count $dir || error "setstripe $dir failed"
1066 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
1068 run_test 16b "Verify setstripe/getstripe with YAML config file + overstriping"
1071 (( $MDS1_VERSION >= $(version_code 2.13.53.205) )) ||
1072 skip "need MDS version at least 2.13.53.205"
1074 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1076 local file=$DIR/$tdir/$tfile
1077 local dir=$DIR/$tdir/dir
1078 local temp=$DIR/$tdir/template
1080 test_mkdir $DIR/$tdir
1082 #####################################################################
1084 # set stripe for source file
1085 $LFS setstripe -E256M -S 1M -c2 -o0,1 -z 64M -E-1 -o1,0 -z 128M \
1086 $file || error "Create $file failed"
1089 verify_yaml_layout $file $file.copy $temp "1. PFL file"
1091 #####################################################################
1093 # set stripe for source dir
1095 $LFS setstripe -E256M -S 1M -c2 -z 64M -E-1 -z 128M \
1096 $dir || error "setstripe $dir failed"
1098 test_mkdir $dir.copy
1099 echo "2. SEL template on dir"
1100 verify_yaml_layout $dir $dir.copy $temp.dir "2. PFL dir"
1102 run_test 16c "Verify setstripe/getstripe for SEL layout with YAML config file"
1105 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1107 local file=$DIR/$tdir/$tfile
1108 local dir=$DIR/$tdir/dir
1109 local temp=$DIR/$tdir/template
1111 test_mkdir $DIR/$tdir
1113 #####################################################################
1115 # set stripe for source file
1116 $LFS setstripe -E1m -L mdt -E-1 -o1,0 $file ||
1117 error "Create $file failed"
1120 verify_yaml_layout $file $file.copy $temp "1. DOM file"
1122 #####################################################################
1124 # set stripe for source dir
1126 $LFS setstripe -E1m -L mdt -E-1 -o1,0 $dir || error "Create $dir failed"
1128 test_mkdir $dir.copy
1130 verify_yaml_layout $dir $dir.copy $temp.dir "2. DOM dir"
1132 run_test 16d "Verify setstripe/getstripe for DOM layout with YAML config file"
1136 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1137 local file=$DIR/$tdir/$tfile
1138 test_mkdir -p $DIR/$tdir
1141 $LFS setstripe -E 1M -S 1M -E 3M -c 2 -E -1 -c -1 $file ||
1142 error "Create $file failed"
1144 local s1=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
1145 local s2=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
1146 local s3=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
1147 echo "1st init: comp size 1:$s1 2:$s2 3:$s3"
1149 # init 2nd component
1150 $TRUNCATE $file $((1024*1024+1))
1151 local s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
1152 local s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
1153 echo "2nd init: comp size 1:$s1n 2:$s2n 3:$s3"
1155 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
1156 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
1158 # init 3rd component
1159 $TRUNCATE $file $((1024*1024*3+1))
1160 s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
1161 s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
1162 local s3n=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
1163 echo "3rd init: comp size 1:$s1n 2:$s2n 3:$s3n"
1165 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
1166 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
1167 [ $s3 -lt $s3n ] || error "3rd comp size $s3 should < $s3n"
1169 run_test 17 "Verify LOVEA grows with more component inited"
1171 check_distribution() {
1175 local obj_min_one=$((OSTCOUNT - 1))
1177 objs=$($LFS getstripe $file |
1178 awk '/l_ost_idx:/ { print $5 }' | wc -l)
1179 let ave=$((objs / OSTCOUNT))
1181 # collect objects per OST distribution
1182 $LFS getstripe $file | awk '/l_ost_idx:/ { print $5 }' | tr -d "," |
1183 (inuse=( $(for i in $(seq 0 $obj_min_one); do echo 0; done) )
1185 let inuse[$O]=$((1 + ${inuse[$O]}))
1188 # verify object distribution varies no more than +-1
1189 for idx in $(seq 0 $obj_min_one); do
1190 let dif=$((${inuse[$idx]} - ave))
1192 if [ "$dif" -gt 1 ]; then
1193 echo "OST${idx}: ${inuse[$idx]} objects"
1194 error "bad distribution on OST${idx}"
1200 local file1=$DIR/${tfile}-1
1201 local file2=$DIR/${tfile}-2
1202 local file3=$DIR/${tfile}-3
1204 rm -f $file1 $file2 $file3
1206 $LFS setstripe -E 1m -S 1m $file1 ||
1207 error "Create $file1 failed"
1208 $LFS setstripe -E 1m -S 1m $file2 ||
1209 error "Create $file2 failed"
1210 $LFS setstripe -E 1m -S 1m $file3 ||
1211 error "Create $file3 failed"
1213 local objs=$((OSTCOUNT+1))
1214 for comp in $(seq 1 $OSTCOUNT); do
1215 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file1 ||
1216 error "Add component to $file1 failed 2"
1217 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file2 ||
1218 error "Add component to $file2 failed 2"
1219 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file3 ||
1220 error "Add component to $file3 failed 2"
1223 $LFS setstripe --component-add -E -1 -c -1 $file1 ||
1224 error "Add component to $file1 failed 3"
1225 $LFS setstripe --component-add -E -1 -c -1 $file2 ||
1226 error "Add component to $file2 failed 3"
1227 $LFS setstripe --component-add -E -1 -c -1 $file3 ||
1228 error "Add component to $file3 failed 3"
1230 # Instantiate all components
1231 dd if=/dev/urandom of=$file1 bs=1M count=$((objs+1)) ||
1232 error "dd failed for $file1"
1233 dd if=/dev/urandom of=$file2 bs=1M count=$((objs+1)) ||
1234 error "dd failed for $file2"
1235 dd if=/dev/urandom of=$file3 bs=1M count=$((objs+1)) ||
1236 error "dd failed for $file3"
1238 check_distribution $file1
1239 check_distribution $file2
1240 check_distribution $file3
1243 run_test 18 "check component distribution"
1247 local already_created=${2:-0}
1248 local rw_len=$((3 * 1024 * 1024)) # 3M
1252 if [ $already_created != 1 ]; then
1253 test_mkdir -p $DIR/$tdir
1254 $LFS setstripe --extension-size 64M -c 1 -E -1 $comp_file ||
1255 error "Create $comp_file failed"
1258 # write past end of first component, so it is extended
1259 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=127 conv=notrunc ||
1260 error "dd to extend failed"
1262 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1263 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1264 local ssize=$($LFS getstripe -S -I1 $comp_file)
1266 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1267 [ $ost_idx2 -ne "-1" ] && error "second component init $ost_idx2"
1269 flg_opts="--comp-flags init"
1270 found=$($LFS find --comp-start 0 -E 128M $flg_opts $comp_file | wc -l)
1271 [ $found -eq 1 ] || error "Write: Extended first component not found"
1273 flg_opts="--comp-flags extension"
1274 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1275 [ $found -eq 1 ] || error "Write: second component not found"
1277 found=$($LFS find -z 64M $comp_file | wc -l)
1278 [ $found -eq 1 ] || error "component not found by ext size"
1280 found=$($LFS find --extension-size +63M $comp_file | wc -l)
1281 [ $found -eq 1 ] || error "component not found by +ext size"
1283 found=$($LFS find --ext-size -65M $comp_file | wc -l)
1284 [ $found -eq 1 ] || error "component not found by -ext size"
1286 found=$($LFS find -z 65M $comp_file | wc -l)
1287 [ $found -eq 0 ] || error "component found by wrong ext size"
1289 found=$($LFS find -z +65M $comp_file | wc -l)
1290 [ $found -eq 0 ] || error "component found by wrong +ext size"
1292 found=$($LFS find -z -63M $comp_file | wc -l)
1293 [ $found -eq 0 ] || error "component found by wrong -ext size"
1295 found=$($LFS find ! -z 64M $comp_file | wc -l)
1296 [ $found -eq 0 ] || error "component found by negation of ext size"
1298 found=$($LFS find ! -z +63M $comp_file | wc -l)
1299 [ $found -eq 0 ] || error "component found by negation of +ext size"
1301 found=$($LFS find ! -z -65M $comp_file | wc -l)
1302 [ $found -eq 0 ] || error "component found by negation of -ext size"
1304 found=$($LFS find ! -z 65M $comp_file | wc -l)
1306 error "component not found by negation of wrong ext size"
1308 found=$($LFS find ! -z +65M $comp_file | wc -l)
1310 error "component not found by negation of wrong +ext size"
1312 found=$($LFS find ! -z -63M $comp_file | wc -l)
1314 error "component not found by negation of wrong -ext size"
1316 found=$($LFS find -S +$ssize $comp_file | wc -l)
1317 [ $found -eq 0 ] || error "component found by wrong +stripe size"
1319 found=$($LFS find -c 1 $comp_file | wc -l)
1320 [ $found -eq 1 ] || error "component not found by stripe count"
1322 small_write $comp_file $rw_len || error "Verify RW failed"
1324 sel_layout_sanity $comp_file 2
1327 # Self-extending PFL tests
1329 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1330 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1331 skip "skipped for lustre < $SEL_VER"
1333 test19_io_base $DIR/$tdir/$tfile
1335 run_test 19a "Simple test of extension behavior"
1337 # Same as 19a, but with default layout set on directory rather than on file
1339 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1340 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1341 skip "skipped for lustre < $SEL_VER"
1343 local comp_file=$DIR/$tdir/$tfile
1344 local comp_dir=$DIR/$tdir/$tdir
1348 test_mkdir -p $DIR/$tdir
1349 $LFS setstripe --ext-size 64M -c 1 -E -1 $DIR/$tdir ||
1350 error "Setstripe on $DIR/$tdir failed"
1352 # check inheritance for a sub-dir and a file
1353 test_mkdir $comp_dir
1354 found=$($LFS find --comp-start 0 -E 64M $comp_dir | wc -l)
1355 [ $found -eq 1 ] || error "Dir Inheritance: wrong first component size"
1357 flg_opts="--comp-flags extension"
1358 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_dir | wc -l)
1359 [ $found -eq 1 ] || error "Dir Inheritance: Second component not found"
1363 flg_opts="--comp-flags init"
1364 found=$($LFS find --comp-start 0 -E 64M $flg_opts $comp_file | wc -l)
1365 [ $found -eq 1 ] || error "File Inheritance: wrong first component size"
1367 flg_opts="--comp-flags extension"
1368 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_file | wc -l)
1369 [ $found -eq 1 ] || error "File Inheritance: Second component not found"
1371 test19_io_base $comp_file 1
1373 run_test 19b "Simple test of SEL as default layout"
1375 # Test behavior when seeking deep in a file
1377 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1378 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1379 skip "skipped for lustre < $SEL_VER"
1381 local comp_file=$DIR/$tdir/$tfile
1385 test_mkdir -p $DIR/$tdir
1387 $LFS setstripe -z 128M -E 1G -E -1 $comp_file ||
1388 error "Create $comp_file failed"
1390 # write past end of first component, so it is extended
1391 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 conv=notrunc ||
1392 error "dd to extend failed"
1394 flg_opts="--comp-flags init"
1395 found=$($LFS find --comp-start 0M -E 256M $flg_opts $comp_file | wc -l)
1396 [ $found -eq 1 ] || error "Write: first extension component not found"
1398 flg_opts="--comp-flags extension,^init"
1399 found=$($LFS find --comp-start 256M -E 1024M $flg_opts $comp_file |\
1401 [ $found -eq 1 ] || error "Write: second extension component not found"
1403 local end_1=$($LFS getstripe -I1 -E $comp_file)
1406 [ $end_1 -eq 268435456 ] ||
1407 error "end of first component $end_1 != 268435456"
1409 # Write past end of extension space component, in to normal component
1410 # should exhaust & remove extension component
1411 dd if=/dev/zero bs=1M count=1 seek=1100 of=$comp_file conv=notrunc ||
1412 error "dd distant seek failed"
1414 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1415 # the last component index is 3
1416 local ost_idx2=$($LFS getstripe -I3 -i $comp_file)
1418 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1420 local start1=$($LFS getstripe -I1 --comp-start $comp_file)
1421 local end1=$($LFS getstripe -I1 -E $comp_file)
1422 local start2=$($LFS getstripe -I3 --comp-start $comp_file)
1423 local end2=$($LFS getstripe -I3 -E $comp_file)
1425 [ $start1 -eq 0 ] || error "start of first component incorrect"
1426 [ $end1 -eq 1073741824 ] || error "end of first component incorrect"
1427 [ $start2 -eq 1073741824 ] ||
1428 error "start of second component incorrect"
1429 [ "$end2" = "EOF" ] || error "end of second component incorrect"
1431 flg_opts="--comp-flags extension"
1432 found=$($LFS find $flg_opts $comp_file | wc -l)
1433 [ $found -eq 0 ] || error "Seek Write: extension component exists"
1435 sel_layout_sanity $comp_file 2
1437 run_test 19c "Test self-extending layout seeking behavior"
1440 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1441 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1442 skip "skipped for lustre < $SEL_VER"
1444 local comp_file=$DIR/$tdir/$tfile
1448 test_mkdir -p $DIR/$tdir
1450 $LFS setstripe -E 128M -c 1 -z 64M -E -1 $comp_file ||
1451 error "Create $comp_file failed"
1453 # This will cause component 1 to be extended to 128M, then the
1454 # extension space component will be removed
1455 dd if=/dev/zero of=$comp_file bs=130M count=1 ||
1456 error "dd to extend failed"
1458 flg_opts="--comp-flags init"
1459 found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file | wc -l)
1460 [ $found -eq 1 ] || error "Write: first component not found"
1462 flg_opts="--comp-flags init"
1463 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1464 [ $found -eq 1 ] || error "Write: second component not found"
1466 sel_layout_sanity $comp_file 2
1468 # always remove large files in case of DO_CLEANUP=false
1469 rm -f $comp_file || error "Delete $comp_file failed"
1471 run_test 19d "Test write which completely spans extension space component"
1476 local comp2_flags=$($LFS getstripe -I2 --comp-flags $comp_file)
1477 local comp3_flags=$($LFS getstripe -I3 --comp-flags $comp_file)
1479 [ "$comp2_flags" != "init" ] && error "$comp2_flags != init"
1480 [ "$comp3_flags" != "extension" ] && error "$comp3_flags != extension"
1482 local flg_opts=" --comp-start 2M -E 66M --comp-flags init"
1483 local found=$($LFS find $flg_opts $comp_file | wc -l)
1484 [ $found -eq 1 ] || error "Write: extended second component not found"
1486 flg_opts="--comp-start 66M -E EOF --comp-flags extension"
1487 found=$($LFS find $flg_opts $comp_file | wc -l)
1488 [ $found -eq 1 ] || error "Write: third component not found"
1490 sel_layout_sanity $comp_file 3
1494 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1495 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1496 skip "skipped for lustre < $SEL_VER"
1498 local comp_file=$DIR/$tdir/$tfile
1499 local rw_len=$((3 * 1024 * 1024)) # 3M
1503 test_mkdir -p $DIR/$tdir
1505 $LFS setstripe -E 2m -E -1 -z 64M $comp_file ||
1506 error "Create $comp_file failed"
1508 replay_barrier $SINGLEMDS
1510 #instantiate & extend second component
1511 dd if=/dev/zero of=$comp_file bs=4M count=1 ||
1512 error "dd to extend failed"
1514 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1515 local ost_idx3=$($LFS getstripe -I3 -i $comp_file)
1517 [ $ost_idx2 -eq $ost_idx3 ] && error "$ost_idx2 == $ost_idx3"
1518 [ $ost_idx3 -ne "-1" ] && error "third component init $ost_idx3"
1520 test_19e_check $comp_file
1522 local f1=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1523 echo "before MDS recovery, the ost fid of 2nd component is $f1"
1527 local f2=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1528 echo "after MDS recovery, the ost fid of 2nd component is $f2"
1529 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
1531 # simply repeat all previous checks, but also verify components are on
1532 # the same OST as before
1534 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1535 local ost_idx3_2=$($LFS getstripe -I3 -i $comp_file)
1537 [ $ost_idx2_2 -eq $ost_idx3_2 ] && error "$ost_idx2_2 == $ost_idx3_2"
1538 [ $ost_idx3_2 -ne "-1" ] && error "second component init $ost_idx3_2"
1540 # verify OST id is the same after failover
1541 [ $ost_idx2 -ne $ost_idx2_2 ] &&
1542 error "$ost_idx2 != $ost_idx2_2, changed after failover"
1544 test_19e_check $comp_file
1546 run_test 19e "Replay of layout instantiation & extension"
1549 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1550 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1551 skip "skipped for lustre < $SEL_VER"
1553 local comp_file=$DIR/$tdir/$tfile
1557 test_mkdir -p $DIR/$tdir
1559 $LFS setstripe -E 256M --comp-flags extension -E -1 $comp_file
1561 [ $? != 0 ] || error "should not be able to manually set extension flag"
1564 run_test 19f "Rejection of invalid layouts"
1567 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1568 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1569 skip "skipped for lustre < $SEL_VER"
1571 local file1=$DIR/${tfile}-1
1572 local file2=$DIR/${tfile}-2
1574 test_mkdir -p $DIR/$tdir
1575 multiop $file1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1576 error "create failed $file1"
1577 multiop $file2 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1578 error "create failed $file2"
1580 $LFS setstripe --component-add -E 1G -c 1 $file1 ||
1581 error "comp-add [0,1G] failed $file1"
1582 $LFS setstripe --component-add -E 512M -z 128M $file1 &&
1583 error "comp-add [1G,1G],SEL[1G,512M] succeded $file1"
1584 $LFS setstripe --component-add -E 10G -z 128M $file1 ||
1585 error "comp-add [1G,1G],SEL[1G,10G] failed $file1"
1586 $LFS setstripe --component-add -E -1 $file1 ||
1587 error "comp-add [10G,-1] failed $file1"
1589 $LFS setstripe --component-add -E 1G -z 32M -c 1 $file2 &&
1590 error "comp-add with smal ext size succeeded $file1"
1591 $LFS setstripe --component-add -E 1G -z 100M -c 1 $file2 &&
1592 error "comp-add with not aligned ext size succeeded $file1"
1593 $LFS setstripe --component-add -E 1G -z 128M -c 1 $file2 ||
1594 error "comp-add [0,128M],SEL[128M,1G] failed $file1"
1595 $LFS setstripe --component-add -E 10G $file2 ||
1596 error "comp-add [1G,10G] failed $file1"
1597 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 ||
1598 error "comp-add [10G,10G],SEL[10G,-1] failed $file1"
1599 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 &&
1600 error "repeated comp-add [10G,10G],SEL[10G,-1] succeeded $file1"
1602 $LFS getstripe $file1
1603 flg_opts="--comp-flags init"
1604 found=$($LFS find --comp-start 0 -E 1G $flg_opts $file1 | wc -l)
1605 [ $found -eq 1 ] || error "First component not found $file1"
1607 flg_opts="--comp-flags ^init"
1608 found=$($LFS find --comp-start 1G -E 1G $flg_opts $file1 | wc -l)
1609 [ $found -eq 1 ] || error "Second component not found $file1"
1611 flg_opts="--comp-flags ^init,extension"
1612 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file1 | wc -l)
1613 [ $found -eq 1 ] || error "Third component not found $file1"
1615 flg_opts="--comp-flags ^init"
1616 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file1 | wc -l)
1617 [ $found -eq 1 ] || error "Fourth component not found $file1"
1619 $LFS getstripe $file2
1620 flg_opts="--comp-flags init"
1621 found=$($LFS find --comp-start 0 -E 128M $flg_opts $file2 | wc -l)
1622 [ $found -eq 1 ] || error "First component not found $file2"
1624 flg_opts="--comp-flags extension"
1625 found=$($LFS find --comp-start 128M -E 1G $flg_opts $file2 | wc -l)
1626 [ $found -eq 1 ] || error "Second component not found $file2"
1628 flg_opts="--comp-flags ^init"
1629 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file2 | wc -l)
1630 [ $found -eq 1 ] || error "Third component not found $file2"
1632 flg_opts="--comp-flags ^init"
1633 found=$($LFS find --comp-start 10G -E 10G $flg_opts $file2 | wc -l)
1634 [ $found -eq 1 ] || error "Fourth component not found $file2"
1636 flg_opts="--comp-flags ^init,extension"
1637 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file2 | wc -l)
1638 [ $found -eq 1 ] || error "Fifth component not found $file2"
1640 run_test 19g "component-add behaviour"
1642 # Test out of space behavior
1644 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1645 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1646 skip "skipped for lustre < $SEL_VER"
1648 local comp_file=$DIR/$tdir/$tfile
1652 test_mkdir -p $DIR/$tdir
1654 # without this, a previous delete can finish after we check free space
1655 wait_delete_completed
1658 # First component is on OST0
1659 $LFS setstripe -E 256M -i 0 -z 64M -E -1 -z 128M $comp_file ||
1660 error "Create $comp_file failed"
1662 # write past end of first component, so it is extended
1663 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=66 ||
1664 error "dd to extend failed"
1666 flg_opts="--comp-flags extension"
1667 found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file |wc -l)
1668 [ $found -eq 1 ] || error "Write: Second component not found"
1670 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1671 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1673 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1675 flg_opts="--comp-flags extension"
1676 # Write past current init comp, but we won't extend (because no space)
1677 dd if=/dev/zero of=$comp_file bs=1M count=10 seek=200 ||
1678 error "dd write past current comp failed"
1680 $LFS getstripe $comp_file
1682 flg_opts="--comp-flags init"
1683 found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file | \
1685 [ $found -eq 1 ] || error "Write: third component not found"
1687 flg_opts="--comp-flags extension"
1688 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file |wc -l)
1689 [ $found -eq 1 ] || error "Write: fourth extension component not found"
1691 sel_layout_sanity $comp_file 3
1693 run_test 20a "Test out of space, spillover to defined component"
1696 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1697 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1698 skip "skipped for lustre < $SEL_VER"
1700 local comp_file=$DIR/$tdir/$tfile
1704 test_mkdir -p $DIR/$tdir
1706 # Pool allows us to force use of only certain OSTs
1707 pool_add $TESTNAME || error "Pool creation failed"
1708 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1710 # normal component to 10M, extendable component to 1G
1711 # further extendable to EOF
1712 $LFS setstripe -E 10M -E 1G -p $TESTNAME -z 64M -E -1 -p "" -z 128M \
1713 $comp_file || error "Create $comp_file failed"
1715 replay_barrier $SINGLEMDS
1717 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1718 [ $found -eq 1 ] || error "Zero length component not found"
1721 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1723 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1725 # write past end of first component
1726 # This should remove the next component, since OST0 is out of space
1727 # and it is striped there (pool contains only OST0)
1728 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=14 ||
1729 error "dd to extend/remove failed"
1731 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1732 [ $found -eq 0 ] || error "Write: zero length component still present"
1734 flg_opts="--comp-flags init"
1735 $LFS find --comp-start 10M -E +137M $flg_opts $comp_file
1736 found=$($LFS find --comp-start 10M -E +137M $flg_opts $comp_file |wc -l)
1737 [ $found -eq 1 ] || error "Write: second component not found"
1739 flg_opts="--comp-flags extension"
1740 found=$($LFS find --comp-start +137M -E EOF $flg_opts $comp_file |wc -l)
1741 [ $found -eq 1 ] || error "Write: third component not found"
1745 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1746 [ $found -eq 0 ] || error "Failover: 0-length component still present"
1748 flg_opts="--comp-flags init"
1749 found=$($LFS find --comp-start 10M -E +137M $flg_opts $comp_file |wc -l)
1750 [ $found -eq 1 ] || error "Failover: second component not found"
1752 flg_opts="--comp-flags extension"
1753 found=$($LFS find --comp-start +137M -E EOF $flg_opts $comp_file |wc -l)
1754 [ $found -eq 1 ] || error "Failover: third component not found"
1756 sel_layout_sanity $comp_file 3
1758 run_test 20b "Remove component without instantiation when there is no space"
1761 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1762 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1763 skip "skipped for lustre < $SEL_VER"
1765 local comp_file=$DIR/$tdir/$tfile
1769 test_mkdir -p $DIR/$tdir
1771 # pool is used to limit available OSTs to 0 and 1, so we can set all
1772 # available OSTs out of space
1773 pool_add $TESTNAME || error "Pool creation failed"
1774 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
1776 # without this, a previous delete can finish after we check free space
1777 wait_delete_completed
1780 $LFS setstripe -E 100M -E -1 -p $TESTNAME -z 64M $comp_file ||
1781 error "Create $comp_file failed"
1785 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1787 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
1789 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1790 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
1792 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=120 &&
1793 error "dd should fail with ENOSPC"
1795 flg_opts="--comp-flags init"
1796 found=$($LFS find --comp-start 0M -E 100M $flg_opts $comp_file | wc -l)
1797 [ $found -eq 1 ] || error "Write: First component not found"
1799 flg_opts="--comp-flags ^init"
1800 found=$($LFS find --comp-start 100M -E 100M $flg_opts $comp_file |wc -l)
1801 [ $found -eq 1 ] || error "Write: 0-length component not found"
1803 flg_opts="--comp-flags extension"
1804 found=$($LFS find --comp-start 100M -E EOF $flg_opts $comp_file | wc -l)
1805 [ $found -eq 1 ] || error "Write: third extension component not found"
1807 sel_layout_sanity $comp_file 3
1809 run_test 20c "Test inability to stripe new extension component"
1812 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1813 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1814 skip "skipped for lustre < $SEL_VER"
1816 local comp_file=$DIR/$tdir/$tfile
1817 test_mkdir -p $DIR/$tdir
1819 wait_delete_completed
1822 pool_add $TESTNAME || error "Pool creation failed"
1823 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1824 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
1825 error "Create $comp_file failed"
1827 replay_barrier $SINGLEMDS
1829 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1830 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1833 ost_watermarks_clear_enospc $tfile 0 $wms
1834 [ $RC -eq 0 ] || error "dd failed: $RC"
1836 $LFS getstripe $comp_file
1837 local flg_opts="--comp-start 64M -E 128M --comp-flags init"
1838 local found=$($LFS find $flg_opts $comp_file | wc -l)
1839 [ $found -eq 1 ] || error "Write: component (64M-128M) not found"
1841 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
1842 [ "$ost_idx" != "-1" ] && error "Write: EXT component disappeared"
1846 found=$($LFS find $flg_opts $comp_file | wc -l)
1847 [ $found -eq 1 ] || error "Failover: component (64M-128M) not found"
1849 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1850 [ "$ost_idx" != "-1" ] && error "Failover: EXT component disappeared"
1852 sel_layout_sanity $comp_file 3
1854 run_test 20d "Low on space + 0-length comp: force extension"
1857 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1858 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1859 skip "skipped for lustre < $SEL_VER"
1861 local comp_file=$DIR/$tdir/$tfile
1862 test_mkdir -p $DIR/$tdir
1864 wait_delete_completed
1867 pool_add $TESTNAME || error "Pool creation failed"
1868 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1870 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
1871 error "Create $comp_file failed"
1873 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1875 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1878 ost_watermarks_clear_enospc $tfile 0 $wms
1879 [ $RC -eq 0 ] || error "dd failed $RC"
1881 $LFS getstripe $comp_file
1882 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
1883 local found=$($LFS find $flg_opts $comp_file | wc -l)
1884 [ $found -eq 1 ] || error "Write: component (64M-EOF) not found"
1886 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
1887 [ "$ost_idx" != "" ] && error "Write: 0-length component still exists"
1888 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1889 [ "$ost_idx" != "" ] && error "Write: extension component still exists"
1891 sel_layout_sanity $comp_file 2
1893 run_test 20e "ENOSPC with next real comp: spillover and backward extension"
1895 # Simple DoM interaction test
1897 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1898 skip "skipped for lustre < $SEL_VER"
1900 local comp_file=$DIR/$tdir/$tfile
1904 test_mkdir -p $DIR/$tdir
1906 # simple, correct self-extending layout after DoM component
1907 $LFS setstripe -E 1M -L mdt -E -1 -z 64m $comp_file || \
1908 error "Create $comp_file failed"
1910 # Write to DoM component & to self-extending comp after it
1911 dd if=/dev/zero bs=1M count=12 of=$comp_file ||
1912 error "dd to extend failed"
1914 flg_opts="--comp-flags init"
1915 found=$($LFS find --comp-start 1M -E 65M $flg_opts $comp_file | wc -l)
1916 [ $found -eq 1 ] || error "Write: extended component not found"
1918 flg_opts="--comp-flags extension"
1919 found=$($LFS find --comp-start 65M $flg_opts $comp_file | wc -l)
1920 [ $found -eq 1 ] || error "Write: extension component not found"
1922 sel_layout_sanity $comp_file 3
1924 run_test 21a "Simple DoM interaction tests"
1926 # DoM + extension + removal
1928 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1929 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1930 skip "skipped for lustre < $SEL_VER"
1932 local comp_file=$DIR/$tdir/$tfile
1933 local ost_name=$(ostname_from_index 0)
1937 test_mkdir -p $DIR/$tdir
1939 # DoM, extendable component, further extendable component
1940 $LFS setstripe -E 1M -L mdt -E 256M -i 0 -z 64M -E -1 -z 128M \
1941 $comp_file || error "Create $comp_file failed"
1943 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1944 [ $found -eq 1 ] || error "Write: Zero length component not found"
1946 # This also demonstrates that we will avoid degraded OSTs
1947 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
1948 # sleep to guarantee we see the degradation
1951 # un-degrade on exit
1952 stack_trap "do_facet ost1 $LCTL set_param -n \
1953 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1955 # This should remove the first component after DoM and spill over to
1957 dd if=/dev/zero bs=1M count=2 of=$comp_file ||
1958 error "dd to remove+spill over failed"
1960 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1961 [ $found -eq 0 ] || error "Write: Zero length component still present"
1963 flg_opts="--comp-flags init"
1964 found=$($LFS find --comp-start 1M -E 129M $flg_opts $comp_file | wc -l)
1965 [ $found -eq 1 ] || error "Write: extended component not found"
1967 flg_opts="--comp-flags extension"
1968 found=$($LFS find --comp-start 129M -E EOF $flg_opts $comp_file |wc -l)
1969 [ $found -eq 1 ] || error "Write: extension component not found"
1971 sel_layout_sanity $comp_file 3
1973 run_test 21b "DoM followed by extendable component with removal"
1975 # Test of repeat component behavior with OOS/degraded OST
1977 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1978 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1979 skip "skipped for lustre < $SEL_VER"
1981 local comp_file=$DIR/$tdir/$tfile
1985 test_mkdir -p $DIR/$tdir
1987 $LFS setstripe -E -1 -c 1 -z 128M $comp_file ||
1988 error "Create $comp_file failed"
1990 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1991 local ost_name=$(ostname_from_index $ost_idx1)
1993 # write past end of first component, so it is extended
1994 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
1995 error "dd to extend failed"
1997 flg_opts="--comp-flags extension"
1998 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
1999 [ $found -eq 1 ] || error "Write: second component not found"
2001 # degrade OST for component 1
2002 do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
2003 obdfilter.$ost_name.degraded=1
2004 # sleep to guarantee we see the degradation
2007 # un-degrade on exit
2008 stack_trap "do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
2009 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
2011 replay_barrier $SINGLEMDS
2013 # seek past the end of current comp & write, should cause a new comp
2014 # to be created (ie repeat previous comp)
2015 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
2016 error "dd to repeat failed"
2018 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
2020 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
2022 flg_opts="--comp-flags init"
2023 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
2024 [ $found -eq 1 ] || error "Write: second component not found"
2026 flg_opts="--comp-flags extension"
2027 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
2028 [ $found -eq 1 ] || error "Write: extension component not found"
2032 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
2033 [ $ost_idx2_2 -ne $ost_idx2 ] && error "$ost_idx2_2 != $ost_idx2"
2035 flg_opts="--comp-flags init"
2036 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
2037 [ $found -eq 1 ] || error "Failover: second component not found"
2039 flg_opts="--comp-flags extension"
2040 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
2041 [ $found -eq 1 ] || error "Failover: extension component not found"
2043 sel_layout_sanity $comp_file 3
2045 run_test 22a "Test repeat component behavior with degraded OST"
2047 # Test repeat behavior with low space
2049 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2050 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2051 skip "skipped for lustre < $SEL_VER"
2053 local comp_file=$DIR/$tdir/$tfile
2057 test_mkdir -p $DIR/$tdir
2059 # without this, a previous delete can finish after we check free space
2060 wait_delete_completed
2063 $LFS setstripe -E -1 -c 1 -z 128M \
2064 $comp_file || error "Create $comp_file failed"
2066 # write past end of first component, so it is extended
2067 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
2068 error "dd to extend failed"
2070 flg_opts="--comp-flags extension"
2071 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
2072 [ $found -eq 1 ] || error "Write: Second component not found"
2074 # set our OST low on space
2075 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
2076 local wms=$(ost_watermarks_set_low_space $ost_idx1 | grep "watermarks")
2078 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
2080 # Write past end of current space, fail to extend, causing repeat
2081 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
2082 error "dd to repeat failed"
2084 $LFS getstripe $comp_file
2086 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
2088 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
2090 flg_opts="--comp-flags init"
2091 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
2092 [ $found -eq 1 ] || error "Write: Second component not found"
2094 flg_opts="--comp-flags extension"
2095 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
2096 [ $found -eq 1 ] || error "Write: Extension component not found"
2098 sel_layout_sanity $comp_file 3
2100 run_test 22b "Test simple 'out of space' condition with repeat"
2102 # This tests both "repeat" and "extend in place when repeat fails" aspects
2103 # of repeating components
2105 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2106 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2107 skip "skipped for lustre < $SEL_VER"
2109 local comp_file=$DIR/$tdir/$tfile
2113 test_mkdir -p $DIR/$tdir
2115 # pool is used to limit available OSTs to 0 and 1, so we can set all
2116 # available OSTs out of space
2117 pool_add $TESTNAME || error "Pool creation failed"
2118 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
2120 # without this, a previous delete can finish after we check free space
2121 wait_delete_completed
2124 $LFS setstripe -E -1 -z 64M -c 1 -p "$TESTNAME" $comp_file || \
2125 error "Create $comp_file failed"
2127 # write past end of first component, so it is extended
2128 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=80 conv=notrunc ||
2129 error "dd to extend failed"
2131 $LFS getstripe $comp_file
2133 flg_opts="--comp-flags extension"
2134 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
2135 [ $found -eq 1 ] || error "Write: second component not found"
2137 # set our OST out of space
2138 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
2139 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
2141 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
2143 # This should create a repeat component on a new OST
2144 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=180 conv=notrunc ||
2145 error "dd to repeat failed"
2147 $LFS getstripe $comp_file
2149 local comp_cnt=$($LFS getstripe --component-count $comp_file)
2150 [ $comp_cnt -ne 3 ] && error "component count: $comp_cnt, should be 3"
2152 # New second component should be on a different OST
2153 local ost_idx2=$($LFS getstripe --comp-start=128m \
2154 --comp-end=192m --comp-flags=init -i $comp_file)
2156 [ $ost_idx1 -eq $ost_idx2 ] && error "2nd comp: same OST $ost_idx1"
2158 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
2160 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
2162 # now that the second OST is out of space (as is the first OST), we
2163 # attempt to extend. This should result in an extension of the
2164 # existing component, rather than a new component.
2165 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=240 conv=notrunc ||
2166 error "dd for forced extension failed"
2168 $LFS getstripe $comp_file
2170 # clear out of space on first OST
2171 ost_watermarks_clear_enospc $tfile $ost_idx1 $wms
2173 # finally, now that the first OST has space again, we attempt to
2174 # extend one last time. This should create a new component on the
2176 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 conv=notrunc ||
2177 error "dd for repeat on first OST failed"
2179 $LFS getstripe $comp_file
2181 flg_opts="--comp-flags init"
2182 found=$($LFS find --comp-start 128M $flg_opts $comp_file | wc -l)
2183 [ $found -eq 1 ] || error "Write: second component not found"
2185 flg_opts="--comp-flags init"
2186 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
2187 [ $found -eq 1 ] || error "Write: third component not found"
2189 flg_opts="--comp-flags extension"
2190 found=$($LFS find --comp-start 320M -E EOF $flg_opts $comp_file | wc -l)
2191 [ $found -eq 1 ] || error "Write: extension component not found"
2193 sel_layout_sanity $comp_file 4
2195 run_test 22c "Test repeat with out of space on > 1 OST"
2197 test_22d_post_check() {
2200 local flg_opts="--comp-flags init"
2201 local found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file |
2203 [ $found -eq 1 ] || {
2204 $LFS getstripe $comp_file
2205 error "$name: second component not found"
2208 flg_opts="--comp-flags extension"
2209 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
2210 [ $found -eq 1 ] || error "$name: third extension component not found"
2212 sel_layout_sanity $comp_file 2
2220 # write past end of first component
2221 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=70
2224 ost_watermarks_clear_enospc $tfile 0 $wms
2225 [ $RC -eq 0 ] || error "dd to force extend failed"
2227 test_22d_post_check $comp_file "Write"
2231 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2232 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2233 skip "skipped for lustre < $SEL_VER"
2235 local comp_file=$DIR/$tdir/$tfile
2239 test_mkdir -p $DIR/$tdir
2241 # without this, a previous delete can finish after we check free space
2242 wait_delete_completed
2245 # Pool allows us to force use of only certain OSTs
2246 pool_add $TESTNAME || error "Pool creation failed"
2247 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2249 # 1. Fail to extend due to OOS, try to repeat within the same pool,
2250 # fail to stripe (again OOS) the 0-length component, remove the
2251 # repeated one, force the extension on the original one.
2252 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2253 error "Create $comp_file failed"
2255 replay_barrier $SINGLEMDS
2257 # set our OST out of space
2258 local wms=$(ost_watermarks_set_enospc $tfile 0 | grep "watermarks")
2260 test_22d_pre $comp_file "$wms"
2262 test_22d_post_check $comp_file "Failover"
2264 # 2. repeat with low on space: 0-length repeated component will be
2265 # striped, but still fails to be extended; otherwise the same as (1).
2267 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2268 error "Create $comp_file failed"
2270 replay_barrier $SINGLEMDS
2272 # set our OST low on space
2273 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2275 test_22d_pre $comp_file "$wms"
2277 test_22d_post_check $comp_file "Failover"
2279 run_test 22d "out of/low on space + failed to repeat + forced extension"
2282 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2283 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2284 skip "skipped for lustre < $SEL_VER"
2286 local comp_file=$DIR/$tdir/$tfile
2287 test_mkdir -p $DIR/$tdir
2289 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2290 error "Create $comp_file failed"
2292 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2293 error "dd append failed"
2295 local flg_opts="--comp-start 0 -E EOF --comp-flags init"
2296 local found=$($LFS find $flg_opts $comp_file | wc -l)
2297 [ $found -eq 1 ] || error "Append: first component (0-EOF) not found"
2299 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2300 [ "$ost_idx" != "" ] && error "Append: second component still exists"
2302 sel_layout_sanity $comp_file 1
2304 run_test 23a "Append: remove EXT comp"
2307 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2308 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2309 skip "skipped for lustre < $SEL_VER"
2311 local comp_file=$DIR/$tdir/$tfile
2312 test_mkdir -p $DIR/$tdir
2314 $LFS setstripe -E 64m -E -1 -z 64M $comp_file ||
2315 error "Create $comp_file failed"
2317 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2318 error "dd append failed"
2320 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2321 local found=$($LFS find $flg_opts $comp_file | wc -l)
2322 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2324 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2325 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2327 sel_layout_sanity $comp_file 2
2329 run_test 23b "Append with 0-length comp: remove EXT comp"
2332 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2333 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2334 skip "skipped for lustre < $SEL_VER"
2336 local comp_file=$DIR/$tdir/$tfile
2337 test_mkdir -p $DIR/$tdir
2339 wait_delete_completed
2342 pool_add $TESTNAME || error "Pool creation failed"
2343 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2344 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
2345 error "Create $comp_file failed"
2347 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2348 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2351 ost_watermarks_clear_enospc $tfile 0 $wms
2352 [ $RC -eq 0 ] || error "dd append failed: $RC"
2354 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2355 local found=$($LFS find $flg_opts $comp_file | wc -l)
2356 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2358 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2359 [ "$ost_idx" != "" ] && error "Append: EXT component still exists"
2361 sel_layout_sanity $comp_file 2
2363 run_test 23c "Append with low on space + 0-length comp: force extension"
2366 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2367 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2368 skip "skipped for lustre < $SEL_VER"
2370 local comp_file=$DIR/$tdir/$tfile
2371 test_mkdir -p $DIR/$tdir
2373 $LFS setstripe -E 64m -E 640M -z 64M -E -1 $comp_file ||
2374 error "Create $comp_file failed"
2376 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2377 error "dd append failed"
2379 flg_opts="--comp-start 64M -E 640M --comp-flags init"
2380 found=$($LFS find $flg_opts $comp_file | wc -l)
2381 [ $found -eq 1 ] || error "Append: component (64M-640M) not found"
2383 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2384 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2386 sel_layout_sanity $comp_file 3
2388 run_test 23d "Append with 0-length comp + next real comp: remove EXT comp"
2391 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2392 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2393 skip "skipped for lustre < $SEL_VER"
2395 local comp_file=$DIR/$tdir/$tfile
2396 test_mkdir -p $DIR/$tdir
2398 wait_delete_completed
2401 pool_add $TESTNAME || error "Pool creation failed"
2402 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2404 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
2405 error "Create $comp_file failed"
2407 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2409 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2412 ost_watermarks_clear_enospc $tfile 0 $wms
2413 [ $RC -eq 0 ] || error "dd append failed $RC"
2415 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2416 local found=$($LFS find $flg_opts $comp_file | wc -l)
2417 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2419 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2420 [ "$ost_idx" != "" ] && error "Append: 0-length component still exists"
2421 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2422 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2424 sel_layout_sanity $comp_file 2
2426 run_test 23e "Append with next real comp: spillover and backward extension"
2429 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2430 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2431 skip "skipped for lustre < $SEL_VER"
2433 local comp_file=$DIR/$tdir/$tfile
2434 test_mkdir -p $DIR/$tdir
2436 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2437 error "Create $comp_file failed"
2439 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
2440 local wms=$(ost_watermarks_set_low_space $ost_idx | grep "watermarks")
2442 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2445 ost_watermarks_clear_enospc $tfile $ost_idx $wms
2446 [ $RC -eq 0 ] || error "dd append failed"
2448 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2449 local found=$($LFS find $flg_opts $comp_file | wc -l)
2450 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2452 ost_idx=$($LFS getstripe -I2 -i $comp_file)
2453 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2455 sel_layout_sanity $comp_file 2
2457 run_test 23f "Append with low on space: repeat and remove EXT comp"
2466 [ "$OSTCOUNT" -lt "3" ] && skip_env "needs >= 3 OSTs"
2468 trap cleanup_24 EXIT RETURN
2470 local file=$DIR/$tfile
2472 $LFS setstripe -E 1m -c1 -o0 -E eof -c2 -S 1M -o1,2 $file ||
2473 error "setstripe on $file"
2475 dd if=/dev/zero of=$file bs=1M count=3 || error "dd failed for $file"
2478 filefrag -ves $file || error "filefrag $file failed"
2479 filefrag_op=$(filefrag -ve -k $file |
2480 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
2482 #Filesystem type is: bd00bd0
2483 #File size of /mnt/lustre/f24a.sanity-pfl is 3145728 (3072 blocks of 1024 bytes)
2484 # ext: device_logical: physical_offset: length: dev: flags:
2485 # 0: 0.. 1023: 1572864.. 1573887: 1024: 0000: net
2486 # 1: 0.. 1023: 1572864.. 1573887: 1024: 0002: net
2487 # 2: 1024.. 2047: 1573888.. 1574911: 1024: 0001: last,net
2488 #/mnt/lustre/f24a.sanity-pfl: 3 extents found
2490 last_lun=$(echo $filefrag_op | cut -d: -f5)
2495 for line in $filefrag_op; do
2496 frag_lun=$(echo $line | cut -d: -f5)
2497 ext_len=$(echo $line | cut -d: -f4)
2498 if [[ "$frag_lun" != "$last_lun" ]]; then
2499 if (( tot_len != 1024 )); then
2501 error "$file: OST$last_lun $tot_len != 1024"
2507 (( tot_len += ext_len ))
2510 if (( num_luns != 3 || tot_len != 1024 )); then
2512 error "$file: $num_luns != 3, $tot_len != 1024 on OST$last_lun"
2515 echo "FIEMAP on $file succeeded"
2517 run_test 24a "FIEMAP upon PFL file"
2520 local pfl_f=$DIR/$tdir/"$tfile"_pfl
2521 local dom_f=$DIR/$tdir/"$tfile"_dom
2522 local common_f=$DIR/$tdir/"$tfile"_common
2526 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2527 $LFS setstripe -E 10M -S 64k -c -1 -E 20M -S 1M -E -1 -S 2M -c 1 \
2528 $pfl_f || error "setstripe $pfl_f failed"
2529 $LFS setstripe -E 256k -L mdt -E -1 -S 1M $dom_f ||
2530 error "setstripe $dom_f failed"
2531 $LFS setstripe -S 512K -c -1 $common_f ||
2532 error "setstripe $common_f failed"
2534 #verify lov_getstripe_old with PFL file
2535 stripe_count=$(lov_getstripe_old $pfl_f |
2536 awk '/stripe_count/ { print $2 }')
2537 stripe_size=$(lov_getstripe_old $pfl_f |
2538 awk '/stripe_size/ { print $2 }')
2539 [ $stripe_count -eq 1 ] ||
2540 error "stripe_count $stripe_count !=1 for $pfl_f"
2541 [ $stripe_size -eq 2097152 ] ||
2542 error "stripe_size $stripe_size != 2097152 for $pfl_f"
2544 #verify lov_getstripe_old with DoM file
2545 stripe_count=$(lov_getstripe_old $dom_f |
2546 awk '/stripe_count/ { print $2 }')
2547 stripe_size=$(lov_getstripe_old $dom_f |
2548 awk '/stripe_size/ { print $2 }')
2549 [ $stripe_count -eq 1 ] ||
2550 error "stripe_count $stripe_count !=1 for $dom_f"
2551 [ $stripe_size -eq 1048576 ] ||
2552 error "stripe_size $stripe_size != 1048576 for $dom_f"
2554 #verify lov_getstripe_old with common file
2555 stripe_count=$(lov_getstripe_old $common_f |
2556 awk '/stripe_count/ { print $2 }')
2557 stripe_size=$(lov_getstripe_old $common_f |
2558 awk '/stripe_size/ { print $2 }')
2559 [ $stripe_count -eq $OSTCOUNT ] ||
2560 error "stripe_count $stripe_count !=$OSTCOUNT for $common_f"
2561 [ $stripe_size -eq 524288 ] ||
2562 error "stripe_size $stripe_size != 524288 for $common_f"
2564 run_test 25 "Verify old lov stripe API with PFL files"
2567 $LFS setstripe -E 1m -S 1M -c 1 $DIR/$tfile
2568 dd if=/dev/urandom bs=1M count=10 >> $DIR/$tfile
2569 [ $? != 0 ] || error "append must return an error"
2571 run_test 26a "Append to not-existent component"
2574 $LFS setstripe -E 1m -S 1M -c 1 $DIR/$tfile
2575 dd if=/dev/urandom bs=1M count=1 > $DIR/$tfile
2576 dd if=/dev/urandom bs=1M count=1 >> $DIR/$tfile
2577 [ $? != 0 ] || error "append must return an error"
2579 run_test 26b "Append to not-existend component, file size is unknown"
2582 $LFS setstripe -E 1m -S 1M -c 1 $DIR/$tfile
2583 dd if=/dev/urandom bs=2M count=1 >> $DIR/$tfile
2584 [ $? != 0 ] || error "append must return an error"
2586 run_test 26c "Append to not-existend component, crossing the component border"
2589 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2590 skip "server does not support overstriping"
2591 (( $MDS1_VERSION >= $(version_code 2.15.55.102) )) ||
2592 skip "need MDS >= 2.12.55.102 for mdt_dump_lmm fix"
2594 stack_trap "rm -f $DIR/$tfile"
2595 # start_full_debug_logging
2596 $LFS setstripe -S 64K -C -1 $DIR/$tfile || error "create $tfile failed"
2597 $LFS getstripe -c $DIR/$tfile || error "getstripe $tfile failed"
2599 $LFS getstripe -c $DIR/$tfile || error "getstripe failed after clear"
2601 test_mkdir $DIR/$tdir
2602 stack_trap "rm -rf $DIR/$tdir/$tfile"
2603 $LFS setstripe -S 64K -C -1 $DIR/$tdir || error "mkdir $tdir failed"
2604 $LFS getstripe -y $DIR/$tdir || error "getstripe $tdir failed"
2605 touch $DIR/$tdir/$tfile || error "create $tdir/$tfile failed"
2607 $LFS getstripe -c $DIR/$tdir/$tfile ||
2608 error "getstripe $tdir/$tfile failed"
2609 #stop_full_debug_logging
2611 run_test 27 "overstriping with -C -1 in mdt_dump_lmm"
2613 complete_test $SECONDS
2614 check_and_cleanup_lustre