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]*
44 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
46 local comp_file=$DIR/$tdir/$tfile
47 local rw_len=$((3 * 1024 * 1024)) # 3M
52 $LFS setstripe -E 1m -S 1M -c 1 -E -1 -c 1 $comp_file ||
53 error "Create $comp_file failed"
55 #instantiate all components, so that objs are allocted
56 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
58 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
59 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
61 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
63 small_write $comp_file $rw_len || error "Verify RW failed"
65 rm -f $comp_file || error "Delete $comp_file failed"
67 run_test 0a "Create full components file, no reused OSTs"
70 [[ $($LCTL get_param mdc.*.import |
71 grep "connect_flags:.*overstriping") ]] ||
72 skip "server does not support overstriping"
73 large_xattr_enabled || skip_env "no large xattr support"
77 local comp_file=$DIR/$tdir/$tfile
81 $LFS setstripe -E -1 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
82 error "Create $comp_file failed"
84 local count=$($LFS getstripe -I1 -c $comp_file)
85 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
86 error "stripe count of first component is shrinked to $count"
88 rm -f $comp_file || error "Delete $comp_file failed"
90 # Create file with 1.1*LOV_MAX_STRIPE_COUNT stripes should succeed
91 $LFS setstripe -E 1m -C $((LOV_MAX_STRIPE_COUNT / 10)) -E -1 \
92 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
93 error "Create $comp_file failed"
95 local count=$($LFS getstripe -I2 -c $comp_file)
96 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
97 error "stripe count of second component is shrinked to $count"
99 rm -f $comp_file || error "Delete $comp_file failed"
101 # Create file with 3*LOV_MAX_STRIPE_COUNT stripes should fail
102 $LFS setstripe -E 200G -C $LOV_MAX_STRIPE_COUNT \
103 -E 500G -C $LOV_MAX_STRIPE_COUNT \
104 -E -1 -C $LOV_MAX_STRIPE_COUNT $comp_file &&
105 error "Create $comp_file succeeded"
107 rm -f $comp_file || error "Delete $comp_file failed"
109 run_test 0b "Verify comp stripe count limits"
112 [[ $($LCTL get_param mdc.*.import |
113 grep "connect_flags:.*overstriping") ]] ||
114 skip "server does not support overstriping"
115 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code $SEL_VER) ] &&
116 skip "skipped for lustre < $SEL_VER"
118 large_xattr_enabled || skip_env "no large xattr support"
122 local comp_file=$DIR/$tdir/$tfile
124 test_mkdir $DIR/$tdir
126 # extension size aligned to 64M and limit to 1G
127 $LFS setstripe -E-1 -S64K -C $LOV_MAX_STRIPE_COUNT \
128 -z $((64*1024*((LOV_MAX_STRIPE_COUNT+1023)>>10<<10))) \
129 $comp_file || error "Create $comp_file failed"
131 local count=$($LFS getstripe -I1 -c $comp_file)
132 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
133 error "stripe count is shrinked to $count"
135 run_test 0c "Verify SEL comp stripe count limits"
138 (( $MDS1_VERSION > $(version_code 2.14.50.115) )) ||
139 skip_env "Need MDS version at least 2.14.50.115"
146 # Create parent directory
149 # Component end must be a multiple of stripe size
150 # and a multiple of 64KiB to align with the minimum
152 # Values below 4096 are assumed to be in KiB units.
153 $LFS setstripe -E 127 $tf-1 > /dev/null 2>&1 &&
154 error "creating $tf-1 with '-E 127' should fail"
156 $LFS setstripe -E 128 -S 512 $tf-1 > /dev/null 2>&1 &&
157 error "creating $tf-1 with '-E 128 -S 512' should fail"
159 $LFS setstripe -E 128 $tf-1 ||
160 error "creating $tf-1 failed"
162 yes | dd bs=1K count=129 iflag=fullblock of=$tf-1 &&
163 error "writing to $tf-1 should fail"
165 yes | dd bs=1K count=128 iflag=fullblock of=$tf-1 ||
166 error "writing to $tf-1 failed"
168 comp_end=$($LFS getstripe -I1 -E $tf-1)
169 stripe_size=$($LFS getstripe -I1 -S $tf-1)
171 [[ $comp_end == $((128 * 1024)) ]] ||
172 error "incorrect component end '$comp_end' for $tf-1"
174 [[ $stripe_size == $((128 * 1024)) ]] ||
175 error "incorrect stripe size '$stripe_size' for $tf-1"
177 rm $tf-1 || error "removing $tf-1 failed"
179 # The stripe size must be a multiple of 64KiB.
180 # Values below 4096 are assumed to be in KiB units.
181 $LFS setstripe -E -1 -S 2047 $tf-2 > /dev/null 2>&1 &&
182 error "creating $tf-2 with '-S 2047' should fail"
184 $LFS setstripe -E -1 -S 2048 $tf-2 ||
185 error "creating $tf-2 failed"
187 stripe_size=$($LFS getstripe -I1 -S $tf-2)
188 [[ $stripe_size == $((2048 * 1024)) ]] ||
189 error "incorrect stripe size '$stripe_size' for $tf-2"
191 rm $tf-2 || error "removing $tf-2 failed"
193 run_test 0d "Verify comp end and stripe size"
196 (( $MDS1_VERSION >= $(version_code 2.15.56.112) )) ||
197 skip "Need MDS version at least 2.15.56.112"
199 (( OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
206 # component size 1M can only utilize 1 stripe
207 $LFS setstripe -E1M -S1M -c2 -Eeof -S1M -c2 $tf ||
208 error "failed to setstripe $tf"
210 local sc=$($LFS getstripe -I1 -c $tf)
213 error "expect 1 stripe count instread of $sc"
215 sc=$($LFS getstripe -I2 -c $tf)
218 error "expect 2 stripe count instread of $sc"
221 (( OSTCOUNT >= 3 )) || skip "needs >= 3 OSTs"
224 # component size 2M can only utilize 2 stripes
225 $LFS setstripe -E2M -S1M -c3 -Eeof -S1M -c3 $tf ||
226 error "failed to setstripe $tf"
227 sc=$($LFS getstripe -I1 -c $tf)
230 error "expect 2 stripe count instread of $sc"
232 sc=$($LFS getstripe -I2 -c $tf)
235 error "expect 3 stripe count instread of $sc"
239 # 2nd component size 11M and stripe_size 4M should cross 3 stripes
240 $LFS setstripe -E1M -S1M -c3 -E12M -S4M -c3 $tf ||
241 error "failed to setstripe $tf"
242 sc=$($LFS getstripe -I1 -c $tf)
245 error "expect 1 stripe count instread of $sc"
247 sc=$($LFS getstripe -I2 -c $tf)
250 error "expect 3 stripe count instread of $sc"
253 run_test 0e "lfs setstripe should limite stripe count for component size"
256 local comp_file=$DIR/$tdir/$tfile
257 local rw_len=$((3 * 1024 * 1024)) # 3M
259 test_mkdir $DIR/$tdir
262 $LFS setstripe -E 1m -S 1m -o 0 -E -1 -o 0 $comp_file ||
263 error "Create $comp_file failed"
265 #instantiate all components, so that objs are allocted
266 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
268 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
269 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
271 [ $ost_idx1 -ne $ost_idx2 ] && error "$ost_idx1 != $ost_idx2"
273 small_write $comp_file $rw_len || error "Verify RW failed"
275 rm -f $comp_file || error "Delete $comp_file failed"
277 run_test 1a "Create full components file, reused OSTs"
279 # test overstriping (>1 stripe/OST within a component)
281 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
282 [[ $($LCTL get_param mdc.*.import |
283 grep "connect_flags:.*overstriping") ]] ||
284 skip "server does not support overstriping"
286 local comp_file=$DIR/$tdir/$tfile
287 local rw_len=$((3 * 1024 * 1024)) # 3M
289 test_mkdir $DIR/$tdir
291 $LFS setstripe -E 2m -S 1m -o 0,0 -E -1 -o 1,1,0,0 $comp_file ||
292 error "Create $comp_file failed"
294 #instantiate all components, so that objs are allocted
295 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=1M
297 $LFS getstripe $comp_file
298 local OSTS_1=$($LFS getstripe -I1 $comp_file | grep -o 'l_ost_idx.*' |
299 awk -e '{print $2}' | tr "\n" "\0")
300 local OSTS_2=$($LFS getstripe -I2 $comp_file | grep -o 'l_ost_idx.*' |
301 awk -e '{print $2}' | tr "\n" "\0")
305 [ "$OSTS_1" = "0,0," ] || error "incorrect OSTs($OSTS_1) in component 1"
306 [ "$OSTS_2" = "1,1,0,0," ] ||
307 error "incorrect OSTs($OSTS_2) in component 2"
309 small_write $comp_file $rw_len || error "Verify RW failed"
311 rm -f $comp_file || error "Delete $comp_file failed"
313 run_test 1b "Create full components file, overstriping in components"
315 # test overstriping with max stripe count
317 [[ $($LCTL get_param mdc.*.import |
318 grep "connect_flags:.*overstriping") ]] ||
319 skip "server does not support overstriping"
320 large_xattr_enabled || skip_env "no large xattr support"
324 local comp_file=$DIR/$tdir/$tfile
325 local rw_len=$((3 * 1024 * 1024)) # 3M
327 test_mkdir $DIR/$tdir
329 $LFS setstripe -E 10m -C 10 -E 110M -C 100 -E -1 \
330 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
331 error "Create $comp_file failed"
333 # Seek & write in to last component so all objects are allocated
334 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=20000
336 local ssize=$($LFS getstripe -S -I1 $DIR/$tdir/$tfile)
337 local count=$($LFS getstripe -c -I1 $DIR/$tdir/$tfile)
338 count=$((count * ssize / 1048576))
339 [ $count -eq 10 ] || error "comp1 stripe count $count, should be 10"
340 ssize=$($LFS getstripe -S -I2 $DIR/$tdir/$tfile)
341 count=$($LFS getstripe -c -I2 $DIR/$tdir/$tfile)
342 count=$((count * ssize / 1048576))
343 [ $count -eq 100 ] || error "comp2 stripe count $count, should be 100"
344 ssize=$($LFS getstripe -S -I3 $DIR/$tdir/$tfile)
345 count=$($LFS getstripe -c -I3 $DIR/$tdir/$tfile)
346 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
347 echo "comp4 stripe count $count != $LOV_MAX_STRIPE_COUNT"
349 small_write $comp_file $rw_len || error "Verify RW failed"
351 rm -f $comp_file || error "Delete $comp_file failed"
353 run_test 1c "Test overstriping w/max stripe count"
356 local comp_file=$DIR/$tdir/$tfile
357 local rw_len=$((5 * 1024 * 1024)) # 5M
360 test_mkdir $DIR/$tdir
363 multiop $comp_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
364 error "create failed $comp_file"
366 $LFS setstripe --component-add $params $comp_file ||
367 error "Add component to $comp_file failed"
369 check_component_count $comp_file 1
371 dd if=/dev/zero of=$comp_file bs=1M count=1 > /dev/null 2>&1 ||
372 error "Write first component failed"
373 dd if=$comp_file of=/dev/null bs=1M count=1 > /dev/null 2>&1 ||
374 error "Read first component failed"
376 dd if=/dev/zero of=$comp_file bs=1M count=2 > /dev/null 2>&1 &&
377 error "Write beyond component should fail"
378 dd if=$comp_file of=/dev/null bs=1M count=2 > /dev/null 2>&1 ||
379 error "Read beyond component should short read, not fail"
381 $LFS setstripe --component-add -E 2M -S 1M -c 1 $comp_file ||
382 error "Add component to $comp_file failed"
384 check_component_count $comp_file 2
386 $LFS setstripe --component-add -E -1 -c 3 $comp_file ||
387 error "Add last component to $comp_file failed"
389 check_component_count $comp_file 3
391 small_write $comp_file $rw_len || error "Verify RW failed"
393 rm -f $comp_file || error "Delete $comp_file failed"
397 base_test_2 "-E 1m -S 1m"
399 run_test 2a "Add components to existing file"
402 base_test_2 "-E 1m -L mdt"
404 run_test 2b "Add components w/DOM to existing file"
406 del_comp_and_verify() {
413 if [ $id == "init" -o $id == "^init" ]; then
414 opt="--component-flags="
417 $LFS setstripe --component-del $opt$id $comp_file ||
418 error "Delete component $id from $comp_file failed"
420 local comp_cnt=$($LFS getstripe --component-count $comp_file)
421 if grep -q "has no stripe info" <<< "$comp_cnt" ; then
424 [ $comp_cnt -ne $left ] && error "$comp_cnt != $left"
426 $CHECKSTAT -s $size $comp_file || error "size != $size"
430 local comp_file=$DIR/$tdir/$tfile
433 test_mkdir $DIR/$tdir
436 $LFS setstripe $params $comp_file || error "Create $comp_file failed"
438 check_component_count $comp_file 3
440 dd if=/dev/zero of=$comp_file bs=1M count=2
442 $LFS setstripe --component-del -I 2 $comp_file &&
443 error "Component deletion makes hole"
445 del_comp_and_verify $comp_file 3 2 $((2 * 1024 * 1024))
446 del_comp_and_verify $comp_file 2 1 $((1 * 1024 * 1024))
447 del_comp_and_verify $comp_file 1 0 0
449 rm -f $comp_file || error "Delete $comp_file failed"
451 $LFS setstripe -E 1M -S 1M -E 16M -E -1 $comp_file ||
452 error "Create second $comp_file failed"
454 del_comp_and_verify $comp_file "^init" 1 0
455 del_comp_and_verify $comp_file "init" 0 0
456 rm -f $comp_file || error "Delete second $comp_file failed"
460 base_test_3 "-E 1M -S 1M -E 64M -c 2 -E -1 -c 3"
462 run_test 3a "Delete components from existing file"
465 base_test_3 "-E 1M -L mdt -E 64M -S 1M -c 2 -E -1 -c 3"
467 run_test 3b "Delete components w/DOM from existing file"
470 skip "Not supported in PFL"
471 # In PFL project, only LCME_FL_INIT is supported, and it can't
472 # be altered by application.
474 run_test 4 "Modify component flags in existing file"
477 local parent=$DIR/$tdir
478 local comp_file=$DIR/$tdir/$tfile
479 local subdir=$parent/subdir
484 # set default layout to parent directory
485 $LFS setstripe -E 64M -c 2 -i 0 -E -1 -c 4 -i 0 $parent ||
486 error "Set default layout to $parent failed"
488 # create file under parent
489 touch $comp_file || error "Create $comp_file failed"
490 check_component_count $comp_file 2
492 #instantiate all components, so that objs are allocted
493 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=65k
495 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
496 [ $ost_idx -ne 0 ] &&
497 error "component 1 ost_idx $ost_idx != 0"
499 ost_idx=$($LFS getstripe -I2 -i $comp_file)
500 [ $ost_idx -ne 0 ] &&
501 error "component 2 ost_idx $ost_idx != 0"
503 # create subdir under parent
504 mkdir -p $subdir || error "Create subdir $subdir failed"
506 comp_cnt=$($LFS getstripe -d --component-count $subdir)
507 [ $comp_cnt -ne 2 ] && error "subdir $comp_cnt != 2"
509 # create file under subdir
510 touch $subdir/$tfile || error "Create $subdir/$tfile failed"
512 check_component_count $subdir/$tfile 2
514 # delete default layout setting from parent
515 $LFS setstripe -d $parent ||
516 error "Delete default layout from $parent failed"
518 comp_cnt=$($LFS getstripe -d --component-count $parent)
519 [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0"
521 rm -f $comp_file || error "Delete $comp_file failed"
522 rm -f $subdir/$tfile || error "Delete $subdir/$tfile failed"
523 rm -r $subdir || error "Delete subdir $subdir failed"
524 rmdir $parent || error "Delete dir $parent failed"
526 run_test 5 "Inherit composite layout from parent directory"
529 local comp_file=$DIR/$tdir/$tfile
531 test_mkdir $DIR/$tdir
534 $LFS setstripe -c 1 -S 128K $comp_file ||
535 error "Create v1 $comp_file failed"
537 check_component_count $comp_file 0
539 dd if=/dev/urandom of=$comp_file bs=1M count=5 oflag=sync ||
540 error "Write to v1 $comp_file failed"
542 local old_chksum=$(md5sum $comp_file)
544 # Migrate v1 to composite
545 $LFS migrate -E 1M -S 512K -c 1 -E -1 -S 1M -c 2 $comp_file ||
546 error "Migrate(v1 -> composite) $comp_file failed"
548 check_component_count $comp_file 2
550 local chksum=$(md5sum $comp_file)
551 [ "$old_chksum" != "$chksum" ] &&
552 error "(v1 -> compsoite) $old_chksum != $chksum"
554 # Migrate composite to composite
555 $LFS migrate -E 1M -S 1M -c 2 -E 4M -S 1M -c 2 \
556 -E -1 -S 3M -c 3 $comp_file ||
557 error "Migrate(compsoite -> composite) $comp_file failed"
559 check_component_count $comp_file 3
561 chksum=$(md5sum $comp_file)
562 [ "$old_chksum" != "$chksum" ] &&
563 error "(composite -> compsoite) $old_chksum != $chksum"
565 # Migrate composite to v1
566 $LFS migrate -c 2 -S 2M $comp_file ||
567 error "Migrate(composite -> v1) $comp_file failed"
569 check_component_count $comp_file 0
571 chksum=$(md5sum $comp_file)
572 [ "$old_chksum" != "$chksum" ] &&
573 error "(composite -> v1) $old_chksum != $chksum"
575 rm -f $comp_file || error "Delete $comp_file failed"
577 run_test 6 "Migrate composite file"
580 test_mkdir $DIR/$tdir
581 chmod 0777 $DIR/$tdir || error "chmod $tdir failed"
583 local comp_file=$DIR/$tdir/$tfile
584 $RUNAS $LFS setstripe -E 1M -S 1M -c 1 $comp_file ||
585 error "Create composite file $comp_file failed"
587 $RUNAS $LFS setstripe --component-add -E 64M -c 4 $comp_file ||
588 error "Add component to $comp_file failed"
590 $RUNAS $LFS setstripe --component-del -I 2 $comp_file ||
591 error "Delete component from $comp_file failed"
593 $RUNAS $LFS setstripe --component-add -E -1 -c 5 $comp_file ||
594 error "Add last component to $comp_file failed"
596 rm $comp_file || error "Delete composite failed"
598 run_test 7 "Add/Delete/Create composite file by non-privileged user"
601 local parent=$DIR/$tdir
604 mkdir_on_mdt0 $parent
606 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c 2 -S 2M \
607 -E -1 -c 4 -S 4M $parent ||
608 error "Set default layout to $parent failed"
610 bash rundbench -C -D $parent 2 || error "dbench failed"
612 rm -fr $parent || error "Delete dir $parent failed"
614 run_test 8 "Run dbench over composite files"
617 local comp_file=$DIR/$tdir/$tfile
619 test_mkdir $DIR/$tdir
622 $LFS setstripe -E 1M -S 1M -E -1 -c 1 $comp_file ||
623 error "Create $comp_file failed"
625 check_component_count $comp_file 2
627 replay_barrier $SINGLEMDS
629 # instantiate the 2nd component
630 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
632 local f1=$($LFS getstripe -I2 $comp_file |
633 awk '/l_fid:/ {print $7}')
634 echo "before MDS recovery, the ost fid of 2nd component is $f1"
637 local f2=$($LFS getstripe -I2 $comp_file |
638 awk '/l_fid:/ {print $7}')
639 echo "after MDS recovery, the ost fid of 2nd component is $f2"
640 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
642 run_test 9 "Replay layout extend object instantiation"
645 echo $($LFS getstripe $1 |
646 awk '$1 == "lcm_entry_count:" { printf("%d", $2) }
647 $1 == "lcme_extent.e_start:" { printf("[%#lx", $2) }
648 $1 == "lcme_extent.e_end:" { printf(",%s]", $2) }')
652 local parent=$DIR/$tdir
655 save_layout_restore_at_exit $MOUNT
659 # mount root on $MOUNT2 if FILESET is set
660 if [ -n "$FILESET" ]; then
661 FILESET="" mount_client $MOUNT2 ||
662 error "mount $MOUNT2 fail"
666 $LFS setstripe -d $root || error "clear root layout"
668 # set root composite layout
669 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c2 -S 2M \
670 -E -1 -c 4 -S 4M $root ||
671 error "Set root layout failed"
673 if [ "$root" == "$MOUNT2" ]; then
674 umount_client $MOUNT2 ||
675 error "umount $MOUNT2 fail"
679 # set a different layout for parent
680 $LFS setstripe -E -1 -c 1 -S 1M $parent ||
681 error "set $parent layout failed"
684 local f1_entry=$(component_dump $parent/file1)
686 # delete parent's layout
687 $LFS setstripe -d $parent || error "Clear $parent layout failed"
690 local f2_entry=$(component_dump $parent/file2)
692 # verify layout inheritance
694 local f1_expect="1[0,EOF]"
695 local f2_expect="3[0,2097152][0x200000,16777216][0x1000000,EOF]"
697 echo "f1 expect=$f1_expect"
698 echo "f1 get =$f1_entry"
699 echo "f2 expect=$f2_expect"
700 echo "f2 get =$f2_entry"
702 [ x$f1_expect != x$f1_entry ] &&
703 error "$parent/file1 does not inherite parent layout"
704 [ x$f2_expect != x$f2_entry ] &&
705 error "$parent/file2 does not inherite root layout"
709 run_test 10 "Inherit composite template from root"
712 local comp_file=$DIR/$tdir/$tfile
713 test_mkdir $DIR/$tdir
716 # only 1st component instantiated
717 $LFS setstripe -E 1M -S 1M -E 2M -E 3M -E -1 $comp_file ||
718 error "Create $comp_file failed"
720 local f1=$($LFS getstripe -I1 $comp_file | grep "l_fid")
721 [[ -z $f1 ]] && error "1: 1st component uninstantiated"
722 local f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
723 [[ -n $f2 ]] && error "1: 2nd component instantiated"
724 local f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
725 [[ -n $f3 ]] && error "1: 3rd component instantiated"
726 local f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
727 [[ -n $f4 ]] && error "1: 4th component instantiated"
729 # the first 2 components instantiated
730 # Truncate to exact start of new component - LU-12586
731 $TRUNCATE $comp_file $((1024*1024*1))
733 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
734 [[ -z $f2 ]] && error "2: 2nd component uninstantiated"
735 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
736 [[ -n $f3 ]] && error "2: 3rd component instantiated"
737 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
738 [[ -n $f4 ]] && error "2: 4th component instantiated"
740 # the first 3 components instantiated
741 $TRUNCATE $comp_file $((1024*1024*3 - 1))
742 $TRUNCATE $comp_file $((1024*1024*1+1))
744 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
745 [[ -z $f2 ]] && error "3: 2nd component uninstantiated"
746 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
747 [[ -z $f3 ]] && error "3: 3rd component uninstantiated"
748 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
749 [[ -n $f4 ]] && error "3: 4th component instantiated"
751 # all 4 components instantiated, using append write
752 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
754 rwv -f $comp_file -w -a -n 2 $((1024*1023)) 1
757 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
758 [[ -z $f4 ]] && error "4: 4th component uninstantiated"
762 run_test 11a "Verify component instantiation with write/truncate"
765 [ $OSTCOUNT -lt 4 ] && skip "needs >= 4 OSTs"
767 local file=$DIR/$tdir/$tfile
769 test_mkdir $DIR/$tdir
772 $LFS setstripe -E 1m -E 1g -c 4 -E eof $DIR/$tdir ||
773 error "setstripe dir $DIR/$tdir failed"
774 expand_truncate_test $file ||
775 error "expand_truncate_test failed on $file"
777 run_test 11b "truncate file set file size correctly"
780 [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs"
782 local file=$DIR/$tdir/$tfile
783 test_mkdir $DIR/$tdir
786 # specify ost list for component
787 $LFS setstripe -E 2M -S 1M -c 2 -o 0,1 -E 4M -c 2 -o 1,2 \
788 -E 6M -c 2 -o 2,1 -E 8M -c 1 -i 2 -E -1 $file ||
789 error "Create $file failed"
791 # clear lod component cache
792 stop $SINGLEMDS || error "stop MDS"
793 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
794 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "start MDS"
796 # instantiate all components
797 $TRUNCATE $file $((1024*1024*8+1))
799 #verify object alloc order
800 local o1=$($LFS getstripe -I1 $file |
801 awk '/l_ost_idx:/ {printf("%d",$5)}')
802 [[ $o1 != "01" ]] && error "$o1 is not 01"
804 local o2=$($LFS getstripe -I2 $file |
805 awk '/l_ost_idx:/ {printf("%d",$5)}')
806 [[ $o2 != "12" ]] && error "$o2 is not 12"
808 local o3=$($LFS getstripe -I3 $file |
809 awk '/l_ost_idx:/ {printf("%d",$5)}')
810 [[ $o3 != "21" ]] && error "$o3 is not 21"
812 local o4=$($LFS getstripe -I4 $file |
813 awk '/l_ost_idx:/ {printf("%d",$5)}')
814 [[ $o4 != "2" ]] && error "$o4 is not 2"
818 run_test 12 "Verify ost list specification"
820 test_13() { # LU-9311
821 [ $OSTCOUNT -lt 8 ] && skip "needs >= 8 OSTs"
823 local file=$DIR/$tfile
825 local dd_size=$(($dd_count * 1024 * 1024))
829 $LFS setstripe -E 1M -S 1M -c 1 -E 2M -c 2 -E -1 -c -1 -i 1 $file ||
830 error "Create $file failed"
831 dd if=/dev/zero of=$file bs=1M count=$dd_count
832 real_size=$(stat -c %s $file)
833 [ $real_size -eq $dd_size ] ||
834 error "dd actually wrote $real_size != $dd_size bytes"
838 run_test 13 "shouldn't reprocess granted resent request"
841 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
842 local file=$DIR/$tdir/$tfile
843 test_mkdir -p $DIR/$tdir
848 create_pool $FSNAME.$p1 || error "create_pool $FSNAME.$p1 failed"
849 create_pool $FSNAME.$p2 || error "create_pool $FSNAME.$p2 failed"
850 $LFS setstripe -E1m -c1 -S1m --pool=$p1 -E2m \
851 -E4m -c2 -S2m --pool=$p2 -E-1 $file ||
852 error "Create $file failed"
854 # check --pool inheritance
856 pool="$($LFS getstripe -I2 --pool $file)"
857 [ x"$pool" != "xpool1" ] && $LFS getstripe -I2 $file &&
858 error "$file: component 2 doesn't have poolname pool1"
859 pool="$($LFS getstripe -I4 --pool $file)"
860 [ x"$pool" != "xpool2" ] && $LFS getstripe -I4 $file &&
861 error "$file: component 4 doesn't have poolname pool2"
863 #check --stripe-count inheritance
865 count="$($LFS getstripe -I2 -c $file)"
866 [ $count -ne 1 ] && $LFS getstripe -I2 $file &&
867 error "$file: component 2 doesn't have 1 stripe_count"
868 count="$($LFS getstripe -I4 -c $file)"
869 [ $count -ne 2 ] && $LFS getstripe -I4 $file &&
870 error "$file: component 4 doesn't have 2 stripe_count"
872 #check --stripe-size inheritance
874 size="$($LFS getstripe -I2 -S $file)"
875 [ $size -ne $((1024*1024)) ] && $LFS getstripe -I2 $file &&
876 error "$file: component 2 doesn't have 1M stripe_size"
877 size="$($LFS getstripe -I4 -S $file)"
878 [ $size -ne $((1024*1024*2)) ] && $LFS getstripe -I4 $file &&
879 error "$file: component 4 doesn't have 2M stripe_size"
883 run_test 14 "Verify setstripe poolname/stripe_count/stripe_size inheritance"
886 local parent=$DIR/$tdir
891 $LFS setstripe -d $parent || error "delete default layout"
893 $LFS setstripe -E 1M -S 1M -E 10M -E eof $parent/f1 || error "create f1"
894 $LFS setstripe -E 4M -E 20M -E eof $parent/f2 || error "create f2"
895 test_mkdir $parent/subdir
896 $LFS setstripe -E 6M -S 1M -c1 -E 30M -c4 -E eof -c $OSTCOUNT \
897 $parent/subdir || error "setstripe to subdir"
898 $LFS setstripe -E 8M -E eof $parent/subdir/f3 || error "create f3"
899 $LFS setstripe -c 1 $parent/subdir/f4 || error "create f4"
902 local found=$($LFS find --component-start +2M -E -15M $parent | wc -l)
903 [ $found -eq 0 ] || error "start+2M, end-15M, $found != 0"
906 found=$($LFS find --component-start +2M -E -35M $parent | wc -l)
907 [ $found -eq 2 ] || error "start+2M, end-35M, $found != 2"
910 found=$($LFS find --component-start +4M -E -eof $parent | wc -l)
911 [ $found -eq 1 ] || error "start+4M, end-eof, $found != 1"
913 local flg_opts="--component-flags init"
915 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
917 error "before write: start=1M, end=10M, flag=init, $found != 0"
919 dd if=/dev/zero of=$parent/f1 bs=1M count=2 ||
920 error "dd $parent/f1 failed"
923 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
925 error "after write: start=1M, end=10M, flag=init, $found != 1"
927 local ext_opts="--component-start -1M -E +5M"
928 # parent, subdir, f3, f4
929 found=$($LFS find $ext_opts $parent | wc -l)
930 [ $found -eq 4 ] || error "start-1M, end+5M, $found != 4"
932 local cnt_opts="--component-count +2"
934 found=$($LFS find $ext_opts $cnt_opts $parent | wc -l)
935 [ $found -eq 1 ] || error "start-1M, end+5M, count+2, $found != 1"
938 found=$($LFS find $ext_opts $cnt_opts $flg_opts $parent | wc -l)
940 error "start-1M, end+5M, count+2, flag=init, $found != 0"
943 found=$($LFS find $ext_opts ! $cnt_opts $flg_opts $parent | wc -l)
945 error "start-1M, end+5M, !count+2, flag=init, $found != 2"
947 # check last component stripe count
948 if [ $OSTCOUNT -gt 1 ]; then
949 touch $parent/subdir/f5
950 $TRUNCATE $parent/subdir/f5 $((32*1024*1024))
951 found=$($LFS find $parent/subdir -c $OSTCOUNT)
952 [[ "$found" == "$parent/subdir/f5" ]] ||
953 error "got '$found' with stripe_count=$OSTCOUNT, not f5"
956 run_test 15 "Verify component options for lfs find"
959 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
960 large_xattr_enabled || skip_env "ea_inode feature disabled"
962 local file=$DIR/$tdir/$tfile
963 local dir=$DIR/$tdir/dir
964 local temp=$DIR/$tdir/template
966 test_mkdir $DIR/$tdir
968 #####################################################################
970 # set stripe for source file
971 $LFS setstripe -E1m -S 1M -c2 -o0,1 -E2m -c2 -E3m -o1,0 -E4m -c1 -E-1 \
972 $file || error "Create $file failed"
975 verify_yaml_layout $file $file.copy $temp "1. PFL file"
977 #####################################################################
979 # set stripe for source file
981 $LFS setstripe -c2 -o0,1 -i1 $file || error "Create $file failed"
985 verify_yaml_layout $file $file.copy $temp "2. plain file"
987 #####################################################################
989 # set stripe for source dir
991 $LFS setstripe -E1m -S 1M -c2 -E2m -c1 -E-1 $dir ||
992 error "setstripe $dir failed"
996 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
998 #####################################################################
1000 # set stripe for source dir
1001 $LFS setstripe -c2 -i-1 $dir || error "setstripe $dir failed"
1004 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
1006 run_test 16a "Verify setstripe/getstripe with YAML config file"
1009 [[ $($LCTL get_param mdc.*.import |
1010 grep "connect_flags:.*overstriping") ]] ||
1011 skip "server does not support overstriping"
1012 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1013 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1014 skip_env "too many osts, skipping"
1015 large_xattr_enabled || skip_env "ea_inode feature disabled"
1019 local file=$DIR/$tdir/$tfile
1020 local dir=$DIR/$tdir/dir
1021 local temp=$DIR/$tdir/template
1022 # We know OSTCOUNT < (LOV_MAX_STRIPE_COUNT / 2), so this is overstriping
1023 local large_count=$((LOV_MAX_STRIPE_COUNT / 2 + 10))
1026 test_mkdir $DIR/$tdir
1028 #####################################################################
1029 # 1. PFL file, overstriping in first comps
1030 # set stripe for source file
1031 $LFS setstripe -E1m -S 1M -o0,0 -E2m -o1,1 -E3m -C $large_count -E-1 \
1032 $file || error "Create $file failed"
1035 verify_yaml_layout $file $file.copy $temp "1. PFL file"
1037 #####################################################################
1038 # 2. plain file + overstriping
1039 # set stripe for source file
1041 $LFS setstripe -C $large_count -i1 $file || error "Create $file failed"
1044 echo "2. plain file"
1045 verify_yaml_layout $file $file.copy $temp "2. plain file"
1047 #####################################################################
1048 # 3. PFL dir + overstriping
1049 # set stripe for source dir
1051 $LFS setstripe -E1m -S 1M -o 0,0 -E2m -C $large_count -E-1 $dir ||
1052 error "setstripe $dir failed"
1054 test_mkdir $dir.copy
1056 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
1058 #####################################################################
1059 # 4. plain dir + overstriping
1060 # set stripe for source dir
1061 $LFS setstripe -C $large_count $dir || error "setstripe $dir failed"
1064 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
1066 run_test 16b "Verify setstripe/getstripe with YAML config file + overstriping"
1069 (( $MDS1_VERSION >= $(version_code 2.13.53.205) )) ||
1070 skip "need MDS version at least 2.13.53.205"
1072 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1074 local file=$DIR/$tdir/$tfile
1075 local dir=$DIR/$tdir/dir
1076 local temp=$DIR/$tdir/template
1078 test_mkdir $DIR/$tdir
1080 #####################################################################
1082 # set stripe for source file
1083 $LFS setstripe -E256M -S 1M -c2 -o0,1 -z 64M -E-1 -o1,0 -z 128M \
1084 $file || error "Create $file failed"
1087 verify_yaml_layout $file $file.copy $temp "1. PFL file"
1089 #####################################################################
1091 # set stripe for source dir
1093 $LFS setstripe -E256M -S 1M -c2 -z 64M -E-1 -z 128M \
1094 $dir || error "setstripe $dir failed"
1096 test_mkdir $dir.copy
1097 echo "2. SEL template on dir"
1098 verify_yaml_layout $dir $dir.copy $temp.dir "2. PFL dir"
1100 run_test 16c "Verify setstripe/getstripe for SEL layout with YAML config file"
1103 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1105 local file=$DIR/$tdir/$tfile
1106 local dir=$DIR/$tdir/dir
1107 local temp=$DIR/$tdir/template
1109 test_mkdir $DIR/$tdir
1111 #####################################################################
1113 # set stripe for source file
1114 $LFS setstripe -E1m -L mdt -E-1 -o1,0 $file ||
1115 error "Create $file failed"
1118 verify_yaml_layout $file $file.copy $temp "1. DOM file"
1120 #####################################################################
1122 # set stripe for source dir
1124 $LFS setstripe -E1m -L mdt -E-1 -o1,0 $dir || error "Create $dir failed"
1126 test_mkdir $dir.copy
1128 verify_yaml_layout $dir $dir.copy $temp.dir "2. DOM dir"
1130 run_test 16d "Verify setstripe/getstripe for DOM layout with YAML config file"
1134 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1135 local file=$DIR/$tdir/$tfile
1136 test_mkdir -p $DIR/$tdir
1139 $LFS setstripe -E 1M -S 1M -E 3M -c 2 -E -1 -c -1 $file ||
1140 error "Create $file failed"
1142 local s1=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
1143 local s2=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
1144 local s3=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
1145 echo "1st init: comp size 1:$s1 2:$s2 3:$s3"
1147 # init 2nd component
1148 $TRUNCATE $file $((1024*1024+1))
1149 local s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
1150 local s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
1151 echo "2nd init: comp size 1:$s1n 2:$s2n 3:$s3"
1153 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
1154 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
1156 # init 3rd component
1157 $TRUNCATE $file $((1024*1024*3+1))
1158 s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
1159 s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
1160 local s3n=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
1161 echo "3rd init: comp size 1:$s1n 2:$s2n 3:$s3n"
1163 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
1164 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
1165 [ $s3 -lt $s3n ] || error "3rd comp size $s3 should < $s3n"
1167 run_test 17 "Verify LOVEA grows with more component inited"
1169 check_distribution() {
1173 local obj_min_one=$((OSTCOUNT - 1))
1175 objs=$($LFS getstripe $file |
1176 awk '/l_ost_idx:/ { print $5 }' | wc -l)
1177 let ave=$((objs / OSTCOUNT))
1179 # collect objects per OST distribution
1180 $LFS getstripe $file | awk '/l_ost_idx:/ { print $5 }' | tr -d "," |
1181 (inuse=( $(for i in $(seq 0 $obj_min_one); do echo 0; done) )
1183 let inuse[$O]=$((1 + ${inuse[$O]}))
1186 # verify object distribution varies no more than +-1
1187 for idx in $(seq 0 $obj_min_one); do
1188 let dif=$((${inuse[$idx]} - ave))
1190 if [ "$dif" -gt 1 ]; then
1191 echo "OST${idx}: ${inuse[$idx]} objects"
1192 error "bad distribution on OST${idx}"
1198 local file1=$DIR/${tfile}-1
1199 local file2=$DIR/${tfile}-2
1200 local file3=$DIR/${tfile}-3
1202 rm -f $file1 $file2 $file3
1204 $LFS setstripe -E 1m -S 1m $file1 ||
1205 error "Create $file1 failed"
1206 $LFS setstripe -E 1m -S 1m $file2 ||
1207 error "Create $file2 failed"
1208 $LFS setstripe -E 1m -S 1m $file3 ||
1209 error "Create $file3 failed"
1211 local objs=$((OSTCOUNT+1))
1212 for comp in $(seq 1 $OSTCOUNT); do
1213 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file1 ||
1214 error "Add component to $file1 failed 2"
1215 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file2 ||
1216 error "Add component to $file2 failed 2"
1217 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file3 ||
1218 error "Add component to $file3 failed 2"
1221 $LFS setstripe --component-add -E -1 -c -1 $file1 ||
1222 error "Add component to $file1 failed 3"
1223 $LFS setstripe --component-add -E -1 -c -1 $file2 ||
1224 error "Add component to $file2 failed 3"
1225 $LFS setstripe --component-add -E -1 -c -1 $file3 ||
1226 error "Add component to $file3 failed 3"
1228 # Instantiate all components
1229 dd if=/dev/urandom of=$file1 bs=1M count=$((objs+1)) ||
1230 error "dd failed for $file1"
1231 dd if=/dev/urandom of=$file2 bs=1M count=$((objs+1)) ||
1232 error "dd failed for $file2"
1233 dd if=/dev/urandom of=$file3 bs=1M count=$((objs+1)) ||
1234 error "dd failed for $file3"
1236 check_distribution $file1
1237 check_distribution $file2
1238 check_distribution $file3
1241 run_test 18 "check component distribution"
1245 local already_created=${2:-0}
1246 local rw_len=$((3 * 1024 * 1024)) # 3M
1250 if [ $already_created != 1 ]; then
1251 test_mkdir -p $DIR/$tdir
1252 $LFS setstripe --extension-size 64M -c 1 -E -1 $comp_file ||
1253 error "Create $comp_file failed"
1256 # write past end of first component, so it is extended
1257 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=127 conv=notrunc ||
1258 error "dd to extend failed"
1260 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1261 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1262 local ssize=$($LFS getstripe -S -I1 $comp_file)
1264 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1265 [ $ost_idx2 -ne "-1" ] && error "second component init $ost_idx2"
1267 flg_opts="--comp-flags init"
1268 found=$($LFS find --comp-start 0 -E 128M $flg_opts $comp_file | wc -l)
1269 [ $found -eq 1 ] || error "Write: Extended first component not found"
1271 flg_opts="--comp-flags extension"
1272 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1273 [ $found -eq 1 ] || error "Write: second component not found"
1275 found=$($LFS find -z 64M $comp_file | wc -l)
1276 [ $found -eq 1 ] || error "component not found by ext size"
1278 found=$($LFS find --extension-size +63M $comp_file | wc -l)
1279 [ $found -eq 1 ] || error "component not found by +ext size"
1281 found=$($LFS find --ext-size -65M $comp_file | wc -l)
1282 [ $found -eq 1 ] || error "component not found by -ext size"
1284 found=$($LFS find -z 65M $comp_file | wc -l)
1285 [ $found -eq 0 ] || error "component found by wrong ext size"
1287 found=$($LFS find -z +65M $comp_file | wc -l)
1288 [ $found -eq 0 ] || error "component found by wrong +ext size"
1290 found=$($LFS find -z -63M $comp_file | wc -l)
1291 [ $found -eq 0 ] || error "component found by wrong -ext size"
1293 found=$($LFS find ! -z 64M $comp_file | wc -l)
1294 [ $found -eq 0 ] || error "component found by negation of ext size"
1296 found=$($LFS find ! -z +63M $comp_file | wc -l)
1297 [ $found -eq 0 ] || error "component found by negation of +ext size"
1299 found=$($LFS find ! -z -65M $comp_file | wc -l)
1300 [ $found -eq 0 ] || error "component found by negation of -ext size"
1302 found=$($LFS find ! -z 65M $comp_file | wc -l)
1304 error "component not found by negation of wrong ext size"
1306 found=$($LFS find ! -z +65M $comp_file | wc -l)
1308 error "component not found by negation of wrong +ext size"
1310 found=$($LFS find ! -z -63M $comp_file | wc -l)
1312 error "component not found by negation of wrong -ext size"
1314 found=$($LFS find -S +$ssize $comp_file | wc -l)
1315 [ $found -eq 0 ] || error "component found by wrong +stripe size"
1317 found=$($LFS find -c 1 $comp_file | wc -l)
1318 [ $found -eq 1 ] || error "component not found by stripe count"
1320 small_write $comp_file $rw_len || error "Verify RW failed"
1322 sel_layout_sanity $comp_file 2
1325 # Self-extending PFL tests
1327 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1328 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1329 skip "skipped for lustre < $SEL_VER"
1331 test19_io_base $DIR/$tdir/$tfile
1333 run_test 19a "Simple test of extension behavior"
1335 # Same as 19a, but with default layout set on directory rather than on file
1337 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1338 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1339 skip "skipped for lustre < $SEL_VER"
1341 local comp_file=$DIR/$tdir/$tfile
1342 local comp_dir=$DIR/$tdir/$tdir
1346 test_mkdir -p $DIR/$tdir
1347 $LFS setstripe --ext-size 64M -c 1 -E -1 $DIR/$tdir ||
1348 error "Setstripe on $DIR/$tdir failed"
1350 # check inheritance for a sub-dir and a file
1351 test_mkdir $comp_dir
1352 found=$($LFS find --comp-start 0 -E 64M $comp_dir | wc -l)
1353 [ $found -eq 1 ] || error "Dir Inheritance: wrong first component size"
1355 flg_opts="--comp-flags extension"
1356 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_dir | wc -l)
1357 [ $found -eq 1 ] || error "Dir Inheritance: Second component not found"
1361 flg_opts="--comp-flags init"
1362 found=$($LFS find --comp-start 0 -E 64M $flg_opts $comp_file | wc -l)
1363 [ $found -eq 1 ] || error "File Inheritance: wrong first component size"
1365 flg_opts="--comp-flags extension"
1366 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_file | wc -l)
1367 [ $found -eq 1 ] || error "File Inheritance: Second component not found"
1369 test19_io_base $comp_file 1
1371 run_test 19b "Simple test of SEL as default layout"
1373 # Test behavior when seeking deep in a file
1375 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1376 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1377 skip "skipped for lustre < $SEL_VER"
1379 local comp_file=$DIR/$tdir/$tfile
1383 test_mkdir -p $DIR/$tdir
1385 $LFS setstripe -z 128M -E 1G -E -1 $comp_file ||
1386 error "Create $comp_file failed"
1388 # write past end of first component, so it is extended
1389 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 conv=notrunc ||
1390 error "dd to extend failed"
1392 flg_opts="--comp-flags init"
1393 found=$($LFS find --comp-start 0M -E 256M $flg_opts $comp_file | wc -l)
1394 [ $found -eq 1 ] || error "Write: first extension component not found"
1396 flg_opts="--comp-flags extension,^init"
1397 found=$($LFS find --comp-start 256M -E 1024M $flg_opts $comp_file |\
1399 [ $found -eq 1 ] || error "Write: second extension component not found"
1401 local end_1=$($LFS getstripe -I1 -E $comp_file)
1404 [ $end_1 -eq 268435456 ] ||
1405 error "end of first component $end_1 != 268435456"
1407 # Write past end of extension space component, in to normal component
1408 # should exhaust & remove extension component
1409 dd if=/dev/zero bs=1M count=1 seek=1100 of=$comp_file conv=notrunc ||
1410 error "dd distant seek failed"
1412 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1413 # the last component index is 3
1414 local ost_idx2=$($LFS getstripe -I3 -i $comp_file)
1416 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1418 local start1=$($LFS getstripe -I1 --comp-start $comp_file)
1419 local end1=$($LFS getstripe -I1 -E $comp_file)
1420 local start2=$($LFS getstripe -I3 --comp-start $comp_file)
1421 local end2=$($LFS getstripe -I3 -E $comp_file)
1423 [ $start1 -eq 0 ] || error "start of first component incorrect"
1424 [ $end1 -eq 1073741824 ] || error "end of first component incorrect"
1425 [ $start2 -eq 1073741824 ] ||
1426 error "start of second component incorrect"
1427 [ "$end2" = "EOF" ] || error "end of second component incorrect"
1429 flg_opts="--comp-flags extension"
1430 found=$($LFS find $flg_opts $comp_file | wc -l)
1431 [ $found -eq 0 ] || error "Seek Write: extension component exists"
1433 sel_layout_sanity $comp_file 2
1435 run_test 19c "Test self-extending layout seeking behavior"
1438 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1439 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1440 skip "skipped for lustre < $SEL_VER"
1442 local comp_file=$DIR/$tdir/$tfile
1446 test_mkdir -p $DIR/$tdir
1448 $LFS setstripe -E 128M -c 1 -z 64M -E -1 $comp_file ||
1449 error "Create $comp_file failed"
1451 # This will cause component 1 to be extended to 128M, then the
1452 # extension space component will be removed
1453 dd if=/dev/zero of=$comp_file bs=130M count=1 ||
1454 error "dd to extend failed"
1456 flg_opts="--comp-flags init"
1457 found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file | wc -l)
1458 [ $found -eq 1 ] || error "Write: first component not found"
1460 flg_opts="--comp-flags init"
1461 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1462 [ $found -eq 1 ] || error "Write: second component not found"
1464 sel_layout_sanity $comp_file 2
1466 # always remove large files in case of DO_CLEANUP=false
1467 rm -f $comp_file || error "Delete $comp_file failed"
1469 run_test 19d "Test write which completely spans extension space component"
1474 local comp2_flags=$($LFS getstripe -I2 --comp-flags $comp_file)
1475 local comp3_flags=$($LFS getstripe -I3 --comp-flags $comp_file)
1477 [ "$comp2_flags" != "init" ] && error "$comp2_flags != init"
1478 [ "$comp3_flags" != "extension" ] && error "$comp3_flags != extension"
1480 local flg_opts=" --comp-start 2M -E 66M --comp-flags init"
1481 local found=$($LFS find $flg_opts $comp_file | wc -l)
1482 [ $found -eq 1 ] || error "Write: extended second component not found"
1484 flg_opts="--comp-start 66M -E EOF --comp-flags extension"
1485 found=$($LFS find $flg_opts $comp_file | wc -l)
1486 [ $found -eq 1 ] || error "Write: third component not found"
1488 sel_layout_sanity $comp_file 3
1492 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1493 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1494 skip "skipped for lustre < $SEL_VER"
1496 local comp_file=$DIR/$tdir/$tfile
1497 local rw_len=$((3 * 1024 * 1024)) # 3M
1501 test_mkdir -p $DIR/$tdir
1503 $LFS setstripe -E 2m -E -1 -z 64M $comp_file ||
1504 error "Create $comp_file failed"
1506 replay_barrier $SINGLEMDS
1508 #instantiate & extend second component
1509 dd if=/dev/zero of=$comp_file bs=4M count=1 ||
1510 error "dd to extend failed"
1512 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1513 local ost_idx3=$($LFS getstripe -I3 -i $comp_file)
1515 [ $ost_idx2 -eq $ost_idx3 ] && error "$ost_idx2 == $ost_idx3"
1516 [ $ost_idx3 -ne "-1" ] && error "third component init $ost_idx3"
1518 test_19e_check $comp_file
1520 local f1=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1521 echo "before MDS recovery, the ost fid of 2nd component is $f1"
1525 local f2=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1526 echo "after MDS recovery, the ost fid of 2nd component is $f2"
1527 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
1529 # simply repeat all previous checks, but also verify components are on
1530 # the same OST as before
1532 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1533 local ost_idx3_2=$($LFS getstripe -I3 -i $comp_file)
1535 [ $ost_idx2_2 -eq $ost_idx3_2 ] && error "$ost_idx2_2 == $ost_idx3_2"
1536 [ $ost_idx3_2 -ne "-1" ] && error "second component init $ost_idx3_2"
1538 # verify OST id is the same after failover
1539 [ $ost_idx2 -ne $ost_idx2_2 ] &&
1540 error "$ost_idx2 != $ost_idx2_2, changed after failover"
1542 test_19e_check $comp_file
1544 run_test 19e "Replay of layout instantiation & extension"
1547 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1548 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1549 skip "skipped for lustre < $SEL_VER"
1551 local comp_file=$DIR/$tdir/$tfile
1555 test_mkdir -p $DIR/$tdir
1557 $LFS setstripe -E 256M --comp-flags extension -E -1 $comp_file
1559 [ $? != 0 ] || error "should not be able to manually set extension flag"
1562 run_test 19f "Rejection of invalid layouts"
1565 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1566 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1567 skip "skipped for lustre < $SEL_VER"
1569 local file1=$DIR/${tfile}-1
1570 local file2=$DIR/${tfile}-2
1572 test_mkdir -p $DIR/$tdir
1573 multiop $file1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1574 error "create failed $file1"
1575 multiop $file2 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1576 error "create failed $file2"
1578 $LFS setstripe --component-add -E 1G -c 1 $file1 ||
1579 error "comp-add [0,1G] failed $file1"
1580 $LFS setstripe --component-add -E 512M -z 128M $file1 &&
1581 error "comp-add [1G,1G],SEL[1G,512M] succeded $file1"
1582 $LFS setstripe --component-add -E 10G -z 128M $file1 ||
1583 error "comp-add [1G,1G],SEL[1G,10G] failed $file1"
1584 $LFS setstripe --component-add -E -1 $file1 ||
1585 error "comp-add [10G,-1] failed $file1"
1587 $LFS setstripe --component-add -E 1G -z 32M -c 1 $file2 &&
1588 error "comp-add with smal ext size succeeded $file1"
1589 $LFS setstripe --component-add -E 1G -z 100M -c 1 $file2 &&
1590 error "comp-add with not aligned ext size succeeded $file1"
1591 $LFS setstripe --component-add -E 1G -z 128M -c 1 $file2 ||
1592 error "comp-add [0,128M],SEL[128M,1G] failed $file1"
1593 $LFS setstripe --component-add -E 10G $file2 ||
1594 error "comp-add [1G,10G] failed $file1"
1595 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 ||
1596 error "comp-add [10G,10G],SEL[10G,-1] failed $file1"
1597 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 &&
1598 error "repeated comp-add [10G,10G],SEL[10G,-1] succeeded $file1"
1600 $LFS getstripe $file1
1601 flg_opts="--comp-flags init"
1602 found=$($LFS find --comp-start 0 -E 1G $flg_opts $file1 | wc -l)
1603 [ $found -eq 1 ] || error "First component not found $file1"
1605 flg_opts="--comp-flags ^init"
1606 found=$($LFS find --comp-start 1G -E 1G $flg_opts $file1 | wc -l)
1607 [ $found -eq 1 ] || error "Second component not found $file1"
1609 flg_opts="--comp-flags ^init,extension"
1610 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file1 | wc -l)
1611 [ $found -eq 1 ] || error "Third component not found $file1"
1613 flg_opts="--comp-flags ^init"
1614 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file1 | wc -l)
1615 [ $found -eq 1 ] || error "Fourth component not found $file1"
1617 $LFS getstripe $file2
1618 flg_opts="--comp-flags init"
1619 found=$($LFS find --comp-start 0 -E 128M $flg_opts $file2 | wc -l)
1620 [ $found -eq 1 ] || error "First component not found $file2"
1622 flg_opts="--comp-flags extension"
1623 found=$($LFS find --comp-start 128M -E 1G $flg_opts $file2 | wc -l)
1624 [ $found -eq 1 ] || error "Second component not found $file2"
1626 flg_opts="--comp-flags ^init"
1627 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file2 | wc -l)
1628 [ $found -eq 1 ] || error "Third component not found $file2"
1630 flg_opts="--comp-flags ^init"
1631 found=$($LFS find --comp-start 10G -E 10G $flg_opts $file2 | wc -l)
1632 [ $found -eq 1 ] || error "Fourth component not found $file2"
1634 flg_opts="--comp-flags ^init,extension"
1635 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file2 | wc -l)
1636 [ $found -eq 1 ] || error "Fifth component not found $file2"
1638 run_test 19g "component-add behaviour"
1640 # Test out of space behavior
1642 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1643 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1644 skip "skipped for lustre < $SEL_VER"
1646 local comp_file=$DIR/$tdir/$tfile
1650 test_mkdir -p $DIR/$tdir
1652 # without this, a previous delete can finish after we check free space
1653 wait_delete_completed
1656 # First component is on OST0
1657 $LFS setstripe -E 256M -i 0 -z 64M -E -1 -z 128M $comp_file ||
1658 error "Create $comp_file failed"
1660 # write past end of first component, so it is extended
1661 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=66 ||
1662 error "dd to extend failed"
1664 flg_opts="--comp-flags extension"
1665 found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file |wc -l)
1666 [ $found -eq 1 ] || error "Write: Second component not found"
1668 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1669 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1671 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1673 flg_opts="--comp-flags extension"
1674 # Write past current init comp, but we won't extend (because no space)
1675 dd if=/dev/zero of=$comp_file bs=1M count=10 seek=200 ||
1676 error "dd write past current comp failed"
1678 $LFS getstripe $comp_file
1680 flg_opts="--comp-flags init"
1681 found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file | \
1683 [ $found -eq 1 ] || error "Write: third component not found"
1685 flg_opts="--comp-flags extension"
1686 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file |wc -l)
1687 [ $found -eq 1 ] || error "Write: fourth extension component not found"
1689 sel_layout_sanity $comp_file 3
1691 run_test 20a "Test out of space, spillover to defined component"
1694 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1695 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1696 skip "skipped for lustre < $SEL_VER"
1698 local comp_file=$DIR/$tdir/$tfile
1702 test_mkdir -p $DIR/$tdir
1704 # Pool allows us to force use of only certain OSTs
1705 pool_add $TESTNAME || error "Pool creation failed"
1706 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1708 # normal component to 10M, extendable component to 1G
1709 # further extendable to EOF
1710 $LFS setstripe -E 10M -E 1G -p $TESTNAME -z 64M -E -1 -p "" -z 128M \
1711 $comp_file || error "Create $comp_file failed"
1713 replay_barrier $SINGLEMDS
1715 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1716 [ $found -eq 1 ] || error "Zero length component not found"
1719 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1721 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1723 # write past end of first component
1724 # This should remove the next component, since OST0 is out of space
1725 # and it is striped there (pool contains only OST0)
1726 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=14 ||
1727 error "dd to extend/remove failed"
1729 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1730 [ $found -eq 0 ] || error "Write: zero length component still present"
1732 flg_opts="--comp-flags init"
1733 $LFS find --comp-start 10M -E +137M $flg_opts $comp_file
1734 found=$($LFS find --comp-start 10M -E +137M $flg_opts $comp_file |wc -l)
1735 [ $found -eq 1 ] || error "Write: second component not found"
1737 flg_opts="--comp-flags extension"
1738 found=$($LFS find --comp-start +137M -E EOF $flg_opts $comp_file |wc -l)
1739 [ $found -eq 1 ] || error "Write: third component not found"
1743 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1744 [ $found -eq 0 ] || error "Failover: 0-length component still present"
1746 flg_opts="--comp-flags init"
1747 found=$($LFS find --comp-start 10M -E +137M $flg_opts $comp_file |wc -l)
1748 [ $found -eq 1 ] || error "Failover: second component not found"
1750 flg_opts="--comp-flags extension"
1751 found=$($LFS find --comp-start +137M -E EOF $flg_opts $comp_file |wc -l)
1752 [ $found -eq 1 ] || error "Failover: third component not found"
1754 sel_layout_sanity $comp_file 3
1756 run_test 20b "Remove component without instantiation when there is no space"
1759 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1760 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1761 skip "skipped for lustre < $SEL_VER"
1763 local comp_file=$DIR/$tdir/$tfile
1767 test_mkdir -p $DIR/$tdir
1769 # pool is used to limit available OSTs to 0 and 1, so we can set all
1770 # available OSTs out of space
1771 pool_add $TESTNAME || error "Pool creation failed"
1772 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
1774 # without this, a previous delete can finish after we check free space
1775 wait_delete_completed
1778 $LFS setstripe -E 100M -E -1 -p $TESTNAME -z 64M $comp_file ||
1779 error "Create $comp_file failed"
1783 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1785 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
1787 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1788 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
1790 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=120 &&
1791 error "dd should fail with ENOSPC"
1793 flg_opts="--comp-flags init"
1794 found=$($LFS find --comp-start 0M -E 100M $flg_opts $comp_file | wc -l)
1795 [ $found -eq 1 ] || error "Write: First component not found"
1797 flg_opts="--comp-flags ^init"
1798 found=$($LFS find --comp-start 100M -E 100M $flg_opts $comp_file |wc -l)
1799 [ $found -eq 1 ] || error "Write: 0-length component not found"
1801 flg_opts="--comp-flags extension"
1802 found=$($LFS find --comp-start 100M -E EOF $flg_opts $comp_file | wc -l)
1803 [ $found -eq 1 ] || error "Write: third extension component not found"
1805 sel_layout_sanity $comp_file 3
1807 run_test 20c "Test inability to stripe new extension component"
1810 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1811 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1812 skip "skipped for lustre < $SEL_VER"
1814 local comp_file=$DIR/$tdir/$tfile
1815 test_mkdir -p $DIR/$tdir
1817 wait_delete_completed
1820 pool_add $TESTNAME || error "Pool creation failed"
1821 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1822 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
1823 error "Create $comp_file failed"
1825 replay_barrier $SINGLEMDS
1827 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1828 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1831 ost_watermarks_clear_enospc $tfile 0 $wms
1832 [ $RC -eq 0 ] || error "dd failed: $RC"
1834 $LFS getstripe $comp_file
1835 local flg_opts="--comp-start 64M -E 128M --comp-flags init"
1836 local found=$($LFS find $flg_opts $comp_file | wc -l)
1837 [ $found -eq 1 ] || error "Write: component (64M-128M) not found"
1839 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
1840 [ "$ost_idx" != "-1" ] && error "Write: EXT component disappeared"
1844 found=$($LFS find $flg_opts $comp_file | wc -l)
1845 [ $found -eq 1 ] || error "Failover: component (64M-128M) not found"
1847 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1848 [ "$ost_idx" != "-1" ] && error "Failover: EXT component disappeared"
1850 sel_layout_sanity $comp_file 3
1852 run_test 20d "Low on space + 0-length comp: force extension"
1855 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1856 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1857 skip "skipped for lustre < $SEL_VER"
1859 local comp_file=$DIR/$tdir/$tfile
1860 test_mkdir -p $DIR/$tdir
1862 wait_delete_completed
1865 pool_add $TESTNAME || error "Pool creation failed"
1866 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1868 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
1869 error "Create $comp_file failed"
1871 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1873 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1876 ost_watermarks_clear_enospc $tfile 0 $wms
1877 [ $RC -eq 0 ] || error "dd failed $RC"
1879 $LFS getstripe $comp_file
1880 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
1881 local found=$($LFS find $flg_opts $comp_file | wc -l)
1882 [ $found -eq 1 ] || error "Write: component (64M-EOF) not found"
1884 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
1885 [ "$ost_idx" != "" ] && error "Write: 0-length component still exists"
1886 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1887 [ "$ost_idx" != "" ] && error "Write: extension component still exists"
1889 sel_layout_sanity $comp_file 2
1891 run_test 20e "ENOSPC with next real comp: spillover and backward extension"
1893 # Simple DoM interaction test
1895 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1896 skip "skipped for lustre < $SEL_VER"
1898 local comp_file=$DIR/$tdir/$tfile
1902 test_mkdir -p $DIR/$tdir
1904 # simple, correct self-extending layout after DoM component
1905 $LFS setstripe -E 1M -L mdt -E -1 -z 64m $comp_file || \
1906 error "Create $comp_file failed"
1908 # Write to DoM component & to self-extending comp after it
1909 dd if=/dev/zero bs=1M count=12 of=$comp_file ||
1910 error "dd to extend failed"
1912 flg_opts="--comp-flags init"
1913 found=$($LFS find --comp-start 1M -E 65M $flg_opts $comp_file | wc -l)
1914 [ $found -eq 1 ] || error "Write: extended component not found"
1916 flg_opts="--comp-flags extension"
1917 found=$($LFS find --comp-start 65M $flg_opts $comp_file | wc -l)
1918 [ $found -eq 1 ] || error "Write: extension component not found"
1920 sel_layout_sanity $comp_file 3
1922 run_test 21a "Simple DoM interaction tests"
1924 # DoM + extension + removal
1926 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1927 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1928 skip "skipped for lustre < $SEL_VER"
1930 local comp_file=$DIR/$tdir/$tfile
1931 local ost_name=$(ostname_from_index 0)
1935 test_mkdir -p $DIR/$tdir
1937 # DoM, extendable component, further extendable component
1938 $LFS setstripe -E 1M -L mdt -E 256M -i 0 -z 64M -E -1 -z 128M \
1939 $comp_file || error "Create $comp_file failed"
1941 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1942 [ $found -eq 1 ] || error "Write: Zero length component not found"
1944 # This also demonstrates that we will avoid degraded OSTs
1945 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
1946 # sleep to guarantee we see the degradation
1949 # un-degrade on exit
1950 stack_trap "do_facet ost1 $LCTL set_param -n \
1951 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1953 # This should remove the first component after DoM and spill over to
1955 dd if=/dev/zero bs=1M count=2 of=$comp_file ||
1956 error "dd to remove+spill over failed"
1958 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1959 [ $found -eq 0 ] || error "Write: Zero length component still present"
1961 flg_opts="--comp-flags init"
1962 found=$($LFS find --comp-start 1M -E 129M $flg_opts $comp_file | wc -l)
1963 [ $found -eq 1 ] || error "Write: extended component not found"
1965 flg_opts="--comp-flags extension"
1966 found=$($LFS find --comp-start 129M -E EOF $flg_opts $comp_file |wc -l)
1967 [ $found -eq 1 ] || error "Write: extension component not found"
1969 sel_layout_sanity $comp_file 3
1971 run_test 21b "DoM followed by extendable component with removal"
1973 # Test of repeat component behavior with OOS/degraded OST
1975 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1976 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1977 skip "skipped for lustre < $SEL_VER"
1979 local comp_file=$DIR/$tdir/$tfile
1983 test_mkdir -p $DIR/$tdir
1985 $LFS setstripe -E -1 -c 1 -z 128M $comp_file ||
1986 error "Create $comp_file failed"
1988 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1989 local ost_name=$(ostname_from_index $ost_idx1)
1991 # write past end of first component, so it is extended
1992 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
1993 error "dd to extend failed"
1995 flg_opts="--comp-flags extension"
1996 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
1997 [ $found -eq 1 ] || error "Write: second component not found"
1999 # degrade OST for component 1
2000 do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
2001 obdfilter.$ost_name.degraded=1
2002 # sleep to guarantee we see the degradation
2005 # un-degrade on exit
2006 stack_trap "do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
2007 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
2009 replay_barrier $SINGLEMDS
2011 # seek past the end of current comp & write, should cause a new comp
2012 # to be created (ie repeat previous comp)
2013 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
2014 error "dd to repeat failed"
2016 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
2018 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
2020 flg_opts="--comp-flags init"
2021 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
2022 [ $found -eq 1 ] || error "Write: second component not found"
2024 flg_opts="--comp-flags extension"
2025 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
2026 [ $found -eq 1 ] || error "Write: extension component not found"
2030 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
2031 [ $ost_idx2_2 -ne $ost_idx2 ] && error "$ost_idx2_2 != $ost_idx2"
2033 flg_opts="--comp-flags init"
2034 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
2035 [ $found -eq 1 ] || error "Failover: second component not found"
2037 flg_opts="--comp-flags extension"
2038 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
2039 [ $found -eq 1 ] || error "Failover: extension component not found"
2041 sel_layout_sanity $comp_file 3
2043 run_test 22a "Test repeat component behavior with degraded OST"
2045 # Test repeat behavior with low space
2047 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2048 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2049 skip "skipped for lustre < $SEL_VER"
2051 local comp_file=$DIR/$tdir/$tfile
2055 test_mkdir -p $DIR/$tdir
2057 # without this, a previous delete can finish after we check free space
2058 wait_delete_completed
2061 $LFS setstripe -E -1 -c 1 -z 128M \
2062 $comp_file || error "Create $comp_file failed"
2064 # write past end of first component, so it is extended
2065 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
2066 error "dd to extend failed"
2068 flg_opts="--comp-flags extension"
2069 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
2070 [ $found -eq 1 ] || error "Write: Second component not found"
2072 # set our OST low on space
2073 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
2074 local wms=$(ost_watermarks_set_low_space $ost_idx1 | grep "watermarks")
2076 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
2078 # Write past end of current space, fail to extend, causing repeat
2079 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
2080 error "dd to repeat failed"
2082 $LFS getstripe $comp_file
2084 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
2086 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
2088 flg_opts="--comp-flags init"
2089 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
2090 [ $found -eq 1 ] || error "Write: Second component not found"
2092 flg_opts="--comp-flags extension"
2093 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
2094 [ $found -eq 1 ] || error "Write: Extension component not found"
2096 sel_layout_sanity $comp_file 3
2098 run_test 22b "Test simple 'out of space' condition with repeat"
2100 # This tests both "repeat" and "extend in place when repeat fails" aspects
2101 # of repeating components
2103 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2104 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2105 skip "skipped for lustre < $SEL_VER"
2107 local comp_file=$DIR/$tdir/$tfile
2111 test_mkdir -p $DIR/$tdir
2113 # pool is used to limit available OSTs to 0 and 1, so we can set all
2114 # available OSTs out of space
2115 pool_add $TESTNAME || error "Pool creation failed"
2116 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
2118 # without this, a previous delete can finish after we check free space
2119 wait_delete_completed
2122 $LFS setstripe -E -1 -z 64M -c 1 -p "$TESTNAME" $comp_file || \
2123 error "Create $comp_file failed"
2125 # write past end of first component, so it is extended
2126 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=80 conv=notrunc ||
2127 error "dd to extend failed"
2129 $LFS getstripe $comp_file
2131 flg_opts="--comp-flags extension"
2132 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
2133 [ $found -eq 1 ] || error "Write: second component not found"
2135 # set our OST out of space
2136 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
2137 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
2139 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
2141 # This should create a repeat component on a new OST
2142 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=180 conv=notrunc ||
2143 error "dd to repeat failed"
2145 $LFS getstripe $comp_file
2147 local comp_cnt=$($LFS getstripe --component-count $comp_file)
2148 [ $comp_cnt -ne 3 ] && error "component count: $comp_cnt, should be 3"
2150 # New second component should be on a different OST
2151 local ost_idx2=$($LFS getstripe --comp-start=128m \
2152 --comp-end=192m --comp-flags=init -i $comp_file)
2154 [ $ost_idx1 -eq $ost_idx2 ] && error "2nd comp: same OST $ost_idx1"
2156 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
2158 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
2160 # now that the second OST is out of space (as is the first OST), we
2161 # attempt to extend. This should result in an extension of the
2162 # existing component, rather than a new component.
2163 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=240 conv=notrunc ||
2164 error "dd for forced extension failed"
2166 $LFS getstripe $comp_file
2168 # clear out of space on first OST
2169 ost_watermarks_clear_enospc $tfile $ost_idx1 $wms
2171 # finally, now that the first OST has space again, we attempt to
2172 # extend one last time. This should create a new component on the
2174 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 conv=notrunc ||
2175 error "dd for repeat on first OST failed"
2177 $LFS getstripe $comp_file
2179 flg_opts="--comp-flags init"
2180 found=$($LFS find --comp-start 128M $flg_opts $comp_file | wc -l)
2181 [ $found -eq 1 ] || error "Write: second component not found"
2183 flg_opts="--comp-flags init"
2184 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
2185 [ $found -eq 1 ] || error "Write: third component not found"
2187 flg_opts="--comp-flags extension"
2188 found=$($LFS find --comp-start 320M -E EOF $flg_opts $comp_file | wc -l)
2189 [ $found -eq 1 ] || error "Write: extension component not found"
2191 sel_layout_sanity $comp_file 4
2193 run_test 22c "Test repeat with out of space on > 1 OST"
2195 test_22d_post_check() {
2198 local flg_opts="--comp-flags init"
2199 local found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file |
2201 [ $found -eq 1 ] || {
2202 $LFS getstripe $comp_file
2203 error "$name: second component not found"
2206 flg_opts="--comp-flags extension"
2207 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
2208 [ $found -eq 1 ] || error "$name: third extension component not found"
2210 sel_layout_sanity $comp_file 2
2218 # write past end of first component
2219 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=70
2222 ost_watermarks_clear_enospc $tfile 0 $wms
2223 [ $RC -eq 0 ] || error "dd to force extend failed"
2225 test_22d_post_check $comp_file "Write"
2229 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2230 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2231 skip "skipped for lustre < $SEL_VER"
2233 local comp_file=$DIR/$tdir/$tfile
2237 test_mkdir -p $DIR/$tdir
2239 # without this, a previous delete can finish after we check free space
2240 wait_delete_completed
2243 # Pool allows us to force use of only certain OSTs
2244 pool_add $TESTNAME || error "Pool creation failed"
2245 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2247 # 1. Fail to extend due to OOS, try to repeat within the same pool,
2248 # fail to stripe (again OOS) the 0-length component, remove the
2249 # repeated one, force the extension on the original one.
2250 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2251 error "Create $comp_file failed"
2253 replay_barrier $SINGLEMDS
2255 # set our OST out of space
2256 local wms=$(ost_watermarks_set_enospc $tfile 0 | grep "watermarks")
2258 test_22d_pre $comp_file "$wms"
2260 test_22d_post_check $comp_file "Failover"
2262 # 2. repeat with low on space: 0-length repeated component will be
2263 # striped, but still fails to be extended; otherwise the same as (1).
2265 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2266 error "Create $comp_file failed"
2268 replay_barrier $SINGLEMDS
2270 # set our OST low on space
2271 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2273 test_22d_pre $comp_file "$wms"
2275 test_22d_post_check $comp_file "Failover"
2277 run_test 22d "out of/low on space + failed to repeat + forced extension"
2280 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2281 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2282 skip "skipped for lustre < $SEL_VER"
2284 local comp_file=$DIR/$tdir/$tfile
2285 test_mkdir -p $DIR/$tdir
2287 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2288 error "Create $comp_file failed"
2290 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2291 error "dd append failed"
2293 local flg_opts="--comp-start 0 -E EOF --comp-flags init"
2294 local found=$($LFS find $flg_opts $comp_file | wc -l)
2295 [ $found -eq 1 ] || error "Append: first component (0-EOF) not found"
2297 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2298 [ "$ost_idx" != "" ] && error "Append: second component still exists"
2300 sel_layout_sanity $comp_file 1
2302 run_test 23a "Append: remove EXT comp"
2305 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2306 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2307 skip "skipped for lustre < $SEL_VER"
2309 local comp_file=$DIR/$tdir/$tfile
2310 test_mkdir -p $DIR/$tdir
2312 $LFS setstripe -E 64m -E -1 -z 64M $comp_file ||
2313 error "Create $comp_file failed"
2315 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2316 error "dd append failed"
2318 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2319 local found=$($LFS find $flg_opts $comp_file | wc -l)
2320 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2322 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2323 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2325 sel_layout_sanity $comp_file 2
2327 run_test 23b "Append with 0-length comp: remove EXT comp"
2330 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2331 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2332 skip "skipped for lustre < $SEL_VER"
2334 local comp_file=$DIR/$tdir/$tfile
2335 test_mkdir -p $DIR/$tdir
2337 wait_delete_completed
2340 pool_add $TESTNAME || error "Pool creation failed"
2341 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2342 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
2343 error "Create $comp_file failed"
2345 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2346 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2349 ost_watermarks_clear_enospc $tfile 0 $wms
2350 [ $RC -eq 0 ] || error "dd append failed: $RC"
2352 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2353 local found=$($LFS find $flg_opts $comp_file | wc -l)
2354 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2356 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2357 [ "$ost_idx" != "" ] && error "Append: EXT component still exists"
2359 sel_layout_sanity $comp_file 2
2361 run_test 23c "Append with low on space + 0-length comp: force extension"
2364 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2365 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2366 skip "skipped for lustre < $SEL_VER"
2368 local comp_file=$DIR/$tdir/$tfile
2369 test_mkdir -p $DIR/$tdir
2371 $LFS setstripe -E 64m -E 640M -z 64M -E -1 $comp_file ||
2372 error "Create $comp_file failed"
2374 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2375 error "dd append failed"
2377 flg_opts="--comp-start 64M -E 640M --comp-flags init"
2378 found=$($LFS find $flg_opts $comp_file | wc -l)
2379 [ $found -eq 1 ] || error "Append: component (64M-640M) not found"
2381 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2382 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2384 sel_layout_sanity $comp_file 3
2386 run_test 23d "Append with 0-length comp + next real comp: remove EXT comp"
2389 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2390 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2391 skip "skipped for lustre < $SEL_VER"
2393 local comp_file=$DIR/$tdir/$tfile
2394 test_mkdir -p $DIR/$tdir
2396 wait_delete_completed
2399 pool_add $TESTNAME || error "Pool creation failed"
2400 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2402 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
2403 error "Create $comp_file failed"
2405 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2407 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2410 ost_watermarks_clear_enospc $tfile 0 $wms
2411 [ $RC -eq 0 ] || error "dd append failed $RC"
2413 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2414 local found=$($LFS find $flg_opts $comp_file | wc -l)
2415 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2417 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2418 [ "$ost_idx" != "" ] && error "Append: 0-length component still exists"
2419 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2420 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2422 sel_layout_sanity $comp_file 2
2424 run_test 23e "Append with next real comp: spillover and backward extension"
2427 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2428 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2429 skip "skipped for lustre < $SEL_VER"
2431 local comp_file=$DIR/$tdir/$tfile
2432 test_mkdir -p $DIR/$tdir
2434 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2435 error "Create $comp_file failed"
2437 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
2438 local wms=$(ost_watermarks_set_low_space $ost_idx | grep "watermarks")
2440 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2443 ost_watermarks_clear_enospc $tfile $ost_idx $wms
2444 [ $RC -eq 0 ] || error "dd append failed"
2446 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2447 local found=$($LFS find $flg_opts $comp_file | wc -l)
2448 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2450 ost_idx=$($LFS getstripe -I2 -i $comp_file)
2451 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2453 sel_layout_sanity $comp_file 2
2455 run_test 23f "Append with low on space: repeat and remove EXT comp"
2464 [ "$OSTCOUNT" -lt "3" ] && skip_env "needs >= 3 OSTs"
2466 trap cleanup_24 EXIT RETURN
2468 local file=$DIR/$tfile
2470 $LFS setstripe -E 1m -c1 -o0 -E eof -c2 -S 1M -o1,2 $file ||
2471 error "setstripe on $file"
2473 dd if=/dev/zero of=$file bs=1M count=3 || error "dd failed for $file"
2476 filefrag -ves $file || error "filefrag $file failed"
2477 filefrag_op=$(filefrag -ve -k $file |
2478 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
2480 #Filesystem type is: bd00bd0
2481 #File size of /mnt/lustre/f24a.sanity-pfl is 3145728 (3072 blocks of 1024 bytes)
2482 # ext: device_logical: physical_offset: length: dev: flags:
2483 # 0: 0.. 1023: 1572864.. 1573887: 1024: 0000: net
2484 # 1: 0.. 1023: 1572864.. 1573887: 1024: 0002: net
2485 # 2: 1024.. 2047: 1573888.. 1574911: 1024: 0001: last,net
2486 #/mnt/lustre/f24a.sanity-pfl: 3 extents found
2488 last_lun=$(echo $filefrag_op | cut -d: -f5)
2493 for line in $filefrag_op; do
2494 frag_lun=$(echo $line | cut -d: -f5)
2495 ext_len=$(echo $line | cut -d: -f4)
2496 if [[ "$frag_lun" != "$last_lun" ]]; then
2497 if (( tot_len != 1024 )); then
2499 error "$file: OST$last_lun $tot_len != 1024"
2505 (( tot_len += ext_len ))
2508 if (( num_luns != 3 || tot_len != 1024 )); then
2510 error "$file: $num_luns != 3, $tot_len != 1024 on OST$last_lun"
2513 echo "FIEMAP on $file succeeded"
2515 run_test 24a "FIEMAP upon PFL file"
2518 local pfl_f=$DIR/$tdir/"$tfile"_pfl
2519 local dom_f=$DIR/$tdir/"$tfile"_dom
2520 local common_f=$DIR/$tdir/"$tfile"_common
2524 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2525 $LFS setstripe -E 10M -S 64k -c -1 -E 20M -S 1M -E -1 -S 2M -c 1 \
2526 $pfl_f || error "setstripe $pfl_f failed"
2527 $LFS setstripe -E 256k -L mdt -E -1 -S 1M $dom_f ||
2528 error "setstripe $dom_f failed"
2529 $LFS setstripe -S 512K -c -1 $common_f ||
2530 error "setstripe $common_f failed"
2532 #verify lov_getstripe_old with PFL file
2533 stripe_count=$(lov_getstripe_old $pfl_f |
2534 awk '/stripe_count/ { print $2 }')
2535 stripe_size=$(lov_getstripe_old $pfl_f |
2536 awk '/stripe_size/ { print $2 }')
2537 [ $stripe_count -eq 1 ] ||
2538 error "stripe_count $stripe_count !=1 for $pfl_f"
2539 [ $stripe_size -eq 2097152 ] ||
2540 error "stripe_size $stripe_size != 2097152 for $pfl_f"
2542 #verify lov_getstripe_old with DoM file
2543 stripe_count=$(lov_getstripe_old $dom_f |
2544 awk '/stripe_count/ { print $2 }')
2545 stripe_size=$(lov_getstripe_old $dom_f |
2546 awk '/stripe_size/ { print $2 }')
2547 [ $stripe_count -eq 1 ] ||
2548 error "stripe_count $stripe_count !=1 for $dom_f"
2549 [ $stripe_size -eq 1048576 ] ||
2550 error "stripe_size $stripe_size != 1048576 for $dom_f"
2552 #verify lov_getstripe_old with common file
2553 stripe_count=$(lov_getstripe_old $common_f |
2554 awk '/stripe_count/ { print $2 }')
2555 stripe_size=$(lov_getstripe_old $common_f |
2556 awk '/stripe_size/ { print $2 }')
2557 [ $stripe_count -eq $OSTCOUNT ] ||
2558 error "stripe_count $stripe_count !=$OSTCOUNT for $common_f"
2559 [ $stripe_size -eq 524288 ] ||
2560 error "stripe_size $stripe_size != 524288 for $common_f"
2562 run_test 25 "Verify old lov stripe API with PFL files"
2565 $LFS setstripe -E 1m -S 1M -c 1 $DIR/$tfile
2566 dd if=/dev/urandom bs=1M count=10 >> $DIR/$tfile
2567 [ $? != 0 ] || error "append must return an error"
2568 dd if=/dev/urandom bs=1M count=10 oflag=direct >> $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"
2578 dd if=/dev/urandom bs=1M count=1 oflag=direct >> $DIR/$tfile
2579 [ $? != 0 ] || error "append must return an error"
2581 run_test 26b "Append to not-existend component, file size is unknown"
2584 $LFS setstripe -E 1m -S 1M -c 1 $DIR/$tfile
2585 dd if=/dev/urandom bs=2M count=1 >> $DIR/$tfile
2586 [ $? != 0 ] || error "append must return an error"
2587 dd if=/dev/urandom bs=2M count=1 oflag=direct >> $DIR/$tfile
2588 [ $? != 0 ] || error "append must return an error"
2590 run_test 26c "Append to not-existend component, crossing the component border"
2593 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2594 skip "server does not support overstriping"
2595 (( $MDS1_VERSION >= $(version_code 2.15.55.102) )) ||
2596 skip "need MDS >= 2.12.55.102 for mdt_dump_lmm fix"
2598 stack_trap "rm -f $DIR/$tfile"
2599 # start_full_debug_logging
2600 $LFS setstripe -S 64K -C -1 $DIR/$tfile || error "create $tfile failed"
2601 $LFS getstripe -c $DIR/$tfile || error "getstripe $tfile failed"
2603 $LFS getstripe -c $DIR/$tfile || error "getstripe failed after clear"
2605 test_mkdir $DIR/$tdir
2606 stack_trap "rm -rf $DIR/$tdir/$tfile"
2607 $LFS setstripe -S 64K -C -1 $DIR/$tdir || error "mkdir $tdir failed"
2608 $LFS getstripe -y $DIR/$tdir || error "getstripe $tdir failed"
2609 touch $DIR/$tdir/$tfile || error "create $tdir/$tfile failed"
2611 $LFS getstripe -c $DIR/$tdir/$tfile ||
2612 error "getstripe $tdir/$tfile failed"
2613 #stop_full_debug_logging
2615 run_test 27 "overstriping with -C -1 in mdt_dump_lmm"
2617 complete_test $SECONDS
2618 check_and_cleanup_lustre