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]*
43 # new sequence needed for MDS < v2_15_61-226-gf00d2467fc
44 if (( $MDS1_VERSION < $(version_code 2.15.61.226) )); then
49 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
51 local comp_file=$DIR/$tdir/$tfile
52 local rw_len=$((3 * 1024 * 1024)) # 3M
57 $LFS setstripe -E 1m -S 1M -c 1 -E -1 -c 1 $comp_file ||
58 error "Create $comp_file failed"
60 #instantiate all components, so that objs are allocted
61 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
63 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
64 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
66 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
68 small_write $comp_file $rw_len || error "Verify RW failed"
70 rm -f $comp_file || error "Delete $comp_file failed"
72 run_test 0a "Create full components file, no reused OSTs"
75 [[ $($LCTL get_param mdc.*.import |
76 grep "connect_flags:.*overstriping") ]] ||
77 skip "server does not support overstriping"
78 large_xattr_enabled || skip_env "no large xattr support"
82 local comp_file=$DIR/$tdir/$tfile
86 $LFS setstripe -E -1 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
87 error "Create $comp_file failed"
89 local count=$($LFS getstripe -I1 -c $comp_file)
90 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
91 error "stripe count of first component is shrinked to $count"
93 rm -f $comp_file || error "Delete $comp_file failed"
95 # Create file with 1.1*LOV_MAX_STRIPE_COUNT stripes should succeed
96 $LFS setstripe -E 1m -C $((LOV_MAX_STRIPE_COUNT / 10)) -E -1 \
97 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
98 error "Create $comp_file failed"
100 local count=$($LFS getstripe -I2 -c $comp_file)
101 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
102 error "stripe count of second component is shrinked to $count"
104 rm -f $comp_file || error "Delete $comp_file failed"
106 # Create file with 3*LOV_MAX_STRIPE_COUNT stripes should fail
107 $LFS setstripe -E 200G -C $LOV_MAX_STRIPE_COUNT \
108 -E 500G -C $LOV_MAX_STRIPE_COUNT \
109 -E -1 -C $LOV_MAX_STRIPE_COUNT $comp_file &&
110 error "Create $comp_file succeeded"
112 rm -f $comp_file || error "Delete $comp_file failed"
114 run_test 0b "Verify comp stripe count limits"
117 [[ $($LCTL get_param mdc.*.import |
118 grep "connect_flags:.*overstriping") ]] ||
119 skip "server does not support overstriping"
120 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code $SEL_VER) ] &&
121 skip "skipped for lustre < $SEL_VER"
123 large_xattr_enabled || skip_env "no large xattr support"
127 local comp_file=$DIR/$tdir/$tfile
129 test_mkdir $DIR/$tdir
131 # extension size aligned to 64M and limit to 1G
132 $LFS setstripe -E-1 -S64K -C $LOV_MAX_STRIPE_COUNT \
133 -z $((64*1024*((LOV_MAX_STRIPE_COUNT+1023)>>10<<10))) \
134 $comp_file || error "Create $comp_file failed"
136 local count=$($LFS getstripe -I1 -c $comp_file)
137 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
138 error "stripe count is shrinked to $count"
140 run_test 0c "Verify SEL comp stripe count limits"
143 (( $MDS1_VERSION > $(version_code 2.14.50.115) )) ||
144 skip_env "Need MDS version at least 2.14.50.115"
151 # Create parent directory
154 # Component end must be a multiple of stripe size
155 # and a multiple of 64KiB to align with the minimum
157 # Values below 4096 are assumed to be in KiB units.
158 $LFS setstripe -E 127 $tf-1 > /dev/null 2>&1 &&
159 error "creating $tf-1 with '-E 127' should fail"
161 $LFS setstripe -E 128 -S 512 $tf-1 > /dev/null 2>&1 &&
162 error "creating $tf-1 with '-E 128 -S 512' should fail"
164 $LFS setstripe -E 128 $tf-1 ||
165 error "creating $tf-1 failed"
167 yes | dd bs=1K count=129 iflag=fullblock of=$tf-1 &&
168 error "writing to $tf-1 should fail"
170 yes | dd bs=1K count=128 iflag=fullblock of=$tf-1 ||
171 error "writing to $tf-1 failed"
173 comp_end=$($LFS getstripe -I1 -E $tf-1)
174 stripe_size=$($LFS getstripe -I1 -S $tf-1)
176 [[ $comp_end == $((128 * 1024)) ]] ||
177 error "incorrect component end '$comp_end' for $tf-1"
179 [[ $stripe_size == $((128 * 1024)) ]] ||
180 error "incorrect stripe size '$stripe_size' for $tf-1"
182 rm $tf-1 || error "removing $tf-1 failed"
184 # The stripe size must be a multiple of 64KiB.
185 # Values below 4096 are assumed to be in KiB units.
186 $LFS setstripe -E -1 -S 2047 $tf-2 > /dev/null 2>&1 &&
187 error "creating $tf-2 with '-S 2047' should fail"
189 $LFS setstripe -E -1 -S 2048 $tf-2 ||
190 error "creating $tf-2 failed"
192 stripe_size=$($LFS getstripe -I1 -S $tf-2)
193 [[ $stripe_size == $((2048 * 1024)) ]] ||
194 error "incorrect stripe size '$stripe_size' for $tf-2"
196 rm $tf-2 || error "removing $tf-2 failed"
198 run_test 0d "Verify comp end and stripe size"
201 (( $MDS1_VERSION >= $(version_code 2.15.56.112) )) ||
202 skip "Need MDS version at least 2.15.56.112"
204 (( OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
211 # component size 1M can only utilize 1 stripe
212 $LFS setstripe -E1M -S1M -c2 -Eeof -S1M -c2 $tf ||
213 error "failed to setstripe $tf"
215 local sc=$($LFS getstripe -I1 -c $tf)
218 error "expect 1 stripe count instread of $sc"
220 sc=$($LFS getstripe -I2 -c $tf)
223 error "expect 2 stripe count instread of $sc"
226 (( OSTCOUNT >= 3 )) || skip "needs >= 3 OSTs"
229 # component size 2M can only utilize 2 stripes
230 $LFS setstripe -E2M -S1M -c3 -Eeof -S1M -c3 $tf ||
231 error "failed to setstripe $tf"
232 sc=$($LFS getstripe -I1 -c $tf)
235 error "expect 2 stripe count instread of $sc"
237 sc=$($LFS getstripe -I2 -c $tf)
240 error "expect 3 stripe count instread of $sc"
244 # 2nd component size 11M and stripe_size 4M should cross 3 stripes
245 $LFS setstripe -E1M -S1M -c3 -E12M -S4M -c3 $tf ||
246 error "failed to setstripe $tf"
247 sc=$($LFS getstripe -I1 -c $tf)
250 error "expect 1 stripe count instread of $sc"
252 sc=$($LFS getstripe -I2 -c $tf)
255 error "expect 3 stripe count instread of $sc"
258 run_test 0e "lfs setstripe should limite stripe count for component size"
261 local comp_file=$DIR/$tdir/$tfile
262 local rw_len=$((3 * 1024 * 1024)) # 3M
264 test_mkdir $DIR/$tdir
267 $LFS setstripe -E 1m -S 1m -o 0 -E -1 -o 0 $comp_file ||
268 error "Create $comp_file failed"
270 #instantiate all components, so that objs are allocted
271 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
273 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
274 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
276 [ $ost_idx1 -ne $ost_idx2 ] && error "$ost_idx1 != $ost_idx2"
278 small_write $comp_file $rw_len || error "Verify RW failed"
280 rm -f $comp_file || error "Delete $comp_file failed"
282 run_test 1a "Create full components file, reused OSTs"
284 # test overstriping (>1 stripe/OST within a component)
286 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
287 [[ $($LCTL get_param mdc.*.import |
288 grep "connect_flags:.*overstriping") ]] ||
289 skip "server does not support overstriping"
291 local comp_file=$DIR/$tdir/$tfile
292 local rw_len=$((3 * 1024 * 1024)) # 3M
294 test_mkdir $DIR/$tdir
296 $LFS setstripe -E 2m -S 1m -o 0,0 -E -1 -o 1,1,0,0 $comp_file ||
297 error "Create $comp_file failed"
299 #instantiate all components, so that objs are allocted
300 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=1M
302 $LFS getstripe $comp_file
303 local OSTS_1=$($LFS getstripe -I1 $comp_file | grep -o 'l_ost_idx.*' |
304 awk -e '{print $2}' | tr "\n" "\0")
305 local OSTS_2=$($LFS getstripe -I2 $comp_file | grep -o 'l_ost_idx.*' |
306 awk -e '{print $2}' | tr "\n" "\0")
310 [ "$OSTS_1" = "0,0," ] || error "incorrect OSTs($OSTS_1) in component 1"
311 [ "$OSTS_2" = "1,1,0,0," ] ||
312 error "incorrect OSTs($OSTS_2) in component 2"
314 small_write $comp_file $rw_len || error "Verify RW failed"
316 rm -f $comp_file || error "Delete $comp_file failed"
318 run_test 1b "Create full components file, overstriping in components"
320 # test overstriping with max stripe count
322 [[ $($LCTL get_param mdc.*.import |
323 grep "connect_flags:.*overstriping") ]] ||
324 skip "server does not support overstriping"
325 large_xattr_enabled || skip_env "no large xattr support"
329 local comp_file=$DIR/$tdir/$tfile
330 local rw_len=$((3 * 1024 * 1024)) # 3M
332 test_mkdir $DIR/$tdir
334 $LFS setstripe -E 10m -C 10 -E 110M -C 100 -E -1 \
335 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
336 error "Create $comp_file failed"
338 # Seek & write in to last component so all objects are allocated
339 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=20000
341 local ssize=$($LFS getstripe -S -I1 $DIR/$tdir/$tfile)
342 local count=$($LFS getstripe -c -I1 $DIR/$tdir/$tfile)
343 count=$((count * ssize / 1048576))
344 [ $count -eq 10 ] || error "comp1 stripe count $count, should be 10"
345 ssize=$($LFS getstripe -S -I2 $DIR/$tdir/$tfile)
346 count=$($LFS getstripe -c -I2 $DIR/$tdir/$tfile)
347 count=$((count * ssize / 1048576))
348 [ $count -eq 100 ] || error "comp2 stripe count $count, should be 100"
349 ssize=$($LFS getstripe -S -I3 $DIR/$tdir/$tfile)
350 count=$($LFS getstripe -c -I3 $DIR/$tdir/$tfile)
351 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
352 echo "comp4 stripe count $count != $LOV_MAX_STRIPE_COUNT"
354 small_write $comp_file $rw_len || error "Verify RW failed"
356 rm -f $comp_file || error "Delete $comp_file failed"
358 run_test 1c "Test overstriping w/max stripe count"
361 local comp_file=$DIR/$tdir/$tfile
362 local rw_len=$((5 * 1024 * 1024)) # 5M
365 test_mkdir $DIR/$tdir
368 multiop $comp_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
369 error "create failed $comp_file"
371 $LFS setstripe --component-add $params $comp_file ||
372 error "Add component to $comp_file failed"
374 check_component_count $comp_file 1
376 dd if=/dev/zero of=$comp_file bs=1M count=1 > /dev/null 2>&1 ||
377 error "Write first component failed"
378 dd if=$comp_file of=/dev/null bs=1M count=1 > /dev/null 2>&1 ||
379 error "Read first component failed"
381 dd if=/dev/zero of=$comp_file bs=1M count=2 > /dev/null 2>&1 &&
382 error "Write beyond component should fail"
383 dd if=$comp_file of=/dev/null bs=1M count=2 > /dev/null 2>&1 ||
384 error "Read beyond component should short read, not fail"
386 $LFS setstripe --component-add -E 2M -S 1M -c 1 $comp_file ||
387 error "Add component to $comp_file failed"
389 check_component_count $comp_file 2
391 $LFS setstripe --component-add -E -1 -c 3 $comp_file ||
392 error "Add last component to $comp_file failed"
394 check_component_count $comp_file 3
396 small_write $comp_file $rw_len || error "Verify RW failed"
398 rm -f $comp_file || error "Delete $comp_file failed"
402 base_test_2 "-E 1m -S 1m"
404 run_test 2a "Add components to existing file"
407 base_test_2 "-E 1m -L mdt"
409 run_test 2b "Add components w/DOM to existing file"
411 del_comp_and_verify() {
418 if [ $id == "init" -o $id == "^init" ]; then
419 opt="--component-flags="
422 $LFS setstripe --component-del $opt$id $comp_file ||
423 error "Delete component $id from $comp_file failed"
425 local comp_cnt=$($LFS getstripe --component-count $comp_file)
426 if grep -q "has no stripe info" <<< "$comp_cnt" ; then
429 [ $comp_cnt -ne $left ] && error "$comp_cnt != $left"
431 $CHECKSTAT -s $size $comp_file || error "size != $size"
435 local comp_file=$DIR/$tdir/$tfile
438 test_mkdir $DIR/$tdir
441 $LFS setstripe $params $comp_file || error "Create $comp_file failed"
443 check_component_count $comp_file 3
445 dd if=/dev/zero of=$comp_file bs=1M count=2
447 $LFS setstripe --component-del -I 2 $comp_file &&
448 error "Component deletion makes hole"
450 del_comp_and_verify $comp_file 3 2 $((2 * 1024 * 1024))
451 del_comp_and_verify $comp_file 2 1 $((1 * 1024 * 1024))
452 del_comp_and_verify $comp_file 1 0 0
454 rm -f $comp_file || error "Delete $comp_file failed"
456 $LFS setstripe -E 1M -S 1M -E 16M -E -1 $comp_file ||
457 error "Create second $comp_file failed"
459 del_comp_and_verify $comp_file "^init" 1 0
460 del_comp_and_verify $comp_file "init" 0 0
461 rm -f $comp_file || error "Delete second $comp_file failed"
465 base_test_3 "-E 1M -S 1M -E 64M -c 2 -E -1 -c 3"
467 run_test 3a "Delete components from existing file"
470 base_test_3 "-E 1M -L mdt -E 64M -S 1M -c 2 -E -1 -c 3"
472 run_test 3b "Delete components w/DOM from existing file"
475 skip "Not supported in PFL"
476 # In PFL project, only LCME_FL_INIT is supported, and it can't
477 # be altered by application.
479 run_test 4 "Modify component flags in existing file"
482 local parent=$DIR/$tdir
483 local comp_file=$DIR/$tdir/$tfile
484 local subdir=$parent/subdir
489 # set default layout to parent directory
490 $LFS setstripe -E 64M -c 2 -i 0 -E -1 -c 4 -i 0 $parent ||
491 error "Set default layout to $parent failed"
493 # create file under parent
494 touch $comp_file || error "Create $comp_file failed"
495 check_component_count $comp_file 2
497 #instantiate all components, so that objs are allocted
498 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=65k
500 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
501 [ $ost_idx -ne 0 ] &&
502 error "component 1 ost_idx $ost_idx != 0"
504 ost_idx=$($LFS getstripe -I2 -i $comp_file)
505 [ $ost_idx -ne 0 ] &&
506 error "component 2 ost_idx $ost_idx != 0"
508 # create subdir under parent
509 mkdir -p $subdir || error "Create subdir $subdir failed"
511 comp_cnt=$($LFS getstripe -d --component-count $subdir)
512 [ $comp_cnt -ne 2 ] && error "subdir $comp_cnt != 2"
514 # create file under subdir
515 touch $subdir/$tfile || error "Create $subdir/$tfile failed"
517 check_component_count $subdir/$tfile 2
519 # delete default layout setting from parent
520 $LFS setstripe -d $parent ||
521 error "Delete default layout from $parent failed"
523 comp_cnt=$($LFS getstripe -d --component-count $parent)
524 [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0"
526 rm -f $comp_file || error "Delete $comp_file failed"
527 rm -f $subdir/$tfile || error "Delete $subdir/$tfile failed"
528 rm -r $subdir || error "Delete subdir $subdir failed"
529 rmdir $parent || error "Delete dir $parent failed"
531 run_test 5 "Inherit composite layout from parent directory"
534 local comp_file=$DIR/$tdir/$tfile
536 test_mkdir $DIR/$tdir
539 $LFS setstripe -c 1 -S 128K $comp_file ||
540 error "Create v1 $comp_file failed"
542 check_component_count $comp_file 0
544 dd if=/dev/urandom of=$comp_file bs=1M count=5 oflag=sync ||
545 error "Write to v1 $comp_file failed"
547 local old_chksum=$(md5sum $comp_file)
549 # Migrate v1 to composite
550 $LFS migrate -E 1M -S 512K -c 1 -E -1 -S 1M -c 2 $comp_file ||
551 error "Migrate(v1 -> composite) $comp_file failed"
553 check_component_count $comp_file 2
555 local chksum=$(md5sum $comp_file)
556 [ "$old_chksum" != "$chksum" ] &&
557 error "(v1 -> compsoite) $old_chksum != $chksum"
559 # Migrate composite to composite
560 $LFS migrate -E 1M -S 1M -c 2 -E 4M -S 1M -c 2 \
561 -E -1 -S 3M -c 3 $comp_file ||
562 error "Migrate(compsoite -> composite) $comp_file failed"
564 check_component_count $comp_file 3
566 chksum=$(md5sum $comp_file)
567 [ "$old_chksum" != "$chksum" ] &&
568 error "(composite -> compsoite) $old_chksum != $chksum"
570 # Migrate composite to v1
571 $LFS migrate -c 2 -S 2M $comp_file ||
572 error "Migrate(composite -> v1) $comp_file failed"
574 check_component_count $comp_file 0
576 chksum=$(md5sum $comp_file)
577 [ "$old_chksum" != "$chksum" ] &&
578 error "(composite -> v1) $old_chksum != $chksum"
580 rm -f $comp_file || error "Delete $comp_file failed"
582 run_test 6 "Migrate composite file"
585 test_mkdir $DIR/$tdir
586 chmod 0777 $DIR/$tdir || error "chmod $tdir failed"
588 local comp_file=$DIR/$tdir/$tfile
589 $RUNAS $LFS setstripe -E 1M -S 1M -c 1 $comp_file ||
590 error "Create composite file $comp_file failed"
592 $RUNAS $LFS setstripe --component-add -E 64M -c 4 $comp_file ||
593 error "Add component to $comp_file failed"
595 $RUNAS $LFS setstripe --component-del -I 2 $comp_file ||
596 error "Delete component from $comp_file failed"
598 $RUNAS $LFS setstripe --component-add -E -1 -c 5 $comp_file ||
599 error "Add last component to $comp_file failed"
601 rm $comp_file || error "Delete composite failed"
603 run_test 7 "Add/Delete/Create composite file by non-privileged user"
606 local parent=$DIR/$tdir
609 mkdir_on_mdt0 $parent
611 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c 2 -S 2M \
612 -E -1 -c 4 -S 4M $parent ||
613 error "Set default layout to $parent failed"
615 bash rundbench -C -D $parent 2 || error "dbench failed"
617 rm -fr $parent || error "Delete dir $parent failed"
619 run_test 8 "Run dbench over composite files"
622 local comp_file=$DIR/$tdir/$tfile
624 test_mkdir $DIR/$tdir
627 $LFS setstripe -E 1M -S 1M -E -1 -c 1 $comp_file ||
628 error "Create $comp_file failed"
630 check_component_count $comp_file 2
632 replay_barrier $SINGLEMDS
634 # instantiate the 2nd component
635 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
637 local f1=$($LFS getstripe -I2 $comp_file |
638 awk '/l_fid:/ {print $7}')
639 echo "before MDS recovery, the ost fid of 2nd component is $f1"
642 local f2=$($LFS getstripe -I2 $comp_file |
643 awk '/l_fid:/ {print $7}')
644 echo "after MDS recovery, the ost fid of 2nd component is $f2"
645 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
647 run_test 9 "Replay layout extend object instantiation"
650 echo $($LFS getstripe $1 |
651 awk '$1 == "lcm_entry_count:" { printf("%d", $2) }
652 $1 == "lcme_extent.e_start:" { printf("[%#lx", $2) }
653 $1 == "lcme_extent.e_end:" { printf(",%s]", $2) }')
657 local parent=$DIR/$tdir
660 save_layout_restore_at_exit $MOUNT
664 # mount root on $MOUNT2 if FILESET is set
665 if [ -n "$FILESET" ]; then
666 FILESET="" mount_client $MOUNT2 ||
667 error "mount $MOUNT2 fail"
671 $LFS setstripe -d $root || error "clear root layout"
673 # set root composite layout
674 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c2 -S 2M \
675 -E -1 -c 4 -S 4M $root ||
676 error "Set root layout failed"
678 if [ "$root" == "$MOUNT2" ]; then
679 umount_client $MOUNT2 ||
680 error "umount $MOUNT2 fail"
684 # set a different layout for parent
685 $LFS setstripe -E -1 -c 1 -S 1M $parent ||
686 error "set $parent layout failed"
689 local f1_entry=$(component_dump $parent/file1)
691 # delete parent's layout
692 $LFS setstripe -d $parent || error "Clear $parent layout failed"
695 local f2_entry=$(component_dump $parent/file2)
697 # verify layout inheritance
699 local f1_expect="1[0,EOF]"
700 local f2_expect="3[0,2097152][0x200000,16777216][0x1000000,EOF]"
702 echo "f1 expect=$f1_expect"
703 echo "f1 get =$f1_entry"
704 echo "f2 expect=$f2_expect"
705 echo "f2 get =$f2_entry"
707 [ x$f1_expect != x$f1_entry ] &&
708 error "$parent/file1 does not inherite parent layout"
709 [ x$f2_expect != x$f2_entry ] &&
710 error "$parent/file2 does not inherite root layout"
714 run_test 10 "Inherit composite template from root"
717 local comp_file=$DIR/$tdir/$tfile
718 test_mkdir $DIR/$tdir
721 # only 1st component instantiated
722 $LFS setstripe -E 1M -S 1M -E 2M -E 3M -E -1 $comp_file ||
723 error "Create $comp_file failed"
725 local f1=$($LFS getstripe -I1 $comp_file | grep "l_fid")
726 [[ -z $f1 ]] && error "1: 1st component uninstantiated"
727 local f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
728 [[ -n $f2 ]] && error "1: 2nd component instantiated"
729 local f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
730 [[ -n $f3 ]] && error "1: 3rd component instantiated"
731 local f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
732 [[ -n $f4 ]] && error "1: 4th component instantiated"
734 # the first 2 components instantiated
735 # Truncate to exact start of new component - LU-12586
736 $TRUNCATE $comp_file $((1024*1024*1))
738 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
739 [[ -z $f2 ]] && error "2: 2nd component uninstantiated"
740 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
741 [[ -n $f3 ]] && error "2: 3rd component instantiated"
742 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
743 [[ -n $f4 ]] && error "2: 4th component instantiated"
745 # the first 3 components instantiated
746 $TRUNCATE $comp_file $((1024*1024*3 - 1))
747 $TRUNCATE $comp_file $((1024*1024*1+1))
749 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
750 [[ -z $f2 ]] && error "3: 2nd component uninstantiated"
751 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
752 [[ -z $f3 ]] && error "3: 3rd component uninstantiated"
753 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
754 [[ -n $f4 ]] && error "3: 4th component instantiated"
756 # all 4 components instantiated, using append write
757 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
759 rwv -f $comp_file -w -a -n 2 $((1024*1023)) 1
762 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
763 [[ -z $f4 ]] && error "4: 4th component uninstantiated"
767 run_test 11a "Verify component instantiation with write/truncate"
770 [ $OSTCOUNT -lt 4 ] && skip "needs >= 4 OSTs"
772 local file=$DIR/$tdir/$tfile
774 test_mkdir $DIR/$tdir
777 $LFS setstripe -E 1m -E 1g -c 4 -E eof $DIR/$tdir ||
778 error "setstripe dir $DIR/$tdir failed"
779 expand_truncate_test $file ||
780 error "expand_truncate_test failed on $file"
782 run_test 11b "truncate file set file size correctly"
785 [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs"
787 local file=$DIR/$tdir/$tfile
788 test_mkdir $DIR/$tdir
791 # specify ost list for component
792 $LFS setstripe -E 2M -S 1M -c 2 -o 0,1 -E 4M -c 2 -o 1,2 \
793 -E 6M -c 2 -o 2,1 -E 8M -c 1 -i 2 -E -1 $file ||
794 error "Create $file failed"
796 # clear lod component cache
797 stop $SINGLEMDS || error "stop MDS"
798 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
799 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "start MDS"
801 # instantiate all components
802 $TRUNCATE $file $((1024*1024*8+1))
804 #verify object alloc order
805 local o1=$($LFS getstripe -I1 $file |
806 awk '/l_ost_idx:/ {printf("%d",$5)}')
807 [[ $o1 != "01" ]] && error "$o1 is not 01"
809 local o2=$($LFS getstripe -I2 $file |
810 awk '/l_ost_idx:/ {printf("%d",$5)}')
811 [[ $o2 != "12" ]] && error "$o2 is not 12"
813 local o3=$($LFS getstripe -I3 $file |
814 awk '/l_ost_idx:/ {printf("%d",$5)}')
815 [[ $o3 != "21" ]] && error "$o3 is not 21"
817 local o4=$($LFS getstripe -I4 $file |
818 awk '/l_ost_idx:/ {printf("%d",$5)}')
819 [[ $o4 != "2" ]] && error "$o4 is not 2"
823 run_test 12 "Verify ost list specification"
825 test_13() { # LU-9311
826 [ $OSTCOUNT -lt 8 ] && skip "needs >= 8 OSTs"
828 local file=$DIR/$tfile
830 local dd_size=$(($dd_count * 1024 * 1024))
834 $LFS setstripe -E 1M -S 1M -c 1 -E 2M -c 2 -E -1 -c -1 -i 1 $file ||
835 error "Create $file failed"
836 dd if=/dev/zero of=$file bs=1M count=$dd_count
837 real_size=$(stat -c %s $file)
838 [ $real_size -eq $dd_size ] ||
839 error "dd actually wrote $real_size != $dd_size bytes"
843 run_test 13 "shouldn't reprocess granted resent request"
846 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
847 local file=$DIR/$tdir/$tfile
848 test_mkdir -p $DIR/$tdir
853 create_pool $FSNAME.$p1 || error "create_pool $FSNAME.$p1 failed"
854 create_pool $FSNAME.$p2 || error "create_pool $FSNAME.$p2 failed"
855 $LFS setstripe -E1m -c1 -S1m --pool=$p1 -E2m \
856 -E4m -c2 -S2m --pool=$p2 -E-1 $file ||
857 error "Create $file failed"
859 # check --pool inheritance
861 pool="$($LFS getstripe -I2 --pool $file)"
862 [ x"$pool" != "xpool1" ] && $LFS getstripe -I2 $file &&
863 error "$file: component 2 doesn't have poolname pool1"
864 pool="$($LFS getstripe -I4 --pool $file)"
865 [ x"$pool" != "xpool2" ] && $LFS getstripe -I4 $file &&
866 error "$file: component 4 doesn't have poolname pool2"
868 #check --stripe-count inheritance
870 count="$($LFS getstripe -I2 -c $file)"
871 [ $count -ne 1 ] && $LFS getstripe -I2 $file &&
872 error "$file: component 2 doesn't have 1 stripe_count"
873 count="$($LFS getstripe -I4 -c $file)"
874 [ $count -ne 2 ] && $LFS getstripe -I4 $file &&
875 error "$file: component 4 doesn't have 2 stripe_count"
877 #check --stripe-size inheritance
879 size="$($LFS getstripe -I2 -S $file)"
880 [ $size -ne $((1024*1024)) ] && $LFS getstripe -I2 $file &&
881 error "$file: component 2 doesn't have 1M stripe_size"
882 size="$($LFS getstripe -I4 -S $file)"
883 [ $size -ne $((1024*1024*2)) ] && $LFS getstripe -I4 $file &&
884 error "$file: component 4 doesn't have 2M stripe_size"
888 run_test 14 "Verify setstripe poolname/stripe_count/stripe_size inheritance"
891 local parent=$DIR/$tdir
896 $LFS setstripe -d $parent || error "delete default layout"
898 $LFS setstripe -E 1M -S 1M -E 10M -E eof $parent/f1 || error "create f1"
899 $LFS setstripe -E 4M -E 20M -E eof $parent/f2 || error "create f2"
900 test_mkdir $parent/subdir
901 $LFS setstripe -E 6M -S 1M -c1 -E 30M -c4 -E eof -c $OSTCOUNT \
902 $parent/subdir || error "setstripe to subdir"
903 $LFS setstripe -E 8M -E eof $parent/subdir/f3 || error "create f3"
904 $LFS setstripe -c 1 $parent/subdir/f4 || error "create f4"
907 local found=$($LFS find --component-start +2M -E -15M $parent | wc -l)
908 [ $found -eq 0 ] || error "start+2M, end-15M, $found != 0"
911 found=$($LFS find --component-start +2M -E -35M $parent | wc -l)
912 [ $found -eq 2 ] || error "start+2M, end-35M, $found != 2"
915 found=$($LFS find --component-start +4M -E -eof $parent | wc -l)
916 [ $found -eq 1 ] || error "start+4M, end-eof, $found != 1"
918 local flg_opts="--component-flags init"
920 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
922 error "before write: start=1M, end=10M, flag=init, $found != 0"
924 dd if=/dev/zero of=$parent/f1 bs=1M count=2 ||
925 error "dd $parent/f1 failed"
928 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
930 error "after write: start=1M, end=10M, flag=init, $found != 1"
932 local ext_opts="--component-start -1M -E +5M"
933 # parent, subdir, f3, f4
934 found=$($LFS find $ext_opts $parent | wc -l)
935 [ $found -eq 4 ] || error "start-1M, end+5M, $found != 4"
937 local cnt_opts="--component-count +2"
939 found=$($LFS find $ext_opts $cnt_opts $parent | wc -l)
940 [ $found -eq 1 ] || error "start-1M, end+5M, count+2, $found != 1"
943 found=$($LFS find $ext_opts $cnt_opts $flg_opts $parent | wc -l)
945 error "start-1M, end+5M, count+2, flag=init, $found != 0"
948 found=$($LFS find $ext_opts ! $cnt_opts $flg_opts $parent | wc -l)
950 error "start-1M, end+5M, !count+2, flag=init, $found != 2"
952 # check last component stripe count
953 if [ $OSTCOUNT -gt 1 ]; then
954 touch $parent/subdir/f5
955 $TRUNCATE $parent/subdir/f5 $((32*1024*1024))
956 found=$($LFS find $parent/subdir -c $OSTCOUNT)
957 [[ "$found" == "$parent/subdir/f5" ]] ||
958 error "got '$found' with stripe_count=$OSTCOUNT, not f5"
961 run_test 15 "Verify component options for lfs find"
964 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
965 large_xattr_enabled || skip_env "ea_inode feature disabled"
967 local file=$DIR/$tdir/$tfile
968 local dir=$DIR/$tdir/dir
969 local temp=$DIR/$tdir/template
971 test_mkdir $DIR/$tdir
973 #####################################################################
975 # set stripe for source file
976 $LFS setstripe -E1m -S 1M -c2 -o0,1 -E2m -c2 -E3m -o1,0 -E4m -c1 -E-1 \
977 $file || error "Create $file failed"
980 verify_yaml_layout $file $file.copy $temp "1. PFL file"
982 #####################################################################
984 # set stripe for source file
986 $LFS setstripe -c2 -o0,1 -i1 $file || error "Create $file failed"
990 verify_yaml_layout $file $file.copy $temp "2. plain file"
992 #####################################################################
994 # set stripe for source dir
996 $LFS setstripe -E1m -S 1M -c2 -E2m -c1 -E-1 $dir ||
997 error "setstripe $dir failed"
1001 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
1003 #####################################################################
1005 # set stripe for source dir
1006 $LFS setstripe -c2 -i-1 $dir || error "setstripe $dir failed"
1009 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
1011 run_test 16a "Verify setstripe/getstripe with YAML config file"
1014 [[ $($LCTL get_param mdc.*.import |
1015 grep "connect_flags:.*overstriping") ]] ||
1016 skip "server does not support overstriping"
1017 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1018 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1019 skip_env "too many osts, skipping"
1020 large_xattr_enabled || skip_env "ea_inode feature disabled"
1024 local file=$DIR/$tdir/$tfile
1025 local dir=$DIR/$tdir/dir
1026 local temp=$DIR/$tdir/template
1027 # We know OSTCOUNT < (LOV_MAX_STRIPE_COUNT / 2), so this is overstriping
1028 local large_count=$((LOV_MAX_STRIPE_COUNT / 2))
1031 test_mkdir $DIR/$tdir
1033 #####################################################################
1034 # 1. PFL file, overstriping in first comps
1035 # set stripe for source file
1036 $LFS setstripe -E1m -S 1M -o0,0 -E2m -o1,1 -E3m -C $large_count -E-1 \
1037 $file || error "Create $file failed"
1040 verify_yaml_layout $file $file.copy $temp "1. PFL file"
1042 #####################################################################
1043 # 2. plain file + overstriping
1044 # set stripe for source file
1046 $LFS setstripe -C $large_count -i1 $file || error "Create $file failed"
1049 echo "2. plain file"
1050 verify_yaml_layout $file $file.copy $temp "2. plain file"
1052 #####################################################################
1053 # 3. PFL dir + overstriping
1054 # set stripe for source dir
1056 $LFS setstripe -E1m -S 1M -o 0,0 -E2m -C $large_count -E-1 $dir || {
1059 getfattr -d -m - -e hex $dir
1060 error "setstripe -E2m -C $large_count -E-1 $dir failed"
1063 test_mkdir $dir.copy
1065 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
1067 #####################################################################
1068 # 4. plain dir + overstriping
1069 # set stripe for source dir
1070 $LFS setstripe -C $large_count $dir || error "setstripe $dir failed"
1073 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
1075 run_test 16b "Verify setstripe/getstripe with YAML config file + overstriping"
1078 (( $MDS1_VERSION >= $(version_code 2.13.53.205) )) ||
1079 skip "need MDS version at least 2.13.53.205"
1081 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1083 local file=$DIR/$tdir/$tfile
1084 local dir=$DIR/$tdir/dir
1085 local temp=$DIR/$tdir/template
1087 test_mkdir $DIR/$tdir
1089 #####################################################################
1091 # set stripe for source file
1092 $LFS setstripe -E256M -S 1M -c2 -o0,1 -z 64M -E-1 -o1,0 -z 128M \
1093 $file || error "Create $file failed"
1096 verify_yaml_layout $file $file.copy $temp "1. PFL file"
1098 #####################################################################
1100 # set stripe for source dir
1102 $LFS setstripe -E256M -S 1M -c2 -z 64M -E-1 -z 128M \
1103 $dir || error "setstripe $dir failed"
1105 test_mkdir $dir.copy
1106 echo "2. SEL template on dir"
1107 verify_yaml_layout $dir $dir.copy $temp.dir "2. PFL dir"
1109 run_test 16c "Verify setstripe/getstripe for SEL layout with YAML config file"
1112 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1114 local file=$DIR/$tdir/$tfile
1115 local dir=$DIR/$tdir/dir
1116 local temp=$DIR/$tdir/template
1118 test_mkdir $DIR/$tdir
1120 #####################################################################
1122 # set stripe for source file
1123 $LFS setstripe -E1m -L mdt -E-1 -o1,0 $file ||
1124 error "Create $file failed"
1127 verify_yaml_layout $file $file.copy $temp "1. DOM file"
1129 #####################################################################
1131 # set stripe for source dir
1133 $LFS setstripe -E1m -L mdt -E-1 -o1,0 $dir || error "Create $dir failed"
1135 test_mkdir $dir.copy
1137 verify_yaml_layout $dir $dir.copy $temp.dir "2. DOM dir"
1139 run_test 16d "Verify setstripe/getstripe for DOM layout with YAML config file"
1143 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1144 local file=$DIR/$tdir/$tfile
1145 test_mkdir -p $DIR/$tdir
1148 $LFS setstripe -E 1M -S 1M -E 3M -c 2 -E -1 -c -1 $file ||
1149 error "Create $file failed"
1151 local s1=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
1152 local s2=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
1153 local s3=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
1154 echo "1st init: comp size 1:$s1 2:$s2 3:$s3"
1156 # init 2nd component
1157 $TRUNCATE $file $((1024*1024+1))
1158 local s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
1159 local s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
1160 echo "2nd init: comp size 1:$s1n 2:$s2n 3:$s3"
1162 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
1163 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
1165 # init 3rd component
1166 $TRUNCATE $file $((1024*1024*3+1))
1167 s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
1168 s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
1169 local s3n=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
1170 echo "3rd init: comp size 1:$s1n 2:$s2n 3:$s3n"
1172 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
1173 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
1174 [ $s3 -lt $s3n ] || error "3rd comp size $s3 should < $s3n"
1176 run_test 17 "Verify LOVEA grows with more component inited"
1178 check_distribution() {
1182 local obj_min_one=$((OSTCOUNT - 1))
1184 objs=$($LFS getstripe $file |
1185 awk '/l_ost_idx:/ { print $5 }' | wc -l)
1186 let ave=$((objs / OSTCOUNT))
1188 # collect objects per OST distribution
1189 $LFS getstripe $file | awk '/l_ost_idx:/ { print $5 }' | tr -d "," |
1190 (inuse=( $(for i in $(seq 0 $obj_min_one); do echo 0; done) )
1192 let inuse[$O]=$((1 + ${inuse[$O]}))
1195 # verify object distribution varies no more than +-1
1196 for idx in $(seq 0 $obj_min_one); do
1197 let dif=$((${inuse[$idx]} - ave))
1199 if [ "$dif" -gt 1 ]; then
1200 echo "OST${idx}: ${inuse[$idx]} objects"
1201 error "bad distribution on OST${idx}"
1207 local file1=$DIR/${tfile}-1
1208 local file2=$DIR/${tfile}-2
1209 local file3=$DIR/${tfile}-3
1211 rm -f $file1 $file2 $file3
1213 $LFS setstripe -E 1m -S 1m $file1 ||
1214 error "Create $file1 failed"
1215 $LFS setstripe -E 1m -S 1m $file2 ||
1216 error "Create $file2 failed"
1217 $LFS setstripe -E 1m -S 1m $file3 ||
1218 error "Create $file3 failed"
1220 local objs=$((OSTCOUNT+1))
1221 for comp in $(seq 1 $OSTCOUNT); do
1222 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file1 ||
1223 error "Add component to $file1 failed 2"
1224 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file2 ||
1225 error "Add component to $file2 failed 2"
1226 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file3 ||
1227 error "Add component to $file3 failed 2"
1230 $LFS setstripe --component-add -E -1 -c -1 $file1 ||
1231 error "Add component to $file1 failed 3"
1232 $LFS setstripe --component-add -E -1 -c -1 $file2 ||
1233 error "Add component to $file2 failed 3"
1234 $LFS setstripe --component-add -E -1 -c -1 $file3 ||
1235 error "Add component to $file3 failed 3"
1237 # Instantiate all components
1238 dd if=/dev/urandom of=$file1 bs=1M count=$((objs+1)) ||
1239 error "dd failed for $file1"
1240 dd if=/dev/urandom of=$file2 bs=1M count=$((objs+1)) ||
1241 error "dd failed for $file2"
1242 dd if=/dev/urandom of=$file3 bs=1M count=$((objs+1)) ||
1243 error "dd failed for $file3"
1245 check_distribution $file1
1246 check_distribution $file2
1247 check_distribution $file3
1250 run_test 18 "check component distribution"
1254 local already_created=${2:-0}
1255 local rw_len=$((3 * 1024 * 1024)) # 3M
1259 if [ $already_created != 1 ]; then
1260 test_mkdir -p $DIR/$tdir
1261 $LFS setstripe --extension-size 64M -c 1 -E -1 $comp_file ||
1262 error "Create $comp_file failed"
1265 # write past end of first component, so it is extended
1266 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=127 conv=notrunc ||
1267 error "dd to extend failed"
1269 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1270 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1271 local ssize=$($LFS getstripe -S -I1 $comp_file)
1273 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1274 [ $ost_idx2 -ne "-1" ] && error "second component init $ost_idx2"
1276 flg_opts="--comp-flags init"
1277 found=$($LFS find --comp-start 0 -E 128M $flg_opts $comp_file | wc -l)
1278 [ $found -eq 1 ] || error "Write: Extended first component not found"
1280 flg_opts="--comp-flags extension"
1281 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1282 [ $found -eq 1 ] || error "Write: second component not found"
1284 found=$($LFS find -z 64M $comp_file | wc -l)
1285 [ $found -eq 1 ] || error "component not found by ext size"
1287 found=$($LFS find --extension-size +63M $comp_file | wc -l)
1288 [ $found -eq 1 ] || error "component not found by +ext size"
1290 found=$($LFS find --ext-size -65M $comp_file | wc -l)
1291 [ $found -eq 1 ] || error "component not found by -ext size"
1293 found=$($LFS find -z 65M $comp_file | wc -l)
1294 [ $found -eq 0 ] || error "component found by wrong ext size"
1296 found=$($LFS find -z +65M $comp_file | wc -l)
1297 [ $found -eq 0 ] || error "component found by wrong +ext size"
1299 found=$($LFS find -z -63M $comp_file | wc -l)
1300 [ $found -eq 0 ] || error "component found by wrong -ext size"
1302 found=$($LFS find ! -z 64M $comp_file | wc -l)
1303 [ $found -eq 0 ] || error "component found by negation of ext size"
1305 found=$($LFS find ! -z +63M $comp_file | wc -l)
1306 [ $found -eq 0 ] || error "component found by negation of +ext size"
1308 found=$($LFS find ! -z -65M $comp_file | wc -l)
1309 [ $found -eq 0 ] || error "component found by negation of -ext size"
1311 found=$($LFS find ! -z 65M $comp_file | wc -l)
1313 error "component not found by negation of wrong ext size"
1315 found=$($LFS find ! -z +65M $comp_file | wc -l)
1317 error "component not found by negation of wrong +ext size"
1319 found=$($LFS find ! -z -63M $comp_file | wc -l)
1321 error "component not found by negation of wrong -ext size"
1323 found=$($LFS find -S +$ssize $comp_file | wc -l)
1324 [ $found -eq 0 ] || error "component found by wrong +stripe size"
1326 found=$($LFS find -c 1 $comp_file | wc -l)
1327 [ $found -eq 1 ] || error "component not found by stripe count"
1329 small_write $comp_file $rw_len || error "Verify RW failed"
1331 sel_layout_sanity $comp_file 2
1334 # Self-extending PFL tests
1336 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1337 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1338 skip "skipped for lustre < $SEL_VER"
1340 test19_io_base $DIR/$tdir/$tfile
1342 run_test 19a "Simple test of extension behavior"
1344 # Same as 19a, but with default layout set on directory rather than on file
1346 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1347 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1348 skip "skipped for lustre < $SEL_VER"
1350 local comp_file=$DIR/$tdir/$tfile
1351 local comp_dir=$DIR/$tdir/$tdir
1355 test_mkdir -p $DIR/$tdir
1356 $LFS setstripe --ext-size 64M -c 1 -E -1 $DIR/$tdir ||
1357 error "Setstripe on $DIR/$tdir failed"
1359 # check inheritance for a sub-dir and a file
1360 test_mkdir $comp_dir
1361 found=$($LFS find --comp-start 0 -E 64M $comp_dir | wc -l)
1362 [ $found -eq 1 ] || error "Dir Inheritance: wrong first component size"
1364 flg_opts="--comp-flags extension"
1365 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_dir | wc -l)
1366 [ $found -eq 1 ] || error "Dir Inheritance: Second component not found"
1370 flg_opts="--comp-flags init"
1371 found=$($LFS find --comp-start 0 -E 64M $flg_opts $comp_file | wc -l)
1372 [ $found -eq 1 ] || error "File Inheritance: wrong first component size"
1374 flg_opts="--comp-flags extension"
1375 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_file | wc -l)
1376 [ $found -eq 1 ] || error "File Inheritance: Second component not found"
1378 test19_io_base $comp_file 1
1380 run_test 19b "Simple test of SEL as default layout"
1382 # Test behavior when seeking deep in a file
1384 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1385 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1386 skip "skipped for lustre < $SEL_VER"
1388 local comp_file=$DIR/$tdir/$tfile
1392 test_mkdir -p $DIR/$tdir
1394 $LFS setstripe -z 128M -E 1G -E -1 $comp_file ||
1395 error "Create $comp_file failed"
1397 # write past end of first component, so it is extended
1398 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 conv=notrunc ||
1399 error "dd to extend failed"
1401 flg_opts="--comp-flags init"
1402 found=$($LFS find --comp-start 0M -E 256M $flg_opts $comp_file | wc -l)
1403 [ $found -eq 1 ] || error "Write: first extension component not found"
1405 flg_opts="--comp-flags extension,^init"
1406 found=$($LFS find --comp-start 256M -E 1024M $flg_opts $comp_file |\
1408 [ $found -eq 1 ] || error "Write: second extension component not found"
1410 local end_1=$($LFS getstripe -I1 -E $comp_file)
1413 [ $end_1 -eq 268435456 ] ||
1414 error "end of first component $end_1 != 268435456"
1416 # Write past end of extension space component, in to normal component
1417 # should exhaust & remove extension component
1418 dd if=/dev/zero bs=1M count=1 seek=1100 of=$comp_file conv=notrunc ||
1419 error "dd distant seek failed"
1421 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1422 # the last component index is 3
1423 local ost_idx2=$($LFS getstripe -I3 -i $comp_file)
1425 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1427 local start1=$($LFS getstripe -I1 --comp-start $comp_file)
1428 local end1=$($LFS getstripe -I1 -E $comp_file)
1429 local start2=$($LFS getstripe -I3 --comp-start $comp_file)
1430 local end2=$($LFS getstripe -I3 -E $comp_file)
1432 [ $start1 -eq 0 ] || error "start of first component incorrect"
1433 [ $end1 -eq 1073741824 ] || error "end of first component incorrect"
1434 [ $start2 -eq 1073741824 ] ||
1435 error "start of second component incorrect"
1436 [ "$end2" = "EOF" ] || error "end of second component incorrect"
1438 flg_opts="--comp-flags extension"
1439 found=$($LFS find $flg_opts $comp_file | wc -l)
1440 [ $found -eq 0 ] || error "Seek Write: extension component exists"
1442 sel_layout_sanity $comp_file 2
1444 run_test 19c "Test self-extending layout seeking behavior"
1447 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1448 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1449 skip "skipped for lustre < $SEL_VER"
1451 local comp_file=$DIR/$tdir/$tfile
1455 test_mkdir -p $DIR/$tdir
1457 $LFS setstripe -E 128M -c 1 -z 64M -E -1 $comp_file ||
1458 error "Create $comp_file failed"
1460 # This will cause component 1 to be extended to 128M, then the
1461 # extension space component will be removed
1462 dd if=/dev/zero of=$comp_file bs=130M count=1 ||
1463 error "dd to extend failed"
1465 flg_opts="--comp-flags init"
1466 found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file | wc -l)
1467 [ $found -eq 1 ] || error "Write: first component not found"
1469 flg_opts="--comp-flags init"
1470 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1471 [ $found -eq 1 ] || error "Write: second component not found"
1473 sel_layout_sanity $comp_file 2
1475 # always remove large files in case of DO_CLEANUP=false
1476 rm -f $comp_file || error "Delete $comp_file failed"
1478 run_test 19d "Test write which completely spans extension space component"
1483 local comp2_flags=$($LFS getstripe -I2 --comp-flags $comp_file)
1484 local comp3_flags=$($LFS getstripe -I3 --comp-flags $comp_file)
1486 [ "$comp2_flags" != "init" ] && error "$comp2_flags != init"
1487 [ "$comp3_flags" != "extension" ] && error "$comp3_flags != extension"
1489 local flg_opts=" --comp-start 2M -E 66M --comp-flags init"
1490 local found=$($LFS find $flg_opts $comp_file | wc -l)
1491 [ $found -eq 1 ] || error "Write: extended second component not found"
1493 flg_opts="--comp-start 66M -E EOF --comp-flags extension"
1494 found=$($LFS find $flg_opts $comp_file | wc -l)
1495 [ $found -eq 1 ] || error "Write: third component not found"
1497 sel_layout_sanity $comp_file 3
1501 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1502 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1503 skip "skipped for lustre < $SEL_VER"
1505 local comp_file=$DIR/$tdir/$tfile
1506 local rw_len=$((3 * 1024 * 1024)) # 3M
1510 test_mkdir -p $DIR/$tdir
1512 $LFS setstripe -E 2m -E -1 -z 64M $comp_file ||
1513 error "Create $comp_file failed"
1515 replay_barrier $SINGLEMDS
1517 #instantiate & extend second component
1518 dd if=/dev/zero of=$comp_file bs=4M count=1 ||
1519 error "dd to extend failed"
1521 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1522 local ost_idx3=$($LFS getstripe -I3 -i $comp_file)
1524 [ $ost_idx2 -eq $ost_idx3 ] && error "$ost_idx2 == $ost_idx3"
1525 [ $ost_idx3 -ne "-1" ] && error "third component init $ost_idx3"
1527 test_19e_check $comp_file
1529 local f1=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1530 echo "before MDS recovery, the ost fid of 2nd component is $f1"
1534 local f2=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1535 echo "after MDS recovery, the ost fid of 2nd component is $f2"
1536 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
1538 # simply repeat all previous checks, but also verify components are on
1539 # the same OST as before
1541 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1542 local ost_idx3_2=$($LFS getstripe -I3 -i $comp_file)
1544 [ $ost_idx2_2 -eq $ost_idx3_2 ] && error "$ost_idx2_2 == $ost_idx3_2"
1545 [ $ost_idx3_2 -ne "-1" ] && error "second component init $ost_idx3_2"
1547 # verify OST id is the same after failover
1548 [ $ost_idx2 -ne $ost_idx2_2 ] &&
1549 error "$ost_idx2 != $ost_idx2_2, changed after failover"
1551 test_19e_check $comp_file
1553 run_test 19e "Replay of layout instantiation & extension"
1556 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1557 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1558 skip "skipped for lustre < $SEL_VER"
1560 local comp_file=$DIR/$tdir/$tfile
1564 test_mkdir -p $DIR/$tdir
1566 $LFS setstripe -E 256M --comp-flags extension -E -1 $comp_file
1568 [ $? != 0 ] || error "should not be able to manually set extension flag"
1571 run_test 19f "Rejection of invalid layouts"
1574 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1575 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1576 skip "skipped for lustre < $SEL_VER"
1578 local file1=$DIR/${tfile}-1
1579 local file2=$DIR/${tfile}-2
1581 test_mkdir -p $DIR/$tdir
1582 multiop $file1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1583 error "create failed $file1"
1584 multiop $file2 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1585 error "create failed $file2"
1587 $LFS setstripe --component-add -E 1G -c 1 $file1 ||
1588 error "comp-add [0,1G] failed $file1"
1589 $LFS setstripe --component-add -E 512M -z 128M $file1 &&
1590 error "comp-add [1G,1G],SEL[1G,512M] succeded $file1"
1591 $LFS setstripe --component-add -E 10G -z 128M $file1 ||
1592 error "comp-add [1G,1G],SEL[1G,10G] failed $file1"
1593 $LFS setstripe --component-add -E -1 $file1 ||
1594 error "comp-add [10G,-1] failed $file1"
1596 $LFS setstripe --component-add -E 1G -z 32M -c 1 $file2 &&
1597 error "comp-add with smal ext size succeeded $file1"
1598 $LFS setstripe --component-add -E 1G -z 100M -c 1 $file2 &&
1599 error "comp-add with not aligned ext size succeeded $file1"
1600 $LFS setstripe --component-add -E 1G -z 128M -c 1 $file2 ||
1601 error "comp-add [0,128M],SEL[128M,1G] failed $file1"
1602 $LFS setstripe --component-add -E 10G $file2 ||
1603 error "comp-add [1G,10G] failed $file1"
1604 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 ||
1605 error "comp-add [10G,10G],SEL[10G,-1] failed $file1"
1606 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 &&
1607 error "repeated comp-add [10G,10G],SEL[10G,-1] succeeded $file1"
1609 $LFS getstripe $file1
1610 flg_opts="--comp-flags init"
1611 found=$($LFS find --comp-start 0 -E 1G $flg_opts $file1 | wc -l)
1612 [ $found -eq 1 ] || error "First component not found $file1"
1614 flg_opts="--comp-flags ^init"
1615 found=$($LFS find --comp-start 1G -E 1G $flg_opts $file1 | wc -l)
1616 [ $found -eq 1 ] || error "Second component not found $file1"
1618 flg_opts="--comp-flags ^init,extension"
1619 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file1 | wc -l)
1620 [ $found -eq 1 ] || error "Third component not found $file1"
1622 flg_opts="--comp-flags ^init"
1623 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file1 | wc -l)
1624 [ $found -eq 1 ] || error "Fourth component not found $file1"
1626 $LFS getstripe $file2
1627 flg_opts="--comp-flags init"
1628 found=$($LFS find --comp-start 0 -E 128M $flg_opts $file2 | wc -l)
1629 [ $found -eq 1 ] || error "First component not found $file2"
1631 flg_opts="--comp-flags extension"
1632 found=$($LFS find --comp-start 128M -E 1G $flg_opts $file2 | wc -l)
1633 [ $found -eq 1 ] || error "Second component not found $file2"
1635 flg_opts="--comp-flags ^init"
1636 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file2 | wc -l)
1637 [ $found -eq 1 ] || error "Third component not found $file2"
1639 flg_opts="--comp-flags ^init"
1640 found=$($LFS find --comp-start 10G -E 10G $flg_opts $file2 | wc -l)
1641 [ $found -eq 1 ] || error "Fourth component not found $file2"
1643 flg_opts="--comp-flags ^init,extension"
1644 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file2 | wc -l)
1645 [ $found -eq 1 ] || error "Fifth component not found $file2"
1647 run_test 19g "component-add behaviour"
1649 # Test out of space behavior
1651 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1652 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1653 skip "skipped for lustre < $SEL_VER"
1655 local comp_file=$DIR/$tdir/$tfile
1659 test_mkdir -p $DIR/$tdir
1661 # without this, a previous delete can finish after we check free space
1662 wait_delete_completed
1665 # First component is on OST0
1666 $LFS setstripe -E 256M -i 0 -z 64M -E -1 -z 128M $comp_file ||
1667 error "Create $comp_file failed"
1669 # write past end of first component, so it is extended
1670 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=66 ||
1671 error "dd to extend failed"
1673 flg_opts="--comp-flags extension"
1674 found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file |wc -l)
1675 [ $found -eq 1 ] || error "Write: Second component not found"
1677 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1678 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1680 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1682 flg_opts="--comp-flags extension"
1683 # Write past current init comp, but we won't extend (because no space)
1684 dd if=/dev/zero of=$comp_file bs=1M count=10 seek=200 ||
1685 error "dd write past current comp failed"
1687 $LFS getstripe $comp_file
1689 flg_opts="--comp-flags init"
1690 found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file | \
1692 [ $found -eq 1 ] || error "Write: third component not found"
1694 flg_opts="--comp-flags extension"
1695 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file |wc -l)
1696 [ $found -eq 1 ] || error "Write: fourth extension component not found"
1698 sel_layout_sanity $comp_file 3
1700 run_test 20a "Test out of space, spillover to defined component"
1703 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1704 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1705 skip "skipped for lustre < $SEL_VER"
1707 local comp_file=$DIR/$tdir/$tfile
1711 test_mkdir -p $DIR/$tdir
1713 # Pool allows us to force use of only certain OSTs
1714 pool_add $TESTNAME || error "Pool creation failed"
1715 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1717 # normal component to 10M, extendable component to 1G
1718 # further extendable to EOF
1719 $LFS setstripe -E 10M -E 1G -p $TESTNAME -z 64M -E -1 -p "" -z 128M \
1720 $comp_file || error "Create $comp_file failed"
1722 replay_barrier $SINGLEMDS
1724 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1725 [ $found -eq 1 ] || error "Zero length component not found"
1728 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1730 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1732 # write past end of first component
1733 # This should remove the next component, since OST0 is out of space
1734 # and it is striped there (pool contains only OST0)
1735 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=14 ||
1736 error "dd to extend/remove failed"
1738 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1739 [ $found -eq 0 ] || error "Write: zero length component still present"
1741 flg_opts="--comp-flags init"
1742 $LFS find --comp-start 10M -E +137M $flg_opts $comp_file
1743 found=$($LFS find --comp-start 10M -E +137M $flg_opts $comp_file |wc -l)
1744 [ $found -eq 1 ] || error "Write: second component not found"
1746 flg_opts="--comp-flags extension"
1747 found=$($LFS find --comp-start +137M -E EOF $flg_opts $comp_file |wc -l)
1748 [ $found -eq 1 ] || error "Write: third component not found"
1752 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1753 [ $found -eq 0 ] || error "Failover: 0-length component still present"
1755 flg_opts="--comp-flags init"
1756 found=$($LFS find --comp-start 10M -E +137M $flg_opts $comp_file |wc -l)
1757 [ $found -eq 1 ] || error "Failover: second component not found"
1759 flg_opts="--comp-flags extension"
1760 found=$($LFS find --comp-start +137M -E EOF $flg_opts $comp_file |wc -l)
1761 [ $found -eq 1 ] || error "Failover: third component not found"
1763 sel_layout_sanity $comp_file 3
1765 run_test 20b "Remove component without instantiation when there is no space"
1768 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1769 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1770 skip "skipped for lustre < $SEL_VER"
1772 local comp_file=$DIR/$tdir/$tfile
1776 test_mkdir -p $DIR/$tdir
1778 # pool is used to limit available OSTs to 0 and 1, so we can set all
1779 # available OSTs out of space
1780 pool_add $TESTNAME || error "Pool creation failed"
1781 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
1783 # without this, a previous delete can finish after we check free space
1784 wait_delete_completed
1787 $LFS setstripe -E 100M -E -1 -p $TESTNAME -z 64M $comp_file ||
1788 error "Create $comp_file failed"
1792 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1794 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
1796 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1797 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
1799 dd if=/dev/urandom of=$comp_file bs=1M count=1 seek=120 &&
1800 error "dd should fail with ENOSPC"
1802 flg_opts="--comp-flags init"
1803 found=$($LFS find --comp-start 0M -E 100M $flg_opts $comp_file | wc -l)
1804 [ $found -eq 1 ] || error "Write: First component not found"
1806 flg_opts="--comp-flags ^init"
1807 found=$($LFS find --comp-start 100M -E 100M $flg_opts $comp_file |wc -l)
1808 [ $found -eq 1 ] || error "Write: 0-length component not found"
1810 flg_opts="--comp-flags extension"
1811 found=$($LFS find --comp-start 100M -E EOF $flg_opts $comp_file | wc -l)
1812 [ $found -eq 1 ] || error "Write: third extension component not found"
1814 sel_layout_sanity $comp_file 3
1816 run_test 20c "Test inability to stripe new extension component"
1819 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1820 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1821 skip "skipped for lustre < $SEL_VER"
1823 local comp_file=$DIR/$tdir/$tfile
1824 test_mkdir -p $DIR/$tdir
1826 wait_delete_completed
1829 pool_add $TESTNAME || error "Pool creation failed"
1830 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1831 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
1832 error "Create $comp_file failed"
1834 replay_barrier $SINGLEMDS
1836 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1837 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1840 ost_watermarks_clear_enospc $tfile 0 $wms
1841 [ $RC -eq 0 ] || error "dd failed: $RC"
1843 $LFS getstripe $comp_file
1844 local flg_opts="--comp-start 64M -E 128M --comp-flags init"
1845 local found=$($LFS find $flg_opts $comp_file | wc -l)
1846 [ $found -eq 1 ] || error "Write: component (64M-128M) not found"
1848 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
1849 [ "$ost_idx" != "-1" ] && error "Write: EXT component disappeared"
1853 found=$($LFS find $flg_opts $comp_file | wc -l)
1854 [ $found -eq 1 ] || error "Failover: component (64M-128M) not found"
1856 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1857 [ "$ost_idx" != "-1" ] && error "Failover: EXT component disappeared"
1859 sel_layout_sanity $comp_file 3
1861 run_test 20d "Low on space + 0-length comp: force extension"
1864 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1865 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1866 skip "skipped for lustre < $SEL_VER"
1868 local comp_file=$DIR/$tdir/$tfile
1869 test_mkdir -p $DIR/$tdir
1871 wait_delete_completed
1874 pool_add $TESTNAME || error "Pool creation failed"
1875 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1877 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
1878 error "Create $comp_file failed"
1880 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1882 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1885 ost_watermarks_clear_enospc $tfile 0 $wms
1886 [ $RC -eq 0 ] || error "dd failed $RC"
1888 $LFS getstripe $comp_file
1889 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
1890 local found=$($LFS find $flg_opts $comp_file | wc -l)
1891 [ $found -eq 1 ] || error "Write: component (64M-EOF) not found"
1893 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
1894 [ "$ost_idx" != "" ] && error "Write: 0-length component still exists"
1895 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1896 [ "$ost_idx" != "" ] && error "Write: extension component still exists"
1898 sel_layout_sanity $comp_file 2
1900 run_test 20e "ENOSPC with next real comp: spillover and backward extension"
1902 # Simple DoM interaction test
1904 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1905 skip "skipped for lustre < $SEL_VER"
1907 local comp_file=$DIR/$tdir/$tfile
1911 test_mkdir -p $DIR/$tdir
1913 # simple, correct self-extending layout after DoM component
1914 $LFS setstripe -E 1M -L mdt -E -1 -z 64m $comp_file || \
1915 error "Create $comp_file failed"
1917 # Write to DoM component & to self-extending comp after it
1918 dd if=/dev/zero bs=1M count=12 of=$comp_file ||
1919 error "dd to extend failed"
1921 flg_opts="--comp-flags init"
1922 found=$($LFS find --comp-start 1M -E 65M $flg_opts $comp_file | wc -l)
1923 [ $found -eq 1 ] || error "Write: extended component not found"
1925 flg_opts="--comp-flags extension"
1926 found=$($LFS find --comp-start 65M $flg_opts $comp_file | wc -l)
1927 [ $found -eq 1 ] || error "Write: extension component not found"
1929 sel_layout_sanity $comp_file 3
1931 run_test 21a "Simple DoM interaction tests"
1933 # DoM + extension + removal
1935 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1936 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1937 skip "skipped for lustre < $SEL_VER"
1939 local comp_file=$DIR/$tdir/$tfile
1940 local ost_name=$(ostname_from_index 0)
1944 test_mkdir -p $DIR/$tdir
1946 # DoM, extendable component, further extendable component
1947 $LFS setstripe -E 1M -L mdt -S 1M -E 256M -i 0 -z 64M -S 1M -E -1 \
1948 -z 128M $comp_file || error "Create $comp_file failed"
1950 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1951 [ $found -eq 1 ] || error "Write: Zero length component not found"
1953 # This also demonstrates that we will avoid degraded OSTs
1954 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
1955 # sleep to guarantee we see the degradation
1958 # un-degrade on exit
1959 stack_trap "do_facet ost1 $LCTL set_param -n \
1960 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1962 # This should remove the first component after DoM and spill over to
1964 dd if=/dev/zero bs=1M count=2 of=$comp_file ||
1965 error "dd to remove+spill over failed"
1967 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1968 [ $found -eq 0 ] || error "Write: Zero length component still present"
1970 flg_opts="--comp-flags init"
1971 found=$($LFS find --comp-start 1M -E 129M $flg_opts $comp_file | wc -l)
1972 [ $found -eq 1 ] || error "Write: extended component not found"
1974 flg_opts="--comp-flags extension"
1975 found=$($LFS find --comp-start 129M -E EOF $flg_opts $comp_file |wc -l)
1976 [ $found -eq 1 ] || error "Write: extension component not found"
1978 sel_layout_sanity $comp_file 3
1980 run_test 21b "DoM followed by extendable component with removal"
1982 # Test of repeat component behavior with OOS/degraded OST
1984 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1985 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1986 skip "skipped for lustre < $SEL_VER"
1988 local comp_file=$DIR/$tdir/$tfile
1992 test_mkdir -p $DIR/$tdir
1994 $LFS setstripe -E -1 -c 1 -z 128M $comp_file ||
1995 error "Create $comp_file failed"
1997 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1998 local ost_name=$(ostname_from_index $ost_idx1)
2000 # write past end of first component, so it is extended
2001 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
2002 error "dd to extend failed"
2004 flg_opts="--comp-flags extension"
2005 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
2006 [ $found -eq 1 ] || error "Write: second component not found"
2008 # degrade OST for component 1
2009 do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
2010 obdfilter.$ost_name.degraded=1
2011 # sleep to guarantee we see the degradation
2014 # un-degrade on exit
2015 stack_trap "do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
2016 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
2018 replay_barrier $SINGLEMDS
2020 # seek past the end of current comp & write, should cause a new comp
2021 # to be created (ie repeat previous comp)
2022 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
2023 error "dd to repeat failed"
2025 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
2027 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
2029 flg_opts="--comp-flags init"
2030 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
2031 [ $found -eq 1 ] || error "Write: second component not found"
2033 flg_opts="--comp-flags extension"
2034 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
2035 [ $found -eq 1 ] || error "Write: extension component not found"
2039 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
2040 [ $ost_idx2_2 -ne $ost_idx2 ] && error "$ost_idx2_2 != $ost_idx2"
2042 flg_opts="--comp-flags init"
2043 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
2044 [ $found -eq 1 ] || error "Failover: second component not found"
2046 flg_opts="--comp-flags extension"
2047 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
2048 [ $found -eq 1 ] || error "Failover: extension component not found"
2050 sel_layout_sanity $comp_file 3
2052 run_test 22a "Test repeat component behavior with degraded OST"
2054 # Test repeat behavior with low space
2056 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2057 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2058 skip "skipped for lustre < $SEL_VER"
2060 local comp_file=$DIR/$tdir/$tfile
2064 test_mkdir -p $DIR/$tdir
2066 # without this, a previous delete can finish after we check free space
2067 wait_delete_completed
2070 $LFS setstripe -E -1 -c 1 -z 128M \
2071 $comp_file || error "Create $comp_file failed"
2073 # write past end of first component, so it is extended
2074 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
2075 error "dd to extend failed"
2077 flg_opts="--comp-flags extension"
2078 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
2079 [ $found -eq 1 ] || error "Write: Second component not found"
2081 # set our OST low on space
2082 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
2083 local wms=$(ost_watermarks_set_low_space $ost_idx1 | grep "watermarks")
2085 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
2087 # Write past end of current space, fail to extend, causing repeat
2088 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
2089 error "dd to repeat failed"
2091 $LFS getstripe $comp_file
2093 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
2095 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
2097 flg_opts="--comp-flags init"
2098 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
2099 [ $found -eq 1 ] || error "Write: Second component not found"
2101 flg_opts="--comp-flags extension"
2102 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
2103 [ $found -eq 1 ] || error "Write: Extension component not found"
2105 sel_layout_sanity $comp_file 3
2107 run_test 22b "Test simple 'out of space' condition with repeat"
2109 # This tests both "repeat" and "extend in place when repeat fails" aspects
2110 # of repeating components
2112 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2113 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2114 skip "skipped for lustre < $SEL_VER"
2116 local comp_file=$DIR/$tdir/$tfile
2120 test_mkdir -p $DIR/$tdir
2122 # pool is used to limit available OSTs to 0 and 1, so we can set all
2123 # available OSTs out of space
2124 pool_add $TESTNAME || error "Pool creation failed"
2125 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
2127 # without this, a previous delete can finish after we check free space
2128 wait_delete_completed
2131 $LFS setstripe -E -1 -z 64M -c 1 -p "$TESTNAME" $comp_file || \
2132 error "Create $comp_file failed"
2134 # write past end of first component, so it is extended
2135 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=80 conv=notrunc ||
2136 error "dd to extend failed"
2138 $LFS getstripe $comp_file
2140 flg_opts="--comp-flags extension"
2141 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
2142 [ $found -eq 1 ] || error "Write: second component not found"
2144 # set our OST out of space
2145 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
2146 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
2148 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
2150 # This should create a repeat component on a new OST
2151 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=180 conv=notrunc ||
2152 error "dd to repeat failed"
2154 $LFS getstripe $comp_file
2156 local comp_cnt=$($LFS getstripe --component-count $comp_file)
2157 [ $comp_cnt -ne 3 ] && error "component count: $comp_cnt, should be 3"
2159 # New second component should be on a different OST
2160 local ost_idx2=$($LFS getstripe --comp-start=128m \
2161 --comp-end=192m --comp-flags=init -i $comp_file)
2163 [ $ost_idx1 -eq $ost_idx2 ] && error "2nd comp: same OST $ost_idx1"
2165 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
2167 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
2169 # now that the second OST is out of space (as is the first OST), we
2170 # attempt to extend. This should result in an extension of the
2171 # existing component, rather than a new component.
2172 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=240 conv=notrunc ||
2173 error "dd for forced extension failed"
2175 $LFS getstripe $comp_file
2177 # clear out of space on first OST
2178 ost_watermarks_clear_enospc $tfile $ost_idx1 $wms
2180 # finally, now that the first OST has space again, we attempt to
2181 # extend one last time. This should create a new component on the
2183 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 conv=notrunc ||
2184 error "dd for repeat on first OST failed"
2186 $LFS getstripe $comp_file
2188 flg_opts="--comp-flags init"
2189 found=$($LFS find --comp-start 128M $flg_opts $comp_file | wc -l)
2190 [ $found -eq 1 ] || error "Write: second component not found"
2192 flg_opts="--comp-flags init"
2193 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
2194 [ $found -eq 1 ] || error "Write: third component not found"
2196 flg_opts="--comp-flags extension"
2197 found=$($LFS find --comp-start 320M -E EOF $flg_opts $comp_file | wc -l)
2198 [ $found -eq 1 ] || error "Write: extension component not found"
2200 sel_layout_sanity $comp_file 4
2202 run_test 22c "Test repeat with out of space on > 1 OST"
2204 test_22d_post_check() {
2207 local flg_opts="--comp-flags init"
2208 local found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file |
2210 [ $found -eq 1 ] || {
2211 $LFS getstripe $comp_file
2212 error "$name: second component not found"
2215 flg_opts="--comp-flags extension"
2216 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
2217 [ $found -eq 1 ] || error "$name: third extension component not found"
2219 sel_layout_sanity $comp_file 2
2227 # write past end of first component
2228 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=70
2231 ost_watermarks_clear_enospc $tfile 0 $wms
2232 [ $RC -eq 0 ] || error "dd to force extend failed"
2234 test_22d_post_check $comp_file "Write"
2238 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2239 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2240 skip "skipped for lustre < $SEL_VER"
2242 local comp_file=$DIR/$tdir/$tfile
2246 test_mkdir -p $DIR/$tdir
2248 # without this, a previous delete can finish after we check free space
2249 wait_delete_completed
2252 # Pool allows us to force use of only certain OSTs
2253 pool_add $TESTNAME || error "Pool creation failed"
2254 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2256 # 1. Fail to extend due to OOS, try to repeat within the same pool,
2257 # fail to stripe (again OOS) the 0-length component, remove the
2258 # repeated one, force the extension on the original one.
2259 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2260 error "Create $comp_file failed"
2262 replay_barrier $SINGLEMDS
2264 # set our OST out of space
2265 local wms=$(ost_watermarks_set_enospc $tfile 0 | grep "watermarks")
2267 test_22d_pre $comp_file "$wms"
2269 test_22d_post_check $comp_file "Failover"
2271 # 2. repeat with low on space: 0-length repeated component will be
2272 # striped, but still fails to be extended; otherwise the same as (1).
2274 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2275 error "Create $comp_file failed"
2277 replay_barrier $SINGLEMDS
2279 # set our OST low on space
2280 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2282 test_22d_pre $comp_file "$wms"
2284 test_22d_post_check $comp_file "Failover"
2286 run_test 22d "out of/low on space + failed to repeat + forced extension"
2289 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2290 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2291 skip "skipped for lustre < $SEL_VER"
2293 local comp_file=$DIR/$tdir/$tfile
2294 test_mkdir -p $DIR/$tdir
2296 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2297 error "Create $comp_file failed"
2299 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2300 error "dd append failed"
2302 local flg_opts="--comp-start 0 -E EOF --comp-flags init"
2303 local found=$($LFS find $flg_opts $comp_file | wc -l)
2304 [ $found -eq 1 ] || error "Append: first component (0-EOF) not found"
2306 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2307 [ "$ost_idx" != "" ] && error "Append: second component still exists"
2309 sel_layout_sanity $comp_file 1
2311 run_test 23a "Append: remove EXT comp"
2314 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2315 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2316 skip "skipped for lustre < $SEL_VER"
2318 local comp_file=$DIR/$tdir/$tfile
2319 test_mkdir -p $DIR/$tdir
2321 $LFS setstripe -E 64m -E -1 -z 64M $comp_file ||
2322 error "Create $comp_file failed"
2324 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2325 error "dd append failed"
2327 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2328 local found=$($LFS find $flg_opts $comp_file | wc -l)
2329 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2331 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2332 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2334 sel_layout_sanity $comp_file 2
2336 run_test 23b "Append with 0-length comp: remove EXT comp"
2339 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2340 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2341 skip "skipped for lustre < $SEL_VER"
2343 local comp_file=$DIR/$tdir/$tfile
2344 test_mkdir -p $DIR/$tdir
2346 wait_delete_completed
2349 pool_add $TESTNAME || error "Pool creation failed"
2350 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2351 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
2352 error "Create $comp_file failed"
2354 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2355 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2358 ost_watermarks_clear_enospc $tfile 0 $wms
2359 [ $RC -eq 0 ] || error "dd append failed: $RC"
2361 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2362 local found=$($LFS find $flg_opts $comp_file | wc -l)
2363 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2365 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2366 [ "$ost_idx" != "" ] && error "Append: EXT component still exists"
2368 sel_layout_sanity $comp_file 2
2370 run_test 23c "Append with low on space + 0-length comp: force extension"
2373 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2374 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2375 skip "skipped for lustre < $SEL_VER"
2377 local comp_file=$DIR/$tdir/$tfile
2378 test_mkdir -p $DIR/$tdir
2380 $LFS setstripe -E 64m -E 640M -z 64M -E -1 $comp_file ||
2381 error "Create $comp_file failed"
2383 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2384 error "dd append failed"
2386 flg_opts="--comp-start 64M -E 640M --comp-flags init"
2387 found=$($LFS find $flg_opts $comp_file | wc -l)
2388 [ $found -eq 1 ] || error "Append: component (64M-640M) not found"
2390 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2391 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2393 sel_layout_sanity $comp_file 3
2395 run_test 23d "Append with 0-length comp + next real comp: remove EXT comp"
2398 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2399 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2400 skip "skipped for lustre < $SEL_VER"
2402 local comp_file=$DIR/$tdir/$tfile
2403 test_mkdir -p $DIR/$tdir
2405 wait_delete_completed
2408 pool_add $TESTNAME || error "Pool creation failed"
2409 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2411 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
2412 error "Create $comp_file failed"
2414 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2416 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2419 ost_watermarks_clear_enospc $tfile 0 $wms
2420 [ $RC -eq 0 ] || error "dd append failed $RC"
2422 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2423 local found=$($LFS find $flg_opts $comp_file | wc -l)
2424 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2426 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2427 [ "$ost_idx" != "" ] && error "Append: 0-length component still exists"
2428 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2429 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2431 sel_layout_sanity $comp_file 2
2433 run_test 23e "Append with next real comp: spillover and backward extension"
2436 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2437 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2438 skip "skipped for lustre < $SEL_VER"
2440 local comp_file=$DIR/$tdir/$tfile
2441 test_mkdir -p $DIR/$tdir
2443 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2444 error "Create $comp_file failed"
2446 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
2447 local wms=$(ost_watermarks_set_low_space $ost_idx | grep "watermarks")
2449 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2452 ost_watermarks_clear_enospc $tfile $ost_idx $wms
2453 [ $RC -eq 0 ] || error "dd append failed"
2455 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2456 local found=$($LFS find $flg_opts $comp_file | wc -l)
2457 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2459 ost_idx=$($LFS getstripe -I2 -i $comp_file)
2460 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2462 sel_layout_sanity $comp_file 2
2464 run_test 23f "Append with low on space: repeat and remove EXT comp"
2473 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
2474 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
2475 [ "$OSTCOUNT" -lt "3" ] && skip_env "needs >= 3 OSTs"
2477 trap cleanup_24 EXIT RETURN
2479 local file=$DIR/$tfile
2481 $LFS setstripe -E 1m -c1 -o0 -E eof -c2 -S 1M -o1,2 $file ||
2482 error "setstripe on $file"
2484 dd if=/dev/zero of=$file bs=1M count=3 || error "dd failed for $file"
2487 filefrag -ves $file || error "filefrag $file failed"
2488 filefrag_op=$(filefrag -ve -k $file |
2489 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
2491 #Filesystem type is: bd00bd0
2492 #File size of /mnt/lustre/f24a.sanity-pfl is 3145728 (3072 blocks of 1024 bytes)
2493 # ext: device_logical: physical_offset: length: dev: flags:
2494 # 0: 0.. 1023: 1572864.. 1573887: 1024: 0000: net
2495 # 1: 0.. 1023: 1572864.. 1573887: 1024: 0002: net
2496 # 2: 1024.. 2047: 1573888.. 1574911: 1024: 0001: last,net
2497 #/mnt/lustre/f24a.sanity-pfl: 3 extents found
2499 last_lun=$(echo $filefrag_op | cut -d: -f5)
2504 for line in $filefrag_op; do
2505 frag_lun=$(echo $line | cut -d: -f5)
2506 ext_len=$(echo $line | cut -d: -f4)
2507 if [[ "$frag_lun" != "$last_lun" ]]; then
2508 if (( tot_len != 1024 )); then
2510 error "$file: OST$last_lun $tot_len != 1024"
2516 (( tot_len += ext_len ))
2519 if (( num_luns != 3 || tot_len != 1024 )); then
2521 error "$file: $num_luns != 3, $tot_len != 1024 on OST$last_lun"
2524 echo "FIEMAP on $file succeeded"
2526 run_test 24a "FIEMAP upon PFL file"
2529 local pfl_f=$DIR/$tdir/"$tfile"_pfl
2530 local dom_f=$DIR/$tdir/"$tfile"_dom
2531 local common_f=$DIR/$tdir/"$tfile"_common
2535 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2536 $LFS setstripe -E 10M -S 64k -c -1 -E 20M -S 1M -E -1 -S 2M -c 1 \
2537 $pfl_f || error "setstripe $pfl_f failed"
2538 $LFS setstripe -E 256k -L mdt -E -1 -S 1M $dom_f ||
2539 error "setstripe $dom_f failed"
2540 $LFS setstripe -S 512K -c -1 $common_f ||
2541 error "setstripe $common_f failed"
2543 #verify lov_getstripe_old with PFL file
2544 stripe_count=$(lov_getstripe_old $pfl_f |
2545 awk '/stripe_count/ { print $2 }')
2546 stripe_size=$(lov_getstripe_old $pfl_f |
2547 awk '/stripe_size/ { print $2 }')
2548 [ $stripe_count -eq 1 ] ||
2549 error "stripe_count $stripe_count !=1 for $pfl_f"
2550 [ $stripe_size -eq 2097152 ] ||
2551 error "stripe_size $stripe_size != 2097152 for $pfl_f"
2553 #verify lov_getstripe_old with DoM file
2554 stripe_count=$(lov_getstripe_old $dom_f |
2555 awk '/stripe_count/ { print $2 }')
2556 stripe_size=$(lov_getstripe_old $dom_f |
2557 awk '/stripe_size/ { print $2 }')
2558 [ $stripe_count -eq 1 ] ||
2559 error "stripe_count $stripe_count !=1 for $dom_f"
2560 [ $stripe_size -eq 1048576 ] ||
2561 error "stripe_size $stripe_size != 1048576 for $dom_f"
2563 #verify lov_getstripe_old with common file
2564 stripe_count=$(lov_getstripe_old $common_f |
2565 awk '/stripe_count/ { print $2 }')
2566 stripe_size=$(lov_getstripe_old $common_f |
2567 awk '/stripe_size/ { print $2 }')
2568 [ $stripe_count -eq $OSTCOUNT ] ||
2569 error "stripe_count $stripe_count !=$OSTCOUNT for $common_f"
2570 [ $stripe_size -eq 524288 ] ||
2571 error "stripe_size $stripe_size != 524288 for $common_f"
2573 run_test 25 "Verify old lov stripe API with PFL files"
2576 $LFS setstripe -E 1m -S 1M -c 1 $DIR/$tfile
2577 dd if=/dev/urandom bs=1M count=10 >> $DIR/$tfile
2578 [ $? != 0 ] || error "append must return an error"
2579 dd if=/dev/urandom bs=1M count=10 oflag=direct >> $DIR/$tfile
2580 [ $? != 0 ] || error "append must return an error"
2582 run_test 26a "Append to not-existent component"
2585 $LFS setstripe -E 1m -S 1M -c 1 $DIR/$tfile
2586 dd if=/dev/urandom bs=1M count=1 > $DIR/$tfile
2587 dd if=/dev/urandom bs=1M count=1 >> $DIR/$tfile
2588 [ $? != 0 ] || error "append must return an error"
2589 dd if=/dev/urandom bs=1M count=1 oflag=direct >> $DIR/$tfile
2590 [ $? != 0 ] || error "append must return an error"
2592 run_test 26b "Append to not-existend component, file size is unknown"
2595 $LFS setstripe -E 1m -S 1M -c 1 $DIR/$tfile
2596 dd if=/dev/urandom bs=2M count=1 >> $DIR/$tfile
2597 [ $? != 0 ] || error "append must return an error"
2598 dd if=/dev/urandom bs=2M count=1 oflag=direct >> $DIR/$tfile
2599 [ $? != 0 ] || error "append must return an error"
2601 run_test 26c "Append to not-existend component, crossing the component border"
2604 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2605 skip "server does not support overstriping"
2606 (( $MDS1_VERSION >= $(version_code 2.15.55.102) )) ||
2607 skip "need MDS >= 2.12.55.102 for mdt_dump_lmm fix"
2609 stack_trap "rm -f $DIR/$tfile"
2610 # start_full_debug_logging
2611 $LFS setstripe -S 64K -C -1 $DIR/$tfile || error "create $tfile failed"
2612 $LFS getstripe -c $DIR/$tfile || error "getstripe $tfile failed"
2614 $LFS getstripe -c $DIR/$tfile || error "getstripe failed after clear"
2616 test_mkdir $DIR/$tdir
2617 stack_trap "rm -rf $DIR/$tdir/$tfile"
2618 $LFS setstripe -S 64K -C -1 $DIR/$tdir || error "mkdir $tdir failed"
2619 $LFS getstripe -y $DIR/$tdir || error "getstripe $tdir failed"
2620 touch $DIR/$tdir/$tfile || error "create $tdir/$tfile failed"
2622 $LFS getstripe -c $DIR/$tdir/$tfile ||
2623 error "getstripe $tdir/$tfile failed"
2624 #stop_full_debug_logging
2626 run_test 27 "overstriping with -C -1 in mdt_dump_lmm"
2628 complete_test $SECONDS
2629 check_and_cleanup_lustre