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"
137 # Create parent directory
140 # Component end must be a multiple of stripe size
141 # and a multiple of 64KiB to align with the minimum
143 # Values below 4096 are assumed to be in KiB units.
144 $LFS setstripe -E 127 $tf-1 > /dev/null 2>&1 &&
145 error "creating $tf-1 with '-E 127' should fail"
147 $LFS setstripe -E 128 -S 512 $tf-1 > /dev/null 2>&1 &&
148 error "creating $tf-1 with '-E 128 -S 512' should fail"
150 $LFS setstripe -E 128 $tf-1 ||
151 error "creating $tf-1 failed"
153 yes | dd bs=1K count=129 iflag=fullblock of=$tf-1 &&
154 error "writing to $tf-1 should fail"
156 yes | dd bs=1K count=128 iflag=fullblock of=$tf-1 ||
157 error "writing to $tf-1 failed"
159 comp_end=$($LFS getstripe -I1 -E $tf-1)
160 stripe_size=$($LFS getstripe -I1 -S $tf-1)
162 [[ $comp_end == $((128 * 1024)) ]] ||
163 error "incorrect component end '$comp_end' for $tf-1"
165 [[ $stripe_size == $((128 * 1024)) ]] ||
166 error "incorrect stripe size '$stripe_size' for $tf-1"
168 rm $tf-1 || error "removing $tf-1 failed"
170 # The stripe size must be a multiple of 64KiB.
171 # Values below 4096 are assumed to be in KiB units.
172 $LFS setstripe -E -1 -S 2047 $tf-2 > /dev/null 2>&1 &&
173 error "creating $tf-2 with '-S 2047' should fail"
175 $LFS setstripe -E -1 -S 2048 $tf-2 ||
176 error "creating $tf-2 failed"
178 stripe_size=$($LFS getstripe -I1 -S $tf-2)
179 [[ $stripe_size == $((2048 * 1024)) ]] ||
180 error "incorrect stripe size '$stripe_size' for $tf-2"
182 rm $tf-2 || error "removing $tf-2 failed"
184 run_test 0d "Verify comp end and stripe size"
187 local comp_file=$DIR/$tdir/$tfile
188 local rw_len=$((3 * 1024 * 1024)) # 3M
190 test_mkdir $DIR/$tdir
193 $LFS setstripe -E 1m -S 1m -o 0 -E -1 -o 0 $comp_file ||
194 error "Create $comp_file failed"
196 #instantiate all components, so that objs are allocted
197 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
199 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
200 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
202 [ $ost_idx1 -ne $ost_idx2 ] && error "$ost_idx1 != $ost_idx2"
204 small_write $comp_file $rw_len || error "Verify RW failed"
206 rm -f $comp_file || error "Delete $comp_file failed"
208 run_test 1a "Create full components file, reused OSTs"
210 # test overstriping (>1 stripe/OST within a component)
212 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
213 [[ $($LCTL get_param mdc.*.import |
214 grep "connect_flags:.*overstriping") ]] ||
215 skip "server does not support overstriping"
217 local comp_file=$DIR/$tdir/$tfile
218 local rw_len=$((3 * 1024 * 1024)) # 3M
220 test_mkdir $DIR/$tdir
222 $LFS setstripe -E 1m -S 1m -o 0,0 -E -1 -o 1,1,0,0 $comp_file ||
223 error "Create $comp_file failed"
225 #instantiate all components, so that objs are allocted
226 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=1M
228 $LFS getstripe $comp_file
229 local OSTS_1=$($LFS getstripe -I1 $comp_file | grep -o 'l_ost_idx.*' |
230 awk -e '{print $2}' | tr "\n" "\0")
231 local OSTS_2=$($LFS getstripe -I2 $comp_file | grep -o 'l_ost_idx.*' |
232 awk -e '{print $2}' | tr "\n" "\0")
236 [ "$OSTS_1" = "0,0," ] || error "incorrect OSTs($OSTS_1) in component 1"
237 [ "$OSTS_2" = "1,1,0,0," ] ||
238 error "incorrect OSTs($OSTS_2) in component 2"
240 small_write $comp_file $rw_len || error "Verify RW failed"
242 rm -f $comp_file || error "Delete $comp_file failed"
244 run_test 1b "Create full components file, overstriping in components"
246 # test overstriping with max stripe count
248 [[ $($LCTL get_param mdc.*.import |
249 grep "connect_flags:.*overstriping") ]] ||
250 skip "server does not support overstriping"
251 large_xattr_enabled || skip_env "no large xattr support"
253 local comp_file=$DIR/$tdir/$tfile
254 local rw_len=$((3 * 1024 * 1024)) # 3M
256 test_mkdir $DIR/$tdir
258 $LFS setstripe -E 1m -C 10 -E 10M -C 100 -E -1 \
259 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
260 error "Create $comp_file failed"
262 # Seek & write in to last component so all objects are allocated
263 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=20000
265 local count=$($LFS getstripe -c -I1 $DIR/$tdir/$tfile)
266 [ $count -eq 10 ] || error "comp1 stripe count $count, should be 10"
267 count=$($LFS getstripe -c -I2 $DIR/$tdir/$tfile)
268 [ $count -eq 100 ] || error "comp2 stripe count $count, should be 100"
269 count=$($LFS getstripe -c -I3 $DIR/$tdir/$tfile)
270 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
271 error "comp4 stripe count $count != $LOV_MAX_STRIPE_COUNT"
273 small_write $comp_file $rw_len || error "Verify RW failed"
275 rm -f $comp_file || error "Delete $comp_file failed"
277 run_test 1c "Test overstriping w/max stripe count"
280 local comp_file=$DIR/$tdir/$tfile
281 local rw_len=$((5 * 1024 * 1024)) # 5M
284 test_mkdir $DIR/$tdir
287 multiop $comp_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
288 error "create failed $comp_file"
290 $LFS setstripe --component-add $params $comp_file ||
291 error "Add component to $comp_file failed"
293 check_component_count $comp_file 1
295 dd if=/dev/zero of=$comp_file bs=1M count=1 > /dev/null 2>&1 ||
296 error "Write first component failed"
297 dd if=$comp_file of=/dev/null bs=1M count=1 > /dev/null 2>&1 ||
298 error "Read first component failed"
300 dd if=/dev/zero of=$comp_file bs=1M count=2 > /dev/null 2>&1 &&
301 error "Write beyond component should fail"
302 dd if=$comp_file of=/dev/null bs=1M count=2 > /dev/null 2>&1 ||
303 error "Read beyond component should short read, not fail"
305 $LFS setstripe --component-add -E 2M -S 1M -c 1 $comp_file ||
306 error "Add component to $comp_file failed"
308 check_component_count $comp_file 2
310 $LFS setstripe --component-add -E -1 -c 3 $comp_file ||
311 error "Add last component to $comp_file failed"
313 check_component_count $comp_file 3
315 small_write $comp_file $rw_len || error "Verify RW failed"
317 rm -f $comp_file || error "Delete $comp_file failed"
321 base_test_2 "-E 1m -S 1m"
323 run_test 2a "Add components to existing file"
326 base_test_2 "-E 1m -L mdt"
328 run_test 2b "Add components w/DOM to existing file"
330 del_comp_and_verify() {
337 if [ $id == "init" -o $id == "^init" ]; then
338 opt="--component-flags="
341 $LFS setstripe --component-del $opt$id $comp_file ||
342 error "Delete component $id from $comp_file failed"
344 local comp_cnt=$($LFS getstripe --component-count $comp_file)
345 if grep -q "has no stripe info" <<< "$comp_cnt" ; then
348 [ $comp_cnt -ne $left ] && error "$comp_cnt != $left"
350 $CHECKSTAT -s $size $comp_file || error "size != $size"
354 local comp_file=$DIR/$tdir/$tfile
357 test_mkdir $DIR/$tdir
360 $LFS setstripe $params $comp_file || error "Create $comp_file failed"
362 check_component_count $comp_file 3
364 dd if=/dev/zero of=$comp_file bs=1M count=2
366 $LFS setstripe --component-del -I 2 $comp_file &&
367 error "Component deletion makes hole"
369 del_comp_and_verify $comp_file 3 2 $((2 * 1024 * 1024))
370 del_comp_and_verify $comp_file 2 1 $((1 * 1024 * 1024))
371 del_comp_and_verify $comp_file 1 0 0
373 rm -f $comp_file || error "Delete $comp_file failed"
375 $LFS setstripe -E 1M -S 1M -E 16M -E -1 $comp_file ||
376 error "Create second $comp_file failed"
378 del_comp_and_verify $comp_file "^init" 1 0
379 del_comp_and_verify $comp_file "init" 0 0
380 rm -f $comp_file || error "Delete second $comp_file failed"
384 base_test_3 "-E 1M -S 1M -E 64M -c 2 -E -1 -c 3"
386 run_test 3a "Delete components from existing file"
389 base_test_3 "-E 1M -L mdt -E 64M -S 1M -c 2 -E -1 -c 3"
391 run_test 3b "Delete components w/DOM from existing file"
394 skip "Not supported in PFL"
395 # In PFL project, only LCME_FL_INIT is supported, and it can't
396 # be altered by application.
398 run_test 4 "Modify component flags in existing file"
401 local parent=$DIR/$tdir
402 local comp_file=$DIR/$tdir/$tfile
403 local subdir=$parent/subdir
408 # set default layout to parent directory
409 $LFS setstripe -E 64M -c 2 -i 0 -E -1 -c 4 -i 0 $parent ||
410 error "Set default layout to $parent failed"
412 # create file under parent
413 touch $comp_file || error "Create $comp_file failed"
414 check_component_count $comp_file 2
416 #instantiate all components, so that objs are allocted
417 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=65k
419 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
420 [ $ost_idx -ne 0 ] &&
421 error "component 1 ost_idx $ost_idx != 0"
423 ost_idx=$($LFS getstripe -I2 -i $comp_file)
424 [ $ost_idx -ne 0 ] &&
425 error "component 2 ost_idx $ost_idx != 0"
427 # create subdir under parent
428 mkdir -p $subdir || error "Create subdir $subdir failed"
430 comp_cnt=$($LFS getstripe -d --component-count $subdir)
431 [ $comp_cnt -ne 2 ] && error "subdir $comp_cnt != 2"
433 # create file under subdir
434 touch $subdir/$tfile || error "Create $subdir/$tfile failed"
436 check_component_count $subdir/$tfile 2
438 # delete default layout setting from parent
439 $LFS setstripe -d $parent ||
440 error "Delete default layout from $parent failed"
442 comp_cnt=$($LFS getstripe -d --component-count $parent)
443 [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0"
445 rm -f $comp_file || error "Delete $comp_file failed"
446 rm -f $subdir/$tfile || error "Delete $subdir/$tfile failed"
447 rm -r $subdir || error "Delete subdir $subdir failed"
448 rmdir $parent || error "Delete dir $parent failed"
450 run_test 5 "Inherit composite layout from parent directory"
453 local comp_file=$DIR/$tdir/$tfile
455 test_mkdir $DIR/$tdir
458 $LFS setstripe -c 1 -S 128K $comp_file ||
459 error "Create v1 $comp_file failed"
461 check_component_count $comp_file 0
463 dd if=/dev/urandom of=$comp_file bs=1M count=5 oflag=sync ||
464 error "Write to v1 $comp_file failed"
466 local old_chksum=$(md5sum $comp_file)
468 # Migrate v1 to composite
469 $LFS migrate -E 1M -S 512K -c 1 -E -1 -S 1M -c 2 $comp_file ||
470 error "Migrate(v1 -> composite) $comp_file failed"
472 check_component_count $comp_file 2
474 local chksum=$(md5sum $comp_file)
475 [ "$old_chksum" != "$chksum" ] &&
476 error "(v1 -> compsoite) $old_chksum != $chksum"
478 # Migrate composite to composite
479 $LFS migrate -E 1M -S 1M -c 2 -E 4M -S 1M -c 2 \
480 -E -1 -S 3M -c 3 $comp_file ||
481 error "Migrate(compsoite -> composite) $comp_file failed"
483 check_component_count $comp_file 3
485 chksum=$(md5sum $comp_file)
486 [ "$old_chksum" != "$chksum" ] &&
487 error "(composite -> compsoite) $old_chksum != $chksum"
489 # Migrate composite to v1
490 $LFS migrate -c 2 -S 2M $comp_file ||
491 error "Migrate(composite -> v1) $comp_file failed"
493 check_component_count $comp_file 0
495 chksum=$(md5sum $comp_file)
496 [ "$old_chksum" != "$chksum" ] &&
497 error "(composite -> v1) $old_chksum != $chksum"
499 rm -f $comp_file || "Delete $comp_file failed"
501 run_test 6 "Migrate composite file"
504 test_mkdir $DIR/$tdir
505 chmod 0777 $DIR/$tdir || error "chmod $tdir failed"
507 local comp_file=$DIR/$tdir/$tfile
508 $RUNAS $LFS setstripe -E 1M -S 1M -c 1 $comp_file ||
509 error "Create composite file $comp_file failed"
511 $RUNAS $LFS setstripe --component-add -E 64M -c 4 $comp_file ||
512 error "Add component to $comp_file failed"
514 $RUNAS $LFS setstripe --component-del -I 2 $comp_file ||
515 error "Delete component from $comp_file failed"
517 $RUNAS $LFS setstripe --component-add -E -1 -c 5 $comp_file ||
518 error "Add last component to $comp_file failed"
520 rm $comp_file || "Delete composite failed"
522 run_test 7 "Add/Delete/Create composite file by non-privileged user"
525 local parent=$DIR/$tdir
530 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c 2 -S 2M \
531 -E -1 -c 4 -S 4M $parent ||
532 error "Set default layout to $parent failed"
534 sh rundbench -C -D $parent 2 || error "dbench failed"
536 rm -fr $parent || error "Delete dir $parent failed"
538 run_test 8 "Run dbench over composite files"
541 local comp_file=$DIR/$tdir/$tfile
543 test_mkdir $DIR/$tdir
546 $LFS setstripe -E 1M -S 1M -E -1 -c 1 $comp_file ||
547 error "Create $comp_file failed"
549 check_component_count $comp_file 2
551 replay_barrier $SINGLEMDS
553 # instantiate the 2nd component
554 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
556 local f1=$($LFS getstripe -I2 $comp_file |
557 awk '/l_fid:/ {print $7}')
558 echo "before MDS recovery, the ost fid of 2nd component is $f1"
561 local f2=$($LFS getstripe -I2 $comp_file |
562 awk '/l_fid:/ {print $7}')
563 echo "after MDS recovery, the ost fid of 2nd component is $f2"
564 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
566 run_test 9 "Replay layout extend object instantiation"
569 echo $($LFS getstripe $1 |
570 awk '$1 == "lcm_entry_count:" { printf("%d", $2) }
571 $1 == "lcme_extent.e_start:" { printf("[%#lx", $2) }
572 $1 == "lcme_extent.e_end:" { printf(",%s]", $2) }')
576 local parent=$DIR/$tdir
579 save_layout_restore_at_exit $MOUNT
583 # mount root on $MOUNT2 if FILESET is set
584 if [ -n "$FILESET" ]; then
585 FILESET="" mount_client $MOUNT2 ||
586 error "mount $MOUNT2 fail"
590 $LFS setstripe -d $root || error "clear root layout"
592 # set root composite layout
593 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c2 -S 2M \
594 -E -1 -c 4 -S 4M $root ||
595 error "Set root layout failed"
597 if [ "$root" == "$MOUNT2" ]; then
598 umount_client $MOUNT2 ||
599 error "umount $MOUNT2 fail"
603 # set a different layout for parent
604 $LFS setstripe -E -1 -c 1 -S 1M $parent ||
605 error "set $parent layout failed"
608 local f1_entry=$(component_dump $parent/file1)
610 # delete parent's layout
611 $LFS setstripe -d $parent || error "Clear $parent layout failed"
614 local f2_entry=$(component_dump $parent/file2)
616 # verify layout inheritance
618 local f1_expect="1[0,EOF]"
619 local f2_expect="3[0,2097152][0x200000,16777216][0x1000000,EOF]"
621 echo "f1 expect=$f1_expect"
622 echo "f1 get =$f1_entry"
623 echo "f2 expect=$f2_expect"
624 echo "f2 get =$f2_entry"
626 [ x$f1_expect != x$f1_entry ] &&
627 error "$parent/file1 does not inherite parent layout"
628 [ x$f2_expect != x$f2_entry ] &&
629 error "$parent/file2 does not inherite root layout"
633 run_test 10 "Inherit composite template from root"
636 local comp_file=$DIR/$tdir/$tfile
637 test_mkdir $DIR/$tdir
640 # only 1st component instantiated
641 $LFS setstripe -E 1M -S 1M -E 2M -E 3M -E -1 $comp_file ||
642 error "Create $comp_file failed"
644 local f1=$($LFS getstripe -I1 $comp_file | grep "l_fid")
645 [[ -z $f1 ]] && error "1: 1st component uninstantiated"
646 local f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
647 [[ -n $f2 ]] && error "1: 2nd component instantiated"
648 local f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
649 [[ -n $f3 ]] && error "1: 3rd component instantiated"
650 local f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
651 [[ -n $f4 ]] && error "1: 4th component instantiated"
653 # the first 2 components instantiated
654 # Truncate to exact start of new component - LU-12586
655 $TRUNCATE $comp_file $((1024*1024*1))
657 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
658 [[ -z $f2 ]] && error "2: 2nd component uninstantiated"
659 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
660 [[ -n $f3 ]] && error "2: 3rd component instantiated"
661 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
662 [[ -n $f4 ]] && error "2: 4th component instantiated"
664 # the first 3 components instantiated
665 $TRUNCATE $comp_file $((1024*1024*3 - 1))
666 $TRUNCATE $comp_file $((1024*1024*1+1))
668 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
669 [[ -z $f2 ]] && error "3: 2nd component uninstantiated"
670 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
671 [[ -z $f3 ]] && error "3: 3rd component uninstantiated"
672 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
673 [[ -n $f4 ]] && error "3: 4th component instantiated"
675 # all 4 components instantiated, using append write
676 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
678 rwv -f $comp_file -w -a -n 2 $((1024*1023)) 1
681 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
682 [[ -z $f4 ]] && error "4: 4th component uninstantiated"
686 run_test 11a "Verify component instantiation with write/truncate"
689 [ $OSTCOUNT -lt 4 ] && skip "needs >= 4 OSTs"
691 local file=$DIR/$tdir/$tfile
693 test_mkdir $DIR/$tdir
696 $LFS setstripe -E 1m -E 1g -c 4 -E eof $DIR/$tdir ||
697 error "setstripe dir $DIR/$tdir failed"
698 expand_truncate_test $file ||
699 error "expand_truncate_test failed on $file"
701 run_test 11b "truncate file set file size correctly"
704 [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs"
706 local file=$DIR/$tdir/$tfile
707 test_mkdir $DIR/$tdir
710 # specify ost list for component
711 $LFS setstripe -E 1M -S 1M -c 2 -o 0,1 -E 2M -c 2 -o 1,2 \
712 -E 3M -c 2 -o 2,1 -E 4M -c 1 -i 2 -E -1 $file ||
713 error "Create $file failed"
715 # clear lod component cache
716 stop $SINGLEMDS || error "stop MDS"
717 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
718 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "start MDS"
720 # instantiate all components
721 $TRUNCATE $file $((1024*1024*4+1))
723 #verify object alloc order
724 local o1=$($LFS getstripe -I1 $file |
725 awk '/l_ost_idx:/ {printf("%d",$5)}')
726 [[ $o1 != "01" ]] && error "$o1 is not 01"
728 local o2=$($LFS getstripe -I2 $file |
729 awk '/l_ost_idx:/ {printf("%d",$5)}')
730 [[ $o2 != "12" ]] && error "$o2 is not 12"
732 local o3=$($LFS getstripe -I3 $file |
733 awk '/l_ost_idx:/ {printf("%d",$5)}')
734 [[ $o3 != "21" ]] && error "$o3 is not 21"
736 local o4=$($LFS getstripe -I4 $file |
737 awk '/l_ost_idx:/ {printf("%d",$5)}')
738 [[ $o4 != "2" ]] && error "$o4 is not 2"
742 run_test 12 "Verify ost list specification"
744 test_13() { # LU-9311
745 [ $OSTCOUNT -lt 8 ] && skip "needs >= 8 OSTs"
747 local file=$DIR/$tfile
749 local dd_size=$(($dd_count * 1024 * 1024))
753 $LFS setstripe -E 1M -S 1M -c 1 -E 2M -c 2 -E -1 -c -1 -i 1 $file ||
754 error "Create $file failed"
755 dd if=/dev/zero of=$file bs=1M count=$dd_count
756 real_size=$(stat -c %s $file)
757 [ $real_size -eq $dd_size ] ||
758 error "dd actually wrote $real_size != $dd_size bytes"
762 run_test 13 "shouldn't reprocess granted resent request"
765 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
766 local file=$DIR/$tdir/$tfile
767 test_mkdir -p $DIR/$tdir
770 $LFS setstripe -E1m -c1 -S1m --pool="pool1" -E2m \
771 -E4m -c2 -S2m --pool="pool2" -E-1 $file ||
772 error "Create $file failed"
774 # check --pool inheritance
776 pool="$($LFS getstripe -I2 --pool $file)"
777 [ x"$pool" != "xpool1" ] && $LFS getstripe -I2 $file &&
778 error "$file: component 2 doesn't have poolname pool1"
779 pool="$($LFS getstripe -I4 --pool $file)"
780 [ x"$pool" != "xpool2" ] && $LFS getstripe -I4 $file &&
781 error "$file: component 4 doesn't have poolname pool2"
783 #check --stripe-count inheritance
785 count="$($LFS getstripe -I2 -c $file)"
786 [ $count -ne 1 ] && $LFS getstripe -I2 $file &&
787 error "$file: component 2 doesn't have 1 stripe_count"
788 count="$($LFS getstripe -I4 -c $file)"
789 [ $count -ne 2 ] && $LFS getstripe -I4 $file &&
790 error "$file: component 4 doesn't have 2 stripe_count"
792 #check --stripe-size inheritance
794 size="$($LFS getstripe -I2 -S $file)"
795 [ $size -ne $((1024*1024)) ] && $LFS getstripe -I2 $file &&
796 error "$file: component 2 doesn't have 1M stripe_size"
797 size="$($LFS getstripe -I4 -S $file)"
798 [ $size -ne $((1024*1024*2)) ] && $LFS getstripe -I4 $file &&
799 error "$file: component 4 doesn't have 2M stripe_size"
803 run_test 14 "Verify setstripe poolname/stripe_count/stripe_size inheritance"
806 local parent=$DIR/$tdir
811 $LFS setstripe -d $parent || error "delete default layout"
813 $LFS setstripe -E 1M -S 1M -E 10M -E eof $parent/f1 || error "create f1"
814 $LFS setstripe -E 4M -E 20M -E eof $parent/f2 || error "create f2"
815 test_mkdir $parent/subdir
816 $LFS setstripe -E 6M -S 1M -c1 -E 30M -c4 -E eof -c -1 $parent/subdir ||
817 error "setstripe to subdir"
818 $LFS setstripe -E 8M -E eof $parent/subdir/f3 || error "create f3"
819 $LFS setstripe -c 1 $parent/subdir/f4 || error "create f4"
822 local found=$($LFS find --component-start +2M -E -15M $parent | wc -l)
823 [ $found -eq 0 ] || error "start+2M, end-15M, $found != 0"
826 found=$($LFS find --component-start +2M -E -35M $parent | wc -l)
827 [ $found -eq 2 ] || error "start+2M, end-35M, $found != 2"
830 found=$($LFS find --component-start +4M -E -eof $parent | wc -l)
831 [ $found -eq 1 ] || error "start+4M, end-eof, $found != 1"
833 local flg_opts="--component-flags init"
835 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
837 error "before write: start=1M, end=10M, flag=init, $found != 0"
839 dd if=/dev/zero of=$parent/f1 bs=1M count=2 ||
840 error "dd $parent/f1 failed"
843 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
845 error "after write: start=1M, end=10M, flag=init, $found != 1"
847 local ext_opts="--component-start -1M -E +5M"
848 # parent, subdir, f3, f4
849 found=$($LFS find $ext_opts $parent | wc -l)
850 [ $found -eq 4 ] || error "start-1M, end+5M, $found != 4"
852 local cnt_opts="--component-count +2"
854 found=$($LFS find $ext_opts $cnt_opts $parent | wc -l)
855 [ $found -eq 1 ] || error "start-1M, end+5M, count+2, $found != 1"
858 found=$($LFS find $ext_opts $cnt_opts $flg_opts $parent | wc -l)
860 error "start-1M, end+5M, count+2, flag=init, $found != 0"
863 found=$($LFS find $ext_opts ! $cnt_opts $flg_opts $parent | wc -l)
865 error "start-1M, end+5M, !count+2, flag=init, $found != 2"
867 # check last component stripe count
868 if [ $OSTCOUNT -gt 1 ]; then
869 touch $parent/subdir/f5
870 $TRUNCATE $parent/subdir/f5 $((32*1024*1024))
871 found=$($LFS find $parent/subdir -c $OSTCOUNT)
872 [[ "$found" == "$parent/subdir/f5" ]] ||
873 error "got '$found' with stripe_count=$OSTCOUNT, not f5"
876 run_test 15 "Verify component options for lfs find"
879 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
880 large_xattr_enabled || skip_env "ea_inode feature disabled"
882 local file=$DIR/$tdir/$tfile
883 local dir=$DIR/$tdir/dir
884 local temp=$DIR/$tdir/template
886 test_mkdir $DIR/$tdir
888 #####################################################################
890 # set stripe for source file
891 $LFS setstripe -E1m -S 1M -c2 -o0,1 -E2m -c2 -E3m -o1,0 -E4m -c1 -E-1 \
892 $file || error "Create $file failed"
895 verify_yaml_layout $file $file.copy $temp "1. PFL file"
897 #####################################################################
899 # set stripe for source file
901 $LFS setstripe -c2 -o0,1 -i1 $file || error "Create $file failed"
905 verify_yaml_layout $file $file.copy $temp "2. plain file"
907 #####################################################################
909 # set stripe for source dir
911 $LFS setstripe -E1m -S 1M -c2 -E2m -c1 -E-1 $dir ||
912 error "setstripe $dir failed"
916 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
918 #####################################################################
920 # set stripe for source dir
921 $LFS setstripe -c2 -i-1 $dir || error "setstripe $dir failed"
924 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
926 run_test 16a "Verify setstripe/getstripe with YAML config file"
929 [[ $($LCTL get_param mdc.*.import |
930 grep "connect_flags:.*overstriping") ]] ||
931 skip "server does not support overstriping"
932 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
933 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
934 skip_env "too many osts, skipping"
935 large_xattr_enabled || skip_env "ea_inode feature disabled"
937 local file=$DIR/$tdir/$tfile
938 local dir=$DIR/$tdir/dir
939 local temp=$DIR/$tdir/template
940 # We know OSTCOUNT < (LOV_MAX_STRIPE_COUNT / 2), so this is overstriping
941 local large_count=$((LOV_MAX_STRIPE_COUNT / 2 + 10))
944 test_mkdir $DIR/$tdir
946 #####################################################################
947 # 1. PFL file, overstriping in first comps
948 # set stripe for source file
949 $LFS setstripe -E1m -S 1M -o0,0 -E2m -o1,1 -E3m -C $large_count -E-1 \
950 $file || error "Create $file failed"
953 verify_yaml_layout $file $file.copy $temp "1. PFL file"
955 #####################################################################
956 # 2. plain file + overstriping
957 # set stripe for source file
959 $LFS setstripe -C $large_count -i1 $file || error "Create $file failed"
963 verify_yaml_layout $file $file.copy $temp "2. plain file"
965 #####################################################################
966 # 3. PFL dir + overstriping
967 # set stripe for source dir
969 $LFS setstripe -E1m -S 1M -o 0,0 -E2m -C $large_count -E-1 $dir ||
970 error "setstripe $dir failed"
974 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
976 #####################################################################
977 # 4. plain dir + overstriping
978 # set stripe for source dir
979 $LFS setstripe -C $large_count $dir || error "setstripe $dir failed"
982 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
984 run_test 16b "Verify setstripe/getstripe with YAML config file + overstriping"
987 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
989 local file=$DIR/$tdir/$tfile
990 local dir=$DIR/$tdir/dir
991 local temp=$DIR/$tdir/template
993 test_mkdir $DIR/$tdir
995 #####################################################################
997 # set stripe for source file
998 $LFS setstripe -E256M -S 1M -c2 -o0,1 -z 64M -E-1 -o1,0 -z 128M \
999 $file || error "Create $file failed"
1002 verify_yaml_layout $file $file.copy $temp "1. PFL file"
1004 #####################################################################
1006 # set stripe for source dir
1008 $LFS setstripe -E256M -S 1M -c2 -z 64M -E-1 -z 128M \
1009 $dir || error "setstripe $dir failed"
1011 test_mkdir $dir.copy
1012 echo "2. SEL template on dir"
1013 verify_yaml_layout $dir $dir.copy $temp.dir "2. PFL dir"
1015 run_test 16c "Verify setstripe/getstripe for SEL layout with YAML config file"
1018 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1019 local file=$DIR/$tdir/$tfile
1020 test_mkdir -p $DIR/$tdir
1023 $LFS setstripe -E 1M -S 1M -E 2M -c 2 -E -1 -c -1 $file ||
1024 error "Create $file failed"
1026 local s1=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
1027 local s2=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
1028 local s3=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
1029 echo "1st init: comp size 1:$s1 2:$s2 3:$s3"
1031 # init 2nd component
1032 $TRUNCATE $file $((1024*1024+1))
1033 local s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
1034 local s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
1035 echo "2nd init: comp size 1:$s1n 2:$s2n 3:$s3"
1037 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
1038 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
1040 # init 3rd component
1041 $TRUNCATE $file $((1024*1024*2+1))
1042 s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
1043 s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
1044 local s3n=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
1045 echo "3rd init: comp size 1:$s1n 2:$s2n 3:$s3n"
1047 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
1048 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
1049 [ $s3 -lt $s3n ] || error "3rd comp size $s3 should < $s3n"
1051 run_test 17 "Verify LOVEA grows with more component inited"
1053 check_distribution() {
1057 local obj_min_one=$((OSTCOUNT - 1))
1059 objs=$($LFS getstripe $file |
1060 awk '/l_ost_idx:/ { print $5 }' | wc -l)
1061 let ave=$((objs / OSTCOUNT))
1063 # collect objects per OST distribution
1064 $LFS getstripe $file | awk '/l_ost_idx:/ { print $5 }' | tr -d "," |
1065 (inuse=( $(for i in $(seq 0 $obj_min_one); do echo 0; done) )
1067 let inuse[$O]=$((1 + ${inuse[$O]}))
1070 # verify object distribution varies no more than +-1
1071 for idx in $(seq 0 $obj_min_one); do
1072 let dif=$((${inuse[$idx]} - ave))
1074 if [ "$dif" -gt 1 ]; then
1075 echo "OST${idx}: ${inuse[$idx]} objects"
1076 error "bad distribution on OST${idx}"
1082 local file1=$DIR/${tfile}-1
1083 local file2=$DIR/${tfile}-2
1084 local file3=$DIR/${tfile}-3
1086 rm -f $file1 $file2 $file3
1088 $LFS setstripe -E 1m -S 1m $file1 ||
1089 error "Create $file1 failed"
1090 $LFS setstripe -E 1m -S 1m $file2 ||
1091 error "Create $file2 failed"
1092 $LFS setstripe -E 1m -S 1m $file3 ||
1093 error "Create $file3 failed"
1095 local objs=$((OSTCOUNT+1))
1096 for comp in $(seq 1 $OSTCOUNT); do
1097 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file1 ||
1098 error "Add component to $file1 failed 2"
1099 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file2 ||
1100 error "Add component to $file2 failed 2"
1101 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file3 ||
1102 error "Add component to $file3 failed 2"
1105 $LFS setstripe --component-add -E -1 -c -1 $file1 ||
1106 error "Add component to $file1 failed 3"
1107 $LFS setstripe --component-add -E -1 -c -1 $file2 ||
1108 error "Add component to $file2 failed 3"
1109 $LFS setstripe --component-add -E -1 -c -1 $file3 ||
1110 error "Add component to $file3 failed 3"
1112 # Instantiate all components
1113 dd if=/dev/urandom of=$file1 bs=1M count=$((objs+1)) ||
1114 error "dd failed for $file1"
1115 dd if=/dev/urandom of=$file2 bs=1M count=$((objs+1)) ||
1116 error "dd failed for $file2"
1117 dd if=/dev/urandom of=$file3 bs=1M count=$((objs+1)) ||
1118 error "dd failed for $file3"
1120 check_distribution $file1
1121 check_distribution $file2
1122 check_distribution $file3
1125 run_test 18 "check component distribution"
1129 local already_created=${2:-0}
1130 local rw_len=$((3 * 1024 * 1024)) # 3M
1134 if [ $already_created != 1 ]; then
1135 test_mkdir -p $DIR/$tdir
1136 $LFS setstripe --extension-size 64M -c 1 -E -1 $comp_file ||
1137 error "Create $comp_file failed"
1140 # write past end of first component, so it is extended
1141 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=127 conv=notrunc ||
1142 error "dd to extend failed"
1144 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1145 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1147 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1148 [ $ost_idx2 -ne "-1" ] && error "second component init $ost_idx2"
1150 flg_opts="--comp-flags init"
1151 found=$($LFS find --comp-start 0 -E 128M $flg_opts $comp_file | wc -l)
1152 [ $found -eq 1 ] || error "Write: Extended first component not found"
1154 flg_opts="--comp-flags extension"
1155 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1156 [ $found -eq 1 ] || error "Write: second component not found"
1158 found=$($LFS find -z 64M $comp_file | wc -l)
1159 [ $found -eq 1 ] || error "component not found by ext size"
1161 found=$($LFS find --extension-size +63M $comp_file | wc -l)
1162 [ $found -eq 1 ] || error "component not found by +ext size"
1164 found=$($LFS find --ext-size -65M $comp_file | wc -l)
1165 [ $found -eq 1 ] || error "component not found by -ext size"
1167 found=$($LFS find -z 65M $comp_file | wc -l)
1168 [ $found -eq 0 ] || error "component found by wrong ext size"
1170 found=$($LFS find -z +65M $comp_file | wc -l)
1171 [ $found -eq 0 ] || error "component found by wrong +ext size"
1173 found=$($LFS find -z -63M $comp_file | wc -l)
1174 [ $found -eq 0 ] || error "component found by wrong -ext size"
1176 found=$($LFS find ! -z 64M $comp_file | wc -l)
1177 [ $found -eq 0 ] || error "component found by negation of ext size"
1179 found=$($LFS find ! -z +63M $comp_file | wc -l)
1180 [ $found -eq 0 ] || error "component found by negation of +ext size"
1182 found=$($LFS find ! -z -65M $comp_file | wc -l)
1183 [ $found -eq 0 ] || error "component found by negation of -ext size"
1185 found=$($LFS find ! -z 65M $comp_file | wc -l)
1187 error "component not found by negation of wrong ext size"
1189 found=$($LFS find ! -z +65M $comp_file | wc -l)
1191 error "component not found by negation of wrong +ext size"
1193 found=$($LFS find ! -z -63M $comp_file | wc -l)
1195 error "component not found by negation of wrong -ext size"
1197 found=$($LFS find -S +1M $comp_file | wc -l)
1198 [ $found -eq 0 ] || error "component found by wrong +stripe size"
1200 found=$($LFS find -c 1 $comp_file | wc -l)
1201 [ $found -eq 1 ] || error "component not found by stripe count"
1203 small_write $comp_file $rw_len || error "Verify RW failed"
1205 sel_layout_sanity $comp_file 2
1208 # Self-extending PFL tests
1210 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1211 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1212 skip "skipped for lustre < $SEL_VER"
1214 test19_io_base $DIR/$tdir/$tfile
1216 run_test 19a "Simple test of extension behavior"
1218 # Same as 19a, but with default layout set on directory rather than on file
1220 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1221 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1222 skip "skipped for lustre < $SEL_VER"
1224 local comp_file=$DIR/$tdir/$tfile
1225 local comp_dir=$DIR/$tdir/$tdir
1229 test_mkdir -p $DIR/$tdir
1230 $LFS setstripe --ext-size 64M -c 1 -E -1 $DIR/$tdir ||
1231 error "Setstripe on $DIR/$tdir failed"
1233 # check inheritance for a sub-dir and a file
1234 test_mkdir $comp_dir
1235 found=$($LFS find --comp-start 0 -E 64M $comp_dir | wc -l)
1236 [ $found -eq 1 ] || error "Dir Inheritance: wrong first component size"
1238 flg_opts="--comp-flags extension"
1239 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_dir | wc -l)
1240 [ $found -eq 1 ] || error "Dir Inheritance: Second component not found"
1244 flg_opts="--comp-flags init"
1245 found=$($LFS find --comp-start 0 -E 64M $flg_opts $comp_file | wc -l)
1246 [ $found -eq 1 ] || error "File Inheritance: wrong first component size"
1248 flg_opts="--comp-flags extension"
1249 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_file | wc -l)
1250 [ $found -eq 1 ] || error "File Inheritance: Second component not found"
1252 test19_io_base $comp_file 1
1254 run_test 19b "Simple test of SEL as default layout"
1256 # Test behavior when seeking deep in a file
1258 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1259 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1260 skip "skipped for lustre < $SEL_VER"
1262 local comp_file=$DIR/$tdir/$tfile
1266 test_mkdir -p $DIR/$tdir
1268 $LFS setstripe -z 128M -E 1G -E -1 $comp_file ||
1269 error "Create $comp_file failed"
1271 # write past end of first component, so it is extended
1272 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 conv=notrunc ||
1273 error "dd to extend failed"
1275 flg_opts="--comp-flags init"
1276 found=$($LFS find --comp-start 0M -E 256M $flg_opts $comp_file | wc -l)
1277 [ $found -eq 1 ] || error "Write: first extension component not found"
1279 flg_opts="--comp-flags extension,^init"
1280 found=$($LFS find --comp-start 256M -E 1024M $flg_opts $comp_file |\
1282 [ $found -eq 1 ] || error "Write: second extension component not found"
1284 local end_1=$($LFS getstripe -I1 -E $comp_file)
1287 [ $end_1 -eq 268435456 ] ||
1288 error "end of first component $end_1 != 268435456"
1290 # Write past end of extension space component, in to normal component
1291 # should exhaust & remove extension component
1292 dd if=/dev/zero bs=1M count=1 seek=1100 of=$comp_file conv=notrunc ||
1293 error "dd distant seek failed"
1295 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1296 # the last component index is 3
1297 local ost_idx2=$($LFS getstripe -I3 -i $comp_file)
1299 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1301 local start1=$($LFS getstripe -I1 --comp-start $comp_file)
1302 local end1=$($LFS getstripe -I1 -E $comp_file)
1303 local start2=$($LFS getstripe -I3 --comp-start $comp_file)
1304 local end2=$($LFS getstripe -I3 -E $comp_file)
1306 [ $start1 -eq 0 ] || error "start of first component incorrect"
1307 [ $end1 -eq 1073741824 ] || error "end of first component incorrect"
1308 [ $start2 -eq 1073741824 ] ||
1309 error "start of second component incorrect"
1310 [ "$end2" = "EOF" ] || error "end of second component incorrect"
1312 flg_opts="--comp-flags extension"
1313 found=$($LFS find $flg_opts $comp_file | wc -l)
1314 [ $found -eq 0 ] || error "Seek Write: extension component exists"
1316 sel_layout_sanity $comp_file 2
1318 run_test 19c "Test self-extending layout seeking behavior"
1321 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1322 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1323 skip "skipped for lustre < $SEL_VER"
1325 local comp_file=$DIR/$tdir/$tfile
1329 test_mkdir -p $DIR/$tdir
1331 $LFS setstripe -E 128M -c 1 -z 64M -E -1 $comp_file ||
1332 error "Create $comp_file failed"
1334 # This will cause component 1 to be extended to 128M, then the
1335 # extension space component will be removed
1336 dd if=/dev/zero of=$comp_file bs=130M count=1 ||
1337 error "dd to extend failed"
1339 flg_opts="--comp-flags init"
1340 found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file | wc -l)
1341 [ $found -eq 1 ] || error "Write: first component not found"
1343 flg_opts="--comp-flags init"
1344 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1345 [ $found -eq 1 ] || error "Write: second component not found"
1347 sel_layout_sanity $comp_file 2
1349 # always remove large files in case of DO_CLEANUP=false
1350 rm -f $comp_file || error "Delete $comp_file failed"
1352 run_test 19d "Test write which completely spans extension space component"
1357 local comp2_flags=$($LFS getstripe -I2 --comp-flags $comp_file)
1358 local comp3_flags=$($LFS getstripe -I3 --comp-flags $comp_file)
1360 [ "$comp2_flags" != "init" ] && error "$comp2_flags != init"
1361 [ "$comp3_flags" != "extension" ] && error "$comp3_flags != extension"
1363 local flg_opts=" --comp-start 2M -E 66M --comp-flags init"
1364 local found=$($LFS find $flg_opts $comp_file | wc -l)
1365 [ $found -eq 1 ] || error "Write: extended second component not found"
1367 flg_opts="--comp-start 66M -E EOF --comp-flags extension"
1368 found=$($LFS find $flg_opts $comp_file | wc -l)
1369 [ $found -eq 1 ] || error "Write: third component not found"
1371 sel_layout_sanity $comp_file 3
1375 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1376 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1377 skip "skipped for lustre < $SEL_VER"
1379 local comp_file=$DIR/$tdir/$tfile
1380 local rw_len=$((3 * 1024 * 1024)) # 3M
1384 test_mkdir -p $DIR/$tdir
1386 $LFS setstripe -E 2m -E -1 -z 64M $comp_file ||
1387 error "Create $comp_file failed"
1389 replay_barrier $SINGLEMDS
1391 #instantiate & extend second component
1392 dd if=/dev/zero of=$comp_file bs=4M count=1 ||
1393 error "dd to extend failed"
1395 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1396 local ost_idx3=$($LFS getstripe -I3 -i $comp_file)
1398 [ $ost_idx2 -eq $ost_idx3 ] && error "$ost_idx2 == $ost_idx3"
1399 [ $ost_idx3 -ne "-1" ] && error "third component init $ost_idx3"
1401 test_19e_check $comp_file
1403 local f1=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1404 echo "before MDS recovery, the ost fid of 2nd component is $f1"
1408 local f2=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1409 echo "after MDS recovery, the ost fid of 2nd component is $f2"
1410 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
1412 # simply repeat all previous checks, but also verify components are on
1413 # the same OST as before
1415 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1416 local ost_idx3_2=$($LFS getstripe -I3 -i $comp_file)
1418 [ $ost_idx2_2 -eq $ost_idx3_2 ] && error "$ost_idx2_2 == $ost_idx3_2"
1419 [ $ost_idx3_2 -ne "-1" ] && error "second component init $ost_idx3_2"
1421 # verify OST id is the same after failover
1422 [ $ost_idx2 -ne $ost_idx2_2 ] &&
1423 error "$ost_idx2 != $ost_idx2_2, changed after failover"
1425 test_19e_check $comp_file
1427 run_test 19e "Replay of layout instantiation & extension"
1430 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1431 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1432 skip "skipped for lustre < $SEL_VER"
1434 local comp_file=$DIR/$tdir/$tfile
1438 test_mkdir -p $DIR/$tdir
1440 $LFS setstripe -E 256M --comp-flags extension -E -1 $comp_file
1442 [ $? != 0 ] || error "should not be able to manually set extension flag"
1445 run_test 19f "Rejection of invalid layouts"
1448 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1449 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1450 skip "skipped for lustre < $SEL_VER"
1452 local file1=$DIR/${tfile}-1
1453 local file2=$DIR/${tfile}-2
1455 test_mkdir -p $DIR/$tdir
1456 multiop $file1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1457 error "create failed $file1"
1458 multiop $file2 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1459 error "create failed $file2"
1461 $LFS setstripe --component-add -E 1G -c 1 $file1 ||
1462 error "comp-add [0,1G] failed $file1"
1463 $LFS setstripe --component-add -E 512M -z 128M $file1 &&
1464 error "comp-add [1G,1G],SEL[1G,512M] succeded $file1"
1465 $LFS setstripe --component-add -E 10G -z 128M $file1 ||
1466 error "comp-add [1G,1G],SEL[1G,10G] failed $file1"
1467 $LFS setstripe --component-add -E -1 $file1 ||
1468 error "comp-add [10G,-1] failed $file1"
1470 $LFS setstripe --component-add -E 1G -z 32M -c 1 $file2 &&
1471 error "comp-add with smal ext size succeeded $file1"
1472 $LFS setstripe --component-add -E 1G -z 100M -c 1 $file2 &&
1473 error "comp-add with not aligned ext size succeeded $file1"
1474 $LFS setstripe --component-add -E 1G -z 128M -c 1 $file2 ||
1475 error "comp-add [0,128M],SEL[128M,1G] failed $file1"
1476 $LFS setstripe --component-add -E 10G $file2 ||
1477 error "comp-add [1G,10G] failed $file1"
1478 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 ||
1479 error "comp-add [10G,10G],SEL[10G,-1] failed $file1"
1480 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 &&
1481 error "repeated comp-add [10G,10G],SEL[10G,-1] succeeded $file1"
1483 $LFS getstripe $file1
1484 flg_opts="--comp-flags init"
1485 found=$($LFS find --comp-start 0 -E 1G $flg_opts $file1 | wc -l)
1486 [ $found -eq 1 ] || error "First component not found $file1"
1488 flg_opts="--comp-flags ^init"
1489 found=$($LFS find --comp-start 1G -E 1G $flg_opts $file1 | wc -l)
1490 [ $found -eq 1 ] || error "Second component not found $file1"
1492 flg_opts="--comp-flags ^init,extension"
1493 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file1 | wc -l)
1494 [ $found -eq 1 ] || error "Third component not found $file1"
1496 flg_opts="--comp-flags ^init"
1497 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file1 | wc -l)
1498 [ $found -eq 1 ] || error "Fourth component not found $file1"
1500 $LFS getstripe $file2
1501 flg_opts="--comp-flags init"
1502 found=$($LFS find --comp-start 0 -E 128M $flg_opts $file2 | wc -l)
1503 [ $found -eq 1 ] || error "First component not found $file2"
1505 flg_opts="--comp-flags extension"
1506 found=$($LFS find --comp-start 128M -E 1G $flg_opts $file2 | wc -l)
1507 [ $found -eq 1 ] || error "Second component not found $file2"
1509 flg_opts="--comp-flags ^init"
1510 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file2 | wc -l)
1511 [ $found -eq 1 ] || error "Third component not found $file2"
1513 flg_opts="--comp-flags ^init"
1514 found=$($LFS find --comp-start 10G -E 10G $flg_opts $file2 | wc -l)
1515 [ $found -eq 1 ] || error "Fourth component not found $file2"
1517 flg_opts="--comp-flags ^init,extension"
1518 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file2 | wc -l)
1519 [ $found -eq 1 ] || error "Fifth component not found $file2"
1521 run_test 19g "component-add behaviour"
1523 # Test out of space behavior
1525 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1526 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1527 skip "skipped for lustre < $SEL_VER"
1529 local comp_file=$DIR/$tdir/$tfile
1533 test_mkdir -p $DIR/$tdir
1535 # without this, a previous delete can finish after we check free space
1536 wait_delete_completed
1539 # First component is on OST0
1540 $LFS setstripe -E 256M -i 0 -z 64M -E -1 -z 128M $comp_file ||
1541 error "Create $comp_file failed"
1543 # write past end of first component, so it is extended
1544 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=66 ||
1545 error "dd to extend failed"
1547 flg_opts="--comp-flags extension"
1548 found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file |wc -l)
1549 [ $found -eq 1 ] || error "Write: Second component not found"
1551 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1552 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1554 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1556 flg_opts="--comp-flags extension"
1557 # Write past current init comp, but we won't extend (because no space)
1558 dd if=/dev/zero of=$comp_file bs=1M count=10 seek=200 ||
1559 error "dd write past current comp failed"
1561 $LFS getstripe $comp_file
1563 flg_opts="--comp-flags init"
1564 found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file | \
1566 [ $found -eq 1 ] || error "Write: third component not found"
1568 flg_opts="--comp-flags extension"
1569 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file |wc -l)
1570 [ $found -eq 1 ] || error "Write: fourth extension component not found"
1572 sel_layout_sanity $comp_file 3
1574 run_test 20a "Test out of space, spillover to defined component"
1577 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1578 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1579 skip "skipped for lustre < $SEL_VER"
1581 local comp_file=$DIR/$tdir/$tfile
1585 test_mkdir -p $DIR/$tdir
1587 # Pool allows us to force use of only certain OSTs
1588 pool_add $TESTNAME || error "Pool creation failed"
1589 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1591 # normal component to 10M, extendable component to 1G
1592 # further extendable to EOF
1593 $LFS setstripe -E 10M -E 1G -p $TESTNAME -z 64M -E -1 -p "" -z 128M \
1594 $comp_file || error "Create $comp_file failed"
1596 replay_barrier $SINGLEMDS
1598 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1599 [ $found -eq 1 ] || error "Zero length component not found"
1602 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1604 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1606 # write past end of first component
1607 # This should remove the next component, since OST0 is out of space
1608 # and it is striped there (pool contains only OST0)
1609 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=14 ||
1610 error "dd to extend/remove failed"
1612 $LFS getstripe $comp_file
1614 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1615 [ $found -eq 0 ] || error "Write: zero length component still present"
1617 flg_opts="--comp-flags init"
1618 found=$($LFS find --comp-start 10M -E 138M $flg_opts $comp_file | wc -l)
1619 [ $found -eq 1 ] || error "Write: second component not found"
1621 flg_opts="--comp-flags extension"
1622 found=$($LFS find --comp-start 138M -E EOF $flg_opts $comp_file | wc -l)
1623 [ $found -eq 1 ] || error "Write: third component not found"
1627 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1628 [ $found -eq 0 ] || error "Failover: 0-length component still present"
1630 flg_opts="--comp-flags init"
1631 found=$($LFS find --comp-start 10M -E 138M $flg_opts $comp_file | wc -l)
1632 [ $found -eq 1 ] || error "Failover: second component not found"
1634 flg_opts="--comp-flags extension"
1635 found=$($LFS find --comp-start 138M -E EOF $flg_opts $comp_file | wc -l)
1636 [ $found -eq 1 ] || error "Failover: third component not found"
1638 sel_layout_sanity $comp_file 3
1640 run_test 20b "Remove component without instantiation when there is no space"
1643 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1644 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1645 skip "skipped for lustre < $SEL_VER"
1647 local comp_file=$DIR/$tdir/$tfile
1651 test_mkdir -p $DIR/$tdir
1653 # pool is used to limit available OSTs to 0 and 1, so we can set all
1654 # available OSTs out of space
1655 pool_add $TESTNAME || error "Pool creation failed"
1656 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
1658 # without this, a previous delete can finish after we check free space
1659 wait_delete_completed
1662 $LFS setstripe -E 100M -E -1 -p $TESTNAME -z 64M $comp_file ||
1663 error "Create $comp_file failed"
1667 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1669 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
1671 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1672 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
1674 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=120 &&
1675 error "dd should fail with ENOSPC"
1677 flg_opts="--comp-flags init"
1678 found=$($LFS find --comp-start 0M -E 100M $flg_opts $comp_file | wc -l)
1679 [ $found -eq 1 ] || error "Write: First component not found"
1681 flg_opts="--comp-flags ^init"
1682 found=$($LFS find --comp-start 100M -E 100M $flg_opts $comp_file |wc -l)
1683 [ $found -eq 1 ] || error "Write: 0-length component not found"
1685 flg_opts="--comp-flags extension"
1686 found=$($LFS find --comp-start 100M -E EOF $flg_opts $comp_file | wc -l)
1687 [ $found -eq 1 ] || error "Write: third extension component not found"
1689 sel_layout_sanity $comp_file 3
1691 run_test 20c "Test inability to stripe new extension component"
1694 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1695 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1696 skip "skipped for lustre < $SEL_VER"
1698 local comp_file=$DIR/$tdir/$tfile
1699 test_mkdir -p $DIR/$tdir
1701 wait_delete_completed
1704 pool_add $TESTNAME || error "Pool creation failed"
1705 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1706 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
1707 error "Create $comp_file failed"
1709 replay_barrier $SINGLEMDS
1711 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1712 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1715 ost_watermarks_clear_enospc $tfile 0 $wms
1716 [ $RC -eq 0 ] || error "dd failed: $RC"
1718 $LFS getstripe $comp_file
1719 local flg_opts="--comp-start 64M -E 128M --comp-flags init"
1720 local found=$($LFS find $flg_opts $comp_file | wc -l)
1721 [ $found -eq 1 ] || error "Write: component (64M-128M) not found"
1723 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
1724 [ "$ost_idx" != "-1" ] && error "Write: EXT component disappeared"
1728 found=$($LFS find $flg_opts $comp_file | wc -l)
1729 [ $found -eq 1 ] || error "Failover: component (64M-128M) not found"
1731 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1732 [ "$ost_idx" != "-1" ] && error "Failover: EXT component disappeared"
1734 sel_layout_sanity $comp_file 3
1736 run_test 20d "Low on space + 0-length comp: force extension"
1739 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1740 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1741 skip "skipped for lustre < $SEL_VER"
1743 local comp_file=$DIR/$tdir/$tfile
1744 test_mkdir -p $DIR/$tdir
1746 wait_delete_completed
1749 pool_add $TESTNAME || error "Pool creation failed"
1750 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1752 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
1753 error "Create $comp_file failed"
1755 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1757 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1760 ost_watermarks_clear_enospc $tfile 0 $wms
1761 [ $RC -eq 0 ] || error "dd failed $RC"
1763 $LFS getstripe $comp_file
1764 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
1765 local found=$($LFS find $flg_opts $comp_file | wc -l)
1766 [ $found -eq 1 ] || error "Write: component (64M-EOF) not found"
1768 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
1769 [ "$ost_idx" != "" ] && error "Write: 0-length component still exists"
1770 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1771 [ "$ost_idx" != "" ] && error "Write: extension component still exists"
1773 sel_layout_sanity $comp_file 2
1775 run_test 20e "ENOSPC with next real comp: spillover and backward extension"
1777 # Simple DoM interaction test
1779 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1780 skip "skipped for lustre < $SEL_VER"
1782 local comp_file=$DIR/$tdir/$tfile
1786 test_mkdir -p $DIR/$tdir
1788 # simple, correct self-extending layout after DoM component
1789 $LFS setstripe -E 1M -L mdt -E -1 -z 64m $comp_file || \
1790 error "Create $comp_file failed"
1792 # Write to DoM component & to self-extending comp after it
1793 dd if=/dev/zero bs=1M count=12 of=$comp_file ||
1794 error "dd to extend failed"
1796 flg_opts="--comp-flags init"
1797 found=$($LFS find --comp-start 1M -E 65M $flg_opts $comp_file | wc -l)
1798 [ $found -eq 1 ] || error "Write: extended component not found"
1800 flg_opts="--comp-flags extension"
1801 found=$($LFS find --comp-start 65M $flg_opts $comp_file | wc -l)
1802 [ $found -eq 1 ] || error "Write: extension component not found"
1804 sel_layout_sanity $comp_file 3
1806 run_test 21a "Simple DoM interaction tests"
1808 # DoM + extension + removal
1810 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1811 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1812 skip "skipped for lustre < $SEL_VER"
1814 local comp_file=$DIR/$tdir/$tfile
1815 local ost_name=$(ostname_from_index 0)
1819 test_mkdir -p $DIR/$tdir
1821 # DoM, extendable component, further extendable component
1822 $LFS setstripe -E 1M -L mdt -E 256M -i 0 -z 64M -E -1 -z 128M \
1823 $comp_file || error "Create $comp_file failed"
1825 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1826 [ $found -eq 1 ] || error "Write: Zero length component not found"
1828 # This also demonstrates that we will avoid degraded OSTs
1829 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
1830 # sleep to guarantee we see the degradation
1833 # un-degrade on exit
1834 stack_trap "do_facet ost1 $LCTL set_param -n \
1835 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1837 # This should remove the first component after DoM and spill over to
1839 dd if=/dev/zero bs=1M count=2 of=$comp_file ||
1840 error "dd to remove+spill over failed"
1842 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1843 [ $found -eq 0 ] || error "Write: Zero length component still present"
1845 flg_opts="--comp-flags init"
1846 found=$($LFS find --comp-start 1M -E 129M $flg_opts $comp_file | wc -l)
1847 [ $found -eq 1 ] || error "Write: extended component not found"
1849 flg_opts="--comp-flags extension"
1850 found=$($LFS find --comp-start 129M -E EOF $flg_opts $comp_file |wc -l)
1851 [ $found -eq 1 ] || error "Write: extension component not found"
1853 sel_layout_sanity $comp_file 3
1855 run_test 21b "DoM followed by extendable component with removal"
1857 # Test of repeat component behavior with OOS/degraded OST
1859 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1860 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1861 skip "skipped for lustre < $SEL_VER"
1863 local comp_file=$DIR/$tdir/$tfile
1867 test_mkdir -p $DIR/$tdir
1869 $LFS setstripe -E -1 -c 1 -z 128M $comp_file ||
1870 error "Create $comp_file failed"
1872 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1873 local ost_name=$(ostname_from_index $ost_idx1)
1875 # write past end of first component, so it is extended
1876 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
1877 error "dd to extend failed"
1879 flg_opts="--comp-flags extension"
1880 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
1881 [ $found -eq 1 ] || error "Write: second component not found"
1883 # degrade OST for component 1
1884 do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
1885 obdfilter.$ost_name.degraded=1
1886 # sleep to guarantee we see the degradation
1889 # un-degrade on exit
1890 stack_trap "do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
1891 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1893 replay_barrier $SINGLEMDS
1895 # seek past the end of current comp & write, should cause a new comp
1896 # to be created (ie repeat previous comp)
1897 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
1898 error "dd to repeat failed"
1900 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1902 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1904 flg_opts="--comp-flags init"
1905 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1906 [ $found -eq 1 ] || error "Write: second component not found"
1908 flg_opts="--comp-flags extension"
1909 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1910 [ $found -eq 1 ] || error "Write: extension component not found"
1914 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1915 [ $ost_idx2_2 -ne $ost_idx2 ] && error "$ost_idx2_2 != $ost_idx2"
1917 flg_opts="--comp-flags init"
1918 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1919 [ $found -eq 1 ] || error "Failover: second component not found"
1921 flg_opts="--comp-flags extension"
1922 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1923 [ $found -eq 1 ] || error "Failover: extension component not found"
1925 sel_layout_sanity $comp_file 3
1927 run_test 22a "Test repeat component behavior with degraded OST"
1929 # Test repeat behavior with low space
1931 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1932 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1933 skip "skipped for lustre < $SEL_VER"
1935 local comp_file=$DIR/$tdir/$tfile
1939 test_mkdir -p $DIR/$tdir
1941 # without this, a previous delete can finish after we check free space
1942 wait_delete_completed
1945 $LFS setstripe -E -1 -c 1 -z 128M \
1946 $comp_file || error "Create $comp_file failed"
1948 # write past end of first component, so it is extended
1949 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
1950 error "dd to extend failed"
1952 flg_opts="--comp-flags extension"
1953 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
1954 [ $found -eq 1 ] || error "Write: Second component not found"
1956 # set our OST low on space
1957 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1958 local wms=$(ost_watermarks_set_low_space $ost_idx1 | grep "watermarks")
1960 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1962 # Write past end of current space, fail to extend, causing repeat
1963 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
1964 error "dd to repeat failed"
1966 $LFS getstripe $comp_file
1968 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1970 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1972 flg_opts="--comp-flags init"
1973 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1974 [ $found -eq 1 ] || error "Write: Second component not found"
1976 flg_opts="--comp-flags extension"
1977 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1978 [ $found -eq 1 ] || error "Write: Extension component not found"
1980 sel_layout_sanity $comp_file 3
1982 run_test 22b "Test simple 'out of space' condition with repeat"
1984 # This tests both "repeat" and "extend in place when repeat fails" aspects
1985 # of repeating components
1987 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1988 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1989 skip "skipped for lustre < $SEL_VER"
1991 local comp_file=$DIR/$tdir/$tfile
1995 test_mkdir -p $DIR/$tdir
1997 # pool is used to limit available OSTs to 0 and 1, so we can set all
1998 # available OSTs out of space
1999 pool_add $TESTNAME || error "Pool creation failed"
2000 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
2002 # without this, a previous delete can finish after we check free space
2003 wait_delete_completed
2006 $LFS setstripe -E -1 -z 64M -c 1 -p "$TESTNAME" $comp_file || \
2007 error "Create $comp_file failed"
2009 # write past end of first component, so it is extended
2010 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=80 conv=notrunc ||
2011 error "dd to extend failed"
2013 $LFS getstripe $comp_file
2015 flg_opts="--comp-flags extension"
2016 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
2017 [ $found -eq 1 ] || error "Write: second component not found"
2019 # set our OST out of space
2020 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
2021 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
2023 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
2025 # This should create a repeat component on a new OST
2026 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=180 conv=notrunc ||
2027 error "dd to repeat failed"
2029 $LFS getstripe $comp_file
2031 local comp_cnt=$($LFS getstripe --component-count $comp_file)
2032 [ $comp_cnt -ne 3 ] && error "component count: $comp_cnt, should be 3"
2034 # New second component should be on a different OST
2035 local ost_idx2=$($LFS getstripe --comp-start=128m \
2036 --comp-end=192m --comp-flags=init -i $comp_file)
2038 [ $ost_idx1 -eq $ost_idx2 ] && error "2nd comp: same OST $ost_idx1"
2040 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
2042 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
2044 # now that the second OST is out of space (as is the first OST), we
2045 # attempt to extend. This should result in an extension of the
2046 # existing component, rather than a new component.
2047 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=240 conv=notrunc ||
2048 error "dd for forced extension failed"
2050 $LFS getstripe $comp_file
2052 # clear out of space on first OST
2053 ost_watermarks_clear_enospc $tfile $ost_idx1 $wms
2055 # finally, now that the first OST has space again, we attempt to
2056 # extend one last time. This should create a new component on the
2058 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 conv=notrunc ||
2059 error "dd for repeat on first OST failed"
2061 $LFS getstripe $comp_file
2063 flg_opts="--comp-flags init"
2064 found=$($LFS find --comp-start 128M $flg_opts $comp_file | wc -l)
2065 [ $found -eq 1 ] || error "Write: second component not found"
2067 flg_opts="--comp-flags init"
2068 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
2069 [ $found -eq 1 ] || error "Write: third component not found"
2071 flg_opts="--comp-flags extension"
2072 found=$($LFS find --comp-start 320M -E EOF $flg_opts $comp_file | wc -l)
2073 [ $found -eq 1 ] || error "Write: extension component not found"
2075 sel_layout_sanity $comp_file 4
2077 run_test 22c "Test repeat with out of space on > 1 OST"
2079 test_22d_post_check() {
2082 local flg_opts="--comp-flags init"
2083 local found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file |
2085 [ $found -eq 1 ] || {
2086 $LFS getstripe $comp_file
2087 error "$name: second component not found"
2090 flg_opts="--comp-flags extension"
2091 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
2092 [ $found -eq 1 ] || error "$name: third extension component not found"
2094 sel_layout_sanity $comp_file 2
2102 # write past end of first component
2103 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=70
2106 ost_watermarks_clear_enospc $tfile 0 $wms
2107 [ $RC -eq 0 ] || error "dd to force extend failed"
2109 test_22d_post_check $comp_file "Write"
2113 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2114 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2115 skip "skipped for lustre < $SEL_VER"
2117 local comp_file=$DIR/$tdir/$tfile
2121 test_mkdir -p $DIR/$tdir
2123 # without this, a previous delete can finish after we check free space
2124 wait_delete_completed
2127 # Pool allows us to force use of only certain OSTs
2128 pool_add $TESTNAME || error "Pool creation failed"
2129 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2131 # 1. Fail to extend due to OOS, try to repeat within the same pool,
2132 # fail to stripe (again OOS) the 0-length component, remove the
2133 # repeated one, force the extension on the original one.
2134 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2135 error "Create $comp_file failed"
2137 replay_barrier $SINGLEMDS
2139 # set our OST out of space
2140 local wms=$(ost_watermarks_set_enospc $tfile 0 | grep "watermarks")
2142 test_22d_pre $comp_file "$wms"
2144 test_22d_post_check $comp_file "Failover"
2146 # 2. repeat with low on space: 0-length repeated component will be
2147 # striped, but still fails to be extended; otherwise the same as (1).
2149 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2150 error "Create $comp_file failed"
2152 replay_barrier $SINGLEMDS
2154 # set our OST low on space
2155 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2157 test_22d_pre $comp_file "$wms"
2159 test_22d_post_check $comp_file "Failover"
2161 run_test 22d "out of/low on space + failed to repeat + forced extension"
2164 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2165 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2166 skip "skipped for lustre < $SEL_VER"
2168 local comp_file=$DIR/$tdir/$tfile
2169 test_mkdir -p $DIR/$tdir
2171 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2172 error "Create $comp_file failed"
2174 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2175 error "dd append failed"
2177 local flg_opts="--comp-start 0 -E EOF --comp-flags init"
2178 local found=$($LFS find $flg_opts $comp_file | wc -l)
2179 [ $found -eq 1 ] || error "Append: first component (0-EOF) not found"
2181 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2182 [ "$ost_idx" != "" ] && error "Append: second component still exists"
2184 sel_layout_sanity $comp_file 1
2186 run_test 23a "Append: remove EXT comp"
2189 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2190 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2191 skip "skipped for lustre < $SEL_VER"
2193 local comp_file=$DIR/$tdir/$tfile
2194 test_mkdir -p $DIR/$tdir
2196 $LFS setstripe -E 64m -E -1 -z 64M $comp_file ||
2197 error "Create $comp_file failed"
2199 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2200 error "dd append failed"
2202 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2203 local found=$($LFS find $flg_opts $comp_file | wc -l)
2204 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2206 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2207 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2209 sel_layout_sanity $comp_file 2
2211 run_test 23b "Append with 0-length comp: remove EXT comp"
2214 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2215 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2216 skip "skipped for lustre < $SEL_VER"
2218 local comp_file=$DIR/$tdir/$tfile
2219 test_mkdir -p $DIR/$tdir
2221 wait_delete_completed
2224 pool_add $TESTNAME || error "Pool creation failed"
2225 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2226 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
2227 error "Create $comp_file failed"
2229 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2230 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2233 ost_watermarks_clear_enospc $tfile 0 $wms
2234 [ $RC -eq 0 ] || error "dd append failed: $RC"
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: EXT component still exists"
2243 sel_layout_sanity $comp_file 2
2245 run_test 23c "Append with low on space + 0-length comp: force extension"
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 $LFS setstripe -E 64m -E 640M -z 64M -E -1 $comp_file ||
2256 error "Create $comp_file failed"
2258 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2259 error "dd append failed"
2261 flg_opts="--comp-start 64M -E 640M --comp-flags init"
2262 found=$($LFS find $flg_opts $comp_file | wc -l)
2263 [ $found -eq 1 ] || error "Append: component (64M-640M) not found"
2265 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2266 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2268 sel_layout_sanity $comp_file 3
2270 run_test 23d "Append with 0-length comp + next real comp: remove EXT comp"
2273 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2274 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2275 skip "skipped for lustre < $SEL_VER"
2277 local comp_file=$DIR/$tdir/$tfile
2278 test_mkdir -p $DIR/$tdir
2280 wait_delete_completed
2283 pool_add $TESTNAME || error "Pool creation failed"
2284 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2286 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
2287 error "Create $comp_file failed"
2289 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2291 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2294 ost_watermarks_clear_enospc $tfile 0 $wms
2295 [ $RC -eq 0 ] || error "dd append failed $RC"
2297 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2298 local found=$($LFS find $flg_opts $comp_file | wc -l)
2299 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2301 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2302 [ "$ost_idx" != "" ] && error "Append: 0-length component still exists"
2303 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2304 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2306 sel_layout_sanity $comp_file 2
2308 run_test 23e "Append with next real comp: spillover and backward extension"
2311 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2312 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2313 skip "skipped for lustre < $SEL_VER"
2315 local comp_file=$DIR/$tdir/$tfile
2316 test_mkdir -p $DIR/$tdir
2318 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2319 error "Create $comp_file failed"
2321 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
2322 local wms=$(ost_watermarks_set_low_space $ost_idx | grep "watermarks")
2324 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2327 ost_watermarks_clear_enospc $tfile $ost_idx $wms
2328 [ $RC -eq 0 ] || error "dd append failed"
2330 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2331 local found=$($LFS find $flg_opts $comp_file | wc -l)
2332 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2334 ost_idx=$($LFS getstripe -I2 -i $comp_file)
2335 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2337 sel_layout_sanity $comp_file 2
2339 run_test 23f "Append with low on space: repeat and remove EXT comp"
2348 [ "$OSTCOUNT" -lt "3" ] && skip_env "needs >= 3 OSTs"
2350 trap cleanup_24 EXIT RETURN
2352 local file=$DIR/$tfile
2354 $LFS setstripe -E 1m -c1 -o0 -E eof -c2 -o1,2 $file ||
2355 error "setstripe on $file"
2357 dd if=/dev/zero of=$file bs=1M count=3 || error "dd failed for $file"
2360 filefrag -ves $file || error "filefrag $file failed"
2361 filefrag_op=$(filefrag -ve -k $file |
2362 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
2364 #Filesystem type is: bd00bd0
2365 #File size of /mnt/lustre/f24a.sanity-pfl is 3145728 (3072 blocks of 1024 bytes)
2366 # ext: device_logical: physical_offset: length: dev: flags:
2367 # 0: 0.. 1023: 1572864.. 1573887: 1024: 0000: net
2368 # 1: 0.. 1023: 1572864.. 1573887: 1024: 0002: net
2369 # 2: 1024.. 2047: 1573888.. 1574911: 1024: 0001: last,net
2370 #/mnt/lustre/f24a.sanity-pfl: 3 extents found
2372 last_lun=$(echo $filefrag_op | cut -d: -f5)
2377 for line in $filefrag_op; do
2378 frag_lun=$(echo $line | cut -d: -f5)
2379 ext_len=$(echo $line | cut -d: -f4)
2380 if [[ "$frag_lun" != "$last_lun" ]]; then
2381 if (( tot_len != 1024 )); then
2383 error "$file: OST$last_lun $tot_len != 1024"
2389 (( tot_len += ext_len ))
2392 if (( num_luns != 3 || tot_len != 1024 )); then
2394 error "$file: $num_luns != 3, $tot_len != 1024 on OST$last_lun"
2397 echo "FIEMAP on $file succeeded"
2399 run_test 24a "FIEMAP upon PFL file"
2402 local pfl_f=$DIR/$tdir/"$tfile"_pfl
2403 local dom_f=$DIR/$tdir/"$tfile"_dom
2404 local common_f=$DIR/$tdir/"$tfile"_common
2408 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2409 $LFS setstripe -E 10M -S 64k -c -1 -E 20M -S 1M -E -1 -S 2M -c 1 \
2410 $pfl_f || error "setstripe $pfl_f failed"
2411 $LFS setstripe -E 256k -L mdt -E -1 -S 1M $dom_f ||
2412 error "setstripe $dom_f failed"
2413 $LFS setstripe -S 512K -c -1 $common_f ||
2414 error "setstripe $common_f failed"
2416 #verify lov_getstripe_old with PFL file
2417 stripe_count=$(lov_getstripe_old $pfl_f |
2418 awk '/stripe_count/ { print $2 }')
2419 stripe_size=$(lov_getstripe_old $pfl_f |
2420 awk '/stripe_size/ { print $2 }')
2421 [ $stripe_count -eq 1 ] ||
2422 error "stripe_count $stripe_count !=1 for $pfl_f"
2423 [ $stripe_size -eq 2097152 ] ||
2424 error "stripe_size $stripe_size != 2097152 for $pfl_f"
2426 #verify lov_getstripe_old with DoM file
2427 stripe_count=$(lov_getstripe_old $dom_f |
2428 awk '/stripe_count/ { print $2 }')
2429 stripe_size=$(lov_getstripe_old $dom_f |
2430 awk '/stripe_size/ { print $2 }')
2431 [ $stripe_count -eq 1 ] ||
2432 error "stripe_count $stripe_count !=1 for $dom_f"
2433 [ $stripe_size -eq 1048576 ] ||
2434 error "stripe_size $stripe_size != 1048576 for $dom_f"
2436 #verify lov_getstripe_old with common file
2437 stripe_count=$(lov_getstripe_old $common_f |
2438 awk '/stripe_count/ { print $2 }')
2439 stripe_size=$(lov_getstripe_old $common_f |
2440 awk '/stripe_size/ { print $2 }')
2441 [ $stripe_count -eq $OSTCOUNT ] ||
2442 error "stripe_count $stripe_count !=$OSTCOUNT for $common_f"
2443 [ $stripe_size -eq 524288 ] ||
2444 error "stripe_size $stripe_size != 524288 for $common_f"
2446 run_test 25 "Verify old lov stripe API with PFL files"
2449 check_and_cleanup_lustre