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"
75 local comp_file=$DIR/$tdir/$tfile
79 $LFS setstripe -E -1 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
80 error "Create $comp_file failed"
82 local count=$($LFS getstripe -I1 -c $comp_file)
83 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
84 error "stripe count of first component is shrinked to $count"
86 rm -f $comp_file || error "Delete $comp_file failed"
88 # Create file with 1.1*LOV_MAX_STRIPE_COUNT stripes should succeed
89 $LFS setstripe -E 1m -C $((LOV_MAX_STRIPE_COUNT / 10)) -E -1 \
90 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
91 error "Create $comp_file failed"
93 local count=$($LFS getstripe -I2 -c $comp_file)
94 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
95 error "stripe count of second component is shrinked to $count"
97 rm -f $comp_file || error "Delete $comp_file failed"
99 # Create file with 3*LOV_MAX_STRIPE_COUNT stripes should fail
100 $LFS setstripe -E 200G -C $LOV_MAX_STRIPE_COUNT \
101 -E 500G -C $LOV_MAX_STRIPE_COUNT \
102 -E -1 -C $LOV_MAX_STRIPE_COUNT $comp_file &&
103 error "Create $comp_file succeeded"
105 rm -f $comp_file || error "Delete $comp_file failed"
107 run_test 0b "Verify comp stripe count limits"
110 [[ $($LCTL get_param mdc.*.import |
111 grep "connect_flags:.*overstriping") ]] ||
112 skip "server does not support overstriping"
113 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code $SEL_VER) ] &&
114 skip "skipped for lustre < $SEL_VER"
116 large_xattr_enabled || skip_env "no large xattr support"
118 local comp_file=$DIR/$tdir/$tfile
120 test_mkdir $DIR/$tdir
122 $LFS setstripe -E -1 -C $LOV_MAX_STRIPE_COUNT -z 128M $comp_file ||
123 error "Create $comp_file failed"
125 local count=$($LFS getstripe -I1 -c $comp_file)
126 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
127 error "stripe count is shrinked to $count"
129 run_test 0c "Verify SEL comp stripe count limits"
132 local comp_file=$DIR/$tdir/$tfile
133 local rw_len=$((3 * 1024 * 1024)) # 3M
135 test_mkdir $DIR/$tdir
138 $LFS setstripe -E 1m -S 1m -o 0 -E -1 -o 0 $comp_file ||
139 error "Create $comp_file failed"
141 #instantiate all components, so that objs are allocted
142 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
144 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
145 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
147 [ $ost_idx1 -ne $ost_idx2 ] && error "$ost_idx1 != $ost_idx2"
149 small_write $comp_file $rw_len || error "Verify RW failed"
151 rm -f $comp_file || error "Delete $comp_file failed"
153 run_test 1a "Create full components file, reused OSTs"
155 # test overstriping (>1 stripe/OST within a component)
157 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
158 [[ $($LCTL get_param mdc.*.import |
159 grep "connect_flags:.*overstriping") ]] ||
160 skip "server does not support overstriping"
162 local comp_file=$DIR/$tdir/$tfile
163 local rw_len=$((3 * 1024 * 1024)) # 3M
165 test_mkdir $DIR/$tdir
167 $LFS setstripe -E 1m -S 1m -o 0,0 -E -1 -o 1,1,0,0 $comp_file ||
168 error "Create $comp_file failed"
170 #instantiate all components, so that objs are allocted
171 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=1M
173 $LFS getstripe $comp_file
174 local OSTS_1=$($LFS getstripe -I1 $comp_file | grep -o 'l_ost_idx.*' |
175 awk -e '{print $2}' | tr "\n" "\0")
176 local OSTS_2=$($LFS getstripe -I2 $comp_file | grep -o 'l_ost_idx.*' |
177 awk -e '{print $2}' | tr "\n" "\0")
181 [ "$OSTS_1" = "0,0," ] || error "incorrect OSTs($OSTS_1) in component 1"
182 [ "$OSTS_2" = "1,1,0,0," ] ||
183 error "incorrect OSTs($OSTS_2) in component 2"
185 small_write $comp_file $rw_len || error "Verify RW failed"
187 rm -f $comp_file || error "Delete $comp_file failed"
189 run_test 1b "Create full components file, overstriping in components"
191 # test overstriping with max stripe count
193 [[ $($LCTL get_param mdc.*.import |
194 grep "connect_flags:.*overstriping") ]] ||
195 skip "server does not support overstriping"
196 large_xattr_enabled || skip_env "no large xattr support"
198 local comp_file=$DIR/$tdir/$tfile
199 local rw_len=$((3 * 1024 * 1024)) # 3M
201 test_mkdir $DIR/$tdir
203 $LFS setstripe -E 1m -C 10 -E 10M -C 100 -E -1 \
204 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
205 error "Create $comp_file failed"
207 # Seek & write in to last component so all objects are allocated
208 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=20000
210 local count=$($LFS getstripe -c -I1 $DIR/$tdir/$tfile)
211 [ $count -eq 10 ] || error "comp1 stripe count $count, should be 10"
212 count=$($LFS getstripe -c -I2 $DIR/$tdir/$tfile)
213 [ $count -eq 100 ] || error "comp2 stripe count $count, should be 100"
214 count=$($LFS getstripe -c -I3 $DIR/$tdir/$tfile)
215 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
216 error "comp4 stripe count $count != $LOV_MAX_STRIPE_COUNT"
218 small_write $comp_file $rw_len || error "Verify RW failed"
220 rm -f $comp_file || error "Delete $comp_file failed"
222 run_test 1c "Test overstriping w/max stripe count"
225 local comp_file=$DIR/$tdir/$tfile
226 local rw_len=$((5 * 1024 * 1024)) # 5M
228 test_mkdir $DIR/$tdir
231 $LFS setstripe -E 1m -S 1m $comp_file ||
232 error "Create $comp_file failed"
234 check_component_count $comp_file 1
236 dd if=/dev/zero of=$comp_file bs=1M count=1 > /dev/null 2>&1 ||
237 error "Write first component failed"
238 dd if=$comp_file of=/dev/null bs=1M count=1 > /dev/null 2>&1 ||
239 error "Read first component failed"
241 dd if=/dev/zero of=$comp_file bs=1M count=2 > /dev/null 2>&1 &&
242 error "Write beyond component should fail"
243 dd if=$comp_file of=/dev/null bs=1M count=2 > /dev/null 2>&1 ||
244 error "Read beyond component should short read, not fail"
246 $LFS setstripe --component-add -E 2M -S 1M -c 1 $comp_file ||
247 error "Add component to $comp_file failed"
249 check_component_count $comp_file 2
251 $LFS setstripe --component-add -E -1 -c 3 $comp_file ||
252 error "Add last component to $comp_file failed"
254 check_component_count $comp_file 3
256 small_write $comp_file $rw_len || error "Verify RW failed"
258 rm -f $comp_file || error "Delete $comp_file failed"
260 run_test 2 "Add component to existing file"
262 del_comp_and_verify() {
269 if [ $id == "init" -o $id == "^init" ]; then
270 opt="--component-flags="
273 $LFS setstripe --component-del $opt$id $comp_file ||
274 error "Delete component $id from $comp_file failed"
276 local comp_cnt=$($LFS getstripe --component-count $comp_file)
277 if grep -q "has no stripe info" <<< "$comp_cnt" ; then
280 [ $comp_cnt -ne $left ] && error "$comp_cnt != $left"
282 $CHECKSTAT -s $size $comp_file || error "size != $size"
286 local comp_file=$DIR/$tdir/$tfile
288 test_mkdir $DIR/$tdir
291 $LFS setstripe -E 1M -S 1M -E 64M -c 2 -E -1 -c 3 $comp_file ||
292 error "Create $comp_file failed"
294 check_component_count $comp_file 3
296 dd if=/dev/zero of=$comp_file bs=1M count=2
298 $LFS setstripe --component-del -I 2 $comp_file &&
299 error "Component deletion makes hole"
301 del_comp_and_verify $comp_file 3 2 $((2 * 1024 * 1024))
302 del_comp_and_verify $comp_file 2 1 $((1 * 1024 * 1024))
303 del_comp_and_verify $comp_file 1 0 0
305 rm -f $comp_file || error "Delete $comp_file failed"
307 $LFS setstripe -E 1M -S 1M -E 16M -E -1 $comp_file ||
308 error "Create second $comp_file failed"
310 del_comp_and_verify $comp_file "^init" 1 0
311 del_comp_and_verify $comp_file "init" 0 0
312 rm -f $comp_file || error "Delete second $comp_file failed"
315 run_test 3 "Delete component from existing file"
318 skip "Not supported in PFL"
319 # In PFL project, only LCME_FL_INIT is supported, and it can't
320 # be altered by application.
322 run_test 4 "Modify component flags in existing file"
325 local parent=$DIR/$tdir
326 local comp_file=$DIR/$tdir/$tfile
327 local subdir=$parent/subdir
332 # set default layout to parent directory
333 $LFS setstripe -E 64M -c 2 -i 0 -E -1 -c 4 -i 0 $parent ||
334 error "Set default layout to $parent failed"
336 # create file under parent
337 touch $comp_file || error "Create $comp_file failed"
338 check_component_count $comp_file 2
340 #instantiate all components, so that objs are allocted
341 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=65k
343 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
344 [ $ost_idx -ne 0 ] &&
345 error "component 1 ost_idx $ost_idx != 0"
347 ost_idx=$($LFS getstripe -I2 -i $comp_file)
348 [ $ost_idx -ne 0 ] &&
349 error "component 2 ost_idx $ost_idx != 0"
351 # create subdir under parent
352 mkdir -p $subdir || error "Create subdir $subdir failed"
354 comp_cnt=$($LFS getstripe -d --component-count $subdir)
355 [ $comp_cnt -ne 2 ] && error "subdir $comp_cnt != 2"
357 # create file under subdir
358 touch $subdir/$tfile || error "Create $subdir/$tfile failed"
360 check_component_count $subdir/$tfile 2
362 # delete default layout setting from parent
363 $LFS setstripe -d $parent ||
364 error "Delete default layout from $parent failed"
366 comp_cnt=$($LFS getstripe -d --component-count $parent)
367 [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0"
369 rm -f $comp_file || error "Delete $comp_file failed"
370 rm -f $subdir/$tfile || error "Delete $subdir/$tfile failed"
371 rm -r $subdir || error "Delete subdir $subdir failed"
372 rmdir $parent || error "Delete dir $parent failed"
374 run_test 5 "Inherit composite layout from parent directory"
377 local comp_file=$DIR/$tdir/$tfile
379 test_mkdir $DIR/$tdir
382 $LFS setstripe -c 1 -S 128K $comp_file ||
383 error "Create v1 $comp_file failed"
385 check_component_count $comp_file 0
387 dd if=/dev/urandom of=$comp_file bs=1M count=5 oflag=sync ||
388 error "Write to v1 $comp_file failed"
390 local old_chksum=$(md5sum $comp_file)
392 # Migrate v1 to composite
393 $LFS migrate -E 1M -S 512K -c 1 -E -1 -S 1M -c 2 $comp_file ||
394 error "Migrate(v1 -> composite) $comp_file failed"
396 check_component_count $comp_file 2
398 local chksum=$(md5sum $comp_file)
399 [ "$old_chksum" != "$chksum" ] &&
400 error "(v1 -> compsoite) $old_chksum != $chksum"
402 # Migrate composite to composite
403 $LFS migrate -E 1M -S 1M -c 2 -E 4M -S 1M -c 2 \
404 -E -1 -S 3M -c 3 $comp_file ||
405 error "Migrate(compsoite -> composite) $comp_file failed"
407 check_component_count $comp_file 3
409 chksum=$(md5sum $comp_file)
410 [ "$old_chksum" != "$chksum" ] &&
411 error "(composite -> compsoite) $old_chksum != $chksum"
413 # Migrate composite to v1
414 $LFS migrate -c 2 -S 2M $comp_file ||
415 error "Migrate(composite -> v1) $comp_file failed"
417 check_component_count $comp_file 0
419 chksum=$(md5sum $comp_file)
420 [ "$old_chksum" != "$chksum" ] &&
421 error "(composite -> v1) $old_chksum != $chksum"
423 rm -f $comp_file || "Delete $comp_file failed"
425 run_test 6 "Migrate composite file"
428 test_mkdir $DIR/$tdir
429 chmod 0777 $DIR/$tdir || error "chmod $tdir failed"
431 local comp_file=$DIR/$tdir/$tfile
432 $RUNAS $LFS setstripe -E 1M -S 1M -c 1 $comp_file ||
433 error "Create composite file $comp_file failed"
435 $RUNAS $LFS setstripe --component-add -E 64M -c 4 $comp_file ||
436 error "Add component to $comp_file failed"
438 $RUNAS $LFS setstripe --component-del -I 2 $comp_file ||
439 error "Delete component from $comp_file failed"
441 $RUNAS $LFS setstripe --component-add -E -1 -c 5 $comp_file ||
442 error "Add last component to $comp_file failed"
444 rm $comp_file || "Delete composite failed"
446 run_test 7 "Add/Delete/Create composite file by non-privileged user"
449 local parent=$DIR/$tdir
454 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c 2 -S 2M \
455 -E -1 -c 4 -S 4M $parent ||
456 error "Set default layout to $parent failed"
458 sh rundbench -C -D $parent 2 || error "dbench failed"
460 rm -fr $parent || error "Delete dir $parent failed"
462 run_test 8 "Run dbench over composite files"
465 local comp_file=$DIR/$tdir/$tfile
467 test_mkdir $DIR/$tdir
470 $LFS setstripe -E 1M -S 1M -E -1 -c 1 $comp_file ||
471 error "Create $comp_file failed"
473 check_component_count $comp_file 2
475 replay_barrier $SINGLEMDS
477 # instantiate the 2nd component
478 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
480 local f1=$($LFS getstripe -I2 $comp_file |
481 awk '/l_fid:/ {print $7}')
482 echo "before MDS recovery, the ost fid of 2nd component is $f1"
485 local f2=$($LFS getstripe -I2 $comp_file |
486 awk '/l_fid:/ {print $7}')
487 echo "after MDS recovery, the ost fid of 2nd component is $f2"
488 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
490 run_test 9 "Replay layout extend object instantiation"
493 echo $($LFS getstripe $1 |
494 awk '$1 == "lcm_entry_count:" { printf("%d", $2) }
495 $1 == "lcme_extent.e_start:" { printf("[%#lx", $2) }
496 $1 == "lcme_extent.e_end:" { printf(",%s]", $2) }')
500 local parent=$DIR/$tdir
503 save_layout_restore_at_exit $MOUNT
507 # mount root on $MOUNT2 if FILESET is set
508 if [ -n "$FILESET" ]; then
509 FILESET="" mount_client $MOUNT2 ||
510 error "mount $MOUNT2 fail"
514 $LFS setstripe -d $root || error "clear root layout"
516 # set root composite layout
517 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c2 -S 2M \
518 -E -1 -c 4 -S 4M $root ||
519 error "Set root layout failed"
521 if [ "$root" == "$MOUNT2" ]; then
522 umount_client $MOUNT2 ||
523 error "umount $MOUNT2 fail"
527 # set a different layout for parent
528 $LFS setstripe -E -1 -c 1 -S 1M $parent ||
529 error "set $parent layout failed"
532 local f1_entry=$(component_dump $parent/file1)
534 # delete parent's layout
535 $LFS setstripe -d $parent || error "Clear $parent layout failed"
538 local f2_entry=$(component_dump $parent/file2)
540 # verify layout inheritance
542 local f1_expect="1[0,EOF]"
543 local f2_expect="3[0,2097152][0x200000,16777216][0x1000000,EOF]"
545 echo "f1 expect=$f1_expect"
546 echo "f1 get =$f1_entry"
547 echo "f2 expect=$f2_expect"
548 echo "f2 get =$f2_entry"
550 [ x$f1_expect != x$f1_entry ] &&
551 error "$parent/file1 does not inherite parent layout"
552 [ x$f2_expect != x$f2_entry ] &&
553 error "$parent/file2 does not inherite root layout"
557 run_test 10 "Inherit composite template from root"
560 local comp_file=$DIR/$tdir/$tfile
561 test_mkdir $DIR/$tdir
564 # only 1st component instantiated
565 $LFS setstripe -E 1M -S 1M -E 2M -E 3M -E -1 $comp_file ||
566 error "Create $comp_file failed"
568 local f1=$($LFS getstripe -I1 $comp_file | grep "l_fid")
569 [[ -z $f1 ]] && error "1: 1st component uninstantiated"
570 local f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
571 [[ -n $f2 ]] && error "1: 2nd component instantiated"
572 local f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
573 [[ -n $f3 ]] && error "1: 3rd component instantiated"
574 local f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
575 [[ -n $f4 ]] && error "1: 4th component instantiated"
577 # the first 2 components instantiated
578 # Truncate to exact start of new component - LU-12586
579 $TRUNCATE $comp_file $((1024*1024*1))
581 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
582 [[ -z $f2 ]] && error "2: 2nd component uninstantiated"
583 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
584 [[ -n $f3 ]] && error "2: 3rd component instantiated"
585 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
586 [[ -n $f4 ]] && error "2: 4th component instantiated"
588 # the first 3 components instantiated
589 $TRUNCATE $comp_file $((1024*1024*3 - 1))
590 $TRUNCATE $comp_file $((1024*1024*1+1))
592 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
593 [[ -z $f2 ]] && error "3: 2nd component uninstantiated"
594 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
595 [[ -z $f3 ]] && error "3: 3rd component uninstantiated"
596 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
597 [[ -n $f4 ]] && error "3: 4th component instantiated"
599 # all 4 components instantiated, using append write
600 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
602 rwv -f $comp_file -w -a -n 2 $((1024*1023)) 1
605 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
606 [[ -z $f4 ]] && error "4: 4th component uninstantiated"
610 run_test 11a "Verify component instantiation with write/truncate"
613 [ $OSTCOUNT -lt 4 ] && skip "needs >= 4 OSTs"
615 local file=$DIR/$tdir/$tfile
617 test_mkdir $DIR/$tdir
620 $LFS setstripe -E 1m -E 1g -c 4 -E eof $DIR/$tdir ||
621 error "setstripe dir $DIR/$tdir failed"
622 expand_truncate_test $file ||
623 error "expand_truncate_test failed on $file"
625 run_test 11b "truncate file set file size correctly"
628 [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs"
630 local file=$DIR/$tdir/$tfile
631 test_mkdir $DIR/$tdir
634 # specify ost list for component
635 $LFS setstripe -E 1M -S 1M -c 2 -o 0,1 -E 2M -c 2 -o 1,2 \
636 -E 3M -c 2 -o 2,1 -E 4M -c 1 -i 2 -E -1 $file ||
637 error "Create $file failed"
639 # clear lod component cache
640 stop $SINGLEMDS || error "stop MDS"
641 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
642 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "start MDS"
644 # instantiate all components
645 $TRUNCATE $file $((1024*1024*4+1))
647 #verify object alloc order
648 local o1=$($LFS getstripe -I1 $file |
649 awk '/l_ost_idx:/ {printf("%d",$5)}')
650 [[ $o1 != "01" ]] && error "$o1 is not 01"
652 local o2=$($LFS getstripe -I2 $file |
653 awk '/l_ost_idx:/ {printf("%d",$5)}')
654 [[ $o2 != "12" ]] && error "$o2 is not 12"
656 local o3=$($LFS getstripe -I3 $file |
657 awk '/l_ost_idx:/ {printf("%d",$5)}')
658 [[ $o3 != "21" ]] && error "$o3 is not 21"
660 local o4=$($LFS getstripe -I4 $file |
661 awk '/l_ost_idx:/ {printf("%d",$5)}')
662 [[ $o4 != "2" ]] && error "$o4 is not 2"
666 run_test 12 "Verify ost list specification"
668 test_13() { # LU-9311
669 [ $OSTCOUNT -lt 8 ] && skip "needs >= 8 OSTs"
671 local file=$DIR/$tfile
673 local dd_size=$(($dd_count * 1024 * 1024))
677 $LFS setstripe -E 1M -S 1M -c 1 -E 2M -c 2 -E -1 -c -1 -i 1 $file ||
678 error "Create $file failed"
679 dd if=/dev/zero of=$file bs=1M count=$dd_count
680 real_size=$(stat -c %s $file)
681 [ $real_size -eq $dd_size ] ||
682 error "dd actually wrote $real_size != $dd_size bytes"
686 run_test 13 "shouldn't reprocess granted resent request"
689 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
690 local file=$DIR/$tdir/$tfile
691 test_mkdir -p $DIR/$tdir
694 $LFS setstripe -E1m -c1 -S1m --pool="pool1" -E2m \
695 -E4m -c2 -S2m --pool="pool2" -E-1 $file ||
696 error "Create $file failed"
698 # check --pool inheritance
700 pool="$($LFS getstripe -I2 --pool $file)"
701 [ x"$pool" != "xpool1" ] && $LFS getstripe -I2 $file &&
702 error "$file: component 2 doesn't have poolname pool1"
703 pool="$($LFS getstripe -I4 --pool $file)"
704 [ x"$pool" != "xpool2" ] && $LFS getstripe -I4 $file &&
705 error "$file: component 4 doesn't have poolname pool2"
707 #check --stripe-count inheritance
709 count="$($LFS getstripe -I2 -c $file)"
710 [ $count -ne 1 ] && $LFS getstripe -I2 $file &&
711 error "$file: component 2 doesn't have 1 stripe_count"
712 count="$($LFS getstripe -I4 -c $file)"
713 [ $count -ne 2 ] && $LFS getstripe -I4 $file &&
714 error "$file: component 4 doesn't have 2 stripe_count"
716 #check --stripe-size inheritance
718 size="$($LFS getstripe -I2 -S $file)"
719 [ $size -ne $((1024*1024)) ] && $LFS getstripe -I2 $file &&
720 error "$file: component 2 doesn't have 1M stripe_size"
721 size="$($LFS getstripe -I4 -S $file)"
722 [ $size -ne $((1024*1024*2)) ] && $LFS getstripe -I4 $file &&
723 error "$file: component 4 doesn't have 2M stripe_size"
727 run_test 14 "Verify setstripe poolname/stripe_count/stripe_size inheritance"
730 local parent=$DIR/$tdir
735 $LFS setstripe -d $parent || error "delete default layout"
737 $LFS setstripe -E 1M -S 1M -E 10M -E eof $parent/f1 || error "create f1"
738 $LFS setstripe -E 4M -E 20M -E eof $parent/f2 || error "create f2"
739 test_mkdir $parent/subdir
740 $LFS setstripe -E 6M -S 1M -c1 -E 30M -c4 -E eof -c -1 $parent/subdir ||
741 error "setstripe to subdir"
742 $LFS setstripe -E 8M -E eof $parent/subdir/f3 || error "create f3"
743 $LFS setstripe -c 1 $parent/subdir/f4 || error "create f4"
746 local found=$($LFS find --component-start +2M -E -15M $parent | wc -l)
747 [ $found -eq 0 ] || error "start+2M, end-15M, $found != 0"
750 found=$($LFS find --component-start +2M -E -35M $parent | wc -l)
751 [ $found -eq 2 ] || error "start+2M, end-35M, $found != 2"
754 found=$($LFS find --component-start +4M -E -eof $parent | wc -l)
755 [ $found -eq 1 ] || error "start+4M, end-eof, $found != 1"
757 local flg_opts="--component-flags init"
759 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
761 error "before write: start=1M, end=10M, flag=init, $found != 0"
763 dd if=/dev/zero of=$parent/f1 bs=1M count=2 ||
764 error "dd $parent/f1 failed"
767 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
769 error "after write: start=1M, end=10M, flag=init, $found != 1"
771 local ext_opts="--component-start -1M -E +5M"
772 # parent, subdir, f3, f4
773 found=$($LFS find $ext_opts $parent | wc -l)
774 [ $found -eq 4 ] || error "start-1M, end+5M, $found != 4"
776 local cnt_opts="--component-count +2"
778 found=$($LFS find $ext_opts $cnt_opts $parent | wc -l)
779 [ $found -eq 1 ] || error "start-1M, end+5M, count+2, $found != 1"
782 found=$($LFS find $ext_opts $cnt_opts $flg_opts $parent | wc -l)
784 error "start-1M, end+5M, count+2, flag=init, $found != 0"
787 found=$($LFS find $ext_opts ! $cnt_opts $flg_opts $parent | wc -l)
789 error "start-1M, end+5M, !count+2, flag=init, $found != 2"
791 # check last component stripe count
792 if [ $OSTCOUNT -gt 1 ]; then
793 touch $parent/subdir/f5
794 $TRUNCATE $parent/subdir/f5 $((32*1024*1024))
795 found=$($LFS find $parent/subdir -c $OSTCOUNT)
796 [[ "$found" == "$parent/subdir/f5" ]] ||
797 error "got '$found' with stripe_count=$OSTCOUNT, not f5"
800 run_test 15 "Verify component options for lfs find"
803 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
804 large_xattr_enabled || skip_env "ea_inode feature disabled"
806 local file=$DIR/$tdir/$tfile
807 local dir=$DIR/$tdir/dir
808 local temp=$DIR/$tdir/template
810 test_mkdir $DIR/$tdir
812 #####################################################################
814 # set stripe for source file
815 $LFS setstripe -E1m -S 1M -c2 -o0,1 -E2m -c2 -E3m -o1,0 -E4m -c1 -E-1 \
816 $file || error "Create $file failed"
819 verify_yaml_layout $file $file.copy $temp "1. PFL file"
821 #####################################################################
823 # set stripe for source file
825 $LFS setstripe -c2 -o0,1 -i1 $file || error "Create $file failed"
829 verify_yaml_layout $file $file.copy $temp "2. plain file"
831 #####################################################################
833 # set stripe for source dir
835 $LFS setstripe -E1m -S 1M -c2 -E2m -c1 -E-1 $dir ||
836 error "setstripe $dir failed"
840 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
842 #####################################################################
844 # set stripe for source dir
845 $LFS setstripe -c2 -i-1 $dir || error "setstripe $dir failed"
848 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
850 run_test 16a "Verify setstripe/getstripe with YAML config file"
853 [[ $($LCTL get_param mdc.*.import |
854 grep "connect_flags:.*overstriping") ]] ||
855 skip "server does not support overstriping"
856 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
857 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
858 skip_env "too many osts, skipping"
859 large_xattr_enabled || skip_env "ea_inode feature disabled"
861 local file=$DIR/$tdir/$tfile
862 local dir=$DIR/$tdir/dir
863 local temp=$DIR/$tdir/template
864 # We know OSTCOUNT < (LOV_MAX_STRIPE_COUNT / 2), so this is overstriping
865 local large_count=$((LOV_MAX_STRIPE_COUNT / 2 + 10))
868 test_mkdir $DIR/$tdir
870 #####################################################################
871 # 1. PFL file, overstriping in first comps
872 # set stripe for source file
873 $LFS setstripe -E1m -S 1M -o0,0 -E2m -o1,1 -E3m -C $large_count -E-1 \
874 $file || error "Create $file failed"
877 verify_yaml_layout $file $file.copy $temp "1. PFL file"
879 #####################################################################
880 # 2. plain file + overstriping
881 # set stripe for source file
883 $LFS setstripe -C $large_count -i1 $file || error "Create $file failed"
887 verify_yaml_layout $file $file.copy $temp "2. plain file"
889 #####################################################################
890 # 3. PFL dir + overstriping
891 # set stripe for source dir
893 $LFS setstripe -E1m -S 1M -o 0,0 -E2m -C $large_count -E-1 $dir ||
894 error "setstripe $dir failed"
898 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
900 #####################################################################
901 # 4. plain dir + overstriping
902 # set stripe for source dir
903 $LFS setstripe -C $large_count $dir || error "setstripe $dir failed"
906 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
908 run_test 16b "Verify setstripe/getstripe with YAML config file + overstriping"
911 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
913 local file=$DIR/$tdir/$tfile
914 local dir=$DIR/$tdir/dir
915 local temp=$DIR/$tdir/template
917 test_mkdir $DIR/$tdir
919 #####################################################################
921 # set stripe for source file
922 $LFS setstripe -E256M -S 1M -c2 -o0,1 -z 64M -E-1 -o1,0 -z 128M \
923 $file || error "Create $file failed"
926 verify_yaml_layout $file $file.copy $temp "1. PFL file"
928 #####################################################################
930 # set stripe for source dir
932 $LFS setstripe -E256M -S 1M -c2 -z 64M -E-1 -z 128M \
933 $dir || error "setstripe $dir failed"
936 echo "2. SEL template on dir"
937 verify_yaml_layout $dir $dir.copy $temp.dir "2. PFL dir"
939 run_test 16c "Verify setstripe/getstripe for SEL layout with YAML config file"
942 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
943 local file=$DIR/$tdir/$tfile
944 test_mkdir -p $DIR/$tdir
947 $LFS setstripe -E 1M -S 1M -E 2M -c 2 -E -1 -c -1 $file ||
948 error "Create $file failed"
950 local s1=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
951 local s2=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
952 local s3=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
953 echo "1st init: comp size 1:$s1 2:$s2 3:$s3"
956 $TRUNCATE $file $((1024*1024+1))
957 local s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
958 local s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
959 echo "2nd init: comp size 1:$s1n 2:$s2n 3:$s3"
961 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
962 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
965 $TRUNCATE $file $((1024*1024*2+1))
966 s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
967 s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
968 local s3n=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
969 echo "3rd init: comp size 1:$s1n 2:$s2n 3:$s3n"
971 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
972 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
973 [ $s3 -lt $s3n ] || error "3rd comp size $s3 should < $s3n"
975 run_test 17 "Verify LOVEA grows with more component inited"
977 check_distribution() {
981 local obj_min_one=$((OSTCOUNT - 1))
983 objs=$($LFS getstripe $file |
984 awk '/l_ost_idx:/ { print $5 }' | wc -l)
985 let ave=$((objs / OSTCOUNT))
987 # collect objects per OST distribution
988 $LFS getstripe $file | awk '/l_ost_idx:/ { print $5 }' | tr -d "," |
989 (inuse=( $(for i in $(seq 0 $obj_min_one); do echo 0; done) )
991 let inuse[$O]=$((1 + ${inuse[$O]}))
994 # verify object distribution varies no more than +-1
995 for idx in $(seq 0 $obj_min_one); do
996 let dif=$((${inuse[$idx]} - ave))
998 if [ "$dif" -gt 1 ]; then
999 echo "OST${idx}: ${inuse[$idx]} objects"
1000 error "bad distribution on OST${idx}"
1006 local file1=$DIR/${tfile}-1
1007 local file2=$DIR/${tfile}-2
1008 local file3=$DIR/${tfile}-3
1010 rm -f $file1 $file2 $file3
1012 $LFS setstripe -E 1m -S 1m $file1 ||
1013 error "Create $file1 failed"
1014 $LFS setstripe -E 1m -S 1m $file2 ||
1015 error "Create $file2 failed"
1016 $LFS setstripe -E 1m -S 1m $file3 ||
1017 error "Create $file3 failed"
1019 local objs=$((OSTCOUNT+1))
1020 for comp in $(seq 1 $OSTCOUNT); do
1021 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file1 ||
1022 error "Add component to $file1 failed 2"
1023 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file2 ||
1024 error "Add component to $file2 failed 2"
1025 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file3 ||
1026 error "Add component to $file3 failed 2"
1029 $LFS setstripe --component-add -E -1 -c -1 $file1 ||
1030 error "Add component to $file1 failed 3"
1031 $LFS setstripe --component-add -E -1 -c -1 $file2 ||
1032 error "Add component to $file2 failed 3"
1033 $LFS setstripe --component-add -E -1 -c -1 $file3 ||
1034 error "Add component to $file3 failed 3"
1036 # Instantiate all components
1037 dd if=/dev/urandom of=$file1 bs=1M count=$((objs+1)) ||
1038 error "dd failed for $file1"
1039 dd if=/dev/urandom of=$file2 bs=1M count=$((objs+1)) ||
1040 error "dd failed for $file2"
1041 dd if=/dev/urandom of=$file3 bs=1M count=$((objs+1)) ||
1042 error "dd failed for $file3"
1044 check_distribution $file1
1045 check_distribution $file2
1046 check_distribution $file3
1049 run_test 18 "check component distribution"
1053 local already_created=${2:-0}
1054 local rw_len=$((3 * 1024 * 1024)) # 3M
1058 if [ $already_created != 1 ]; then
1059 test_mkdir -p $DIR/$tdir
1060 $LFS setstripe --extension-size 64M -c 1 -E -1 $comp_file ||
1061 error "Create $comp_file failed"
1064 # write past end of first component, so it is extended
1065 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=127 conv=notrunc ||
1066 error "dd to extend failed"
1068 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1069 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1071 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1072 [ $ost_idx2 -ne "-1" ] && error "second component init $ost_idx2"
1074 flg_opts="--comp-flags init"
1075 found=$($LFS find --comp-start 0 -E 128M $flg_opts $comp_file | wc -l)
1076 [ $found -eq 1 ] || error "Write: Extended first component not found"
1078 flg_opts="--comp-flags extension"
1079 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1080 [ $found -eq 1 ] || error "Write: second component not found"
1082 found=$($LFS find -z 64M $comp_file | wc -l)
1083 [ $found -eq 1 ] || error "component not found by ext size"
1085 found=$($LFS find --extension-size +63M $comp_file | wc -l)
1086 [ $found -eq 1 ] || error "component not found by +ext size"
1088 found=$($LFS find --ext-size -65M $comp_file | wc -l)
1089 [ $found -eq 1 ] || error "component not found by -ext size"
1091 found=$($LFS find -z 65M $comp_file | wc -l)
1092 [ $found -eq 0 ] || error "component found by wrong ext size"
1094 found=$($LFS find -z +65M $comp_file | wc -l)
1095 [ $found -eq 0 ] || error "component found by wrong +ext size"
1097 found=$($LFS find -z -63M $comp_file | wc -l)
1098 [ $found -eq 0 ] || error "component found by wrong -ext size"
1100 found=$($LFS find ! -z 64M $comp_file | wc -l)
1101 [ $found -eq 0 ] || error "component found by negation of ext size"
1103 found=$($LFS find ! -z +63M $comp_file | wc -l)
1104 [ $found -eq 0 ] || error "component found by negation of +ext size"
1106 found=$($LFS find ! -z -65M $comp_file | wc -l)
1107 [ $found -eq 0 ] || error "component found by negation of -ext size"
1109 found=$($LFS find ! -z 65M $comp_file | wc -l)
1111 error "component not found by negation of wrong ext size"
1113 found=$($LFS find ! -z +65M $comp_file | wc -l)
1115 error "component not found by negation of wrong +ext size"
1117 found=$($LFS find ! -z -63M $comp_file | wc -l)
1119 error "component not found by negation of wrong -ext size"
1121 found=$($LFS find -S +1M $comp_file | wc -l)
1122 [ $found -eq 0 ] || error "component found by wrong +stripe size"
1124 found=$($LFS find -c 1 $comp_file | wc -l)
1125 [ $found -eq 1 ] || error "component not found by stripe count"
1127 small_write $comp_file $rw_len || error "Verify RW failed"
1129 sel_layout_sanity $comp_file 2
1132 # Self-extending PFL tests
1134 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1135 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1136 skip "skipped for lustre < $SEL_VER"
1138 test19_io_base $DIR/$tdir/$tfile
1140 run_test 19a "Simple test of extension behavior"
1142 # Same as 19a, but with default layout set on directory rather than on file
1144 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1145 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1146 skip "skipped for lustre < $SEL_VER"
1148 local comp_file=$DIR/$tdir/$tfile
1149 local comp_dir=$DIR/$tdir/$tdir
1153 test_mkdir -p $DIR/$tdir
1154 $LFS setstripe --ext-size 64M -c 1 -E -1 $DIR/$tdir ||
1155 error "Setstripe on $DIR/$tdir failed"
1157 # check inheritance for a sub-dir and a file
1158 test_mkdir $comp_dir
1159 found=$($LFS find --comp-start 0 -E 64M $comp_dir | wc -l)
1160 [ $found -eq 1 ] || error "Dir Inheritance: wrong first component size"
1162 flg_opts="--comp-flags extension"
1163 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_dir | wc -l)
1164 [ $found -eq 1 ] || error "Dir Inheritance: Second component not found"
1168 flg_opts="--comp-flags init"
1169 found=$($LFS find --comp-start 0 -E 64M $flg_opts $comp_file | wc -l)
1170 [ $found -eq 1 ] || error "File Inheritance: wrong first component size"
1172 flg_opts="--comp-flags extension"
1173 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_file | wc -l)
1174 [ $found -eq 1 ] || error "File Inheritance: Second component not found"
1176 test19_io_base $comp_file 1
1178 run_test 19b "Simple test of SEL as default layout"
1180 # Test behavior when seeking deep in a file
1182 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1183 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1184 skip "skipped for lustre < $SEL_VER"
1186 local comp_file=$DIR/$tdir/$tfile
1190 test_mkdir -p $DIR/$tdir
1192 $LFS setstripe -z 128M -E 1G -E -1 $comp_file ||
1193 error "Create $comp_file failed"
1195 # write past end of first component, so it is extended
1196 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 conv=notrunc ||
1197 error "dd to extend failed"
1199 flg_opts="--comp-flags init"
1200 found=$($LFS find --comp-start 0M -E 256M $flg_opts $comp_file | wc -l)
1201 [ $found -eq 1 ] || error "Write: first extension component not found"
1203 flg_opts="--comp-flags extension,^init"
1204 found=$($LFS find --comp-start 256M -E 1024M $flg_opts $comp_file |\
1206 [ $found -eq 1 ] || error "Write: second extension component not found"
1208 local end_1=$($LFS getstripe -I1 -E $comp_file)
1211 [ $end_1 -eq 268435456 ] ||
1212 error "end of first component $end_1 != 268435456"
1214 # Write past end of extension space component, in to normal component
1215 # should exhaust & remove extension component
1216 dd if=/dev/zero bs=1M count=1 seek=1100 of=$comp_file conv=notrunc ||
1217 error "dd distant seek failed"
1219 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1220 # the last component index is 3
1221 local ost_idx2=$($LFS getstripe -I3 -i $comp_file)
1223 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1225 local start1=$($LFS getstripe -I1 --comp-start $comp_file)
1226 local end1=$($LFS getstripe -I1 -E $comp_file)
1227 local start2=$($LFS getstripe -I3 --comp-start $comp_file)
1228 local end2=$($LFS getstripe -I3 -E $comp_file)
1230 [ $start1 -eq 0 ] || error "start of first component incorrect"
1231 [ $end1 -eq 1073741824 ] || error "end of first component incorrect"
1232 [ $start2 -eq 1073741824 ] ||
1233 error "start of second component incorrect"
1234 [ "$end2" = "EOF" ] || error "end of second component incorrect"
1236 flg_opts="--comp-flags extension"
1237 found=$($LFS find $flg_opts $comp_file | wc -l)
1238 [ $found -eq 0 ] || error "Seek Write: extension component exists"
1240 sel_layout_sanity $comp_file 2
1242 run_test 19c "Test self-extending layout seeking behavior"
1245 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1246 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1247 skip "skipped for lustre < $SEL_VER"
1249 local comp_file=$DIR/$tdir/$tfile
1253 test_mkdir -p $DIR/$tdir
1255 $LFS setstripe -E 128M -c 1 -z 64M -E -1 $comp_file ||
1256 error "Create $comp_file failed"
1258 # This will cause component 1 to be extended to 128M, then the
1259 # extension space component will be removed
1260 dd if=/dev/zero of=$comp_file bs=130M count=1 ||
1261 error "dd to extend failed"
1263 flg_opts="--comp-flags init"
1264 found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file | wc -l)
1265 [ $found -eq 1 ] || error "Write: first component not found"
1267 flg_opts="--comp-flags init"
1268 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1269 [ $found -eq 1 ] || error "Write: second component not found"
1271 sel_layout_sanity $comp_file 2
1273 # always remove large files in case of DO_CLEANUP=false
1274 rm -f $comp_file || error "Delete $comp_file failed"
1276 run_test 19d "Test write which completely spans extension space component"
1281 local comp2_flags=$($LFS getstripe -I2 --comp-flags $comp_file)
1282 local comp3_flags=$($LFS getstripe -I3 --comp-flags $comp_file)
1284 [ "$comp2_flags" != "init" ] && error "$comp2_flags != init"
1285 [ "$comp3_flags" != "extension" ] && error "$comp3_flags != extension"
1287 local flg_opts=" --comp-start 2M -E 66M --comp-flags init"
1288 local found=$($LFS find $flg_opts $comp_file | wc -l)
1289 [ $found -eq 1 ] || error "Write: extended second component not found"
1291 flg_opts="--comp-start 66M -E EOF --comp-flags extension"
1292 found=$($LFS find $flg_opts $comp_file | wc -l)
1293 [ $found -eq 1 ] || error "Write: third component not found"
1295 sel_layout_sanity $comp_file 3
1299 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1300 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1301 skip "skipped for lustre < $SEL_VER"
1303 local comp_file=$DIR/$tdir/$tfile
1304 local rw_len=$((3 * 1024 * 1024)) # 3M
1308 test_mkdir -p $DIR/$tdir
1310 $LFS setstripe -E 2m -E -1 -z 64M $comp_file ||
1311 error "Create $comp_file failed"
1313 replay_barrier $SINGLEMDS
1315 #instantiate & extend second component
1316 dd if=/dev/zero of=$comp_file bs=4M count=1 ||
1317 error "dd to extend failed"
1319 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1320 local ost_idx3=$($LFS getstripe -I3 -i $comp_file)
1322 [ $ost_idx2 -eq $ost_idx3 ] && error "$ost_idx2 == $ost_idx3"
1323 [ $ost_idx3 -ne "-1" ] && error "third component init $ost_idx3"
1325 test_19e_check $comp_file
1327 local f1=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1328 echo "before MDS recovery, the ost fid of 2nd component is $f1"
1332 local f2=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1333 echo "after MDS recovery, the ost fid of 2nd component is $f2"
1334 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
1336 # simply repeat all previous checks, but also verify components are on
1337 # the same OST as before
1339 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1340 local ost_idx3_2=$($LFS getstripe -I3 -i $comp_file)
1342 [ $ost_idx2_2 -eq $ost_idx3_2 ] && error "$ost_idx2_2 == $ost_idx3_2"
1343 [ $ost_idx3_2 -ne "-1" ] && error "second component init $ost_idx3_2"
1345 # verify OST id is the same after failover
1346 [ $ost_idx2 -ne $ost_idx2_2 ] &&
1347 error "$ost_idx2 != $ost_idx2_2, changed after failover"
1349 test_19e_check $comp_file
1351 run_test 19e "Replay of layout instantiation & extension"
1354 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1355 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1356 skip "skipped for lustre < $SEL_VER"
1358 local comp_file=$DIR/$tdir/$tfile
1362 test_mkdir -p $DIR/$tdir
1364 $LFS setstripe -E 256M --comp-flags extension -E -1 $comp_file
1366 [ $? != 0 ] || error "should not be able to manually set extension flag"
1369 run_test 19f "Rejection of invalid layouts"
1372 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1373 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1374 skip "skipped for lustre < $SEL_VER"
1376 local file1=$DIR/${tfile}-1
1377 local file2=$DIR/${tfile}-2
1379 test_mkdir -p $DIR/$tdir
1380 multiop $file1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1381 error "create failed $file1"
1382 multiop $file2 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1383 error "create failed $file2"
1385 $LFS setstripe --component-add -E 1G -c 1 $file1 ||
1386 error "comp-add [0,1G] failed $file1"
1387 $LFS setstripe --component-add -E 512M -z 128M $file1 &&
1388 error "comp-add [1G,1G],SEL[1G,512M] succeded $file1"
1389 $LFS setstripe --component-add -E 10G -z 128M $file1 ||
1390 error "comp-add [1G,1G],SEL[1G,10G] failed $file1"
1391 $LFS setstripe --component-add -E -1 $file1 ||
1392 error "comp-add [10G,-1] failed $file1"
1394 $LFS setstripe --component-add -E 1G -z 32M -c 1 $file2 &&
1395 error "comp-add with smal ext size succeeded $file1"
1396 $LFS setstripe --component-add -E 1G -z 100M -c 1 $file2 &&
1397 error "comp-add with not aligned ext size succeeded $file1"
1398 $LFS setstripe --component-add -E 1G -z 128M -c 1 $file2 ||
1399 error "comp-add [0,128M],SEL[128M,1G] failed $file1"
1400 $LFS setstripe --component-add -E 10G $file2 ||
1401 error "comp-add [1G,10G] failed $file1"
1402 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 ||
1403 error "comp-add [10G,10G],SEL[10G,-1] failed $file1"
1404 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 &&
1405 error "repeated comp-add [10G,10G],SEL[10G,-1] succeeded $file1"
1407 $LFS getstripe $file1
1408 flg_opts="--comp-flags init"
1409 found=$($LFS find --comp-start 0 -E 1G $flg_opts $file1 | wc -l)
1410 [ $found -eq 1 ] || error "First component not found $file1"
1412 flg_opts="--comp-flags ^init"
1413 found=$($LFS find --comp-start 1G -E 1G $flg_opts $file1 | wc -l)
1414 [ $found -eq 1 ] || error "Second component not found $file1"
1416 flg_opts="--comp-flags ^init,extension"
1417 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file1 | wc -l)
1418 [ $found -eq 1 ] || error "Third component not found $file1"
1420 flg_opts="--comp-flags ^init"
1421 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file1 | wc -l)
1422 [ $found -eq 1 ] || error "Fourth component not found $file1"
1424 $LFS getstripe $file2
1425 flg_opts="--comp-flags init"
1426 found=$($LFS find --comp-start 0 -E 128M $flg_opts $file2 | wc -l)
1427 [ $found -eq 1 ] || error "First component not found $file2"
1429 flg_opts="--comp-flags extension"
1430 found=$($LFS find --comp-start 128M -E 1G $flg_opts $file2 | wc -l)
1431 [ $found -eq 1 ] || error "Second component not found $file2"
1433 flg_opts="--comp-flags ^init"
1434 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file2 | wc -l)
1435 [ $found -eq 1 ] || error "Third component not found $file2"
1437 flg_opts="--comp-flags ^init"
1438 found=$($LFS find --comp-start 10G -E 10G $flg_opts $file2 | wc -l)
1439 [ $found -eq 1 ] || error "Fourth component not found $file2"
1441 flg_opts="--comp-flags ^init,extension"
1442 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file2 | wc -l)
1443 [ $found -eq 1 ] || error "Fifth component not found $file2"
1445 run_test 19g "component-add behaviour"
1447 # Test out of space behavior
1449 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1450 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1451 skip "skipped for lustre < $SEL_VER"
1453 local comp_file=$DIR/$tdir/$tfile
1457 test_mkdir -p $DIR/$tdir
1459 # without this, a previous delete can finish after we check free space
1460 wait_delete_completed
1463 # First component is on OST0
1464 $LFS setstripe -E 256M -i 0 -z 64M -E -1 -z 128M $comp_file ||
1465 error "Create $comp_file failed"
1467 # write past end of first component, so it is extended
1468 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=66 ||
1469 error "dd to extend failed"
1471 flg_opts="--comp-flags extension"
1472 found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file |wc -l)
1473 [ $found -eq 1 ] || error "Write: Second component not found"
1475 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1476 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1478 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1480 flg_opts="--comp-flags extension"
1481 # Write past current init comp, but we won't extend (because no space)
1482 dd if=/dev/zero of=$comp_file bs=1M count=10 seek=200 ||
1483 error "dd write past current comp failed"
1485 $LFS getstripe $comp_file
1487 flg_opts="--comp-flags init"
1488 found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file | \
1490 [ $found -eq 1 ] || error "Write: third component not found"
1492 flg_opts="--comp-flags extension"
1493 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file |wc -l)
1494 [ $found -eq 1 ] || error "Write: fourth extension component not found"
1496 sel_layout_sanity $comp_file 3
1498 run_test 20a "Test out of space, spillover to defined component"
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
1509 test_mkdir -p $DIR/$tdir
1511 # Pool allows us to force use of only certain OSTs
1512 pool_add $TESTNAME || error "Pool creation failed"
1513 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1515 # normal component to 10M, extendable component to 1G
1516 # further extendable to EOF
1517 $LFS setstripe -E 10M -E 1G -p $TESTNAME -z 64M -E -1 -p "" -z 128M \
1518 $comp_file || error "Create $comp_file failed"
1520 replay_barrier $SINGLEMDS
1522 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1523 [ $found -eq 1 ] || error "Zero length component not found"
1526 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1528 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1530 # write past end of first component
1531 # This should remove the next component, since OST0 is out of space
1532 # and it is striped there (pool contains only OST0)
1533 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=14 ||
1534 error "dd to extend/remove failed"
1536 $LFS getstripe $comp_file
1538 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1539 [ $found -eq 0 ] || error "Write: zero length component still present"
1541 flg_opts="--comp-flags init"
1542 found=$($LFS find --comp-start 10M -E 138M $flg_opts $comp_file | wc -l)
1543 [ $found -eq 1 ] || error "Write: second component not found"
1545 flg_opts="--comp-flags extension"
1546 found=$($LFS find --comp-start 138M -E EOF $flg_opts $comp_file | wc -l)
1547 [ $found -eq 1 ] || error "Write: third component not found"
1551 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1552 [ $found -eq 0 ] || error "Failover: 0-length component still present"
1554 flg_opts="--comp-flags init"
1555 found=$($LFS find --comp-start 10M -E 138M $flg_opts $comp_file | wc -l)
1556 [ $found -eq 1 ] || error "Failover: second component not found"
1558 flg_opts="--comp-flags extension"
1559 found=$($LFS find --comp-start 138M -E EOF $flg_opts $comp_file | wc -l)
1560 [ $found -eq 1 ] || error "Failover: third component not found"
1562 sel_layout_sanity $comp_file 3
1564 run_test 20b "Remove component without instantiation when there is no space"
1567 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1568 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1569 skip "skipped for lustre < $SEL_VER"
1571 local comp_file=$DIR/$tdir/$tfile
1575 test_mkdir -p $DIR/$tdir
1577 # pool is used to limit available OSTs to 0 and 1, so we can set all
1578 # available OSTs out of space
1579 pool_add $TESTNAME || error "Pool creation failed"
1580 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
1582 # without this, a previous delete can finish after we check free space
1583 wait_delete_completed
1586 $LFS setstripe -E 100M -E -1 -p $TESTNAME -z 64M $comp_file ||
1587 error "Create $comp_file failed"
1591 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1593 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
1595 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1596 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
1598 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=120 &&
1599 error "dd should fail with ENOSPC"
1601 flg_opts="--comp-flags init"
1602 found=$($LFS find --comp-start 0M -E 100M $flg_opts $comp_file | wc -l)
1603 [ $found -eq 1 ] || error "Write: First component not found"
1605 flg_opts="--comp-flags ^init"
1606 found=$($LFS find --comp-start 100M -E 100M $flg_opts $comp_file |wc -l)
1607 [ $found -eq 1 ] || error "Write: 0-length component not found"
1609 flg_opts="--comp-flags extension"
1610 found=$($LFS find --comp-start 100M -E EOF $flg_opts $comp_file | wc -l)
1611 [ $found -eq 1 ] || error "Write: third extension component not found"
1613 sel_layout_sanity $comp_file 3
1615 run_test 20c "Test inability to stripe new extension component"
1618 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1619 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1620 skip "skipped for lustre < $SEL_VER"
1622 local comp_file=$DIR/$tdir/$tfile
1623 test_mkdir -p $DIR/$tdir
1625 wait_delete_completed
1628 pool_add $TESTNAME || error "Pool creation failed"
1629 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1630 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
1631 error "Create $comp_file failed"
1633 replay_barrier $SINGLEMDS
1635 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1636 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1639 ost_watermarks_clear_enospc $tfile 0 $wms
1640 [ $RC -eq 0 ] || error "dd failed: $RC"
1642 $LFS getstripe $comp_file
1643 local flg_opts="--comp-start 64M -E 128M --comp-flags init"
1644 local found=$($LFS find $flg_opts $comp_file | wc -l)
1645 [ $found -eq 1 ] || error "Write: component (64M-128M) not found"
1647 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
1648 [ "$ost_idx" != "-1" ] && error "Write: EXT component disappeared"
1652 found=$($LFS find $flg_opts $comp_file | wc -l)
1653 [ $found -eq 1 ] || error "Failover: component (64M-128M) not found"
1655 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1656 [ "$ost_idx" != "-1" ] && error "Failover: EXT component disappeared"
1658 sel_layout_sanity $comp_file 3
1660 run_test 20d "Low on space + 0-length comp: force extension"
1663 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1664 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1665 skip "skipped for lustre < $SEL_VER"
1667 local comp_file=$DIR/$tdir/$tfile
1668 test_mkdir -p $DIR/$tdir
1670 wait_delete_completed
1673 pool_add $TESTNAME || error "Pool creation failed"
1674 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1676 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
1677 error "Create $comp_file failed"
1679 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1681 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1684 ost_watermarks_clear_enospc $tfile 0 $wms
1685 [ $RC -eq 0 ] || error "dd failed $RC"
1687 $LFS getstripe $comp_file
1688 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
1689 local found=$($LFS find $flg_opts $comp_file | wc -l)
1690 [ $found -eq 1 ] || error "Write: component (64M-EOF) not found"
1692 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
1693 [ "$ost_idx" != "" ] && error "Write: 0-length component still exists"
1694 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1695 [ "$ost_idx" != "" ] && error "Write: extension component still exists"
1697 sel_layout_sanity $comp_file 2
1699 run_test 20e "ENOSPC with next real comp: spillover and backward extension"
1701 # Simple DoM interaction test
1703 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1704 skip "skipped for lustre < $SEL_VER"
1706 local comp_file=$DIR/$tdir/$tfile
1710 test_mkdir -p $DIR/$tdir
1712 # simple, correct self-extending layout after DoM component
1713 $LFS setstripe -E 1M -L mdt -E -1 -z 64m $comp_file || \
1714 error "Create $comp_file failed"
1716 # Write to DoM component & to self-extending comp after it
1717 dd if=/dev/zero bs=1M count=12 of=$comp_file ||
1718 error "dd to extend failed"
1720 flg_opts="--comp-flags init"
1721 found=$($LFS find --comp-start 1M -E 65M $flg_opts $comp_file | wc -l)
1722 [ $found -eq 1 ] || error "Write: extended component not found"
1724 flg_opts="--comp-flags extension"
1725 found=$($LFS find --comp-start 65M $flg_opts $comp_file | wc -l)
1726 [ $found -eq 1 ] || error "Write: extension component not found"
1728 sel_layout_sanity $comp_file 3
1730 run_test 21a "Simple DoM interaction tests"
1732 # DoM + extension + removal
1734 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1735 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1736 skip "skipped for lustre < $SEL_VER"
1738 local comp_file=$DIR/$tdir/$tfile
1739 local ost_name=$(ostname_from_index 0)
1743 test_mkdir -p $DIR/$tdir
1745 # DoM, extendable component, further extendable component
1746 $LFS setstripe -E 1M -L mdt -E 256M -i 0 -z 64M -E -1 -z 128M \
1747 $comp_file || error "Create $comp_file failed"
1749 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1750 [ $found -eq 1 ] || error "Write: Zero length component not found"
1752 # This also demonstrates that we will avoid degraded OSTs
1753 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
1754 # sleep to guarantee we see the degradation
1757 # un-degrade on exit
1758 stack_trap "do_facet ost1 $LCTL set_param -n \
1759 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1761 # This should remove the first component after DoM and spill over to
1763 dd if=/dev/zero bs=1M count=2 of=$comp_file ||
1764 error "dd to remove+spill over failed"
1766 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1767 [ $found -eq 0 ] || error "Write: Zero length component still present"
1769 flg_opts="--comp-flags init"
1770 found=$($LFS find --comp-start 1M -E 129M $flg_opts $comp_file | wc -l)
1771 [ $found -eq 1 ] || error "Write: extended component not found"
1773 flg_opts="--comp-flags extension"
1774 found=$($LFS find --comp-start 129M -E EOF $flg_opts $comp_file |wc -l)
1775 [ $found -eq 1 ] || error "Write: extension component not found"
1777 sel_layout_sanity $comp_file 3
1779 run_test 21b "DoM followed by extendable component with removal"
1781 # Test of repeat component behavior with OOS/degraded OST
1783 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1784 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1785 skip "skipped for lustre < $SEL_VER"
1787 local comp_file=$DIR/$tdir/$tfile
1791 test_mkdir -p $DIR/$tdir
1793 $LFS setstripe -E -1 -c 1 -z 128M $comp_file ||
1794 error "Create $comp_file failed"
1796 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1797 local ost_name=$(ostname_from_index $ost_idx1)
1799 # write past end of first component, so it is extended
1800 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
1801 error "dd to extend failed"
1803 flg_opts="--comp-flags extension"
1804 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
1805 [ $found -eq 1 ] || error "Write: second component not found"
1807 # degrade OST for component 1
1808 do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
1809 obdfilter.$ost_name.degraded=1
1810 # sleep to guarantee we see the degradation
1813 # un-degrade on exit
1814 stack_trap "do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
1815 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1817 replay_barrier $SINGLEMDS
1819 # seek past the end of current comp & write, should cause a new comp
1820 # to be created (ie repeat previous comp)
1821 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
1822 error "dd to repeat failed"
1824 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1826 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1828 flg_opts="--comp-flags init"
1829 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1830 [ $found -eq 1 ] || error "Write: second component not found"
1832 flg_opts="--comp-flags extension"
1833 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1834 [ $found -eq 1 ] || error "Write: extension component not found"
1838 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1839 [ $ost_idx2_2 -ne $ost_idx2 ] && error "$ost_idx2_2 != $ost_idx2"
1841 flg_opts="--comp-flags init"
1842 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1843 [ $found -eq 1 ] || error "Failover: second component not found"
1845 flg_opts="--comp-flags extension"
1846 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1847 [ $found -eq 1 ] || error "Failover: extension component not found"
1849 sel_layout_sanity $comp_file 3
1851 run_test 22a "Test repeat component behavior with degraded OST"
1853 # Test repeat behavior with low space
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
1863 test_mkdir -p $DIR/$tdir
1865 # without this, a previous delete can finish after we check free space
1866 wait_delete_completed
1869 $LFS setstripe -E -1 -c 1 -z 128M \
1870 $comp_file || error "Create $comp_file failed"
1872 # write past end of first component, so it is extended
1873 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
1874 error "dd to extend failed"
1876 flg_opts="--comp-flags extension"
1877 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
1878 [ $found -eq 1 ] || error "Write: Second component not found"
1880 # set our OST low on space
1881 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1882 local wms=$(ost_watermarks_set_low_space $ost_idx1 | grep "watermarks")
1884 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1886 # Write past end of current space, fail to extend, causing repeat
1887 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
1888 error "dd to repeat failed"
1890 $LFS getstripe $comp_file
1892 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1894 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1896 flg_opts="--comp-flags init"
1897 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1898 [ $found -eq 1 ] || error "Write: Second component not found"
1900 flg_opts="--comp-flags extension"
1901 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1902 [ $found -eq 1 ] || error "Write: Extension component not found"
1904 sel_layout_sanity $comp_file 3
1906 run_test 22b "Test simple 'out of space' condition with repeat"
1908 # This tests both "repeat" and "extend in place when repeat fails" aspects
1909 # of repeating components
1911 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1912 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1913 skip "skipped for lustre < $SEL_VER"
1915 local comp_file=$DIR/$tdir/$tfile
1919 test_mkdir -p $DIR/$tdir
1921 # pool is used to limit available OSTs to 0 and 1, so we can set all
1922 # available OSTs out of space
1923 pool_add $TESTNAME || error "Pool creation failed"
1924 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
1926 # without this, a previous delete can finish after we check free space
1927 wait_delete_completed
1930 $LFS setstripe -E -1 -z 64M -c 1 -p "$TESTNAME" $comp_file || \
1931 error "Create $comp_file failed"
1933 # write past end of first component, so it is extended
1934 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=80 conv=notrunc ||
1935 error "dd to extend failed"
1937 $LFS getstripe $comp_file
1939 flg_opts="--comp-flags extension"
1940 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1941 [ $found -eq 1 ] || error "Write: second component not found"
1943 # set our OST out of space
1944 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1945 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1947 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1949 # This should create a repeat component on a new OST
1950 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=180 conv=notrunc ||
1951 error "dd to repeat failed"
1953 $LFS getstripe $comp_file
1955 local comp_cnt=$($LFS getstripe --component-count $comp_file)
1956 [ $comp_cnt -ne 3 ] && error "component count: $comp_cnt, should be 3"
1958 # New second component should be on a different OST
1959 local ost_idx2=$($LFS getstripe --comp-start=128m \
1960 --comp-end=192m --comp-flags=init -i $comp_file)
1962 [ $ost_idx1 -eq $ost_idx2 ] && error "2nd comp: same OST $ost_idx1"
1964 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
1966 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
1968 # now that the second OST is out of space (as is the first OST), we
1969 # attempt to extend. This should result in an extension of the
1970 # existing component, rather than a new component.
1971 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=240 conv=notrunc ||
1972 error "dd for forced extension failed"
1974 $LFS getstripe $comp_file
1976 # clear out of space on first OST
1977 ost_watermarks_clear_enospc $tfile $ost_idx1 $wms
1979 # finally, now that the first OST has space again, we attempt to
1980 # extend one last time. This should create a new component on the
1982 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 conv=notrunc ||
1983 error "dd for repeat on first OST failed"
1985 $LFS getstripe $comp_file
1987 flg_opts="--comp-flags init"
1988 found=$($LFS find --comp-start 128M $flg_opts $comp_file | wc -l)
1989 [ $found -eq 1 ] || error "Write: second component not found"
1991 flg_opts="--comp-flags init"
1992 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1993 [ $found -eq 1 ] || error "Write: third component not found"
1995 flg_opts="--comp-flags extension"
1996 found=$($LFS find --comp-start 320M -E EOF $flg_opts $comp_file | wc -l)
1997 [ $found -eq 1 ] || error "Write: extension component not found"
1999 sel_layout_sanity $comp_file 4
2001 run_test 22c "Test repeat with out of space on > 1 OST"
2003 test_22d_post_check() {
2006 local flg_opts="--comp-flags init"
2007 local found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file |
2009 [ $found -eq 1 ] || {
2010 $LFS getstripe $comp_file
2011 error "$name: second component not found"
2014 flg_opts="--comp-flags extension"
2015 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
2016 [ $found -eq 1 ] || error "$name: third extension component not found"
2018 sel_layout_sanity $comp_file 2
2026 # write past end of first component
2027 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=70
2030 ost_watermarks_clear_enospc $tfile 0 $wms
2031 [ $RC -eq 0 ] || error "dd to force extend failed"
2033 test_22d_post_check $comp_file "Write"
2037 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2038 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2039 skip "skipped for lustre < $SEL_VER"
2041 local comp_file=$DIR/$tdir/$tfile
2045 test_mkdir -p $DIR/$tdir
2047 # without this, a previous delete can finish after we check free space
2048 wait_delete_completed
2051 # Pool allows us to force use of only certain OSTs
2052 pool_add $TESTNAME || error "Pool creation failed"
2053 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2055 # 1. Fail to extend due to OOS, try to repeat within the same pool,
2056 # fail to stripe (again OOS) the 0-length component, remove the
2057 # repeated one, force the extension on the original one.
2058 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2059 error "Create $comp_file failed"
2061 replay_barrier $SINGLEMDS
2063 # set our OST out of space
2064 local wms=$(ost_watermarks_set_enospc $tfile 0 | grep "watermarks")
2066 test_22d_pre $comp_file "$wms"
2068 test_22d_post_check $comp_file "Failover"
2070 # 2. repeat with low on space: 0-length repeated component will be
2071 # striped, but still fails to be extended; otherwise the same as (1).
2073 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2074 error "Create $comp_file failed"
2076 replay_barrier $SINGLEMDS
2078 # set our OST low on space
2079 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2081 test_22d_pre $comp_file "$wms"
2083 test_22d_post_check $comp_file "Failover"
2085 run_test 22d "out of/low on space + failed to repeat + forced extension"
2088 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2089 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2090 skip "skipped for lustre < $SEL_VER"
2092 local comp_file=$DIR/$tdir/$tfile
2093 test_mkdir -p $DIR/$tdir
2095 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2096 error "Create $comp_file failed"
2098 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2099 error "dd append failed"
2101 local flg_opts="--comp-start 0 -E EOF --comp-flags init"
2102 local found=$($LFS find $flg_opts $comp_file | wc -l)
2103 [ $found -eq 1 ] || error "Append: first component (0-EOF) not found"
2105 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2106 [ "$ost_idx" != "" ] && error "Append: second component still exists"
2108 sel_layout_sanity $comp_file 1
2110 run_test 23a "Append: remove EXT comp"
2113 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2114 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2115 skip "skipped for lustre < $SEL_VER"
2117 local comp_file=$DIR/$tdir/$tfile
2118 test_mkdir -p $DIR/$tdir
2120 $LFS setstripe -E 64m -E -1 -z 64M $comp_file ||
2121 error "Create $comp_file failed"
2123 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2124 error "dd append failed"
2126 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2127 local found=$($LFS find $flg_opts $comp_file | wc -l)
2128 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2130 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2131 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2133 sel_layout_sanity $comp_file 2
2135 run_test 23b "Append with 0-length comp: remove EXT comp"
2138 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2139 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2140 skip "skipped for lustre < $SEL_VER"
2142 local comp_file=$DIR/$tdir/$tfile
2143 test_mkdir -p $DIR/$tdir
2145 wait_delete_completed
2148 pool_add $TESTNAME || error "Pool creation failed"
2149 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2150 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
2151 error "Create $comp_file failed"
2153 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2154 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2157 ost_watermarks_clear_enospc $tfile 0 $wms
2158 [ $RC -eq 0 ] || error "dd append failed: $RC"
2160 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2161 local found=$($LFS find $flg_opts $comp_file | wc -l)
2162 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2164 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2165 [ "$ost_idx" != "" ] && error "Append: EXT component still exists"
2167 sel_layout_sanity $comp_file 2
2169 run_test 23c "Append with low on space + 0-length comp: force extension"
2172 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2173 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2174 skip "skipped for lustre < $SEL_VER"
2176 local comp_file=$DIR/$tdir/$tfile
2177 test_mkdir -p $DIR/$tdir
2179 $LFS setstripe -E 64m -E 640M -z 64M -E -1 $comp_file ||
2180 error "Create $comp_file failed"
2182 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2183 error "dd append failed"
2185 flg_opts="--comp-start 64M -E 640M --comp-flags init"
2186 found=$($LFS find $flg_opts $comp_file | wc -l)
2187 [ $found -eq 1 ] || error "Append: component (64M-640M) not found"
2189 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2190 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2192 sel_layout_sanity $comp_file 3
2194 run_test 23d "Append with 0-length comp + next real comp: remove EXT comp"
2197 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2198 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2199 skip "skipped for lustre < $SEL_VER"
2201 local comp_file=$DIR/$tdir/$tfile
2202 test_mkdir -p $DIR/$tdir
2204 wait_delete_completed
2207 pool_add $TESTNAME || error "Pool creation failed"
2208 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2210 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
2211 error "Create $comp_file failed"
2213 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2215 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2218 ost_watermarks_clear_enospc $tfile 0 $wms
2219 [ $RC -eq 0 ] || error "dd append failed $RC"
2221 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2222 local found=$($LFS find $flg_opts $comp_file | wc -l)
2223 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2225 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2226 [ "$ost_idx" != "" ] && error "Append: 0-length component still exists"
2227 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2228 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2230 sel_layout_sanity $comp_file 2
2232 run_test 23e "Append with next real comp: spillover and backward extension"
2235 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2236 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2237 skip "skipped for lustre < $SEL_VER"
2239 local comp_file=$DIR/$tdir/$tfile
2240 test_mkdir -p $DIR/$tdir
2242 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2243 error "Create $comp_file failed"
2245 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
2246 local wms=$(ost_watermarks_set_low_space $ost_idx | grep "watermarks")
2248 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2251 ost_watermarks_clear_enospc $tfile $ost_idx $wms
2252 [ $RC -eq 0 ] || error "dd append failed"
2254 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2255 local found=$($LFS find $flg_opts $comp_file | wc -l)
2256 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2258 ost_idx=$($LFS getstripe -I2 -i $comp_file)
2259 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2261 sel_layout_sanity $comp_file 2
2263 run_test 23f "Append with low on space: repeat and remove EXT comp"
2272 [ "$OSTCOUNT" -lt "3" ] && skip_env "needs >= 3 OSTs"
2274 trap cleanup_24 EXIT RETURN
2276 local file=$DIR/$tfile
2278 $LFS setstripe -E 1m -c1 -o0 -E eof -c2 -o1,2 $file ||
2279 error "setstripe on $file"
2281 dd if=/dev/zero of=$file bs=1M count=3 || error "dd failed for $file"
2284 filefrag -ves $file || error "filefrag $file failed"
2285 filefrag_op=$(filefrag -ve -k $file |
2286 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
2288 #Filesystem type is: bd00bd0
2289 #File size of /mnt/lustre/f24a.sanity-pfl is 3145728 (3072 blocks of 1024 bytes)
2290 # ext: device_logical: physical_offset: length: dev: flags:
2291 # 0: 0.. 1023: 1572864.. 1573887: 1024: 0000: net
2292 # 1: 0.. 1023: 1572864.. 1573887: 1024: 0002: net
2293 # 2: 1024.. 2047: 1573888.. 1574911: 1024: 0001: last,net
2294 #/mnt/lustre/f24a.sanity-pfl: 3 extents found
2296 last_lun=$(echo $filefrag_op | cut -d: -f5)
2301 for line in $filefrag_op; do
2302 frag_lun=$(echo $line | cut -d: -f5)
2303 ext_len=$(echo $line | cut -d: -f4)
2304 if [[ "$frag_lun" != "$last_lun" ]]; then
2305 if (( tot_len != 1024 )); then
2307 error "$file: OST$last_lun $tot_len != 1024"
2313 (( tot_len += ext_len ))
2316 if (( num_luns != 3 || tot_len != 1024 )); then
2318 error "$file: $num_luns != 3, $tot_len != 1024 on OST$last_lun"
2321 echo "FIEMAP on $file succeeded"
2323 run_test 24a "FIEMAP upon PFL file"
2326 check_and_cleanup_lustre