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 11 "Verify component instantiation with write/truncate"
613 [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs"
615 local file=$DIR/$tdir/$tfile
616 test_mkdir $DIR/$tdir
619 # specify ost list for component
620 $LFS setstripe -E 1M -S 1M -c 2 -o 0,1 -E 2M -c 2 -o 1,2 \
621 -E 3M -c 2 -o 2,1 -E 4M -c 1 -i 2 -E -1 $file ||
622 error "Create $file failed"
624 # clear lod component cache
625 stop $SINGLEMDS || error "stop MDS"
626 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
627 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "start MDS"
629 # instantiate all components
630 $TRUNCATE $file $((1024*1024*4+1))
632 #verify object alloc order
633 local o1=$($LFS getstripe -I1 $file |
634 awk '/l_ost_idx:/ {printf("%d",$5)}')
635 [[ $o1 != "01" ]] && error "$o1 is not 01"
637 local o2=$($LFS getstripe -I2 $file |
638 awk '/l_ost_idx:/ {printf("%d",$5)}')
639 [[ $o2 != "12" ]] && error "$o2 is not 12"
641 local o3=$($LFS getstripe -I3 $file |
642 awk '/l_ost_idx:/ {printf("%d",$5)}')
643 [[ $o3 != "21" ]] && error "$o3 is not 21"
645 local o4=$($LFS getstripe -I4 $file |
646 awk '/l_ost_idx:/ {printf("%d",$5)}')
647 [[ $o4 != "2" ]] && error "$o4 is not 2"
651 run_test 12 "Verify ost list specification"
653 test_13() { # LU-9311
654 [ $OSTCOUNT -lt 8 ] && skip "needs >= 8 OSTs"
656 local file=$DIR/$tfile
658 local dd_size=$(($dd_count * 1024 * 1024))
662 $LFS setstripe -E 1M -S 1M -c 1 -E 2M -c 2 -E -1 -c -1 -i 1 $file ||
663 error "Create $file failed"
664 dd if=/dev/zero of=$file bs=1M count=$dd_count
665 real_size=$(stat -c %s $file)
666 [ $real_size -eq $dd_size ] ||
667 error "dd actually wrote $real_size != $dd_size bytes"
671 run_test 13 "shouldn't reprocess granted resent request"
674 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
675 local file=$DIR/$tdir/$tfile
676 test_mkdir -p $DIR/$tdir
679 $LFS setstripe -E1m -c1 -S1m --pool="pool1" -E2m \
680 -E4m -c2 -S2m --pool="pool2" -E-1 $file ||
681 error "Create $file failed"
683 # check --pool inheritance
685 pool="$($LFS getstripe -I2 --pool $file)"
686 [ x"$pool" != "xpool1" ] && $LFS getstripe -I2 $file &&
687 error "$file: component 2 doesn't have poolname pool1"
688 pool="$($LFS getstripe -I4 --pool $file)"
689 [ x"$pool" != "xpool2" ] && $LFS getstripe -I4 $file &&
690 error "$file: component 4 doesn't have poolname pool2"
692 #check --stripe-count inheritance
694 count="$($LFS getstripe -I2 -c $file)"
695 [ $count -ne 1 ] && $LFS getstripe -I2 $file &&
696 error "$file: component 2 doesn't have 1 stripe_count"
697 count="$($LFS getstripe -I4 -c $file)"
698 [ $count -ne 2 ] && $LFS getstripe -I4 $file &&
699 error "$file: component 4 doesn't have 2 stripe_count"
701 #check --stripe-size inheritance
703 size="$($LFS getstripe -I2 -S $file)"
704 [ $size -ne $((1024*1024)) ] && $LFS getstripe -I2 $file &&
705 error "$file: component 2 doesn't have 1M stripe_size"
706 size="$($LFS getstripe -I4 -S $file)"
707 [ $size -ne $((1024*1024*2)) ] && $LFS getstripe -I4 $file &&
708 error "$file: component 4 doesn't have 2M stripe_size"
712 run_test 14 "Verify setstripe poolname/stripe_count/stripe_size inheritance"
715 local parent=$DIR/$tdir
720 $LFS setstripe -d $parent || error "delete default layout"
722 $LFS setstripe -E 1M -S 1M -E 10M -E eof $parent/f1 || error "create f1"
723 $LFS setstripe -E 4M -E 20M -E eof $parent/f2 || error "create f2"
724 test_mkdir $parent/subdir
725 $LFS setstripe -E 6M -S 1M -c1 -E 30M -c4 -E eof -c -1 $parent/subdir ||
726 error "setstripe to subdir"
727 $LFS setstripe -E 8M -E eof $parent/subdir/f3 || error "create f3"
728 $LFS setstripe -c 1 $parent/subdir/f4 || error "create f4"
731 local found=$($LFS find --component-start +2M -E -15M $parent | wc -l)
732 [ $found -eq 0 ] || error "start+2M, end-15M, $found != 0"
735 found=$($LFS find --component-start +2M -E -35M $parent | wc -l)
736 [ $found -eq 2 ] || error "start+2M, end-35M, $found != 2"
739 found=$($LFS find --component-start +4M -E -eof $parent | wc -l)
740 [ $found -eq 1 ] || error "start+4M, end-eof, $found != 1"
742 local flg_opts="--component-flags init"
744 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
746 error "before write: start=1M, end=10M, flag=init, $found != 0"
748 dd if=/dev/zero of=$parent/f1 bs=1M count=2 ||
749 error "dd $parent/f1 failed"
752 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
754 error "after write: start=1M, end=10M, flag=init, $found != 1"
756 local ext_opts="--component-start -1M -E +5M"
757 # parent, subdir, f3, f4
758 found=$($LFS find $ext_opts $parent | wc -l)
759 [ $found -eq 4 ] || error "start-1M, end+5M, $found != 4"
761 local cnt_opts="--component-count +2"
763 found=$($LFS find $ext_opts $cnt_opts $parent | wc -l)
764 [ $found -eq 1 ] || error "start-1M, end+5M, count+2, $found != 1"
767 found=$($LFS find $ext_opts $cnt_opts $flg_opts $parent | wc -l)
769 error "start-1M, end+5M, count+2, flag=init, $found != 0"
772 found=$($LFS find $ext_opts ! $cnt_opts $flg_opts $parent | wc -l)
774 error "start-1M, end+5M, !count+2, flag=init, $found != 2"
776 # check last component stripe count
777 if [ $OSTCOUNT -gt 1 ]; then
778 touch $parent/subdir/f5
779 $TRUNCATE $parent/subdir/f5 $((32*1024*1024))
780 found=$($LFS find $parent/subdir -c $OSTCOUNT)
781 [[ "$found" == "$parent/subdir/f5" ]] ||
782 error "got '$found' with stripe_count=$OSTCOUNT, not f5"
785 run_test 15 "Verify component options for lfs find"
788 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
789 large_xattr_enabled || skip_env "ea_inode feature disabled"
791 local file=$DIR/$tdir/$tfile
792 local dir=$DIR/$tdir/dir
793 local temp=$DIR/$tdir/template
795 test_mkdir $DIR/$tdir
797 #####################################################################
799 # set stripe for source file
800 $LFS setstripe -E1m -S 1M -c2 -o0,1 -E2m -c2 -E3m -o1,0 -E4m -c1 -E-1 \
801 $file || error "Create $file failed"
804 verify_yaml_layout $file $file.copy $temp "1. PFL file"
806 #####################################################################
808 # set stripe for source file
810 $LFS setstripe -c2 -o0,1 -i1 $file || error "Create $file failed"
814 verify_yaml_layout $file $file.copy $temp "2. plain file"
816 #####################################################################
818 # set stripe for source dir
820 $LFS setstripe -E1m -S 1M -c2 -E2m -c1 -E-1 $dir ||
821 error "setstripe $dir failed"
825 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
827 #####################################################################
829 # set stripe for source dir
830 $LFS setstripe -c2 -i-1 $dir || error "setstripe $dir failed"
833 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
835 run_test 16a "Verify setstripe/getstripe with YAML config file"
838 [[ $($LCTL get_param mdc.*.import |
839 grep "connect_flags:.*overstriping") ]] ||
840 skip "server does not support overstriping"
841 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
842 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
843 skip_env "too many osts, skipping"
844 large_xattr_enabled || skip_env "ea_inode feature disabled"
846 local file=$DIR/$tdir/$tfile
847 local dir=$DIR/$tdir/dir
848 local temp=$DIR/$tdir/template
849 # We know OSTCOUNT < (LOV_MAX_STRIPE_COUNT / 2), so this is overstriping
850 local large_count=$((LOV_MAX_STRIPE_COUNT / 2 + 10))
853 test_mkdir $DIR/$tdir
855 #####################################################################
856 # 1. PFL file, overstriping in first comps
857 # set stripe for source file
858 $LFS setstripe -E1m -S 1M -o0,0 -E2m -o1,1 -E3m -C $large_count -E-1 \
859 $file || error "Create $file failed"
862 verify_yaml_layout $file $file.copy $temp "1. PFL file"
864 #####################################################################
865 # 2. plain file + overstriping
866 # set stripe for source file
868 $LFS setstripe -C $large_count -i1 $file || error "Create $file failed"
872 verify_yaml_layout $file $file.copy $temp "2. plain file"
874 #####################################################################
875 # 3. PFL dir + overstriping
876 # set stripe for source dir
878 $LFS setstripe -E1m -S 1M -o 0,0 -E2m -C $large_count -E-1 $dir ||
879 error "setstripe $dir failed"
883 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
885 #####################################################################
886 # 4. plain dir + overstriping
887 # set stripe for source dir
888 $LFS setstripe -C $large_count $dir || error "setstripe $dir failed"
891 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
893 run_test 16b "Verify setstripe/getstripe with YAML config file + overstriping"
896 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
898 local file=$DIR/$tdir/$tfile
899 local dir=$DIR/$tdir/dir
900 local temp=$DIR/$tdir/template
902 test_mkdir $DIR/$tdir
904 #####################################################################
906 # set stripe for source file
907 $LFS setstripe -E256M -S 1M -c2 -o0,1 -z 64M -E-1 -o1,0 -z 128M \
908 $file || error "Create $file failed"
911 verify_yaml_layout $file $file.copy $temp "1. PFL file"
913 #####################################################################
915 # set stripe for source dir
917 $LFS setstripe -E256M -S 1M -c2 -z 64M -E-1 -z 128M \
918 $dir || error "setstripe $dir failed"
921 echo "2. SEL template on dir"
922 verify_yaml_layout $dir $dir.copy $temp.dir "2. PFL dir"
924 run_test 16c "Verify setstripe/getstripe for SEL layout with YAML config file"
927 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
928 local file=$DIR/$tdir/$tfile
929 test_mkdir -p $DIR/$tdir
932 $LFS setstripe -E 1M -S 1M -E 2M -c 2 -E -1 -c -1 $file ||
933 error "Create $file failed"
935 local s1=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
936 local s2=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
937 local s3=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
938 echo "1st init: comp size 1:$s1 2:$s2 3:$s3"
941 $TRUNCATE $file $((1024*1024+1))
942 local s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
943 local s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
944 echo "2nd init: comp size 1:$s1n 2:$s2n 3:$s3"
946 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
947 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
950 $TRUNCATE $file $((1024*1024*2+1))
951 s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
952 s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
953 local s3n=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
954 echo "3rd init: comp size 1:$s1n 2:$s2n 3:$s3n"
956 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
957 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
958 [ $s3 -lt $s3n ] || error "3rd comp size $s3 should < $s3n"
960 run_test 17 "Verify LOVEA grows with more component inited"
962 check_distribution() {
966 local obj_min_one=$((OSTCOUNT - 1))
968 objs=$($LFS getstripe $file |
969 awk '/l_ost_idx:/ { print $5 }' | wc -l)
970 let ave=$((objs / OSTCOUNT))
972 # collect objects per OST distribution
973 $LFS getstripe $file | awk '/l_ost_idx:/ { print $5 }' | tr -d "," |
974 (inuse=( $(for i in $(seq 0 $obj_min_one); do echo 0; done) )
976 let inuse[$O]=$((1 + ${inuse[$O]}))
979 # verify object distribution varies no more than +-1
980 for idx in $(seq 0 $obj_min_one); do
981 let dif=$((${inuse[$idx]} - ave))
983 if [ "$dif" -gt 1 ]; then
984 echo "OST${idx}: ${inuse[$idx]} objects"
985 error "bad distribution on OST${idx}"
991 local file1=$DIR/${tfile}-1
992 local file2=$DIR/${tfile}-2
993 local file3=$DIR/${tfile}-3
995 rm -f $file1 $file2 $file3
997 $LFS setstripe -E 1m -S 1m $file1 ||
998 error "Create $file1 failed"
999 $LFS setstripe -E 1m -S 1m $file2 ||
1000 error "Create $file2 failed"
1001 $LFS setstripe -E 1m -S 1m $file3 ||
1002 error "Create $file3 failed"
1004 local objs=$((OSTCOUNT+1))
1005 for comp in $(seq 1 $OSTCOUNT); do
1006 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file1 ||
1007 error "Add component to $file1 failed 2"
1008 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file2 ||
1009 error "Add component to $file2 failed 2"
1010 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file3 ||
1011 error "Add component to $file3 failed 2"
1014 $LFS setstripe --component-add -E -1 -c -1 $file1 ||
1015 error "Add component to $file1 failed 3"
1016 $LFS setstripe --component-add -E -1 -c -1 $file2 ||
1017 error "Add component to $file2 failed 3"
1018 $LFS setstripe --component-add -E -1 -c -1 $file3 ||
1019 error "Add component to $file3 failed 3"
1021 # Instantiate all components
1022 dd if=/dev/urandom of=$file1 bs=1M count=$((objs+1)) ||
1023 error "dd failed for $file1"
1024 dd if=/dev/urandom of=$file2 bs=1M count=$((objs+1)) ||
1025 error "dd failed for $file2"
1026 dd if=/dev/urandom of=$file3 bs=1M count=$((objs+1)) ||
1027 error "dd failed for $file3"
1029 check_distribution $file1
1030 check_distribution $file2
1031 check_distribution $file3
1034 run_test 18 "check component distribution"
1038 local already_created=${2:-0}
1039 local rw_len=$((3 * 1024 * 1024)) # 3M
1043 if [ $already_created != 1 ]; then
1044 test_mkdir -p $DIR/$tdir
1045 $LFS setstripe --extension-size 64M -c 1 -E -1 $comp_file ||
1046 error "Create $comp_file failed"
1049 # write past end of first component, so it is extended
1050 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=127 conv=notrunc ||
1051 error "dd to extend failed"
1053 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1054 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1056 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1057 [ $ost_idx2 -ne "-1" ] && error "second component init $ost_idx2"
1059 flg_opts="--comp-flags init"
1060 found=$($LFS find --comp-start 0 -E 128M $flg_opts $comp_file | wc -l)
1061 [ $found -eq 1 ] || error "Write: Extended first component not found"
1063 flg_opts="--comp-flags extension"
1064 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1065 [ $found -eq 1 ] || error "Write: second component not found"
1067 found=$($LFS find -z 64M $comp_file | wc -l)
1068 [ $found -eq 1 ] || error "component not found by ext size"
1070 found=$($LFS find --extension-size +63M $comp_file | wc -l)
1071 [ $found -eq 1 ] || error "component not found by +ext size"
1073 found=$($LFS find --ext-size -65M $comp_file | wc -l)
1074 [ $found -eq 1 ] || error "component not found by -ext size"
1076 found=$($LFS find -z 65M $comp_file | wc -l)
1077 [ $found -eq 0 ] || error "component found by wrong ext size"
1079 found=$($LFS find -z +65M $comp_file | wc -l)
1080 [ $found -eq 0 ] || error "component found by wrong +ext size"
1082 found=$($LFS find -z -63M $comp_file | wc -l)
1083 [ $found -eq 0 ] || error "component found by wrong -ext size"
1085 found=$($LFS find ! -z 64M $comp_file | wc -l)
1086 [ $found -eq 0 ] || error "component found by negation of ext size"
1088 found=$($LFS find ! -z +63M $comp_file | wc -l)
1089 [ $found -eq 0 ] || error "component found by negation of +ext size"
1091 found=$($LFS find ! -z -65M $comp_file | wc -l)
1092 [ $found -eq 0 ] || error "component found by negation of -ext size"
1094 found=$($LFS find ! -z 65M $comp_file | wc -l)
1096 error "component not found by negation of wrong ext size"
1098 found=$($LFS find ! -z +65M $comp_file | wc -l)
1100 error "component not found by negation of wrong +ext size"
1102 found=$($LFS find ! -z -63M $comp_file | wc -l)
1104 error "component not found by negation of wrong -ext size"
1106 found=$($LFS find -S +1M $comp_file | wc -l)
1107 [ $found -eq 0 ] || error "component found by wrong +stripe size"
1109 found=$($LFS find -c 1 $comp_file | wc -l)
1110 [ $found -eq 1 ] || error "component not found by stripe count"
1112 small_write $comp_file $rw_len || error "Verify RW failed"
1114 sel_layout_sanity $comp_file 2
1117 # Self-extending PFL tests
1119 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1120 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1121 skip "skipped for lustre < $SEL_VER"
1123 test19_io_base $DIR/$tdir/$tfile
1125 run_test 19a "Simple test of extension behavior"
1127 # Same as 19a, but with default layout set on directory rather than on file
1129 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1130 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1131 skip "skipped for lustre < $SEL_VER"
1133 local comp_file=$DIR/$tdir/$tfile
1134 local comp_dir=$DIR/$tdir/$tdir
1138 test_mkdir -p $DIR/$tdir
1139 $LFS setstripe --ext-size 64M -c 1 -E -1 $DIR/$tdir ||
1140 error "Setstripe on $DIR/$tdir failed"
1142 # check inheritance for a sub-dir and a file
1143 test_mkdir $comp_dir
1144 found=$($LFS find --comp-start 0 -E 64M $comp_dir | wc -l)
1145 [ $found -eq 1 ] || error "Dir Inheritance: wrong first component size"
1147 flg_opts="--comp-flags extension"
1148 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_dir | wc -l)
1149 [ $found -eq 1 ] || error "Dir Inheritance: Second component not found"
1153 flg_opts="--comp-flags init"
1154 found=$($LFS find --comp-start 0 -E 64M $flg_opts $comp_file | wc -l)
1155 [ $found -eq 1 ] || error "File Inheritance: wrong first component size"
1157 flg_opts="--comp-flags extension"
1158 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_file | wc -l)
1159 [ $found -eq 1 ] || error "File Inheritance: Second component not found"
1161 test19_io_base $comp_file 1
1163 run_test 19b "Simple test of SEL as default layout"
1165 # Test behavior when seeking deep in a file
1167 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1168 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1169 skip "skipped for lustre < $SEL_VER"
1171 local comp_file=$DIR/$tdir/$tfile
1175 test_mkdir -p $DIR/$tdir
1177 $LFS setstripe -z 128M -E 1G -E -1 $comp_file ||
1178 error "Create $comp_file failed"
1180 # write past end of first component, so it is extended
1181 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 conv=notrunc ||
1182 error "dd to extend failed"
1184 flg_opts="--comp-flags init"
1185 found=$($LFS find --comp-start 0M -E 256M $flg_opts $comp_file | wc -l)
1186 [ $found -eq 1 ] || error "Write: first extension component not found"
1188 flg_opts="--comp-flags extension,^init"
1189 found=$($LFS find --comp-start 256M -E 1024M $flg_opts $comp_file |\
1191 [ $found -eq 1 ] || error "Write: second extension component not found"
1193 local end_1=$($LFS getstripe -I1 -E $comp_file)
1196 [ $end_1 -eq 268435456 ] ||
1197 error "end of first component $end_1 != 268435456"
1199 # Write past end of extension space component, in to normal component
1200 # should exhaust & remove extension component
1201 dd if=/dev/zero bs=1M count=1 seek=1100 of=$comp_file conv=notrunc ||
1202 error "dd distant seek failed"
1204 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1205 # the last component index is 3
1206 local ost_idx2=$($LFS getstripe -I3 -i $comp_file)
1208 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1210 local start1=$($LFS getstripe -I1 --comp-start $comp_file)
1211 local end1=$($LFS getstripe -I1 -E $comp_file)
1212 local start2=$($LFS getstripe -I3 --comp-start $comp_file)
1213 local end2=$($LFS getstripe -I3 -E $comp_file)
1215 [ $start1 -eq 0 ] || error "start of first component incorrect"
1216 [ $end1 -eq 1073741824 ] || error "end of first component incorrect"
1217 [ $start2 -eq 1073741824 ] ||
1218 error "start of second component incorrect"
1219 [ "$end2" = "EOF" ] || error "end of second component incorrect"
1221 flg_opts="--comp-flags extension"
1222 found=$($LFS find $flg_opts $comp_file | wc -l)
1223 [ $found -eq 0 ] || error "Seek Write: extension component exists"
1225 sel_layout_sanity $comp_file 2
1227 run_test 19c "Test self-extending layout seeking behavior"
1230 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1231 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1232 skip "skipped for lustre < $SEL_VER"
1234 local comp_file=$DIR/$tdir/$tfile
1238 test_mkdir -p $DIR/$tdir
1240 $LFS setstripe -E 128M -c 1 -z 64M -E -1 $comp_file ||
1241 error "Create $comp_file failed"
1243 # This will cause component 1 to be extended to 128M, then the
1244 # extension space component will be removed
1245 dd if=/dev/zero of=$comp_file bs=130M count=1 ||
1246 error "dd to extend failed"
1248 flg_opts="--comp-flags init"
1249 found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file | wc -l)
1250 [ $found -eq 1 ] || error "Write: first component not found"
1252 flg_opts="--comp-flags init"
1253 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1254 [ $found -eq 1 ] || error "Write: second component not found"
1256 sel_layout_sanity $comp_file 2
1258 # always remove large files in case of DO_CLEANUP=false
1259 rm -f $comp_file || error "Delete $comp_file failed"
1261 run_test 19d "Test write which completely spans extension space component"
1266 local comp2_flags=$($LFS getstripe -I2 --comp-flags $comp_file)
1267 local comp3_flags=$($LFS getstripe -I3 --comp-flags $comp_file)
1269 [ "$comp2_flags" != "init" ] && error "$comp2_flags != init"
1270 [ "$comp3_flags" != "extension" ] && error "$comp3_flags != extension"
1272 local flg_opts=" --comp-start 2M -E 66M --comp-flags init"
1273 local found=$($LFS find $flg_opts $comp_file | wc -l)
1274 [ $found -eq 1 ] || error "Write: extended second component not found"
1276 flg_opts="--comp-start 66M -E EOF --comp-flags extension"
1277 found=$($LFS find $flg_opts $comp_file | wc -l)
1278 [ $found -eq 1 ] || error "Write: third component not found"
1280 sel_layout_sanity $comp_file 3
1284 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1285 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1286 skip "skipped for lustre < $SEL_VER"
1288 local comp_file=$DIR/$tdir/$tfile
1289 local rw_len=$((3 * 1024 * 1024)) # 3M
1293 test_mkdir -p $DIR/$tdir
1295 $LFS setstripe -E 2m -E -1 -z 64M $comp_file ||
1296 error "Create $comp_file failed"
1298 replay_barrier $SINGLEMDS
1300 #instantiate & extend second component
1301 dd if=/dev/zero of=$comp_file bs=4M count=1 ||
1302 error "dd to extend failed"
1304 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1305 local ost_idx3=$($LFS getstripe -I3 -i $comp_file)
1307 [ $ost_idx2 -eq $ost_idx3 ] && error "$ost_idx2 == $ost_idx3"
1308 [ $ost_idx3 -ne "-1" ] && error "third component init $ost_idx3"
1310 test_19e_check $comp_file
1312 local f1=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1313 echo "before MDS recovery, the ost fid of 2nd component is $f1"
1317 local f2=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1318 echo "after MDS recovery, the ost fid of 2nd component is $f2"
1319 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
1321 # simply repeat all previous checks, but also verify components are on
1322 # the same OST as before
1324 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1325 local ost_idx3_2=$($LFS getstripe -I3 -i $comp_file)
1327 [ $ost_idx2_2 -eq $ost_idx3_2 ] && error "$ost_idx2_2 == $ost_idx3_2"
1328 [ $ost_idx3_2 -ne "-1" ] && error "second component init $ost_idx3_2"
1330 # verify OST id is the same after failover
1331 [ $ost_idx2 -ne $ost_idx2_2 ] &&
1332 error "$ost_idx2 != $ost_idx2_2, changed after failover"
1334 test_19e_check $comp_file
1336 run_test 19e "Replay of layout instantiation & extension"
1339 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1340 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1341 skip "skipped for lustre < $SEL_VER"
1343 local comp_file=$DIR/$tdir/$tfile
1347 test_mkdir -p $DIR/$tdir
1349 $LFS setstripe -E 256M --comp-flags extension -E -1 $comp_file
1351 [ $? != 0 ] || error "should not be able to manually set extension flag"
1354 run_test 19f "Rejection of invalid layouts"
1357 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1358 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1359 skip "skipped for lustre < $SEL_VER"
1361 local file1=$DIR/${tfile}-1
1362 local file2=$DIR/${tfile}-2
1364 test_mkdir -p $DIR/$tdir
1365 multiop $file1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1366 error "create failed $file1"
1367 multiop $file2 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1368 error "create failed $file2"
1370 $LFS setstripe --component-add -E 1G -c 1 $file1 ||
1371 error "comp-add [0,1G] failed $file1"
1372 $LFS setstripe --component-add -E 512M -z 128M $file1 &&
1373 error "comp-add [1G,1G],SEL[1G,512M] succeded $file1"
1374 $LFS setstripe --component-add -E 10G -z 128M $file1 ||
1375 error "comp-add [1G,1G],SEL[1G,10G] failed $file1"
1376 $LFS setstripe --component-add -E -1 $file1 ||
1377 error "comp-add [10G,-1] failed $file1"
1379 $LFS setstripe --component-add -E 1G -z 32M -c 1 $file2 &&
1380 error "comp-add with smal ext size succeeded $file1"
1381 $LFS setstripe --component-add -E 1G -z 100M -c 1 $file2 &&
1382 error "comp-add with not aligned ext size succeeded $file1"
1383 $LFS setstripe --component-add -E 1G -z 128M -c 1 $file2 ||
1384 error "comp-add [0,128M],SEL[128M,1G] failed $file1"
1385 $LFS setstripe --component-add -E 10G $file2 ||
1386 error "comp-add [1G,10G] failed $file1"
1387 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 ||
1388 error "comp-add [10G,10G],SEL[10G,-1] failed $file1"
1389 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 &&
1390 error "repeated comp-add [10G,10G],SEL[10G,-1] succeeded $file1"
1392 $LFS getstripe $file1
1393 flg_opts="--comp-flags init"
1394 found=$($LFS find --comp-start 0 -E 1G $flg_opts $file1 | wc -l)
1395 [ $found -eq 1 ] || error "First component not found $file1"
1397 flg_opts="--comp-flags ^init"
1398 found=$($LFS find --comp-start 1G -E 1G $flg_opts $file1 | wc -l)
1399 [ $found -eq 1 ] || error "Second component not found $file1"
1401 flg_opts="--comp-flags ^init,extension"
1402 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file1 | wc -l)
1403 [ $found -eq 1 ] || error "Third component not found $file1"
1405 flg_opts="--comp-flags ^init"
1406 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file1 | wc -l)
1407 [ $found -eq 1 ] || error "Fourth component not found $file1"
1409 $LFS getstripe $file2
1410 flg_opts="--comp-flags init"
1411 found=$($LFS find --comp-start 0 -E 128M $flg_opts $file2 | wc -l)
1412 [ $found -eq 1 ] || error "First component not found $file2"
1414 flg_opts="--comp-flags extension"
1415 found=$($LFS find --comp-start 128M -E 1G $flg_opts $file2 | wc -l)
1416 [ $found -eq 1 ] || error "Second component not found $file2"
1418 flg_opts="--comp-flags ^init"
1419 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file2 | wc -l)
1420 [ $found -eq 1 ] || error "Third component not found $file2"
1422 flg_opts="--comp-flags ^init"
1423 found=$($LFS find --comp-start 10G -E 10G $flg_opts $file2 | wc -l)
1424 [ $found -eq 1 ] || error "Fourth component not found $file2"
1426 flg_opts="--comp-flags ^init,extension"
1427 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file2 | wc -l)
1428 [ $found -eq 1 ] || error "Fifth component not found $file2"
1430 run_test 19g "component-add behaviour"
1432 # Test out of space behavior
1434 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1435 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1436 skip "skipped for lustre < $SEL_VER"
1438 local comp_file=$DIR/$tdir/$tfile
1442 test_mkdir -p $DIR/$tdir
1444 # without this, a previous delete can finish after we check free space
1445 wait_delete_completed
1448 # First component is on OST0
1449 $LFS setstripe -E 256M -i 0 -z 64M -E -1 -z 128M $comp_file ||
1450 error "Create $comp_file failed"
1452 # write past end of first component, so it is extended
1453 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=66 ||
1454 error "dd to extend failed"
1456 flg_opts="--comp-flags extension"
1457 found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file |wc -l)
1458 [ $found -eq 1 ] || error "Write: Second component not found"
1460 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1461 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1463 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1465 flg_opts="--comp-flags extension"
1466 # Write past current init comp, but we won't extend (because no space)
1467 dd if=/dev/zero of=$comp_file bs=1M count=10 seek=200 ||
1468 error "dd write past current comp failed"
1470 $LFS getstripe $comp_file
1472 flg_opts="--comp-flags init"
1473 found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file | \
1475 [ $found -eq 1 ] || error "Write: third component not found"
1477 flg_opts="--comp-flags extension"
1478 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file |wc -l)
1479 [ $found -eq 1 ] || error "Write: fourth extension component not found"
1481 sel_layout_sanity $comp_file 3
1483 run_test 20a "Test out of space, spillover to defined component"
1486 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1487 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1488 skip "skipped for lustre < $SEL_VER"
1490 local comp_file=$DIR/$tdir/$tfile
1494 test_mkdir -p $DIR/$tdir
1496 # Pool allows us to force use of only certain OSTs
1497 pool_add $TESTNAME || error "Pool creation failed"
1498 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1500 # normal component to 10M, extendable component to 1G
1501 # further extendable to EOF
1502 $LFS setstripe -E 10M -E 1G -p $TESTNAME -z 64M -E -1 -p "" -z 128M \
1503 $comp_file || error "Create $comp_file failed"
1505 replay_barrier $SINGLEMDS
1507 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1508 [ $found -eq 1 ] || error "Zero length component not found"
1511 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1513 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1515 # write past end of first component
1516 # This should remove the next component, since OST0 is out of space
1517 # and it is striped there (pool contains only OST0)
1518 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=14 ||
1519 error "dd to extend/remove failed"
1521 $LFS getstripe $comp_file
1523 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1524 [ $found -eq 0 ] || error "Write: zero length component still present"
1526 flg_opts="--comp-flags init"
1527 found=$($LFS find --comp-start 10M -E 138M $flg_opts $comp_file | wc -l)
1528 [ $found -eq 1 ] || error "Write: second component not found"
1530 flg_opts="--comp-flags extension"
1531 found=$($LFS find --comp-start 138M -E EOF $flg_opts $comp_file | wc -l)
1532 [ $found -eq 1 ] || error "Write: third component not found"
1536 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1537 [ $found -eq 0 ] || error "Failover: 0-length component still present"
1539 flg_opts="--comp-flags init"
1540 found=$($LFS find --comp-start 10M -E 138M $flg_opts $comp_file | wc -l)
1541 [ $found -eq 1 ] || error "Failover: second component not found"
1543 flg_opts="--comp-flags extension"
1544 found=$($LFS find --comp-start 138M -E EOF $flg_opts $comp_file | wc -l)
1545 [ $found -eq 1 ] || error "Failover: third component not found"
1547 sel_layout_sanity $comp_file 3
1549 run_test 20b "Remove component without instantiation when there is no space"
1552 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1553 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1554 skip "skipped for lustre < $SEL_VER"
1556 local comp_file=$DIR/$tdir/$tfile
1560 test_mkdir -p $DIR/$tdir
1562 # pool is used to limit available OSTs to 0 and 1, so we can set all
1563 # available OSTs out of space
1564 pool_add $TESTNAME || error "Pool creation failed"
1565 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
1567 # without this, a previous delete can finish after we check free space
1568 wait_delete_completed
1571 $LFS setstripe -E 100M -E -1 -p $TESTNAME -z 64M $comp_file ||
1572 error "Create $comp_file failed"
1576 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1578 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
1580 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1581 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
1583 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=120 &&
1584 error "dd should fail with ENOSPC"
1586 flg_opts="--comp-flags init"
1587 found=$($LFS find --comp-start 0M -E 100M $flg_opts $comp_file | wc -l)
1588 [ $found -eq 1 ] || error "Write: First component not found"
1590 flg_opts="--comp-flags ^init"
1591 found=$($LFS find --comp-start 100M -E 100M $flg_opts $comp_file |wc -l)
1592 [ $found -eq 1 ] || error "Write: 0-length component not found"
1594 flg_opts="--comp-flags extension"
1595 found=$($LFS find --comp-start 100M -E EOF $flg_opts $comp_file | wc -l)
1596 [ $found -eq 1 ] || error "Write: third extension component not found"
1598 sel_layout_sanity $comp_file 3
1600 run_test 20c "Test inability to stripe new extension component"
1603 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1604 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1605 skip "skipped for lustre < $SEL_VER"
1607 local comp_file=$DIR/$tdir/$tfile
1608 test_mkdir -p $DIR/$tdir
1610 wait_delete_completed
1613 pool_add $TESTNAME || error "Pool creation failed"
1614 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1615 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
1616 error "Create $comp_file failed"
1618 replay_barrier $SINGLEMDS
1620 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1621 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1624 ost_watermarks_clear_enospc $tfile 0 $wms
1625 [ $RC -eq 0 ] || error "dd failed: $RC"
1627 $LFS getstripe $comp_file
1628 local flg_opts="--comp-start 64M -E 128M --comp-flags init"
1629 local found=$($LFS find $flg_opts $comp_file | wc -l)
1630 [ $found -eq 1 ] || error "Write: component (64M-128M) not found"
1632 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
1633 [ "$ost_idx" != "-1" ] && error "Write: EXT component disappeared"
1637 found=$($LFS find $flg_opts $comp_file | wc -l)
1638 [ $found -eq 1 ] || error "Failover: component (64M-128M) not found"
1640 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1641 [ "$ost_idx" != "-1" ] && error "Failover: EXT component disappeared"
1643 sel_layout_sanity $comp_file 3
1645 run_test 20d "Low on space + 0-length comp: force extension"
1648 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1649 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1650 skip "skipped for lustre < $SEL_VER"
1652 local comp_file=$DIR/$tdir/$tfile
1653 test_mkdir -p $DIR/$tdir
1655 wait_delete_completed
1658 pool_add $TESTNAME || error "Pool creation failed"
1659 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1661 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
1662 error "Create $comp_file failed"
1664 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1666 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1669 ost_watermarks_clear_enospc $tfile 0 $wms
1670 [ $RC -eq 0 ] || error "dd failed $RC"
1672 $LFS getstripe $comp_file
1673 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
1674 local found=$($LFS find $flg_opts $comp_file | wc -l)
1675 [ $found -eq 1 ] || error "Write: component (64M-EOF) not found"
1677 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
1678 [ "$ost_idx" != "" ] && error "Write: 0-length component still exists"
1679 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1680 [ "$ost_idx" != "" ] && error "Write: extension component still exists"
1682 sel_layout_sanity $comp_file 2
1684 run_test 20e "ENOSPC with next real comp: spillover and backward extension"
1686 # Simple DoM interaction test
1688 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1689 skip "skipped for lustre < $SEL_VER"
1691 local comp_file=$DIR/$tdir/$tfile
1695 test_mkdir -p $DIR/$tdir
1697 # simple, correct self-extending layout after DoM component
1698 $LFS setstripe -E 1M -L mdt -E -1 -z 64m $comp_file || \
1699 error "Create $comp_file failed"
1701 # Write to DoM component & to self-extending comp after it
1702 dd if=/dev/zero bs=1M count=12 of=$comp_file ||
1703 error "dd to extend failed"
1705 flg_opts="--comp-flags init"
1706 found=$($LFS find --comp-start 1M -E 65M $flg_opts $comp_file | wc -l)
1707 [ $found -eq 1 ] || error "Write: extended component not found"
1709 flg_opts="--comp-flags extension"
1710 found=$($LFS find --comp-start 65M $flg_opts $comp_file | wc -l)
1711 [ $found -eq 1 ] || error "Write: extension component not found"
1713 sel_layout_sanity $comp_file 3
1715 run_test 21a "Simple DoM interaction tests"
1717 # DoM + extension + removal
1719 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1720 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1721 skip "skipped for lustre < $SEL_VER"
1723 local comp_file=$DIR/$tdir/$tfile
1724 local ost_name=$(ostname_from_index 0)
1728 test_mkdir -p $DIR/$tdir
1730 # DoM, extendable component, further extendable component
1731 $LFS setstripe -E 1M -L mdt -E 256M -i 0 -z 64M -E -1 -z 128M \
1732 $comp_file || error "Create $comp_file failed"
1734 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1735 [ $found -eq 1 ] || error "Write: Zero length component not found"
1737 # This also demonstrates that we will avoid degraded OSTs
1738 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
1739 # sleep to guarantee we see the degradation
1742 # un-degrade on exit
1743 stack_trap "do_facet ost1 $LCTL set_param -n \
1744 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1746 # This should remove the first component after DoM and spill over to
1748 dd if=/dev/zero bs=1M count=2 of=$comp_file ||
1749 error "dd to remove+spill over failed"
1751 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1752 [ $found -eq 0 ] || error "Write: Zero length component still present"
1754 flg_opts="--comp-flags init"
1755 found=$($LFS find --comp-start 1M -E 129M $flg_opts $comp_file | wc -l)
1756 [ $found -eq 1 ] || error "Write: extended component not found"
1758 flg_opts="--comp-flags extension"
1759 found=$($LFS find --comp-start 129M -E EOF $flg_opts $comp_file |wc -l)
1760 [ $found -eq 1 ] || error "Write: extension component not found"
1762 sel_layout_sanity $comp_file 3
1764 run_test 21b "DoM followed by extendable component with removal"
1766 # Test of repeat component behavior with OOS/degraded OST
1768 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1769 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1770 skip "skipped for lustre < $SEL_VER"
1772 local comp_file=$DIR/$tdir/$tfile
1776 test_mkdir -p $DIR/$tdir
1778 $LFS setstripe -E -1 -c 1 -z 128M $comp_file ||
1779 error "Create $comp_file failed"
1781 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1782 local ost_name=$(ostname_from_index $ost_idx1)
1784 # write past end of first component, so it is extended
1785 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
1786 error "dd to extend failed"
1788 flg_opts="--comp-flags extension"
1789 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
1790 [ $found -eq 1 ] || error "Write: second component not found"
1792 # degrade OST for component 1
1793 do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
1794 obdfilter.$ost_name.degraded=1
1795 # sleep to guarantee we see the degradation
1798 # un-degrade on exit
1799 stack_trap "do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
1800 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1802 replay_barrier $SINGLEMDS
1804 # seek past the end of current comp & write, should cause a new comp
1805 # to be created (ie repeat previous comp)
1806 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
1807 error "dd to repeat failed"
1809 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1811 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1813 flg_opts="--comp-flags init"
1814 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1815 [ $found -eq 1 ] || error "Write: second component not found"
1817 flg_opts="--comp-flags extension"
1818 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1819 [ $found -eq 1 ] || error "Write: extension component not found"
1823 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1824 [ $ost_idx2_2 -ne $ost_idx2 ] && error "$ost_idx2_2 != $ost_idx2"
1826 flg_opts="--comp-flags init"
1827 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1828 [ $found -eq 1 ] || error "Failover: second component not found"
1830 flg_opts="--comp-flags extension"
1831 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1832 [ $found -eq 1 ] || error "Failover: extension component not found"
1834 sel_layout_sanity $comp_file 3
1836 run_test 22a "Test repeat component behavior with degraded OST"
1838 # Test repeat behavior with low space
1840 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1841 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1842 skip "skipped for lustre < $SEL_VER"
1844 local comp_file=$DIR/$tdir/$tfile
1848 test_mkdir -p $DIR/$tdir
1850 # without this, a previous delete can finish after we check free space
1851 wait_delete_completed
1854 $LFS setstripe -E -1 -c 1 -z 128M \
1855 $comp_file || error "Create $comp_file failed"
1857 # write past end of first component, so it is extended
1858 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
1859 error "dd to extend failed"
1861 flg_opts="--comp-flags extension"
1862 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
1863 [ $found -eq 1 ] || error "Write: Second component not found"
1865 # set our OST low on space
1866 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1867 local wms=$(ost_watermarks_set_low_space $ost_idx1 | grep "watermarks")
1869 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1871 # Write past end of current space, fail to extend, causing repeat
1872 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
1873 error "dd to repeat failed"
1875 $LFS getstripe $comp_file
1877 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1879 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1881 flg_opts="--comp-flags init"
1882 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1883 [ $found -eq 1 ] || error "Write: Second component not found"
1885 flg_opts="--comp-flags extension"
1886 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1887 [ $found -eq 1 ] || error "Write: Extension component not found"
1889 sel_layout_sanity $comp_file 3
1891 run_test 22b "Test simple 'out of space' condition with repeat"
1893 # This tests both "repeat" and "extend in place when repeat fails" aspects
1894 # of repeating components
1896 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1897 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1898 skip "skipped for lustre < $SEL_VER"
1900 local comp_file=$DIR/$tdir/$tfile
1904 test_mkdir -p $DIR/$tdir
1906 # pool is used to limit available OSTs to 0 and 1, so we can set all
1907 # available OSTs out of space
1908 pool_add $TESTNAME || error "Pool creation failed"
1909 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
1911 # without this, a previous delete can finish after we check free space
1912 wait_delete_completed
1915 $LFS setstripe -E -1 -z 64M -c 1 -p "$TESTNAME" $comp_file || \
1916 error "Create $comp_file failed"
1918 # write past end of first component, so it is extended
1919 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=80 conv=notrunc ||
1920 error "dd to extend failed"
1922 $LFS getstripe $comp_file
1924 flg_opts="--comp-flags extension"
1925 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1926 [ $found -eq 1 ] || error "Write: second component not found"
1928 # set our OST out of space
1929 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1930 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1932 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1934 # This should create a repeat component on a new OST
1935 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=180 conv=notrunc ||
1936 error "dd to repeat failed"
1938 $LFS getstripe $comp_file
1940 local comp_cnt=$($LFS getstripe --component-count $comp_file)
1941 [ $comp_cnt -ne 3 ] && error "component count: $comp_cnt, should be 3"
1943 # New second component should be on a different OST
1944 local ost_idx2=$($LFS getstripe --comp-start=128m \
1945 --comp-end=192m --comp-flags=init -i $comp_file)
1947 [ $ost_idx1 -eq $ost_idx2 ] && error "2nd comp: same OST $ost_idx1"
1949 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
1951 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
1953 # now that the second OST is out of space (as is the first OST), we
1954 # attempt to extend. This should result in an extension of the
1955 # existing component, rather than a new component.
1956 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=240 conv=notrunc ||
1957 error "dd for forced extension failed"
1959 $LFS getstripe $comp_file
1961 # clear out of space on first OST
1962 ost_watermarks_clear_enospc $tfile $ost_idx1 $wms
1964 # finally, now that the first OST has space again, we attempt to
1965 # extend one last time. This should create a new component on the
1967 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 conv=notrunc ||
1968 error "dd for repeat on first OST failed"
1970 $LFS getstripe $comp_file
1972 flg_opts="--comp-flags init"
1973 found=$($LFS find --comp-start 128M $flg_opts $comp_file | wc -l)
1974 [ $found -eq 1 ] || error "Write: second component not found"
1976 flg_opts="--comp-flags init"
1977 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1978 [ $found -eq 1 ] || error "Write: third component not found"
1980 flg_opts="--comp-flags extension"
1981 found=$($LFS find --comp-start 320M -E EOF $flg_opts $comp_file | wc -l)
1982 [ $found -eq 1 ] || error "Write: extension component not found"
1984 sel_layout_sanity $comp_file 4
1986 run_test 22c "Test repeat with out of space on > 1 OST"
1988 test_22d_post_check() {
1991 local flg_opts="--comp-flags init"
1992 local found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file |
1994 [ $found -eq 1 ] || {
1995 $LFS getstripe $comp_file
1996 error "$name: second component not found"
1999 flg_opts="--comp-flags extension"
2000 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
2001 [ $found -eq 1 ] || error "$name: third extension component not found"
2003 sel_layout_sanity $comp_file 2
2011 # write past end of first component
2012 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=70
2015 ost_watermarks_clear_enospc $tfile 0 $wms
2016 [ $RC -eq 0 ] || error "dd to force extend failed"
2018 test_22d_post_check $comp_file "Write"
2022 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2023 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2024 skip "skipped for lustre < $SEL_VER"
2026 local comp_file=$DIR/$tdir/$tfile
2030 test_mkdir -p $DIR/$tdir
2032 # without this, a previous delete can finish after we check free space
2033 wait_delete_completed
2036 # Pool allows us to force use of only certain OSTs
2037 pool_add $TESTNAME || error "Pool creation failed"
2038 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2040 # 1. Fail to extend due to OOS, try to repeat within the same pool,
2041 # fail to stripe (again OOS) the 0-length component, remove the
2042 # repeated one, force the extension on the original one.
2043 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2044 error "Create $comp_file failed"
2046 replay_barrier $SINGLEMDS
2048 # set our OST out of space
2049 local wms=$(ost_watermarks_set_enospc $tfile 0 | grep "watermarks")
2051 test_22d_pre $comp_file "$wms"
2053 test_22d_post_check $comp_file "Failover"
2055 # 2. repeat with low on space: 0-length repeated component will be
2056 # striped, but still fails to be extended; otherwise the same as (1).
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 low on space
2064 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2066 test_22d_pre $comp_file "$wms"
2068 test_22d_post_check $comp_file "Failover"
2070 run_test 22d "out of/low on space + failed to repeat + forced extension"
2073 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2074 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2075 skip "skipped for lustre < $SEL_VER"
2077 local comp_file=$DIR/$tdir/$tfile
2078 test_mkdir -p $DIR/$tdir
2080 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2081 error "Create $comp_file failed"
2083 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2084 error "dd append failed"
2086 local flg_opts="--comp-start 0 -E EOF --comp-flags init"
2087 local found=$($LFS find $flg_opts $comp_file | wc -l)
2088 [ $found -eq 1 ] || error "Append: first component (0-EOF) not found"
2090 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2091 [ "$ost_idx" != "" ] && error "Append: second component still exists"
2093 sel_layout_sanity $comp_file 1
2095 run_test 23a "Append: remove EXT comp"
2098 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2099 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2100 skip "skipped for lustre < $SEL_VER"
2102 local comp_file=$DIR/$tdir/$tfile
2103 test_mkdir -p $DIR/$tdir
2105 $LFS setstripe -E 64m -E -1 -z 64M $comp_file ||
2106 error "Create $comp_file failed"
2108 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2109 error "dd append failed"
2111 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2112 local found=$($LFS find $flg_opts $comp_file | wc -l)
2113 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2115 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2116 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2118 sel_layout_sanity $comp_file 2
2120 run_test 23b "Append with 0-length comp: remove EXT comp"
2123 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2124 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2125 skip "skipped for lustre < $SEL_VER"
2127 local comp_file=$DIR/$tdir/$tfile
2128 test_mkdir -p $DIR/$tdir
2130 wait_delete_completed
2133 pool_add $TESTNAME || error "Pool creation failed"
2134 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2135 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
2136 error "Create $comp_file failed"
2138 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2139 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2142 ost_watermarks_clear_enospc $tfile 0 $wms
2143 [ $RC -eq 0 ] || error "dd append failed: $RC"
2145 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2146 local found=$($LFS find $flg_opts $comp_file | wc -l)
2147 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2149 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2150 [ "$ost_idx" != "" ] && error "Append: EXT component still exists"
2152 sel_layout_sanity $comp_file 2
2154 run_test 23c "Append with low on space + 0-length comp: force extension"
2157 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2158 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2159 skip "skipped for lustre < $SEL_VER"
2161 local comp_file=$DIR/$tdir/$tfile
2162 test_mkdir -p $DIR/$tdir
2164 $LFS setstripe -E 64m -E 640M -z 64M -E -1 $comp_file ||
2165 error "Create $comp_file failed"
2167 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2168 error "dd append failed"
2170 flg_opts="--comp-start 64M -E 640M --comp-flags init"
2171 found=$($LFS find $flg_opts $comp_file | wc -l)
2172 [ $found -eq 1 ] || error "Append: component (64M-640M) not found"
2174 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2175 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2177 sel_layout_sanity $comp_file 3
2179 run_test 23d "Append with 0-length comp + next real comp: remove EXT comp"
2182 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2183 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2184 skip "skipped for lustre < $SEL_VER"
2186 local comp_file=$DIR/$tdir/$tfile
2187 test_mkdir -p $DIR/$tdir
2189 wait_delete_completed
2192 pool_add $TESTNAME || error "Pool creation failed"
2193 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2195 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
2196 error "Create $comp_file failed"
2198 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2200 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2203 ost_watermarks_clear_enospc $tfile 0 $wms
2204 [ $RC -eq 0 ] || error "dd append failed $RC"
2206 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2207 local found=$($LFS find $flg_opts $comp_file | wc -l)
2208 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2210 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2211 [ "$ost_idx" != "" ] && error "Append: 0-length component still exists"
2212 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2213 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2215 sel_layout_sanity $comp_file 2
2217 run_test 23e "Append with next real comp: spillover and backward extension"
2220 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2221 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2222 skip "skipped for lustre < $SEL_VER"
2224 local comp_file=$DIR/$tdir/$tfile
2225 test_mkdir -p $DIR/$tdir
2227 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2228 error "Create $comp_file failed"
2230 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
2231 local wms=$(ost_watermarks_set_low_space $ost_idx | grep "watermarks")
2233 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2236 ost_watermarks_clear_enospc $tfile $ost_idx $wms
2237 [ $RC -eq 0 ] || error "dd append failed"
2239 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2240 local found=$($LFS find $flg_opts $comp_file | wc -l)
2241 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2243 ost_idx=$($LFS getstripe -I2 -i $comp_file)
2244 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2246 sel_layout_sanity $comp_file 2
2248 run_test 23f "Append with low on space: repeat and remove EXT comp"
2257 [ "$OSTCOUNT" -lt "3" ] && skip_env "needs >= 3 OSTs"
2259 trap cleanup_24 EXIT RETURN
2261 local file=$DIR/$tfile
2263 $LFS setstripe -E 1m -c1 -o0 -E eof -c2 -o1,2 $file ||
2264 error "setstripe on $file"
2266 dd if=/dev/zero of=$file bs=1M count=3 || error "dd failed for $file"
2269 filefrag -ves $file || error "filefrag $file failed"
2270 filefrag_op=$(filefrag -ve -k $file |
2271 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
2273 #Filesystem type is: bd00bd0
2274 #File size of /mnt/lustre/f24a.sanity-pfl is 3145728 (3072 blocks of 1024 bytes)
2275 # ext: device_logical: physical_offset: length: dev: flags:
2276 # 0: 0.. 1023: 1572864.. 1573887: 1024: 0000: net
2277 # 1: 0.. 1023: 1572864.. 1573887: 1024: 0002: net
2278 # 2: 1024.. 2047: 1573888.. 1574911: 1024: 0001: last,net
2279 #/mnt/lustre/f24a.sanity-pfl: 3 extents found
2281 last_lun=$(echo $filefrag_op | cut -d: -f5)
2286 for line in $filefrag_op; do
2287 frag_lun=$(echo $line | cut -d: -f5)
2288 ext_len=$(echo $line | cut -d: -f4)
2289 if [[ "$frag_lun" != "$last_lun" ]]; then
2290 if (( tot_len != 1024 )); then
2292 error "$file: OST$last_lun $tot_len != 1024"
2298 (( tot_len += ext_len ))
2301 if (( num_luns != 3 || tot_len != 1024 )); then
2303 error "$file: $num_luns != 3, $tot_len != 1024 on OST$last_lun"
2306 echo "FIEMAP on $file succeeded"
2308 run_test 24a "FIEMAP upon PFL file"
2311 check_and_cleanup_lustre