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 (( $MDS1_VERSION > $(version_code 2.14.50.115) )) ||
133 skip_env "Need MDS version at least 2.14.50.115"
140 # Create parent directory
143 # Component end must be a multiple of stripe size
144 # and a multiple of 64KiB to align with the minimum
146 # Values below 4096 are assumed to be in KiB units.
147 $LFS setstripe -E 127 $tf-1 > /dev/null 2>&1 &&
148 error "creating $tf-1 with '-E 127' should fail"
150 $LFS setstripe -E 128 -S 512 $tf-1 > /dev/null 2>&1 &&
151 error "creating $tf-1 with '-E 128 -S 512' should fail"
153 $LFS setstripe -E 128 $tf-1 ||
154 error "creating $tf-1 failed"
156 yes | dd bs=1K count=129 iflag=fullblock of=$tf-1 &&
157 error "writing to $tf-1 should fail"
159 yes | dd bs=1K count=128 iflag=fullblock of=$tf-1 ||
160 error "writing to $tf-1 failed"
162 comp_end=$($LFS getstripe -I1 -E $tf-1)
163 stripe_size=$($LFS getstripe -I1 -S $tf-1)
165 [[ $comp_end == $((128 * 1024)) ]] ||
166 error "incorrect component end '$comp_end' for $tf-1"
168 [[ $stripe_size == $((128 * 1024)) ]] ||
169 error "incorrect stripe size '$stripe_size' for $tf-1"
171 rm $tf-1 || error "removing $tf-1 failed"
173 # The stripe size must be a multiple of 64KiB.
174 # Values below 4096 are assumed to be in KiB units.
175 $LFS setstripe -E -1 -S 2047 $tf-2 > /dev/null 2>&1 &&
176 error "creating $tf-2 with '-S 2047' should fail"
178 $LFS setstripe -E -1 -S 2048 $tf-2 ||
179 error "creating $tf-2 failed"
181 stripe_size=$($LFS getstripe -I1 -S $tf-2)
182 [[ $stripe_size == $((2048 * 1024)) ]] ||
183 error "incorrect stripe size '$stripe_size' for $tf-2"
185 rm $tf-2 || error "removing $tf-2 failed"
187 run_test 0d "Verify comp end and stripe size"
190 local comp_file=$DIR/$tdir/$tfile
191 local rw_len=$((3 * 1024 * 1024)) # 3M
193 test_mkdir $DIR/$tdir
196 $LFS setstripe -E 1m -S 1m -o 0 -E -1 -o 0 $comp_file ||
197 error "Create $comp_file failed"
199 #instantiate all components, so that objs are allocted
200 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
202 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
203 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
205 [ $ost_idx1 -ne $ost_idx2 ] && error "$ost_idx1 != $ost_idx2"
207 small_write $comp_file $rw_len || error "Verify RW failed"
209 rm -f $comp_file || error "Delete $comp_file failed"
211 run_test 1a "Create full components file, reused OSTs"
213 # test overstriping (>1 stripe/OST within a component)
215 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
216 [[ $($LCTL get_param mdc.*.import |
217 grep "connect_flags:.*overstriping") ]] ||
218 skip "server does not support overstriping"
220 local comp_file=$DIR/$tdir/$tfile
221 local rw_len=$((3 * 1024 * 1024)) # 3M
223 test_mkdir $DIR/$tdir
225 $LFS setstripe -E 1m -S 1m -o 0,0 -E -1 -o 1,1,0,0 $comp_file ||
226 error "Create $comp_file failed"
228 #instantiate all components, so that objs are allocted
229 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=1M
231 $LFS getstripe $comp_file
232 local OSTS_1=$($LFS getstripe -I1 $comp_file | grep -o 'l_ost_idx.*' |
233 awk -e '{print $2}' | tr "\n" "\0")
234 local OSTS_2=$($LFS getstripe -I2 $comp_file | grep -o 'l_ost_idx.*' |
235 awk -e '{print $2}' | tr "\n" "\0")
239 [ "$OSTS_1" = "0,0," ] || error "incorrect OSTs($OSTS_1) in component 1"
240 [ "$OSTS_2" = "1,1,0,0," ] ||
241 error "incorrect OSTs($OSTS_2) in component 2"
243 small_write $comp_file $rw_len || error "Verify RW failed"
245 rm -f $comp_file || error "Delete $comp_file failed"
247 run_test 1b "Create full components file, overstriping in components"
249 # test overstriping with max stripe count
251 [[ $($LCTL get_param mdc.*.import |
252 grep "connect_flags:.*overstriping") ]] ||
253 skip "server does not support overstriping"
254 large_xattr_enabled || skip_env "no large xattr support"
256 local comp_file=$DIR/$tdir/$tfile
257 local rw_len=$((3 * 1024 * 1024)) # 3M
259 test_mkdir $DIR/$tdir
261 $LFS setstripe -E 1m -C 10 -E 10M -C 100 -E -1 \
262 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
263 error "Create $comp_file failed"
265 # Seek & write in to last component so all objects are allocated
266 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=20000
268 local count=$($LFS getstripe -c -I1 $DIR/$tdir/$tfile)
269 [ $count -eq 10 ] || error "comp1 stripe count $count, should be 10"
270 count=$($LFS getstripe -c -I2 $DIR/$tdir/$tfile)
271 [ $count -eq 100 ] || error "comp2 stripe count $count, should be 100"
272 count=$($LFS getstripe -c -I3 $DIR/$tdir/$tfile)
273 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
274 error "comp4 stripe count $count != $LOV_MAX_STRIPE_COUNT"
276 small_write $comp_file $rw_len || error "Verify RW failed"
278 rm -f $comp_file || error "Delete $comp_file failed"
280 run_test 1c "Test overstriping w/max stripe count"
283 local comp_file=$DIR/$tdir/$tfile
284 local rw_len=$((5 * 1024 * 1024)) # 5M
287 test_mkdir $DIR/$tdir
290 multiop $comp_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
291 error "create failed $comp_file"
293 $LFS setstripe --component-add $params $comp_file ||
294 error "Add component to $comp_file failed"
296 check_component_count $comp_file 1
298 dd if=/dev/zero of=$comp_file bs=1M count=1 > /dev/null 2>&1 ||
299 error "Write first component failed"
300 dd if=$comp_file of=/dev/null bs=1M count=1 > /dev/null 2>&1 ||
301 error "Read first component failed"
303 dd if=/dev/zero of=$comp_file bs=1M count=2 > /dev/null 2>&1 &&
304 error "Write beyond component should fail"
305 dd if=$comp_file of=/dev/null bs=1M count=2 > /dev/null 2>&1 ||
306 error "Read beyond component should short read, not fail"
308 $LFS setstripe --component-add -E 2M -S 1M -c 1 $comp_file ||
309 error "Add component to $comp_file failed"
311 check_component_count $comp_file 2
313 $LFS setstripe --component-add -E -1 -c 3 $comp_file ||
314 error "Add last component to $comp_file failed"
316 check_component_count $comp_file 3
318 small_write $comp_file $rw_len || error "Verify RW failed"
320 rm -f $comp_file || error "Delete $comp_file failed"
324 base_test_2 "-E 1m -S 1m"
326 run_test 2a "Add components to existing file"
329 base_test_2 "-E 1m -L mdt"
331 run_test 2b "Add components w/DOM to existing file"
333 del_comp_and_verify() {
340 if [ $id == "init" -o $id == "^init" ]; then
341 opt="--component-flags="
344 $LFS setstripe --component-del $opt$id $comp_file ||
345 error "Delete component $id from $comp_file failed"
347 local comp_cnt=$($LFS getstripe --component-count $comp_file)
348 if grep -q "has no stripe info" <<< "$comp_cnt" ; then
351 [ $comp_cnt -ne $left ] && error "$comp_cnt != $left"
353 $CHECKSTAT -s $size $comp_file || error "size != $size"
357 local comp_file=$DIR/$tdir/$tfile
360 test_mkdir $DIR/$tdir
363 $LFS setstripe $params $comp_file || error "Create $comp_file failed"
365 check_component_count $comp_file 3
367 dd if=/dev/zero of=$comp_file bs=1M count=2
369 $LFS setstripe --component-del -I 2 $comp_file &&
370 error "Component deletion makes hole"
372 del_comp_and_verify $comp_file 3 2 $((2 * 1024 * 1024))
373 del_comp_and_verify $comp_file 2 1 $((1 * 1024 * 1024))
374 del_comp_and_verify $comp_file 1 0 0
376 rm -f $comp_file || error "Delete $comp_file failed"
378 $LFS setstripe -E 1M -S 1M -E 16M -E -1 $comp_file ||
379 error "Create second $comp_file failed"
381 del_comp_and_verify $comp_file "^init" 1 0
382 del_comp_and_verify $comp_file "init" 0 0
383 rm -f $comp_file || error "Delete second $comp_file failed"
387 base_test_3 "-E 1M -S 1M -E 64M -c 2 -E -1 -c 3"
389 run_test 3a "Delete components from existing file"
392 base_test_3 "-E 1M -L mdt -E 64M -S 1M -c 2 -E -1 -c 3"
394 run_test 3b "Delete components w/DOM from existing file"
397 skip "Not supported in PFL"
398 # In PFL project, only LCME_FL_INIT is supported, and it can't
399 # be altered by application.
401 run_test 4 "Modify component flags in existing file"
404 local parent=$DIR/$tdir
405 local comp_file=$DIR/$tdir/$tfile
406 local subdir=$parent/subdir
411 # set default layout to parent directory
412 $LFS setstripe -E 64M -c 2 -i 0 -E -1 -c 4 -i 0 $parent ||
413 error "Set default layout to $parent failed"
415 # create file under parent
416 touch $comp_file || error "Create $comp_file failed"
417 check_component_count $comp_file 2
419 #instantiate all components, so that objs are allocted
420 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=65k
422 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
423 [ $ost_idx -ne 0 ] &&
424 error "component 1 ost_idx $ost_idx != 0"
426 ost_idx=$($LFS getstripe -I2 -i $comp_file)
427 [ $ost_idx -ne 0 ] &&
428 error "component 2 ost_idx $ost_idx != 0"
430 # create subdir under parent
431 mkdir -p $subdir || error "Create subdir $subdir failed"
433 comp_cnt=$($LFS getstripe -d --component-count $subdir)
434 [ $comp_cnt -ne 2 ] && error "subdir $comp_cnt != 2"
436 # create file under subdir
437 touch $subdir/$tfile || error "Create $subdir/$tfile failed"
439 check_component_count $subdir/$tfile 2
441 # delete default layout setting from parent
442 $LFS setstripe -d $parent ||
443 error "Delete default layout from $parent failed"
445 comp_cnt=$($LFS getstripe -d --component-count $parent)
446 [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0"
448 rm -f $comp_file || error "Delete $comp_file failed"
449 rm -f $subdir/$tfile || error "Delete $subdir/$tfile failed"
450 rm -r $subdir || error "Delete subdir $subdir failed"
451 rmdir $parent || error "Delete dir $parent failed"
453 run_test 5 "Inherit composite layout from parent directory"
456 local comp_file=$DIR/$tdir/$tfile
458 test_mkdir $DIR/$tdir
461 $LFS setstripe -c 1 -S 128K $comp_file ||
462 error "Create v1 $comp_file failed"
464 check_component_count $comp_file 0
466 dd if=/dev/urandom of=$comp_file bs=1M count=5 oflag=sync ||
467 error "Write to v1 $comp_file failed"
469 local old_chksum=$(md5sum $comp_file)
471 # Migrate v1 to composite
472 $LFS migrate -E 1M -S 512K -c 1 -E -1 -S 1M -c 2 $comp_file ||
473 error "Migrate(v1 -> composite) $comp_file failed"
475 check_component_count $comp_file 2
477 local chksum=$(md5sum $comp_file)
478 [ "$old_chksum" != "$chksum" ] &&
479 error "(v1 -> compsoite) $old_chksum != $chksum"
481 # Migrate composite to composite
482 $LFS migrate -E 1M -S 1M -c 2 -E 4M -S 1M -c 2 \
483 -E -1 -S 3M -c 3 $comp_file ||
484 error "Migrate(compsoite -> composite) $comp_file failed"
486 check_component_count $comp_file 3
488 chksum=$(md5sum $comp_file)
489 [ "$old_chksum" != "$chksum" ] &&
490 error "(composite -> compsoite) $old_chksum != $chksum"
492 # Migrate composite to v1
493 $LFS migrate -c 2 -S 2M $comp_file ||
494 error "Migrate(composite -> v1) $comp_file failed"
496 check_component_count $comp_file 0
498 chksum=$(md5sum $comp_file)
499 [ "$old_chksum" != "$chksum" ] &&
500 error "(composite -> v1) $old_chksum != $chksum"
502 rm -f $comp_file || "Delete $comp_file failed"
504 run_test 6 "Migrate composite file"
507 test_mkdir $DIR/$tdir
508 chmod 0777 $DIR/$tdir || error "chmod $tdir failed"
510 local comp_file=$DIR/$tdir/$tfile
511 $RUNAS $LFS setstripe -E 1M -S 1M -c 1 $comp_file ||
512 error "Create composite file $comp_file failed"
514 $RUNAS $LFS setstripe --component-add -E 64M -c 4 $comp_file ||
515 error "Add component to $comp_file failed"
517 $RUNAS $LFS setstripe --component-del -I 2 $comp_file ||
518 error "Delete component from $comp_file failed"
520 $RUNAS $LFS setstripe --component-add -E -1 -c 5 $comp_file ||
521 error "Add last component to $comp_file failed"
523 rm $comp_file || "Delete composite failed"
525 run_test 7 "Add/Delete/Create composite file by non-privileged user"
528 local parent=$DIR/$tdir
533 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c 2 -S 2M \
534 -E -1 -c 4 -S 4M $parent ||
535 error "Set default layout to $parent failed"
537 sh rundbench -C -D $parent 2 || error "dbench failed"
539 rm -fr $parent || error "Delete dir $parent failed"
541 run_test 8 "Run dbench over composite files"
544 local comp_file=$DIR/$tdir/$tfile
546 test_mkdir $DIR/$tdir
549 $LFS setstripe -E 1M -S 1M -E -1 -c 1 $comp_file ||
550 error "Create $comp_file failed"
552 check_component_count $comp_file 2
554 replay_barrier $SINGLEMDS
556 # instantiate the 2nd component
557 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
559 local f1=$($LFS getstripe -I2 $comp_file |
560 awk '/l_fid:/ {print $7}')
561 echo "before MDS recovery, the ost fid of 2nd component is $f1"
564 local f2=$($LFS getstripe -I2 $comp_file |
565 awk '/l_fid:/ {print $7}')
566 echo "after MDS recovery, the ost fid of 2nd component is $f2"
567 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
569 run_test 9 "Replay layout extend object instantiation"
572 echo $($LFS getstripe $1 |
573 awk '$1 == "lcm_entry_count:" { printf("%d", $2) }
574 $1 == "lcme_extent.e_start:" { printf("[%#lx", $2) }
575 $1 == "lcme_extent.e_end:" { printf(",%s]", $2) }')
579 local parent=$DIR/$tdir
582 save_layout_restore_at_exit $MOUNT
586 # mount root on $MOUNT2 if FILESET is set
587 if [ -n "$FILESET" ]; then
588 FILESET="" mount_client $MOUNT2 ||
589 error "mount $MOUNT2 fail"
593 $LFS setstripe -d $root || error "clear root layout"
595 # set root composite layout
596 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c2 -S 2M \
597 -E -1 -c 4 -S 4M $root ||
598 error "Set root layout failed"
600 if [ "$root" == "$MOUNT2" ]; then
601 umount_client $MOUNT2 ||
602 error "umount $MOUNT2 fail"
606 # set a different layout for parent
607 $LFS setstripe -E -1 -c 1 -S 1M $parent ||
608 error "set $parent layout failed"
611 local f1_entry=$(component_dump $parent/file1)
613 # delete parent's layout
614 $LFS setstripe -d $parent || error "Clear $parent layout failed"
617 local f2_entry=$(component_dump $parent/file2)
619 # verify layout inheritance
621 local f1_expect="1[0,EOF]"
622 local f2_expect="3[0,2097152][0x200000,16777216][0x1000000,EOF]"
624 echo "f1 expect=$f1_expect"
625 echo "f1 get =$f1_entry"
626 echo "f2 expect=$f2_expect"
627 echo "f2 get =$f2_entry"
629 [ x$f1_expect != x$f1_entry ] &&
630 error "$parent/file1 does not inherite parent layout"
631 [ x$f2_expect != x$f2_entry ] &&
632 error "$parent/file2 does not inherite root layout"
636 run_test 10 "Inherit composite template from root"
639 local comp_file=$DIR/$tdir/$tfile
640 test_mkdir $DIR/$tdir
643 # only 1st component instantiated
644 $LFS setstripe -E 1M -S 1M -E 2M -E 3M -E -1 $comp_file ||
645 error "Create $comp_file failed"
647 local f1=$($LFS getstripe -I1 $comp_file | grep "l_fid")
648 [[ -z $f1 ]] && error "1: 1st component uninstantiated"
649 local f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
650 [[ -n $f2 ]] && error "1: 2nd component instantiated"
651 local f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
652 [[ -n $f3 ]] && error "1: 3rd component instantiated"
653 local f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
654 [[ -n $f4 ]] && error "1: 4th component instantiated"
656 # the first 2 components instantiated
657 # Truncate to exact start of new component - LU-12586
658 $TRUNCATE $comp_file $((1024*1024*1))
660 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
661 [[ -z $f2 ]] && error "2: 2nd component uninstantiated"
662 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
663 [[ -n $f3 ]] && error "2: 3rd component instantiated"
664 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
665 [[ -n $f4 ]] && error "2: 4th component instantiated"
667 # the first 3 components instantiated
668 $TRUNCATE $comp_file $((1024*1024*3 - 1))
669 $TRUNCATE $comp_file $((1024*1024*1+1))
671 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
672 [[ -z $f2 ]] && error "3: 2nd component uninstantiated"
673 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
674 [[ -z $f3 ]] && error "3: 3rd component uninstantiated"
675 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
676 [[ -n $f4 ]] && error "3: 4th component instantiated"
678 # all 4 components instantiated, using append write
679 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
681 rwv -f $comp_file -w -a -n 2 $((1024*1023)) 1
684 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
685 [[ -z $f4 ]] && error "4: 4th component uninstantiated"
689 run_test 11a "Verify component instantiation with write/truncate"
692 [ $OSTCOUNT -lt 4 ] && skip "needs >= 4 OSTs"
694 local file=$DIR/$tdir/$tfile
696 test_mkdir $DIR/$tdir
699 $LFS setstripe -E 1m -E 1g -c 4 -E eof $DIR/$tdir ||
700 error "setstripe dir $DIR/$tdir failed"
701 expand_truncate_test $file ||
702 error "expand_truncate_test failed on $file"
704 run_test 11b "truncate file set file size correctly"
707 [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs"
709 local file=$DIR/$tdir/$tfile
710 test_mkdir $DIR/$tdir
713 # specify ost list for component
714 $LFS setstripe -E 1M -S 1M -c 2 -o 0,1 -E 2M -c 2 -o 1,2 \
715 -E 3M -c 2 -o 2,1 -E 4M -c 1 -i 2 -E -1 $file ||
716 error "Create $file failed"
718 # clear lod component cache
719 stop $SINGLEMDS || error "stop MDS"
720 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
721 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "start MDS"
723 # instantiate all components
724 $TRUNCATE $file $((1024*1024*4+1))
726 #verify object alloc order
727 local o1=$($LFS getstripe -I1 $file |
728 awk '/l_ost_idx:/ {printf("%d",$5)}')
729 [[ $o1 != "01" ]] && error "$o1 is not 01"
731 local o2=$($LFS getstripe -I2 $file |
732 awk '/l_ost_idx:/ {printf("%d",$5)}')
733 [[ $o2 != "12" ]] && error "$o2 is not 12"
735 local o3=$($LFS getstripe -I3 $file |
736 awk '/l_ost_idx:/ {printf("%d",$5)}')
737 [[ $o3 != "21" ]] && error "$o3 is not 21"
739 local o4=$($LFS getstripe -I4 $file |
740 awk '/l_ost_idx:/ {printf("%d",$5)}')
741 [[ $o4 != "2" ]] && error "$o4 is not 2"
745 run_test 12 "Verify ost list specification"
747 test_13() { # LU-9311
748 [ $OSTCOUNT -lt 8 ] && skip "needs >= 8 OSTs"
750 local file=$DIR/$tfile
752 local dd_size=$(($dd_count * 1024 * 1024))
756 $LFS setstripe -E 1M -S 1M -c 1 -E 2M -c 2 -E -1 -c -1 -i 1 $file ||
757 error "Create $file failed"
758 dd if=/dev/zero of=$file bs=1M count=$dd_count
759 real_size=$(stat -c %s $file)
760 [ $real_size -eq $dd_size ] ||
761 error "dd actually wrote $real_size != $dd_size bytes"
765 run_test 13 "shouldn't reprocess granted resent request"
768 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
769 local file=$DIR/$tdir/$tfile
770 test_mkdir -p $DIR/$tdir
773 $LFS setstripe -E1m -c1 -S1m --pool="pool1" -E2m \
774 -E4m -c2 -S2m --pool="pool2" -E-1 $file ||
775 error "Create $file failed"
777 # check --pool inheritance
779 pool="$($LFS getstripe -I2 --pool $file)"
780 [ x"$pool" != "xpool1" ] && $LFS getstripe -I2 $file &&
781 error "$file: component 2 doesn't have poolname pool1"
782 pool="$($LFS getstripe -I4 --pool $file)"
783 [ x"$pool" != "xpool2" ] && $LFS getstripe -I4 $file &&
784 error "$file: component 4 doesn't have poolname pool2"
786 #check --stripe-count inheritance
788 count="$($LFS getstripe -I2 -c $file)"
789 [ $count -ne 1 ] && $LFS getstripe -I2 $file &&
790 error "$file: component 2 doesn't have 1 stripe_count"
791 count="$($LFS getstripe -I4 -c $file)"
792 [ $count -ne 2 ] && $LFS getstripe -I4 $file &&
793 error "$file: component 4 doesn't have 2 stripe_count"
795 #check --stripe-size inheritance
797 size="$($LFS getstripe -I2 -S $file)"
798 [ $size -ne $((1024*1024)) ] && $LFS getstripe -I2 $file &&
799 error "$file: component 2 doesn't have 1M stripe_size"
800 size="$($LFS getstripe -I4 -S $file)"
801 [ $size -ne $((1024*1024*2)) ] && $LFS getstripe -I4 $file &&
802 error "$file: component 4 doesn't have 2M stripe_size"
806 run_test 14 "Verify setstripe poolname/stripe_count/stripe_size inheritance"
809 local parent=$DIR/$tdir
814 $LFS setstripe -d $parent || error "delete default layout"
816 $LFS setstripe -E 1M -S 1M -E 10M -E eof $parent/f1 || error "create f1"
817 $LFS setstripe -E 4M -E 20M -E eof $parent/f2 || error "create f2"
818 test_mkdir $parent/subdir
819 $LFS setstripe -E 6M -S 1M -c1 -E 30M -c4 -E eof -c -1 $parent/subdir ||
820 error "setstripe to subdir"
821 $LFS setstripe -E 8M -E eof $parent/subdir/f3 || error "create f3"
822 $LFS setstripe -c 1 $parent/subdir/f4 || error "create f4"
825 local found=$($LFS find --component-start +2M -E -15M $parent | wc -l)
826 [ $found -eq 0 ] || error "start+2M, end-15M, $found != 0"
829 found=$($LFS find --component-start +2M -E -35M $parent | wc -l)
830 [ $found -eq 2 ] || error "start+2M, end-35M, $found != 2"
833 found=$($LFS find --component-start +4M -E -eof $parent | wc -l)
834 [ $found -eq 1 ] || error "start+4M, end-eof, $found != 1"
836 local flg_opts="--component-flags init"
838 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
840 error "before write: start=1M, end=10M, flag=init, $found != 0"
842 dd if=/dev/zero of=$parent/f1 bs=1M count=2 ||
843 error "dd $parent/f1 failed"
846 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
848 error "after write: start=1M, end=10M, flag=init, $found != 1"
850 local ext_opts="--component-start -1M -E +5M"
851 # parent, subdir, f3, f4
852 found=$($LFS find $ext_opts $parent | wc -l)
853 [ $found -eq 4 ] || error "start-1M, end+5M, $found != 4"
855 local cnt_opts="--component-count +2"
857 found=$($LFS find $ext_opts $cnt_opts $parent | wc -l)
858 [ $found -eq 1 ] || error "start-1M, end+5M, count+2, $found != 1"
861 found=$($LFS find $ext_opts $cnt_opts $flg_opts $parent | wc -l)
863 error "start-1M, end+5M, count+2, flag=init, $found != 0"
866 found=$($LFS find $ext_opts ! $cnt_opts $flg_opts $parent | wc -l)
868 error "start-1M, end+5M, !count+2, flag=init, $found != 2"
870 # check last component stripe count
871 if [ $OSTCOUNT -gt 1 ]; then
872 touch $parent/subdir/f5
873 $TRUNCATE $parent/subdir/f5 $((32*1024*1024))
874 found=$($LFS find $parent/subdir -c $OSTCOUNT)
875 [[ "$found" == "$parent/subdir/f5" ]] ||
876 error "got '$found' with stripe_count=$OSTCOUNT, not f5"
879 run_test 15 "Verify component options for lfs find"
882 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
883 large_xattr_enabled || skip_env "ea_inode feature disabled"
885 local file=$DIR/$tdir/$tfile
886 local dir=$DIR/$tdir/dir
887 local temp=$DIR/$tdir/template
889 test_mkdir $DIR/$tdir
891 #####################################################################
893 # set stripe for source file
894 $LFS setstripe -E1m -S 1M -c2 -o0,1 -E2m -c2 -E3m -o1,0 -E4m -c1 -E-1 \
895 $file || error "Create $file failed"
898 verify_yaml_layout $file $file.copy $temp "1. PFL file"
900 #####################################################################
902 # set stripe for source file
904 $LFS setstripe -c2 -o0,1 -i1 $file || error "Create $file failed"
908 verify_yaml_layout $file $file.copy $temp "2. plain file"
910 #####################################################################
912 # set stripe for source dir
914 $LFS setstripe -E1m -S 1M -c2 -E2m -c1 -E-1 $dir ||
915 error "setstripe $dir failed"
919 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
921 #####################################################################
923 # set stripe for source dir
924 $LFS setstripe -c2 -i-1 $dir || error "setstripe $dir failed"
927 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
929 run_test 16a "Verify setstripe/getstripe with YAML config file"
932 [[ $($LCTL get_param mdc.*.import |
933 grep "connect_flags:.*overstriping") ]] ||
934 skip "server does not support overstriping"
935 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
936 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
937 skip_env "too many osts, skipping"
938 large_xattr_enabled || skip_env "ea_inode feature disabled"
940 local file=$DIR/$tdir/$tfile
941 local dir=$DIR/$tdir/dir
942 local temp=$DIR/$tdir/template
943 # We know OSTCOUNT < (LOV_MAX_STRIPE_COUNT / 2), so this is overstriping
944 local large_count=$((LOV_MAX_STRIPE_COUNT / 2 + 10))
947 test_mkdir $DIR/$tdir
949 #####################################################################
950 # 1. PFL file, overstriping in first comps
951 # set stripe for source file
952 $LFS setstripe -E1m -S 1M -o0,0 -E2m -o1,1 -E3m -C $large_count -E-1 \
953 $file || error "Create $file failed"
956 verify_yaml_layout $file $file.copy $temp "1. PFL file"
958 #####################################################################
959 # 2. plain file + overstriping
960 # set stripe for source file
962 $LFS setstripe -C $large_count -i1 $file || error "Create $file failed"
966 verify_yaml_layout $file $file.copy $temp "2. plain file"
968 #####################################################################
969 # 3. PFL dir + overstriping
970 # set stripe for source dir
972 $LFS setstripe -E1m -S 1M -o 0,0 -E2m -C $large_count -E-1 $dir ||
973 error "setstripe $dir failed"
977 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
979 #####################################################################
980 # 4. plain dir + overstriping
981 # set stripe for source dir
982 $LFS setstripe -C $large_count $dir || error "setstripe $dir failed"
985 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
987 run_test 16b "Verify setstripe/getstripe with YAML config file + overstriping"
990 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
992 local file=$DIR/$tdir/$tfile
993 local dir=$DIR/$tdir/dir
994 local temp=$DIR/$tdir/template
996 test_mkdir $DIR/$tdir
998 #####################################################################
1000 # set stripe for source file
1001 $LFS setstripe -E256M -S 1M -c2 -o0,1 -z 64M -E-1 -o1,0 -z 128M \
1002 $file || error "Create $file failed"
1005 verify_yaml_layout $file $file.copy $temp "1. PFL file"
1007 #####################################################################
1009 # set stripe for source dir
1011 $LFS setstripe -E256M -S 1M -c2 -z 64M -E-1 -z 128M \
1012 $dir || error "setstripe $dir failed"
1014 test_mkdir $dir.copy
1015 echo "2. SEL template on dir"
1016 verify_yaml_layout $dir $dir.copy $temp.dir "2. PFL dir"
1018 run_test 16c "Verify setstripe/getstripe for SEL layout with YAML config file"
1021 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1023 local file=$DIR/$tdir/$tfile
1024 local dir=$DIR/$tdir/dir
1025 local temp=$DIR/$tdir/template
1027 test_mkdir $DIR/$tdir
1029 #####################################################################
1031 # set stripe for source file
1032 $LFS setstripe -E1m -L mdt -E-1 -o1,0 $file ||
1033 error "Create $file failed"
1036 verify_yaml_layout $file $file.copy $temp "1. DOM file"
1038 #####################################################################
1040 # set stripe for source dir
1042 $LFS setstripe -E1m -L mdt -E-1 -o1,0 $dir || error "Create $dir failed"
1044 test_mkdir $dir.copy
1046 verify_yaml_layout $dir $dir.copy $temp.dir "2. DOM dir"
1048 run_test 16d "Verify setstripe/getstripe for DOM layout with YAML config file"
1052 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1053 local file=$DIR/$tdir/$tfile
1054 test_mkdir -p $DIR/$tdir
1057 $LFS setstripe -E 1M -S 1M -E 2M -c 2 -E -1 -c -1 $file ||
1058 error "Create $file failed"
1060 local s1=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
1061 local s2=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
1062 local s3=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
1063 echo "1st init: comp size 1:$s1 2:$s2 3:$s3"
1065 # init 2nd component
1066 $TRUNCATE $file $((1024*1024+1))
1067 local s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
1068 local s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
1069 echo "2nd init: comp size 1:$s1n 2:$s2n 3:$s3"
1071 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
1072 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
1074 # init 3rd component
1075 $TRUNCATE $file $((1024*1024*2+1))
1076 s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
1077 s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
1078 local s3n=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
1079 echo "3rd init: comp size 1:$s1n 2:$s2n 3:$s3n"
1081 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
1082 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
1083 [ $s3 -lt $s3n ] || error "3rd comp size $s3 should < $s3n"
1085 run_test 17 "Verify LOVEA grows with more component inited"
1087 check_distribution() {
1091 local obj_min_one=$((OSTCOUNT - 1))
1093 objs=$($LFS getstripe $file |
1094 awk '/l_ost_idx:/ { print $5 }' | wc -l)
1095 let ave=$((objs / OSTCOUNT))
1097 # collect objects per OST distribution
1098 $LFS getstripe $file | awk '/l_ost_idx:/ { print $5 }' | tr -d "," |
1099 (inuse=( $(for i in $(seq 0 $obj_min_one); do echo 0; done) )
1101 let inuse[$O]=$((1 + ${inuse[$O]}))
1104 # verify object distribution varies no more than +-1
1105 for idx in $(seq 0 $obj_min_one); do
1106 let dif=$((${inuse[$idx]} - ave))
1108 if [ "$dif" -gt 1 ]; then
1109 echo "OST${idx}: ${inuse[$idx]} objects"
1110 error "bad distribution on OST${idx}"
1116 local file1=$DIR/${tfile}-1
1117 local file2=$DIR/${tfile}-2
1118 local file3=$DIR/${tfile}-3
1120 rm -f $file1 $file2 $file3
1122 $LFS setstripe -E 1m -S 1m $file1 ||
1123 error "Create $file1 failed"
1124 $LFS setstripe -E 1m -S 1m $file2 ||
1125 error "Create $file2 failed"
1126 $LFS setstripe -E 1m -S 1m $file3 ||
1127 error "Create $file3 failed"
1129 local objs=$((OSTCOUNT+1))
1130 for comp in $(seq 1 $OSTCOUNT); do
1131 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file1 ||
1132 error "Add component to $file1 failed 2"
1133 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file2 ||
1134 error "Add component to $file2 failed 2"
1135 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file3 ||
1136 error "Add component to $file3 failed 2"
1139 $LFS setstripe --component-add -E -1 -c -1 $file1 ||
1140 error "Add component to $file1 failed 3"
1141 $LFS setstripe --component-add -E -1 -c -1 $file2 ||
1142 error "Add component to $file2 failed 3"
1143 $LFS setstripe --component-add -E -1 -c -1 $file3 ||
1144 error "Add component to $file3 failed 3"
1146 # Instantiate all components
1147 dd if=/dev/urandom of=$file1 bs=1M count=$((objs+1)) ||
1148 error "dd failed for $file1"
1149 dd if=/dev/urandom of=$file2 bs=1M count=$((objs+1)) ||
1150 error "dd failed for $file2"
1151 dd if=/dev/urandom of=$file3 bs=1M count=$((objs+1)) ||
1152 error "dd failed for $file3"
1154 check_distribution $file1
1155 check_distribution $file2
1156 check_distribution $file3
1159 run_test 18 "check component distribution"
1163 local already_created=${2:-0}
1164 local rw_len=$((3 * 1024 * 1024)) # 3M
1168 if [ $already_created != 1 ]; then
1169 test_mkdir -p $DIR/$tdir
1170 $LFS setstripe --extension-size 64M -c 1 -E -1 $comp_file ||
1171 error "Create $comp_file failed"
1174 # write past end of first component, so it is extended
1175 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=127 conv=notrunc ||
1176 error "dd to extend failed"
1178 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1179 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1181 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1182 [ $ost_idx2 -ne "-1" ] && error "second component init $ost_idx2"
1184 flg_opts="--comp-flags init"
1185 found=$($LFS find --comp-start 0 -E 128M $flg_opts $comp_file | wc -l)
1186 [ $found -eq 1 ] || error "Write: Extended first component not found"
1188 flg_opts="--comp-flags extension"
1189 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1190 [ $found -eq 1 ] || error "Write: second component not found"
1192 found=$($LFS find -z 64M $comp_file | wc -l)
1193 [ $found -eq 1 ] || error "component not found by ext size"
1195 found=$($LFS find --extension-size +63M $comp_file | wc -l)
1196 [ $found -eq 1 ] || error "component not found by +ext size"
1198 found=$($LFS find --ext-size -65M $comp_file | wc -l)
1199 [ $found -eq 1 ] || error "component not found by -ext size"
1201 found=$($LFS find -z 65M $comp_file | wc -l)
1202 [ $found -eq 0 ] || error "component found by wrong ext size"
1204 found=$($LFS find -z +65M $comp_file | wc -l)
1205 [ $found -eq 0 ] || error "component found by wrong +ext size"
1207 found=$($LFS find -z -63M $comp_file | wc -l)
1208 [ $found -eq 0 ] || error "component found by wrong -ext size"
1210 found=$($LFS find ! -z 64M $comp_file | wc -l)
1211 [ $found -eq 0 ] || error "component found by negation of ext size"
1213 found=$($LFS find ! -z +63M $comp_file | wc -l)
1214 [ $found -eq 0 ] || error "component found by negation of +ext size"
1216 found=$($LFS find ! -z -65M $comp_file | wc -l)
1217 [ $found -eq 0 ] || error "component found by negation of -ext size"
1219 found=$($LFS find ! -z 65M $comp_file | wc -l)
1221 error "component not found by negation of wrong ext size"
1223 found=$($LFS find ! -z +65M $comp_file | wc -l)
1225 error "component not found by negation of wrong +ext size"
1227 found=$($LFS find ! -z -63M $comp_file | wc -l)
1229 error "component not found by negation of wrong -ext size"
1231 found=$($LFS find -S +1M $comp_file | wc -l)
1232 [ $found -eq 0 ] || error "component found by wrong +stripe size"
1234 found=$($LFS find -c 1 $comp_file | wc -l)
1235 [ $found -eq 1 ] || error "component not found by stripe count"
1237 small_write $comp_file $rw_len || error "Verify RW failed"
1239 sel_layout_sanity $comp_file 2
1242 # Self-extending PFL tests
1244 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1245 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1246 skip "skipped for lustre < $SEL_VER"
1248 test19_io_base $DIR/$tdir/$tfile
1250 run_test 19a "Simple test of extension behavior"
1252 # Same as 19a, but with default layout set on directory rather than on file
1254 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1255 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1256 skip "skipped for lustre < $SEL_VER"
1258 local comp_file=$DIR/$tdir/$tfile
1259 local comp_dir=$DIR/$tdir/$tdir
1263 test_mkdir -p $DIR/$tdir
1264 $LFS setstripe --ext-size 64M -c 1 -E -1 $DIR/$tdir ||
1265 error "Setstripe on $DIR/$tdir failed"
1267 # check inheritance for a sub-dir and a file
1268 test_mkdir $comp_dir
1269 found=$($LFS find --comp-start 0 -E 64M $comp_dir | wc -l)
1270 [ $found -eq 1 ] || error "Dir Inheritance: wrong first component size"
1272 flg_opts="--comp-flags extension"
1273 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_dir | wc -l)
1274 [ $found -eq 1 ] || error "Dir Inheritance: Second component not found"
1278 flg_opts="--comp-flags init"
1279 found=$($LFS find --comp-start 0 -E 64M $flg_opts $comp_file | wc -l)
1280 [ $found -eq 1 ] || error "File Inheritance: wrong first component size"
1282 flg_opts="--comp-flags extension"
1283 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_file | wc -l)
1284 [ $found -eq 1 ] || error "File Inheritance: Second component not found"
1286 test19_io_base $comp_file 1
1288 run_test 19b "Simple test of SEL as default layout"
1290 # Test behavior when seeking deep in a file
1292 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1293 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1294 skip "skipped for lustre < $SEL_VER"
1296 local comp_file=$DIR/$tdir/$tfile
1300 test_mkdir -p $DIR/$tdir
1302 $LFS setstripe -z 128M -E 1G -E -1 $comp_file ||
1303 error "Create $comp_file failed"
1305 # write past end of first component, so it is extended
1306 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 conv=notrunc ||
1307 error "dd to extend failed"
1309 flg_opts="--comp-flags init"
1310 found=$($LFS find --comp-start 0M -E 256M $flg_opts $comp_file | wc -l)
1311 [ $found -eq 1 ] || error "Write: first extension component not found"
1313 flg_opts="--comp-flags extension,^init"
1314 found=$($LFS find --comp-start 256M -E 1024M $flg_opts $comp_file |\
1316 [ $found -eq 1 ] || error "Write: second extension component not found"
1318 local end_1=$($LFS getstripe -I1 -E $comp_file)
1321 [ $end_1 -eq 268435456 ] ||
1322 error "end of first component $end_1 != 268435456"
1324 # Write past end of extension space component, in to normal component
1325 # should exhaust & remove extension component
1326 dd if=/dev/zero bs=1M count=1 seek=1100 of=$comp_file conv=notrunc ||
1327 error "dd distant seek failed"
1329 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1330 # the last component index is 3
1331 local ost_idx2=$($LFS getstripe -I3 -i $comp_file)
1333 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1335 local start1=$($LFS getstripe -I1 --comp-start $comp_file)
1336 local end1=$($LFS getstripe -I1 -E $comp_file)
1337 local start2=$($LFS getstripe -I3 --comp-start $comp_file)
1338 local end2=$($LFS getstripe -I3 -E $comp_file)
1340 [ $start1 -eq 0 ] || error "start of first component incorrect"
1341 [ $end1 -eq 1073741824 ] || error "end of first component incorrect"
1342 [ $start2 -eq 1073741824 ] ||
1343 error "start of second component incorrect"
1344 [ "$end2" = "EOF" ] || error "end of second component incorrect"
1346 flg_opts="--comp-flags extension"
1347 found=$($LFS find $flg_opts $comp_file | wc -l)
1348 [ $found -eq 0 ] || error "Seek Write: extension component exists"
1350 sel_layout_sanity $comp_file 2
1352 run_test 19c "Test self-extending layout seeking behavior"
1355 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1356 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1357 skip "skipped for lustre < $SEL_VER"
1359 local comp_file=$DIR/$tdir/$tfile
1363 test_mkdir -p $DIR/$tdir
1365 $LFS setstripe -E 128M -c 1 -z 64M -E -1 $comp_file ||
1366 error "Create $comp_file failed"
1368 # This will cause component 1 to be extended to 128M, then the
1369 # extension space component will be removed
1370 dd if=/dev/zero of=$comp_file bs=130M count=1 ||
1371 error "dd to extend failed"
1373 flg_opts="--comp-flags init"
1374 found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file | wc -l)
1375 [ $found -eq 1 ] || error "Write: first component not found"
1377 flg_opts="--comp-flags init"
1378 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1379 [ $found -eq 1 ] || error "Write: second component not found"
1381 sel_layout_sanity $comp_file 2
1383 # always remove large files in case of DO_CLEANUP=false
1384 rm -f $comp_file || error "Delete $comp_file failed"
1386 run_test 19d "Test write which completely spans extension space component"
1391 local comp2_flags=$($LFS getstripe -I2 --comp-flags $comp_file)
1392 local comp3_flags=$($LFS getstripe -I3 --comp-flags $comp_file)
1394 [ "$comp2_flags" != "init" ] && error "$comp2_flags != init"
1395 [ "$comp3_flags" != "extension" ] && error "$comp3_flags != extension"
1397 local flg_opts=" --comp-start 2M -E 66M --comp-flags init"
1398 local found=$($LFS find $flg_opts $comp_file | wc -l)
1399 [ $found -eq 1 ] || error "Write: extended second component not found"
1401 flg_opts="--comp-start 66M -E EOF --comp-flags extension"
1402 found=$($LFS find $flg_opts $comp_file | wc -l)
1403 [ $found -eq 1 ] || error "Write: third component not found"
1405 sel_layout_sanity $comp_file 3
1409 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1410 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1411 skip "skipped for lustre < $SEL_VER"
1413 local comp_file=$DIR/$tdir/$tfile
1414 local rw_len=$((3 * 1024 * 1024)) # 3M
1418 test_mkdir -p $DIR/$tdir
1420 $LFS setstripe -E 2m -E -1 -z 64M $comp_file ||
1421 error "Create $comp_file failed"
1423 replay_barrier $SINGLEMDS
1425 #instantiate & extend second component
1426 dd if=/dev/zero of=$comp_file bs=4M count=1 ||
1427 error "dd to extend failed"
1429 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1430 local ost_idx3=$($LFS getstripe -I3 -i $comp_file)
1432 [ $ost_idx2 -eq $ost_idx3 ] && error "$ost_idx2 == $ost_idx3"
1433 [ $ost_idx3 -ne "-1" ] && error "third component init $ost_idx3"
1435 test_19e_check $comp_file
1437 local f1=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1438 echo "before MDS recovery, the ost fid of 2nd component is $f1"
1442 local f2=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1443 echo "after MDS recovery, the ost fid of 2nd component is $f2"
1444 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
1446 # simply repeat all previous checks, but also verify components are on
1447 # the same OST as before
1449 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1450 local ost_idx3_2=$($LFS getstripe -I3 -i $comp_file)
1452 [ $ost_idx2_2 -eq $ost_idx3_2 ] && error "$ost_idx2_2 == $ost_idx3_2"
1453 [ $ost_idx3_2 -ne "-1" ] && error "second component init $ost_idx3_2"
1455 # verify OST id is the same after failover
1456 [ $ost_idx2 -ne $ost_idx2_2 ] &&
1457 error "$ost_idx2 != $ost_idx2_2, changed after failover"
1459 test_19e_check $comp_file
1461 run_test 19e "Replay of layout instantiation & extension"
1464 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1465 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1466 skip "skipped for lustre < $SEL_VER"
1468 local comp_file=$DIR/$tdir/$tfile
1472 test_mkdir -p $DIR/$tdir
1474 $LFS setstripe -E 256M --comp-flags extension -E -1 $comp_file
1476 [ $? != 0 ] || error "should not be able to manually set extension flag"
1479 run_test 19f "Rejection of invalid layouts"
1482 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1483 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1484 skip "skipped for lustre < $SEL_VER"
1486 local file1=$DIR/${tfile}-1
1487 local file2=$DIR/${tfile}-2
1489 test_mkdir -p $DIR/$tdir
1490 multiop $file1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1491 error "create failed $file1"
1492 multiop $file2 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1493 error "create failed $file2"
1495 $LFS setstripe --component-add -E 1G -c 1 $file1 ||
1496 error "comp-add [0,1G] failed $file1"
1497 $LFS setstripe --component-add -E 512M -z 128M $file1 &&
1498 error "comp-add [1G,1G],SEL[1G,512M] succeded $file1"
1499 $LFS setstripe --component-add -E 10G -z 128M $file1 ||
1500 error "comp-add [1G,1G],SEL[1G,10G] failed $file1"
1501 $LFS setstripe --component-add -E -1 $file1 ||
1502 error "comp-add [10G,-1] failed $file1"
1504 $LFS setstripe --component-add -E 1G -z 32M -c 1 $file2 &&
1505 error "comp-add with smal ext size succeeded $file1"
1506 $LFS setstripe --component-add -E 1G -z 100M -c 1 $file2 &&
1507 error "comp-add with not aligned ext size succeeded $file1"
1508 $LFS setstripe --component-add -E 1G -z 128M -c 1 $file2 ||
1509 error "comp-add [0,128M],SEL[128M,1G] failed $file1"
1510 $LFS setstripe --component-add -E 10G $file2 ||
1511 error "comp-add [1G,10G] failed $file1"
1512 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 ||
1513 error "comp-add [10G,10G],SEL[10G,-1] failed $file1"
1514 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 &&
1515 error "repeated comp-add [10G,10G],SEL[10G,-1] succeeded $file1"
1517 $LFS getstripe $file1
1518 flg_opts="--comp-flags init"
1519 found=$($LFS find --comp-start 0 -E 1G $flg_opts $file1 | wc -l)
1520 [ $found -eq 1 ] || error "First component not found $file1"
1522 flg_opts="--comp-flags ^init"
1523 found=$($LFS find --comp-start 1G -E 1G $flg_opts $file1 | wc -l)
1524 [ $found -eq 1 ] || error "Second component not found $file1"
1526 flg_opts="--comp-flags ^init,extension"
1527 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file1 | wc -l)
1528 [ $found -eq 1 ] || error "Third component not found $file1"
1530 flg_opts="--comp-flags ^init"
1531 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file1 | wc -l)
1532 [ $found -eq 1 ] || error "Fourth component not found $file1"
1534 $LFS getstripe $file2
1535 flg_opts="--comp-flags init"
1536 found=$($LFS find --comp-start 0 -E 128M $flg_opts $file2 | wc -l)
1537 [ $found -eq 1 ] || error "First component not found $file2"
1539 flg_opts="--comp-flags extension"
1540 found=$($LFS find --comp-start 128M -E 1G $flg_opts $file2 | wc -l)
1541 [ $found -eq 1 ] || error "Second component not found $file2"
1543 flg_opts="--comp-flags ^init"
1544 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file2 | wc -l)
1545 [ $found -eq 1 ] || error "Third component not found $file2"
1547 flg_opts="--comp-flags ^init"
1548 found=$($LFS find --comp-start 10G -E 10G $flg_opts $file2 | wc -l)
1549 [ $found -eq 1 ] || error "Fourth component not found $file2"
1551 flg_opts="--comp-flags ^init,extension"
1552 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file2 | wc -l)
1553 [ $found -eq 1 ] || error "Fifth component not found $file2"
1555 run_test 19g "component-add behaviour"
1557 # Test out of space behavior
1559 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1560 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1561 skip "skipped for lustre < $SEL_VER"
1563 local comp_file=$DIR/$tdir/$tfile
1567 test_mkdir -p $DIR/$tdir
1569 # without this, a previous delete can finish after we check free space
1570 wait_delete_completed
1573 # First component is on OST0
1574 $LFS setstripe -E 256M -i 0 -z 64M -E -1 -z 128M $comp_file ||
1575 error "Create $comp_file failed"
1577 # write past end of first component, so it is extended
1578 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=66 ||
1579 error "dd to extend failed"
1581 flg_opts="--comp-flags extension"
1582 found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file |wc -l)
1583 [ $found -eq 1 ] || error "Write: Second component not found"
1585 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1586 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1588 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1590 flg_opts="--comp-flags extension"
1591 # Write past current init comp, but we won't extend (because no space)
1592 dd if=/dev/zero of=$comp_file bs=1M count=10 seek=200 ||
1593 error "dd write past current comp failed"
1595 $LFS getstripe $comp_file
1597 flg_opts="--comp-flags init"
1598 found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file | \
1600 [ $found -eq 1 ] || error "Write: third component not found"
1602 flg_opts="--comp-flags extension"
1603 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file |wc -l)
1604 [ $found -eq 1 ] || error "Write: fourth extension component not found"
1606 sel_layout_sanity $comp_file 3
1608 run_test 20a "Test out of space, spillover to defined component"
1611 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1612 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1613 skip "skipped for lustre < $SEL_VER"
1615 local comp_file=$DIR/$tdir/$tfile
1619 test_mkdir -p $DIR/$tdir
1621 # Pool allows us to force use of only certain OSTs
1622 pool_add $TESTNAME || error "Pool creation failed"
1623 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1625 # normal component to 10M, extendable component to 1G
1626 # further extendable to EOF
1627 $LFS setstripe -E 10M -E 1G -p $TESTNAME -z 64M -E -1 -p "" -z 128M \
1628 $comp_file || error "Create $comp_file failed"
1630 replay_barrier $SINGLEMDS
1632 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1633 [ $found -eq 1 ] || error "Zero length component not found"
1636 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1638 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1640 # write past end of first component
1641 # This should remove the next component, since OST0 is out of space
1642 # and it is striped there (pool contains only OST0)
1643 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=14 ||
1644 error "dd to extend/remove failed"
1646 $LFS getstripe $comp_file
1648 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1649 [ $found -eq 0 ] || error "Write: zero length component still present"
1651 flg_opts="--comp-flags init"
1652 found=$($LFS find --comp-start 10M -E 138M $flg_opts $comp_file | wc -l)
1653 [ $found -eq 1 ] || error "Write: second component not found"
1655 flg_opts="--comp-flags extension"
1656 found=$($LFS find --comp-start 138M -E EOF $flg_opts $comp_file | wc -l)
1657 [ $found -eq 1 ] || error "Write: third component not found"
1661 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1662 [ $found -eq 0 ] || error "Failover: 0-length component still present"
1664 flg_opts="--comp-flags init"
1665 found=$($LFS find --comp-start 10M -E 138M $flg_opts $comp_file | wc -l)
1666 [ $found -eq 1 ] || error "Failover: second component not found"
1668 flg_opts="--comp-flags extension"
1669 found=$($LFS find --comp-start 138M -E EOF $flg_opts $comp_file | wc -l)
1670 [ $found -eq 1 ] || error "Failover: third component not found"
1672 sel_layout_sanity $comp_file 3
1674 run_test 20b "Remove component without instantiation when there is no space"
1677 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1678 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1679 skip "skipped for lustre < $SEL_VER"
1681 local comp_file=$DIR/$tdir/$tfile
1685 test_mkdir -p $DIR/$tdir
1687 # pool is used to limit available OSTs to 0 and 1, so we can set all
1688 # available OSTs out of space
1689 pool_add $TESTNAME || error "Pool creation failed"
1690 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
1692 # without this, a previous delete can finish after we check free space
1693 wait_delete_completed
1696 $LFS setstripe -E 100M -E -1 -p $TESTNAME -z 64M $comp_file ||
1697 error "Create $comp_file failed"
1701 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1703 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
1705 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1706 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
1708 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=120 &&
1709 error "dd should fail with ENOSPC"
1711 flg_opts="--comp-flags init"
1712 found=$($LFS find --comp-start 0M -E 100M $flg_opts $comp_file | wc -l)
1713 [ $found -eq 1 ] || error "Write: First component not found"
1715 flg_opts="--comp-flags ^init"
1716 found=$($LFS find --comp-start 100M -E 100M $flg_opts $comp_file |wc -l)
1717 [ $found -eq 1 ] || error "Write: 0-length component not found"
1719 flg_opts="--comp-flags extension"
1720 found=$($LFS find --comp-start 100M -E EOF $flg_opts $comp_file | wc -l)
1721 [ $found -eq 1 ] || error "Write: third extension component not found"
1723 sel_layout_sanity $comp_file 3
1725 run_test 20c "Test inability to stripe new extension component"
1728 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1729 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1730 skip "skipped for lustre < $SEL_VER"
1732 local comp_file=$DIR/$tdir/$tfile
1733 test_mkdir -p $DIR/$tdir
1735 wait_delete_completed
1738 pool_add $TESTNAME || error "Pool creation failed"
1739 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1740 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
1741 error "Create $comp_file failed"
1743 replay_barrier $SINGLEMDS
1745 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1746 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1749 ost_watermarks_clear_enospc $tfile 0 $wms
1750 [ $RC -eq 0 ] || error "dd failed: $RC"
1752 $LFS getstripe $comp_file
1753 local flg_opts="--comp-start 64M -E 128M --comp-flags init"
1754 local found=$($LFS find $flg_opts $comp_file | wc -l)
1755 [ $found -eq 1 ] || error "Write: component (64M-128M) not found"
1757 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
1758 [ "$ost_idx" != "-1" ] && error "Write: EXT component disappeared"
1762 found=$($LFS find $flg_opts $comp_file | wc -l)
1763 [ $found -eq 1 ] || error "Failover: component (64M-128M) not found"
1765 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1766 [ "$ost_idx" != "-1" ] && error "Failover: EXT component disappeared"
1768 sel_layout_sanity $comp_file 3
1770 run_test 20d "Low on space + 0-length comp: force extension"
1773 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1774 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1775 skip "skipped for lustre < $SEL_VER"
1777 local comp_file=$DIR/$tdir/$tfile
1778 test_mkdir -p $DIR/$tdir
1780 wait_delete_completed
1783 pool_add $TESTNAME || error "Pool creation failed"
1784 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1786 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
1787 error "Create $comp_file failed"
1789 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1791 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1794 ost_watermarks_clear_enospc $tfile 0 $wms
1795 [ $RC -eq 0 ] || error "dd failed $RC"
1797 $LFS getstripe $comp_file
1798 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
1799 local found=$($LFS find $flg_opts $comp_file | wc -l)
1800 [ $found -eq 1 ] || error "Write: component (64M-EOF) not found"
1802 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
1803 [ "$ost_idx" != "" ] && error "Write: 0-length component still exists"
1804 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1805 [ "$ost_idx" != "" ] && error "Write: extension component still exists"
1807 sel_layout_sanity $comp_file 2
1809 run_test 20e "ENOSPC with next real comp: spillover and backward extension"
1811 # Simple DoM interaction test
1813 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1814 skip "skipped for lustre < $SEL_VER"
1816 local comp_file=$DIR/$tdir/$tfile
1820 test_mkdir -p $DIR/$tdir
1822 # simple, correct self-extending layout after DoM component
1823 $LFS setstripe -E 1M -L mdt -E -1 -z 64m $comp_file || \
1824 error "Create $comp_file failed"
1826 # Write to DoM component & to self-extending comp after it
1827 dd if=/dev/zero bs=1M count=12 of=$comp_file ||
1828 error "dd to extend failed"
1830 flg_opts="--comp-flags init"
1831 found=$($LFS find --comp-start 1M -E 65M $flg_opts $comp_file | wc -l)
1832 [ $found -eq 1 ] || error "Write: extended component not found"
1834 flg_opts="--comp-flags extension"
1835 found=$($LFS find --comp-start 65M $flg_opts $comp_file | wc -l)
1836 [ $found -eq 1 ] || error "Write: extension component not found"
1838 sel_layout_sanity $comp_file 3
1840 run_test 21a "Simple DoM interaction tests"
1842 # DoM + extension + removal
1844 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1845 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1846 skip "skipped for lustre < $SEL_VER"
1848 local comp_file=$DIR/$tdir/$tfile
1849 local ost_name=$(ostname_from_index 0)
1853 test_mkdir -p $DIR/$tdir
1855 # DoM, extendable component, further extendable component
1856 $LFS setstripe -E 1M -L mdt -E 256M -i 0 -z 64M -E -1 -z 128M \
1857 $comp_file || error "Create $comp_file failed"
1859 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1860 [ $found -eq 1 ] || error "Write: Zero length component not found"
1862 # This also demonstrates that we will avoid degraded OSTs
1863 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
1864 # sleep to guarantee we see the degradation
1867 # un-degrade on exit
1868 stack_trap "do_facet ost1 $LCTL set_param -n \
1869 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1871 # This should remove the first component after DoM and spill over to
1873 dd if=/dev/zero bs=1M count=2 of=$comp_file ||
1874 error "dd to remove+spill over failed"
1876 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1877 [ $found -eq 0 ] || error "Write: Zero length component still present"
1879 flg_opts="--comp-flags init"
1880 found=$($LFS find --comp-start 1M -E 129M $flg_opts $comp_file | wc -l)
1881 [ $found -eq 1 ] || error "Write: extended component not found"
1883 flg_opts="--comp-flags extension"
1884 found=$($LFS find --comp-start 129M -E EOF $flg_opts $comp_file |wc -l)
1885 [ $found -eq 1 ] || error "Write: extension component not found"
1887 sel_layout_sanity $comp_file 3
1889 run_test 21b "DoM followed by extendable component with removal"
1891 # Test of repeat component behavior with OOS/degraded OST
1893 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1894 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1895 skip "skipped for lustre < $SEL_VER"
1897 local comp_file=$DIR/$tdir/$tfile
1901 test_mkdir -p $DIR/$tdir
1903 $LFS setstripe -E -1 -c 1 -z 128M $comp_file ||
1904 error "Create $comp_file failed"
1906 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1907 local ost_name=$(ostname_from_index $ost_idx1)
1909 # write past end of first component, so it is extended
1910 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
1911 error "dd to extend failed"
1913 flg_opts="--comp-flags extension"
1914 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
1915 [ $found -eq 1 ] || error "Write: second component not found"
1917 # degrade OST for component 1
1918 do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
1919 obdfilter.$ost_name.degraded=1
1920 # sleep to guarantee we see the degradation
1923 # un-degrade on exit
1924 stack_trap "do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
1925 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1927 replay_barrier $SINGLEMDS
1929 # seek past the end of current comp & write, should cause a new comp
1930 # to be created (ie repeat previous comp)
1931 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
1932 error "dd to repeat failed"
1934 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1936 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1938 flg_opts="--comp-flags init"
1939 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1940 [ $found -eq 1 ] || error "Write: second component not found"
1942 flg_opts="--comp-flags extension"
1943 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1944 [ $found -eq 1 ] || error "Write: extension component not found"
1948 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1949 [ $ost_idx2_2 -ne $ost_idx2 ] && error "$ost_idx2_2 != $ost_idx2"
1951 flg_opts="--comp-flags init"
1952 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1953 [ $found -eq 1 ] || error "Failover: second component not found"
1955 flg_opts="--comp-flags extension"
1956 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1957 [ $found -eq 1 ] || error "Failover: extension component not found"
1959 sel_layout_sanity $comp_file 3
1961 run_test 22a "Test repeat component behavior with degraded OST"
1963 # Test repeat behavior with low space
1965 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1966 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1967 skip "skipped for lustre < $SEL_VER"
1969 local comp_file=$DIR/$tdir/$tfile
1973 test_mkdir -p $DIR/$tdir
1975 # without this, a previous delete can finish after we check free space
1976 wait_delete_completed
1979 $LFS setstripe -E -1 -c 1 -z 128M \
1980 $comp_file || error "Create $comp_file failed"
1982 # write past end of first component, so it is extended
1983 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
1984 error "dd to extend failed"
1986 flg_opts="--comp-flags extension"
1987 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
1988 [ $found -eq 1 ] || error "Write: Second component not found"
1990 # set our OST low on space
1991 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1992 local wms=$(ost_watermarks_set_low_space $ost_idx1 | grep "watermarks")
1994 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1996 # Write past end of current space, fail to extend, causing repeat
1997 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
1998 error "dd to repeat failed"
2000 $LFS getstripe $comp_file
2002 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
2004 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
2006 flg_opts="--comp-flags init"
2007 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
2008 [ $found -eq 1 ] || error "Write: Second component not found"
2010 flg_opts="--comp-flags extension"
2011 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
2012 [ $found -eq 1 ] || error "Write: Extension component not found"
2014 sel_layout_sanity $comp_file 3
2016 run_test 22b "Test simple 'out of space' condition with repeat"
2018 # This tests both "repeat" and "extend in place when repeat fails" aspects
2019 # of repeating components
2021 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2022 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2023 skip "skipped for lustre < $SEL_VER"
2025 local comp_file=$DIR/$tdir/$tfile
2029 test_mkdir -p $DIR/$tdir
2031 # pool is used to limit available OSTs to 0 and 1, so we can set all
2032 # available OSTs out of space
2033 pool_add $TESTNAME || error "Pool creation failed"
2034 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
2036 # without this, a previous delete can finish after we check free space
2037 wait_delete_completed
2040 $LFS setstripe -E -1 -z 64M -c 1 -p "$TESTNAME" $comp_file || \
2041 error "Create $comp_file failed"
2043 # write past end of first component, so it is extended
2044 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=80 conv=notrunc ||
2045 error "dd to extend failed"
2047 $LFS getstripe $comp_file
2049 flg_opts="--comp-flags extension"
2050 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
2051 [ $found -eq 1 ] || error "Write: second component not found"
2053 # set our OST out of space
2054 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
2055 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
2057 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
2059 # This should create a repeat component on a new OST
2060 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=180 conv=notrunc ||
2061 error "dd to repeat failed"
2063 $LFS getstripe $comp_file
2065 local comp_cnt=$($LFS getstripe --component-count $comp_file)
2066 [ $comp_cnt -ne 3 ] && error "component count: $comp_cnt, should be 3"
2068 # New second component should be on a different OST
2069 local ost_idx2=$($LFS getstripe --comp-start=128m \
2070 --comp-end=192m --comp-flags=init -i $comp_file)
2072 [ $ost_idx1 -eq $ost_idx2 ] && error "2nd comp: same OST $ost_idx1"
2074 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
2076 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
2078 # now that the second OST is out of space (as is the first OST), we
2079 # attempt to extend. This should result in an extension of the
2080 # existing component, rather than a new component.
2081 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=240 conv=notrunc ||
2082 error "dd for forced extension failed"
2084 $LFS getstripe $comp_file
2086 # clear out of space on first OST
2087 ost_watermarks_clear_enospc $tfile $ost_idx1 $wms
2089 # finally, now that the first OST has space again, we attempt to
2090 # extend one last time. This should create a new component on the
2092 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 conv=notrunc ||
2093 error "dd for repeat on first OST failed"
2095 $LFS getstripe $comp_file
2097 flg_opts="--comp-flags init"
2098 found=$($LFS find --comp-start 128M $flg_opts $comp_file | wc -l)
2099 [ $found -eq 1 ] || error "Write: second component not found"
2101 flg_opts="--comp-flags init"
2102 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
2103 [ $found -eq 1 ] || error "Write: third component not found"
2105 flg_opts="--comp-flags extension"
2106 found=$($LFS find --comp-start 320M -E EOF $flg_opts $comp_file | wc -l)
2107 [ $found -eq 1 ] || error "Write: extension component not found"
2109 sel_layout_sanity $comp_file 4
2111 run_test 22c "Test repeat with out of space on > 1 OST"
2113 test_22d_post_check() {
2116 local flg_opts="--comp-flags init"
2117 local found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file |
2119 [ $found -eq 1 ] || {
2120 $LFS getstripe $comp_file
2121 error "$name: second component not found"
2124 flg_opts="--comp-flags extension"
2125 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
2126 [ $found -eq 1 ] || error "$name: third extension component not found"
2128 sel_layout_sanity $comp_file 2
2136 # write past end of first component
2137 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=70
2140 ost_watermarks_clear_enospc $tfile 0 $wms
2141 [ $RC -eq 0 ] || error "dd to force extend failed"
2143 test_22d_post_check $comp_file "Write"
2147 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2148 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2149 skip "skipped for lustre < $SEL_VER"
2151 local comp_file=$DIR/$tdir/$tfile
2155 test_mkdir -p $DIR/$tdir
2157 # without this, a previous delete can finish after we check free space
2158 wait_delete_completed
2161 # Pool allows us to force use of only certain OSTs
2162 pool_add $TESTNAME || error "Pool creation failed"
2163 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2165 # 1. Fail to extend due to OOS, try to repeat within the same pool,
2166 # fail to stripe (again OOS) the 0-length component, remove the
2167 # repeated one, force the extension on the original one.
2168 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2169 error "Create $comp_file failed"
2171 replay_barrier $SINGLEMDS
2173 # set our OST out of space
2174 local wms=$(ost_watermarks_set_enospc $tfile 0 | grep "watermarks")
2176 test_22d_pre $comp_file "$wms"
2178 test_22d_post_check $comp_file "Failover"
2180 # 2. repeat with low on space: 0-length repeated component will be
2181 # striped, but still fails to be extended; otherwise the same as (1).
2183 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2184 error "Create $comp_file failed"
2186 replay_barrier $SINGLEMDS
2188 # set our OST low on space
2189 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2191 test_22d_pre $comp_file "$wms"
2193 test_22d_post_check $comp_file "Failover"
2195 run_test 22d "out of/low on space + failed to repeat + forced extension"
2198 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2199 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2200 skip "skipped for lustre < $SEL_VER"
2202 local comp_file=$DIR/$tdir/$tfile
2203 test_mkdir -p $DIR/$tdir
2205 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2206 error "Create $comp_file failed"
2208 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2209 error "dd append failed"
2211 local flg_opts="--comp-start 0 -E EOF --comp-flags init"
2212 local found=$($LFS find $flg_opts $comp_file | wc -l)
2213 [ $found -eq 1 ] || error "Append: first component (0-EOF) not found"
2215 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2216 [ "$ost_idx" != "" ] && error "Append: second component still exists"
2218 sel_layout_sanity $comp_file 1
2220 run_test 23a "Append: remove EXT comp"
2223 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2224 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2225 skip "skipped for lustre < $SEL_VER"
2227 local comp_file=$DIR/$tdir/$tfile
2228 test_mkdir -p $DIR/$tdir
2230 $LFS setstripe -E 64m -E -1 -z 64M $comp_file ||
2231 error "Create $comp_file failed"
2233 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2234 error "dd append failed"
2236 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2237 local found=$($LFS find $flg_opts $comp_file | wc -l)
2238 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2240 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2241 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2243 sel_layout_sanity $comp_file 2
2245 run_test 23b "Append with 0-length comp: remove EXT comp"
2248 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2249 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2250 skip "skipped for lustre < $SEL_VER"
2252 local comp_file=$DIR/$tdir/$tfile
2253 test_mkdir -p $DIR/$tdir
2255 wait_delete_completed
2258 pool_add $TESTNAME || error "Pool creation failed"
2259 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2260 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
2261 error "Create $comp_file failed"
2263 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2264 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2267 ost_watermarks_clear_enospc $tfile 0 $wms
2268 [ $RC -eq 0 ] || error "dd append failed: $RC"
2270 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2271 local found=$($LFS find $flg_opts $comp_file | wc -l)
2272 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2274 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2275 [ "$ost_idx" != "" ] && error "Append: EXT component still exists"
2277 sel_layout_sanity $comp_file 2
2279 run_test 23c "Append with low on space + 0-length comp: force extension"
2282 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2283 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2284 skip "skipped for lustre < $SEL_VER"
2286 local comp_file=$DIR/$tdir/$tfile
2287 test_mkdir -p $DIR/$tdir
2289 $LFS setstripe -E 64m -E 640M -z 64M -E -1 $comp_file ||
2290 error "Create $comp_file failed"
2292 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2293 error "dd append failed"
2295 flg_opts="--comp-start 64M -E 640M --comp-flags init"
2296 found=$($LFS find $flg_opts $comp_file | wc -l)
2297 [ $found -eq 1 ] || error "Append: component (64M-640M) not found"
2299 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2300 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2302 sel_layout_sanity $comp_file 3
2304 run_test 23d "Append with 0-length comp + next real comp: remove EXT comp"
2307 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2308 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2309 skip "skipped for lustre < $SEL_VER"
2311 local comp_file=$DIR/$tdir/$tfile
2312 test_mkdir -p $DIR/$tdir
2314 wait_delete_completed
2317 pool_add $TESTNAME || error "Pool creation failed"
2318 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2320 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
2321 error "Create $comp_file failed"
2323 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2325 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2328 ost_watermarks_clear_enospc $tfile 0 $wms
2329 [ $RC -eq 0 ] || error "dd append failed $RC"
2331 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2332 local found=$($LFS find $flg_opts $comp_file | wc -l)
2333 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2335 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2336 [ "$ost_idx" != "" ] && error "Append: 0-length component still exists"
2337 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2338 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2340 sel_layout_sanity $comp_file 2
2342 run_test 23e "Append with next real comp: spillover and backward extension"
2345 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2346 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2347 skip "skipped for lustre < $SEL_VER"
2349 local comp_file=$DIR/$tdir/$tfile
2350 test_mkdir -p $DIR/$tdir
2352 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2353 error "Create $comp_file failed"
2355 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
2356 local wms=$(ost_watermarks_set_low_space $ost_idx | grep "watermarks")
2358 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2361 ost_watermarks_clear_enospc $tfile $ost_idx $wms
2362 [ $RC -eq 0 ] || error "dd append failed"
2364 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2365 local found=$($LFS find $flg_opts $comp_file | wc -l)
2366 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2368 ost_idx=$($LFS getstripe -I2 -i $comp_file)
2369 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2371 sel_layout_sanity $comp_file 2
2373 run_test 23f "Append with low on space: repeat and remove EXT comp"
2382 [ "$OSTCOUNT" -lt "3" ] && skip_env "needs >= 3 OSTs"
2384 trap cleanup_24 EXIT RETURN
2386 local file=$DIR/$tfile
2388 $LFS setstripe -E 1m -c1 -o0 -E eof -c2 -o1,2 $file ||
2389 error "setstripe on $file"
2391 dd if=/dev/zero of=$file bs=1M count=3 || error "dd failed for $file"
2394 filefrag -ves $file || error "filefrag $file failed"
2395 filefrag_op=$(filefrag -ve -k $file |
2396 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
2398 #Filesystem type is: bd00bd0
2399 #File size of /mnt/lustre/f24a.sanity-pfl is 3145728 (3072 blocks of 1024 bytes)
2400 # ext: device_logical: physical_offset: length: dev: flags:
2401 # 0: 0.. 1023: 1572864.. 1573887: 1024: 0000: net
2402 # 1: 0.. 1023: 1572864.. 1573887: 1024: 0002: net
2403 # 2: 1024.. 2047: 1573888.. 1574911: 1024: 0001: last,net
2404 #/mnt/lustre/f24a.sanity-pfl: 3 extents found
2406 last_lun=$(echo $filefrag_op | cut -d: -f5)
2411 for line in $filefrag_op; do
2412 frag_lun=$(echo $line | cut -d: -f5)
2413 ext_len=$(echo $line | cut -d: -f4)
2414 if [[ "$frag_lun" != "$last_lun" ]]; then
2415 if (( tot_len != 1024 )); then
2417 error "$file: OST$last_lun $tot_len != 1024"
2423 (( tot_len += ext_len ))
2426 if (( num_luns != 3 || tot_len != 1024 )); then
2428 error "$file: $num_luns != 3, $tot_len != 1024 on OST$last_lun"
2431 echo "FIEMAP on $file succeeded"
2433 run_test 24a "FIEMAP upon PFL file"
2436 local pfl_f=$DIR/$tdir/"$tfile"_pfl
2437 local dom_f=$DIR/$tdir/"$tfile"_dom
2438 local common_f=$DIR/$tdir/"$tfile"_common
2442 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2443 $LFS setstripe -E 10M -S 64k -c -1 -E 20M -S 1M -E -1 -S 2M -c 1 \
2444 $pfl_f || error "setstripe $pfl_f failed"
2445 $LFS setstripe -E 256k -L mdt -E -1 -S 1M $dom_f ||
2446 error "setstripe $dom_f failed"
2447 $LFS setstripe -S 512K -c -1 $common_f ||
2448 error "setstripe $common_f failed"
2450 #verify lov_getstripe_old with PFL file
2451 stripe_count=$(lov_getstripe_old $pfl_f |
2452 awk '/stripe_count/ { print $2 }')
2453 stripe_size=$(lov_getstripe_old $pfl_f |
2454 awk '/stripe_size/ { print $2 }')
2455 [ $stripe_count -eq 1 ] ||
2456 error "stripe_count $stripe_count !=1 for $pfl_f"
2457 [ $stripe_size -eq 2097152 ] ||
2458 error "stripe_size $stripe_size != 2097152 for $pfl_f"
2460 #verify lov_getstripe_old with DoM file
2461 stripe_count=$(lov_getstripe_old $dom_f |
2462 awk '/stripe_count/ { print $2 }')
2463 stripe_size=$(lov_getstripe_old $dom_f |
2464 awk '/stripe_size/ { print $2 }')
2465 [ $stripe_count -eq 1 ] ||
2466 error "stripe_count $stripe_count !=1 for $dom_f"
2467 [ $stripe_size -eq 1048576 ] ||
2468 error "stripe_size $stripe_size != 1048576 for $dom_f"
2470 #verify lov_getstripe_old with common file
2471 stripe_count=$(lov_getstripe_old $common_f |
2472 awk '/stripe_count/ { print $2 }')
2473 stripe_size=$(lov_getstripe_old $common_f |
2474 awk '/stripe_size/ { print $2 }')
2475 [ $stripe_count -eq $OSTCOUNT ] ||
2476 error "stripe_count $stripe_count !=$OSTCOUNT for $common_f"
2477 [ $stripe_size -eq 524288 ] ||
2478 error "stripe_size $stripe_size != 524288 for $common_f"
2480 run_test 25 "Verify old lov stripe API with PFL files"
2483 check_and_cleanup_lustre