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
283 test_mkdir $DIR/$tdir
286 $LFS setstripe -E 1m -S 1m $comp_file ||
287 error "Create $comp_file failed"
289 check_component_count $comp_file 1
291 dd if=/dev/zero of=$comp_file bs=1M count=1 > /dev/null 2>&1 ||
292 error "Write first component failed"
293 dd if=$comp_file of=/dev/null bs=1M count=1 > /dev/null 2>&1 ||
294 error "Read first component failed"
296 dd if=/dev/zero of=$comp_file bs=1M count=2 > /dev/null 2>&1 &&
297 error "Write beyond component should fail"
298 dd if=$comp_file of=/dev/null bs=1M count=2 > /dev/null 2>&1 ||
299 error "Read beyond component should short read, not fail"
301 $LFS setstripe --component-add -E 2M -S 1M -c 1 $comp_file ||
302 error "Add component to $comp_file failed"
304 check_component_count $comp_file 2
306 $LFS setstripe --component-add -E -1 -c 3 $comp_file ||
307 error "Add last component to $comp_file failed"
309 check_component_count $comp_file 3
311 small_write $comp_file $rw_len || error "Verify RW failed"
313 rm -f $comp_file || error "Delete $comp_file failed"
315 run_test 2 "Add component to existing file"
317 del_comp_and_verify() {
324 if [ $id == "init" -o $id == "^init" ]; then
325 opt="--component-flags="
328 $LFS setstripe --component-del $opt$id $comp_file ||
329 error "Delete component $id from $comp_file failed"
331 local comp_cnt=$($LFS getstripe --component-count $comp_file)
332 if grep -q "has no stripe info" <<< "$comp_cnt" ; then
335 [ $comp_cnt -ne $left ] && error "$comp_cnt != $left"
337 $CHECKSTAT -s $size $comp_file || error "size != $size"
341 local comp_file=$DIR/$tdir/$tfile
343 test_mkdir $DIR/$tdir
346 $LFS setstripe -E 1M -S 1M -E 64M -c 2 -E -1 -c 3 $comp_file ||
347 error "Create $comp_file failed"
349 check_component_count $comp_file 3
351 dd if=/dev/zero of=$comp_file bs=1M count=2
353 $LFS setstripe --component-del -I 2 $comp_file &&
354 error "Component deletion makes hole"
356 del_comp_and_verify $comp_file 3 2 $((2 * 1024 * 1024))
357 del_comp_and_verify $comp_file 2 1 $((1 * 1024 * 1024))
358 del_comp_and_verify $comp_file 1 0 0
360 rm -f $comp_file || error "Delete $comp_file failed"
362 $LFS setstripe -E 1M -S 1M -E 16M -E -1 $comp_file ||
363 error "Create second $comp_file failed"
365 del_comp_and_verify $comp_file "^init" 1 0
366 del_comp_and_verify $comp_file "init" 0 0
367 rm -f $comp_file || error "Delete second $comp_file failed"
370 run_test 3 "Delete component from existing file"
373 skip "Not supported in PFL"
374 # In PFL project, only LCME_FL_INIT is supported, and it can't
375 # be altered by application.
377 run_test 4 "Modify component flags in existing file"
380 local parent=$DIR/$tdir
381 local comp_file=$DIR/$tdir/$tfile
382 local subdir=$parent/subdir
387 # set default layout to parent directory
388 $LFS setstripe -E 64M -c 2 -i 0 -E -1 -c 4 -i 0 $parent ||
389 error "Set default layout to $parent failed"
391 # create file under parent
392 touch $comp_file || error "Create $comp_file failed"
393 check_component_count $comp_file 2
395 #instantiate all components, so that objs are allocted
396 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=65k
398 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
399 [ $ost_idx -ne 0 ] &&
400 error "component 1 ost_idx $ost_idx != 0"
402 ost_idx=$($LFS getstripe -I2 -i $comp_file)
403 [ $ost_idx -ne 0 ] &&
404 error "component 2 ost_idx $ost_idx != 0"
406 # create subdir under parent
407 mkdir -p $subdir || error "Create subdir $subdir failed"
409 comp_cnt=$($LFS getstripe -d --component-count $subdir)
410 [ $comp_cnt -ne 2 ] && error "subdir $comp_cnt != 2"
412 # create file under subdir
413 touch $subdir/$tfile || error "Create $subdir/$tfile failed"
415 check_component_count $subdir/$tfile 2
417 # delete default layout setting from parent
418 $LFS setstripe -d $parent ||
419 error "Delete default layout from $parent failed"
421 comp_cnt=$($LFS getstripe -d --component-count $parent)
422 [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0"
424 rm -f $comp_file || error "Delete $comp_file failed"
425 rm -f $subdir/$tfile || error "Delete $subdir/$tfile failed"
426 rm -r $subdir || error "Delete subdir $subdir failed"
427 rmdir $parent || error "Delete dir $parent failed"
429 run_test 5 "Inherit composite layout from parent directory"
432 local comp_file=$DIR/$tdir/$tfile
434 test_mkdir $DIR/$tdir
437 $LFS setstripe -c 1 -S 128K $comp_file ||
438 error "Create v1 $comp_file failed"
440 check_component_count $comp_file 0
442 dd if=/dev/urandom of=$comp_file bs=1M count=5 oflag=sync ||
443 error "Write to v1 $comp_file failed"
445 local old_chksum=$(md5sum $comp_file)
447 # Migrate v1 to composite
448 $LFS migrate -E 1M -S 512K -c 1 -E -1 -S 1M -c 2 $comp_file ||
449 error "Migrate(v1 -> composite) $comp_file failed"
451 check_component_count $comp_file 2
453 local chksum=$(md5sum $comp_file)
454 [ "$old_chksum" != "$chksum" ] &&
455 error "(v1 -> compsoite) $old_chksum != $chksum"
457 # Migrate composite to composite
458 $LFS migrate -E 1M -S 1M -c 2 -E 4M -S 1M -c 2 \
459 -E -1 -S 3M -c 3 $comp_file ||
460 error "Migrate(compsoite -> composite) $comp_file failed"
462 check_component_count $comp_file 3
464 chksum=$(md5sum $comp_file)
465 [ "$old_chksum" != "$chksum" ] &&
466 error "(composite -> compsoite) $old_chksum != $chksum"
468 # Migrate composite to v1
469 $LFS migrate -c 2 -S 2M $comp_file ||
470 error "Migrate(composite -> v1) $comp_file failed"
472 check_component_count $comp_file 0
474 chksum=$(md5sum $comp_file)
475 [ "$old_chksum" != "$chksum" ] &&
476 error "(composite -> v1) $old_chksum != $chksum"
478 rm -f $comp_file || "Delete $comp_file failed"
480 run_test 6 "Migrate composite file"
483 test_mkdir $DIR/$tdir
484 chmod 0777 $DIR/$tdir || error "chmod $tdir failed"
486 local comp_file=$DIR/$tdir/$tfile
487 $RUNAS $LFS setstripe -E 1M -S 1M -c 1 $comp_file ||
488 error "Create composite file $comp_file failed"
490 $RUNAS $LFS setstripe --component-add -E 64M -c 4 $comp_file ||
491 error "Add component to $comp_file failed"
493 $RUNAS $LFS setstripe --component-del -I 2 $comp_file ||
494 error "Delete component from $comp_file failed"
496 $RUNAS $LFS setstripe --component-add -E -1 -c 5 $comp_file ||
497 error "Add last component to $comp_file failed"
499 rm $comp_file || "Delete composite failed"
501 run_test 7 "Add/Delete/Create composite file by non-privileged user"
504 local parent=$DIR/$tdir
509 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c 2 -S 2M \
510 -E -1 -c 4 -S 4M $parent ||
511 error "Set default layout to $parent failed"
513 sh rundbench -C -D $parent 2 || error "dbench failed"
515 rm -fr $parent || error "Delete dir $parent failed"
517 run_test 8 "Run dbench over composite files"
520 local comp_file=$DIR/$tdir/$tfile
522 test_mkdir $DIR/$tdir
525 $LFS setstripe -E 1M -S 1M -E -1 -c 1 $comp_file ||
526 error "Create $comp_file failed"
528 check_component_count $comp_file 2
530 replay_barrier $SINGLEMDS
532 # instantiate the 2nd component
533 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
535 local f1=$($LFS getstripe -I2 $comp_file |
536 awk '/l_fid:/ {print $7}')
537 echo "before MDS recovery, the ost fid of 2nd component is $f1"
540 local f2=$($LFS getstripe -I2 $comp_file |
541 awk '/l_fid:/ {print $7}')
542 echo "after MDS recovery, the ost fid of 2nd component is $f2"
543 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
545 run_test 9 "Replay layout extend object instantiation"
548 echo $($LFS getstripe $1 |
549 awk '$1 == "lcm_entry_count:" { printf("%d", $2) }
550 $1 == "lcme_extent.e_start:" { printf("[%#lx", $2) }
551 $1 == "lcme_extent.e_end:" { printf(",%s]", $2) }')
555 local parent=$DIR/$tdir
558 save_layout_restore_at_exit $MOUNT
562 # mount root on $MOUNT2 if FILESET is set
563 if [ -n "$FILESET" ]; then
564 FILESET="" mount_client $MOUNT2 ||
565 error "mount $MOUNT2 fail"
569 $LFS setstripe -d $root || error "clear root layout"
571 # set root composite layout
572 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c2 -S 2M \
573 -E -1 -c 4 -S 4M $root ||
574 error "Set root layout failed"
576 if [ "$root" == "$MOUNT2" ]; then
577 umount_client $MOUNT2 ||
578 error "umount $MOUNT2 fail"
582 # set a different layout for parent
583 $LFS setstripe -E -1 -c 1 -S 1M $parent ||
584 error "set $parent layout failed"
587 local f1_entry=$(component_dump $parent/file1)
589 # delete parent's layout
590 $LFS setstripe -d $parent || error "Clear $parent layout failed"
593 local f2_entry=$(component_dump $parent/file2)
595 # verify layout inheritance
597 local f1_expect="1[0,EOF]"
598 local f2_expect="3[0,2097152][0x200000,16777216][0x1000000,EOF]"
600 echo "f1 expect=$f1_expect"
601 echo "f1 get =$f1_entry"
602 echo "f2 expect=$f2_expect"
603 echo "f2 get =$f2_entry"
605 [ x$f1_expect != x$f1_entry ] &&
606 error "$parent/file1 does not inherite parent layout"
607 [ x$f2_expect != x$f2_entry ] &&
608 error "$parent/file2 does not inherite root layout"
612 run_test 10 "Inherit composite template from root"
615 local comp_file=$DIR/$tdir/$tfile
616 test_mkdir $DIR/$tdir
619 # only 1st component instantiated
620 $LFS setstripe -E 1M -S 1M -E 2M -E 3M -E -1 $comp_file ||
621 error "Create $comp_file failed"
623 local f1=$($LFS getstripe -I1 $comp_file | grep "l_fid")
624 [[ -z $f1 ]] && error "1: 1st component uninstantiated"
625 local f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
626 [[ -n $f2 ]] && error "1: 2nd component instantiated"
627 local f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
628 [[ -n $f3 ]] && error "1: 3rd component instantiated"
629 local f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
630 [[ -n $f4 ]] && error "1: 4th component instantiated"
632 # the first 2 components instantiated
633 # Truncate to exact start of new component - LU-12586
634 $TRUNCATE $comp_file $((1024*1024*1))
636 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
637 [[ -z $f2 ]] && error "2: 2nd component uninstantiated"
638 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
639 [[ -n $f3 ]] && error "2: 3rd component instantiated"
640 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
641 [[ -n $f4 ]] && error "2: 4th component instantiated"
643 # the first 3 components instantiated
644 $TRUNCATE $comp_file $((1024*1024*3 - 1))
645 $TRUNCATE $comp_file $((1024*1024*1+1))
647 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
648 [[ -z $f2 ]] && error "3: 2nd component uninstantiated"
649 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
650 [[ -z $f3 ]] && error "3: 3rd component uninstantiated"
651 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
652 [[ -n $f4 ]] && error "3: 4th component instantiated"
654 # all 4 components instantiated, using append write
655 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
657 rwv -f $comp_file -w -a -n 2 $((1024*1023)) 1
660 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
661 [[ -z $f4 ]] && error "4: 4th component uninstantiated"
665 run_test 11a "Verify component instantiation with write/truncate"
668 [ $OSTCOUNT -lt 4 ] && skip "needs >= 4 OSTs"
670 local file=$DIR/$tdir/$tfile
672 test_mkdir $DIR/$tdir
675 $LFS setstripe -E 1m -E 1g -c 4 -E eof $DIR/$tdir ||
676 error "setstripe dir $DIR/$tdir failed"
677 expand_truncate_test $file ||
678 error "expand_truncate_test failed on $file"
680 run_test 11b "truncate file set file size correctly"
683 [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs"
685 local file=$DIR/$tdir/$tfile
686 test_mkdir $DIR/$tdir
689 # specify ost list for component
690 $LFS setstripe -E 1M -S 1M -c 2 -o 0,1 -E 2M -c 2 -o 1,2 \
691 -E 3M -c 2 -o 2,1 -E 4M -c 1 -i 2 -E -1 $file ||
692 error "Create $file failed"
694 # clear lod component cache
695 stop $SINGLEMDS || error "stop MDS"
696 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
697 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "start MDS"
699 # instantiate all components
700 $TRUNCATE $file $((1024*1024*4+1))
702 #verify object alloc order
703 local o1=$($LFS getstripe -I1 $file |
704 awk '/l_ost_idx:/ {printf("%d",$5)}')
705 [[ $o1 != "01" ]] && error "$o1 is not 01"
707 local o2=$($LFS getstripe -I2 $file |
708 awk '/l_ost_idx:/ {printf("%d",$5)}')
709 [[ $o2 != "12" ]] && error "$o2 is not 12"
711 local o3=$($LFS getstripe -I3 $file |
712 awk '/l_ost_idx:/ {printf("%d",$5)}')
713 [[ $o3 != "21" ]] && error "$o3 is not 21"
715 local o4=$($LFS getstripe -I4 $file |
716 awk '/l_ost_idx:/ {printf("%d",$5)}')
717 [[ $o4 != "2" ]] && error "$o4 is not 2"
721 run_test 12 "Verify ost list specification"
723 test_13() { # LU-9311
724 [ $OSTCOUNT -lt 8 ] && skip "needs >= 8 OSTs"
726 local file=$DIR/$tfile
728 local dd_size=$(($dd_count * 1024 * 1024))
732 $LFS setstripe -E 1M -S 1M -c 1 -E 2M -c 2 -E -1 -c -1 -i 1 $file ||
733 error "Create $file failed"
734 dd if=/dev/zero of=$file bs=1M count=$dd_count
735 real_size=$(stat -c %s $file)
736 [ $real_size -eq $dd_size ] ||
737 error "dd actually wrote $real_size != $dd_size bytes"
741 run_test 13 "shouldn't reprocess granted resent request"
744 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
745 local file=$DIR/$tdir/$tfile
746 test_mkdir -p $DIR/$tdir
749 $LFS setstripe -E1m -c1 -S1m --pool="pool1" -E2m \
750 -E4m -c2 -S2m --pool="pool2" -E-1 $file ||
751 error "Create $file failed"
753 # check --pool inheritance
755 pool="$($LFS getstripe -I2 --pool $file)"
756 [ x"$pool" != "xpool1" ] && $LFS getstripe -I2 $file &&
757 error "$file: component 2 doesn't have poolname pool1"
758 pool="$($LFS getstripe -I4 --pool $file)"
759 [ x"$pool" != "xpool2" ] && $LFS getstripe -I4 $file &&
760 error "$file: component 4 doesn't have poolname pool2"
762 #check --stripe-count inheritance
764 count="$($LFS getstripe -I2 -c $file)"
765 [ $count -ne 1 ] && $LFS getstripe -I2 $file &&
766 error "$file: component 2 doesn't have 1 stripe_count"
767 count="$($LFS getstripe -I4 -c $file)"
768 [ $count -ne 2 ] && $LFS getstripe -I4 $file &&
769 error "$file: component 4 doesn't have 2 stripe_count"
771 #check --stripe-size inheritance
773 size="$($LFS getstripe -I2 -S $file)"
774 [ $size -ne $((1024*1024)) ] && $LFS getstripe -I2 $file &&
775 error "$file: component 2 doesn't have 1M stripe_size"
776 size="$($LFS getstripe -I4 -S $file)"
777 [ $size -ne $((1024*1024*2)) ] && $LFS getstripe -I4 $file &&
778 error "$file: component 4 doesn't have 2M stripe_size"
782 run_test 14 "Verify setstripe poolname/stripe_count/stripe_size inheritance"
785 local parent=$DIR/$tdir
790 $LFS setstripe -d $parent || error "delete default layout"
792 $LFS setstripe -E 1M -S 1M -E 10M -E eof $parent/f1 || error "create f1"
793 $LFS setstripe -E 4M -E 20M -E eof $parent/f2 || error "create f2"
794 test_mkdir $parent/subdir
795 $LFS setstripe -E 6M -S 1M -c1 -E 30M -c4 -E eof -c -1 $parent/subdir ||
796 error "setstripe to subdir"
797 $LFS setstripe -E 8M -E eof $parent/subdir/f3 || error "create f3"
798 $LFS setstripe -c 1 $parent/subdir/f4 || error "create f4"
801 local found=$($LFS find --component-start +2M -E -15M $parent | wc -l)
802 [ $found -eq 0 ] || error "start+2M, end-15M, $found != 0"
805 found=$($LFS find --component-start +2M -E -35M $parent | wc -l)
806 [ $found -eq 2 ] || error "start+2M, end-35M, $found != 2"
809 found=$($LFS find --component-start +4M -E -eof $parent | wc -l)
810 [ $found -eq 1 ] || error "start+4M, end-eof, $found != 1"
812 local flg_opts="--component-flags init"
814 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
816 error "before write: start=1M, end=10M, flag=init, $found != 0"
818 dd if=/dev/zero of=$parent/f1 bs=1M count=2 ||
819 error "dd $parent/f1 failed"
822 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
824 error "after write: start=1M, end=10M, flag=init, $found != 1"
826 local ext_opts="--component-start -1M -E +5M"
827 # parent, subdir, f3, f4
828 found=$($LFS find $ext_opts $parent | wc -l)
829 [ $found -eq 4 ] || error "start-1M, end+5M, $found != 4"
831 local cnt_opts="--component-count +2"
833 found=$($LFS find $ext_opts $cnt_opts $parent | wc -l)
834 [ $found -eq 1 ] || error "start-1M, end+5M, count+2, $found != 1"
837 found=$($LFS find $ext_opts $cnt_opts $flg_opts $parent | wc -l)
839 error "start-1M, end+5M, count+2, flag=init, $found != 0"
842 found=$($LFS find $ext_opts ! $cnt_opts $flg_opts $parent | wc -l)
844 error "start-1M, end+5M, !count+2, flag=init, $found != 2"
846 # check last component stripe count
847 if [ $OSTCOUNT -gt 1 ]; then
848 touch $parent/subdir/f5
849 $TRUNCATE $parent/subdir/f5 $((32*1024*1024))
850 found=$($LFS find $parent/subdir -c $OSTCOUNT)
851 [[ "$found" == "$parent/subdir/f5" ]] ||
852 error "got '$found' with stripe_count=$OSTCOUNT, not f5"
855 run_test 15 "Verify component options for lfs find"
858 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
859 large_xattr_enabled || skip_env "ea_inode feature disabled"
861 local file=$DIR/$tdir/$tfile
862 local dir=$DIR/$tdir/dir
863 local temp=$DIR/$tdir/template
865 test_mkdir $DIR/$tdir
867 #####################################################################
869 # set stripe for source file
870 $LFS setstripe -E1m -S 1M -c2 -o0,1 -E2m -c2 -E3m -o1,0 -E4m -c1 -E-1 \
871 $file || error "Create $file failed"
874 verify_yaml_layout $file $file.copy $temp "1. PFL file"
876 #####################################################################
878 # set stripe for source file
880 $LFS setstripe -c2 -o0,1 -i1 $file || error "Create $file failed"
884 verify_yaml_layout $file $file.copy $temp "2. plain file"
886 #####################################################################
888 # set stripe for source dir
890 $LFS setstripe -E1m -S 1M -c2 -E2m -c1 -E-1 $dir ||
891 error "setstripe $dir failed"
895 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
897 #####################################################################
899 # set stripe for source dir
900 $LFS setstripe -c2 -i-1 $dir || error "setstripe $dir failed"
903 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
905 run_test 16a "Verify setstripe/getstripe with YAML config file"
908 [[ $($LCTL get_param mdc.*.import |
909 grep "connect_flags:.*overstriping") ]] ||
910 skip "server does not support overstriping"
911 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
912 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
913 skip_env "too many osts, skipping"
914 large_xattr_enabled || skip_env "ea_inode feature disabled"
916 local file=$DIR/$tdir/$tfile
917 local dir=$DIR/$tdir/dir
918 local temp=$DIR/$tdir/template
919 # We know OSTCOUNT < (LOV_MAX_STRIPE_COUNT / 2), so this is overstriping
920 local large_count=$((LOV_MAX_STRIPE_COUNT / 2 + 10))
923 test_mkdir $DIR/$tdir
925 #####################################################################
926 # 1. PFL file, overstriping in first comps
927 # set stripe for source file
928 $LFS setstripe -E1m -S 1M -o0,0 -E2m -o1,1 -E3m -C $large_count -E-1 \
929 $file || error "Create $file failed"
932 verify_yaml_layout $file $file.copy $temp "1. PFL file"
934 #####################################################################
935 # 2. plain file + overstriping
936 # set stripe for source file
938 $LFS setstripe -C $large_count -i1 $file || error "Create $file failed"
942 verify_yaml_layout $file $file.copy $temp "2. plain file"
944 #####################################################################
945 # 3. PFL dir + overstriping
946 # set stripe for source dir
948 $LFS setstripe -E1m -S 1M -o 0,0 -E2m -C $large_count -E-1 $dir ||
949 error "setstripe $dir failed"
953 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
955 #####################################################################
956 # 4. plain dir + overstriping
957 # set stripe for source dir
958 $LFS setstripe -C $large_count $dir || error "setstripe $dir failed"
961 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
963 run_test 16b "Verify setstripe/getstripe with YAML config file + overstriping"
966 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
968 local file=$DIR/$tdir/$tfile
969 local dir=$DIR/$tdir/dir
970 local temp=$DIR/$tdir/template
972 test_mkdir $DIR/$tdir
974 #####################################################################
976 # set stripe for source file
977 $LFS setstripe -E256M -S 1M -c2 -o0,1 -z 64M -E-1 -o1,0 -z 128M \
978 $file || error "Create $file failed"
981 verify_yaml_layout $file $file.copy $temp "1. PFL file"
983 #####################################################################
985 # set stripe for source dir
987 $LFS setstripe -E256M -S 1M -c2 -z 64M -E-1 -z 128M \
988 $dir || error "setstripe $dir failed"
991 echo "2. SEL template on dir"
992 verify_yaml_layout $dir $dir.copy $temp.dir "2. PFL dir"
994 run_test 16c "Verify setstripe/getstripe for SEL layout with YAML config file"
997 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
998 local file=$DIR/$tdir/$tfile
999 test_mkdir -p $DIR/$tdir
1002 $LFS setstripe -E 1M -S 1M -E 2M -c 2 -E -1 -c -1 $file ||
1003 error "Create $file failed"
1005 local s1=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
1006 local s2=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
1007 local s3=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
1008 echo "1st init: comp size 1:$s1 2:$s2 3:$s3"
1010 # init 2nd component
1011 $TRUNCATE $file $((1024*1024+1))
1012 local s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
1013 local s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
1014 echo "2nd init: comp size 1:$s1n 2:$s2n 3:$s3"
1016 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
1017 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
1019 # init 3rd component
1020 $TRUNCATE $file $((1024*1024*2+1))
1021 s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
1022 s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
1023 local s3n=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
1024 echo "3rd init: comp size 1:$s1n 2:$s2n 3:$s3n"
1026 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
1027 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
1028 [ $s3 -lt $s3n ] || error "3rd comp size $s3 should < $s3n"
1030 run_test 17 "Verify LOVEA grows with more component inited"
1032 check_distribution() {
1036 local obj_min_one=$((OSTCOUNT - 1))
1038 objs=$($LFS getstripe $file |
1039 awk '/l_ost_idx:/ { print $5 }' | wc -l)
1040 let ave=$((objs / OSTCOUNT))
1042 # collect objects per OST distribution
1043 $LFS getstripe $file | awk '/l_ost_idx:/ { print $5 }' | tr -d "," |
1044 (inuse=( $(for i in $(seq 0 $obj_min_one); do echo 0; done) )
1046 let inuse[$O]=$((1 + ${inuse[$O]}))
1049 # verify object distribution varies no more than +-1
1050 for idx in $(seq 0 $obj_min_one); do
1051 let dif=$((${inuse[$idx]} - ave))
1053 if [ "$dif" -gt 1 ]; then
1054 echo "OST${idx}: ${inuse[$idx]} objects"
1055 error "bad distribution on OST${idx}"
1061 local file1=$DIR/${tfile}-1
1062 local file2=$DIR/${tfile}-2
1063 local file3=$DIR/${tfile}-3
1065 rm -f $file1 $file2 $file3
1067 $LFS setstripe -E 1m -S 1m $file1 ||
1068 error "Create $file1 failed"
1069 $LFS setstripe -E 1m -S 1m $file2 ||
1070 error "Create $file2 failed"
1071 $LFS setstripe -E 1m -S 1m $file3 ||
1072 error "Create $file3 failed"
1074 local objs=$((OSTCOUNT+1))
1075 for comp in $(seq 1 $OSTCOUNT); do
1076 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file1 ||
1077 error "Add component to $file1 failed 2"
1078 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file2 ||
1079 error "Add component to $file2 failed 2"
1080 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file3 ||
1081 error "Add component to $file3 failed 2"
1084 $LFS setstripe --component-add -E -1 -c -1 $file1 ||
1085 error "Add component to $file1 failed 3"
1086 $LFS setstripe --component-add -E -1 -c -1 $file2 ||
1087 error "Add component to $file2 failed 3"
1088 $LFS setstripe --component-add -E -1 -c -1 $file3 ||
1089 error "Add component to $file3 failed 3"
1091 # Instantiate all components
1092 dd if=/dev/urandom of=$file1 bs=1M count=$((objs+1)) ||
1093 error "dd failed for $file1"
1094 dd if=/dev/urandom of=$file2 bs=1M count=$((objs+1)) ||
1095 error "dd failed for $file2"
1096 dd if=/dev/urandom of=$file3 bs=1M count=$((objs+1)) ||
1097 error "dd failed for $file3"
1099 check_distribution $file1
1100 check_distribution $file2
1101 check_distribution $file3
1104 run_test 18 "check component distribution"
1108 local already_created=${2:-0}
1109 local rw_len=$((3 * 1024 * 1024)) # 3M
1113 if [ $already_created != 1 ]; then
1114 test_mkdir -p $DIR/$tdir
1115 $LFS setstripe --extension-size 64M -c 1 -E -1 $comp_file ||
1116 error "Create $comp_file failed"
1119 # write past end of first component, so it is extended
1120 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=127 conv=notrunc ||
1121 error "dd to extend failed"
1123 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1124 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1126 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1127 [ $ost_idx2 -ne "-1" ] && error "second component init $ost_idx2"
1129 flg_opts="--comp-flags init"
1130 found=$($LFS find --comp-start 0 -E 128M $flg_opts $comp_file | wc -l)
1131 [ $found -eq 1 ] || error "Write: Extended first component not found"
1133 flg_opts="--comp-flags extension"
1134 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1135 [ $found -eq 1 ] || error "Write: second component not found"
1137 found=$($LFS find -z 64M $comp_file | wc -l)
1138 [ $found -eq 1 ] || error "component not found by ext size"
1140 found=$($LFS find --extension-size +63M $comp_file | wc -l)
1141 [ $found -eq 1 ] || error "component not found by +ext size"
1143 found=$($LFS find --ext-size -65M $comp_file | wc -l)
1144 [ $found -eq 1 ] || error "component not found by -ext size"
1146 found=$($LFS find -z 65M $comp_file | wc -l)
1147 [ $found -eq 0 ] || error "component found by wrong ext size"
1149 found=$($LFS find -z +65M $comp_file | wc -l)
1150 [ $found -eq 0 ] || error "component found by wrong +ext size"
1152 found=$($LFS find -z -63M $comp_file | wc -l)
1153 [ $found -eq 0 ] || error "component found by wrong -ext size"
1155 found=$($LFS find ! -z 64M $comp_file | wc -l)
1156 [ $found -eq 0 ] || error "component found by negation of ext size"
1158 found=$($LFS find ! -z +63M $comp_file | wc -l)
1159 [ $found -eq 0 ] || error "component found by negation of +ext size"
1161 found=$($LFS find ! -z -65M $comp_file | wc -l)
1162 [ $found -eq 0 ] || error "component found by negation of -ext size"
1164 found=$($LFS find ! -z 65M $comp_file | wc -l)
1166 error "component not found by negation of wrong ext size"
1168 found=$($LFS find ! -z +65M $comp_file | wc -l)
1170 error "component not found by negation of wrong +ext size"
1172 found=$($LFS find ! -z -63M $comp_file | wc -l)
1174 error "component not found by negation of wrong -ext size"
1176 found=$($LFS find -S +1M $comp_file | wc -l)
1177 [ $found -eq 0 ] || error "component found by wrong +stripe size"
1179 found=$($LFS find -c 1 $comp_file | wc -l)
1180 [ $found -eq 1 ] || error "component not found by stripe count"
1182 small_write $comp_file $rw_len || error "Verify RW failed"
1184 sel_layout_sanity $comp_file 2
1187 # Self-extending PFL tests
1189 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1190 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1191 skip "skipped for lustre < $SEL_VER"
1193 test19_io_base $DIR/$tdir/$tfile
1195 run_test 19a "Simple test of extension behavior"
1197 # Same as 19a, but with default layout set on directory rather than on file
1199 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1200 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1201 skip "skipped for lustre < $SEL_VER"
1203 local comp_file=$DIR/$tdir/$tfile
1204 local comp_dir=$DIR/$tdir/$tdir
1208 test_mkdir -p $DIR/$tdir
1209 $LFS setstripe --ext-size 64M -c 1 -E -1 $DIR/$tdir ||
1210 error "Setstripe on $DIR/$tdir failed"
1212 # check inheritance for a sub-dir and a file
1213 test_mkdir $comp_dir
1214 found=$($LFS find --comp-start 0 -E 64M $comp_dir | wc -l)
1215 [ $found -eq 1 ] || error "Dir Inheritance: wrong first component size"
1217 flg_opts="--comp-flags extension"
1218 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_dir | wc -l)
1219 [ $found -eq 1 ] || error "Dir Inheritance: Second component not found"
1223 flg_opts="--comp-flags init"
1224 found=$($LFS find --comp-start 0 -E 64M $flg_opts $comp_file | wc -l)
1225 [ $found -eq 1 ] || error "File Inheritance: wrong first component size"
1227 flg_opts="--comp-flags extension"
1228 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_file | wc -l)
1229 [ $found -eq 1 ] || error "File Inheritance: Second component not found"
1231 test19_io_base $comp_file 1
1233 run_test 19b "Simple test of SEL as default layout"
1235 # Test behavior when seeking deep in a file
1237 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1238 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1239 skip "skipped for lustre < $SEL_VER"
1241 local comp_file=$DIR/$tdir/$tfile
1245 test_mkdir -p $DIR/$tdir
1247 $LFS setstripe -z 128M -E 1G -E -1 $comp_file ||
1248 error "Create $comp_file failed"
1250 # write past end of first component, so it is extended
1251 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 conv=notrunc ||
1252 error "dd to extend failed"
1254 flg_opts="--comp-flags init"
1255 found=$($LFS find --comp-start 0M -E 256M $flg_opts $comp_file | wc -l)
1256 [ $found -eq 1 ] || error "Write: first extension component not found"
1258 flg_opts="--comp-flags extension,^init"
1259 found=$($LFS find --comp-start 256M -E 1024M $flg_opts $comp_file |\
1261 [ $found -eq 1 ] || error "Write: second extension component not found"
1263 local end_1=$($LFS getstripe -I1 -E $comp_file)
1266 [ $end_1 -eq 268435456 ] ||
1267 error "end of first component $end_1 != 268435456"
1269 # Write past end of extension space component, in to normal component
1270 # should exhaust & remove extension component
1271 dd if=/dev/zero bs=1M count=1 seek=1100 of=$comp_file conv=notrunc ||
1272 error "dd distant seek failed"
1274 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1275 # the last component index is 3
1276 local ost_idx2=$($LFS getstripe -I3 -i $comp_file)
1278 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1280 local start1=$($LFS getstripe -I1 --comp-start $comp_file)
1281 local end1=$($LFS getstripe -I1 -E $comp_file)
1282 local start2=$($LFS getstripe -I3 --comp-start $comp_file)
1283 local end2=$($LFS getstripe -I3 -E $comp_file)
1285 [ $start1 -eq 0 ] || error "start of first component incorrect"
1286 [ $end1 -eq 1073741824 ] || error "end of first component incorrect"
1287 [ $start2 -eq 1073741824 ] ||
1288 error "start of second component incorrect"
1289 [ "$end2" = "EOF" ] || error "end of second component incorrect"
1291 flg_opts="--comp-flags extension"
1292 found=$($LFS find $flg_opts $comp_file | wc -l)
1293 [ $found -eq 0 ] || error "Seek Write: extension component exists"
1295 sel_layout_sanity $comp_file 2
1297 run_test 19c "Test self-extending layout seeking behavior"
1300 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1301 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1302 skip "skipped for lustre < $SEL_VER"
1304 local comp_file=$DIR/$tdir/$tfile
1308 test_mkdir -p $DIR/$tdir
1310 $LFS setstripe -E 128M -c 1 -z 64M -E -1 $comp_file ||
1311 error "Create $comp_file failed"
1313 # This will cause component 1 to be extended to 128M, then the
1314 # extension space component will be removed
1315 dd if=/dev/zero of=$comp_file bs=130M count=1 ||
1316 error "dd to extend failed"
1318 flg_opts="--comp-flags init"
1319 found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file | wc -l)
1320 [ $found -eq 1 ] || error "Write: first component not found"
1322 flg_opts="--comp-flags init"
1323 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1324 [ $found -eq 1 ] || error "Write: second component not found"
1326 sel_layout_sanity $comp_file 2
1328 # always remove large files in case of DO_CLEANUP=false
1329 rm -f $comp_file || error "Delete $comp_file failed"
1331 run_test 19d "Test write which completely spans extension space component"
1336 local comp2_flags=$($LFS getstripe -I2 --comp-flags $comp_file)
1337 local comp3_flags=$($LFS getstripe -I3 --comp-flags $comp_file)
1339 [ "$comp2_flags" != "init" ] && error "$comp2_flags != init"
1340 [ "$comp3_flags" != "extension" ] && error "$comp3_flags != extension"
1342 local flg_opts=" --comp-start 2M -E 66M --comp-flags init"
1343 local found=$($LFS find $flg_opts $comp_file | wc -l)
1344 [ $found -eq 1 ] || error "Write: extended second component not found"
1346 flg_opts="--comp-start 66M -E EOF --comp-flags extension"
1347 found=$($LFS find $flg_opts $comp_file | wc -l)
1348 [ $found -eq 1 ] || error "Write: third component not found"
1350 sel_layout_sanity $comp_file 3
1354 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1355 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1356 skip "skipped for lustre < $SEL_VER"
1358 local comp_file=$DIR/$tdir/$tfile
1359 local rw_len=$((3 * 1024 * 1024)) # 3M
1363 test_mkdir -p $DIR/$tdir
1365 $LFS setstripe -E 2m -E -1 -z 64M $comp_file ||
1366 error "Create $comp_file failed"
1368 replay_barrier $SINGLEMDS
1370 #instantiate & extend second component
1371 dd if=/dev/zero of=$comp_file bs=4M count=1 ||
1372 error "dd to extend failed"
1374 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1375 local ost_idx3=$($LFS getstripe -I3 -i $comp_file)
1377 [ $ost_idx2 -eq $ost_idx3 ] && error "$ost_idx2 == $ost_idx3"
1378 [ $ost_idx3 -ne "-1" ] && error "third component init $ost_idx3"
1380 test_19e_check $comp_file
1382 local f1=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1383 echo "before MDS recovery, the ost fid of 2nd component is $f1"
1387 local f2=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1388 echo "after MDS recovery, the ost fid of 2nd component is $f2"
1389 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
1391 # simply repeat all previous checks, but also verify components are on
1392 # the same OST as before
1394 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1395 local ost_idx3_2=$($LFS getstripe -I3 -i $comp_file)
1397 [ $ost_idx2_2 -eq $ost_idx3_2 ] && error "$ost_idx2_2 == $ost_idx3_2"
1398 [ $ost_idx3_2 -ne "-1" ] && error "second component init $ost_idx3_2"
1400 # verify OST id is the same after failover
1401 [ $ost_idx2 -ne $ost_idx2_2 ] &&
1402 error "$ost_idx2 != $ost_idx2_2, changed after failover"
1404 test_19e_check $comp_file
1406 run_test 19e "Replay of layout instantiation & extension"
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
1417 test_mkdir -p $DIR/$tdir
1419 $LFS setstripe -E 256M --comp-flags extension -E -1 $comp_file
1421 [ $? != 0 ] || error "should not be able to manually set extension flag"
1424 run_test 19f "Rejection of invalid layouts"
1427 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1428 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1429 skip "skipped for lustre < $SEL_VER"
1431 local file1=$DIR/${tfile}-1
1432 local file2=$DIR/${tfile}-2
1434 test_mkdir -p $DIR/$tdir
1435 multiop $file1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1436 error "create failed $file1"
1437 multiop $file2 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1438 error "create failed $file2"
1440 $LFS setstripe --component-add -E 1G -c 1 $file1 ||
1441 error "comp-add [0,1G] failed $file1"
1442 $LFS setstripe --component-add -E 512M -z 128M $file1 &&
1443 error "comp-add [1G,1G],SEL[1G,512M] succeded $file1"
1444 $LFS setstripe --component-add -E 10G -z 128M $file1 ||
1445 error "comp-add [1G,1G],SEL[1G,10G] failed $file1"
1446 $LFS setstripe --component-add -E -1 $file1 ||
1447 error "comp-add [10G,-1] failed $file1"
1449 $LFS setstripe --component-add -E 1G -z 32M -c 1 $file2 &&
1450 error "comp-add with smal ext size succeeded $file1"
1451 $LFS setstripe --component-add -E 1G -z 100M -c 1 $file2 &&
1452 error "comp-add with not aligned ext size succeeded $file1"
1453 $LFS setstripe --component-add -E 1G -z 128M -c 1 $file2 ||
1454 error "comp-add [0,128M],SEL[128M,1G] failed $file1"
1455 $LFS setstripe --component-add -E 10G $file2 ||
1456 error "comp-add [1G,10G] failed $file1"
1457 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 ||
1458 error "comp-add [10G,10G],SEL[10G,-1] failed $file1"
1459 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 &&
1460 error "repeated comp-add [10G,10G],SEL[10G,-1] succeeded $file1"
1462 $LFS getstripe $file1
1463 flg_opts="--comp-flags init"
1464 found=$($LFS find --comp-start 0 -E 1G $flg_opts $file1 | wc -l)
1465 [ $found -eq 1 ] || error "First component not found $file1"
1467 flg_opts="--comp-flags ^init"
1468 found=$($LFS find --comp-start 1G -E 1G $flg_opts $file1 | wc -l)
1469 [ $found -eq 1 ] || error "Second component not found $file1"
1471 flg_opts="--comp-flags ^init,extension"
1472 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file1 | wc -l)
1473 [ $found -eq 1 ] || error "Third component not found $file1"
1475 flg_opts="--comp-flags ^init"
1476 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file1 | wc -l)
1477 [ $found -eq 1 ] || error "Fourth component not found $file1"
1479 $LFS getstripe $file2
1480 flg_opts="--comp-flags init"
1481 found=$($LFS find --comp-start 0 -E 128M $flg_opts $file2 | wc -l)
1482 [ $found -eq 1 ] || error "First component not found $file2"
1484 flg_opts="--comp-flags extension"
1485 found=$($LFS find --comp-start 128M -E 1G $flg_opts $file2 | wc -l)
1486 [ $found -eq 1 ] || error "Second component not found $file2"
1488 flg_opts="--comp-flags ^init"
1489 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file2 | wc -l)
1490 [ $found -eq 1 ] || error "Third component not found $file2"
1492 flg_opts="--comp-flags ^init"
1493 found=$($LFS find --comp-start 10G -E 10G $flg_opts $file2 | wc -l)
1494 [ $found -eq 1 ] || error "Fourth component not found $file2"
1496 flg_opts="--comp-flags ^init,extension"
1497 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file2 | wc -l)
1498 [ $found -eq 1 ] || error "Fifth component not found $file2"
1500 run_test 19g "component-add behaviour"
1502 # Test out of space behavior
1504 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1505 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1506 skip "skipped for lustre < $SEL_VER"
1508 local comp_file=$DIR/$tdir/$tfile
1512 test_mkdir -p $DIR/$tdir
1514 # without this, a previous delete can finish after we check free space
1515 wait_delete_completed
1518 # First component is on OST0
1519 $LFS setstripe -E 256M -i 0 -z 64M -E -1 -z 128M $comp_file ||
1520 error "Create $comp_file failed"
1522 # write past end of first component, so it is extended
1523 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=66 ||
1524 error "dd to extend failed"
1526 flg_opts="--comp-flags extension"
1527 found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file |wc -l)
1528 [ $found -eq 1 ] || error "Write: Second component not found"
1530 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1531 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1533 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1535 flg_opts="--comp-flags extension"
1536 # Write past current init comp, but we won't extend (because no space)
1537 dd if=/dev/zero of=$comp_file bs=1M count=10 seek=200 ||
1538 error "dd write past current comp failed"
1540 $LFS getstripe $comp_file
1542 flg_opts="--comp-flags init"
1543 found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file | \
1545 [ $found -eq 1 ] || error "Write: third component not found"
1547 flg_opts="--comp-flags extension"
1548 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file |wc -l)
1549 [ $found -eq 1 ] || error "Write: fourth extension component not found"
1551 sel_layout_sanity $comp_file 3
1553 run_test 20a "Test out of space, spillover to defined component"
1556 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1557 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1558 skip "skipped for lustre < $SEL_VER"
1560 local comp_file=$DIR/$tdir/$tfile
1564 test_mkdir -p $DIR/$tdir
1566 # Pool allows us to force use of only certain OSTs
1567 pool_add $TESTNAME || error "Pool creation failed"
1568 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1570 # normal component to 10M, extendable component to 1G
1571 # further extendable to EOF
1572 $LFS setstripe -E 10M -E 1G -p $TESTNAME -z 64M -E -1 -p "" -z 128M \
1573 $comp_file || error "Create $comp_file failed"
1575 replay_barrier $SINGLEMDS
1577 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1578 [ $found -eq 1 ] || error "Zero length component not found"
1581 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1583 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1585 # write past end of first component
1586 # This should remove the next component, since OST0 is out of space
1587 # and it is striped there (pool contains only OST0)
1588 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=14 ||
1589 error "dd to extend/remove failed"
1591 $LFS getstripe $comp_file
1593 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1594 [ $found -eq 0 ] || error "Write: zero length component still present"
1596 flg_opts="--comp-flags init"
1597 found=$($LFS find --comp-start 10M -E 138M $flg_opts $comp_file | wc -l)
1598 [ $found -eq 1 ] || error "Write: second component not found"
1600 flg_opts="--comp-flags extension"
1601 found=$($LFS find --comp-start 138M -E EOF $flg_opts $comp_file | wc -l)
1602 [ $found -eq 1 ] || error "Write: third component not found"
1606 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1607 [ $found -eq 0 ] || error "Failover: 0-length component still present"
1609 flg_opts="--comp-flags init"
1610 found=$($LFS find --comp-start 10M -E 138M $flg_opts $comp_file | wc -l)
1611 [ $found -eq 1 ] || error "Failover: second component not found"
1613 flg_opts="--comp-flags extension"
1614 found=$($LFS find --comp-start 138M -E EOF $flg_opts $comp_file | wc -l)
1615 [ $found -eq 1 ] || error "Failover: third component not found"
1617 sel_layout_sanity $comp_file 3
1619 run_test 20b "Remove component without instantiation when there is no space"
1622 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1623 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1624 skip "skipped for lustre < $SEL_VER"
1626 local comp_file=$DIR/$tdir/$tfile
1630 test_mkdir -p $DIR/$tdir
1632 # pool is used to limit available OSTs to 0 and 1, so we can set all
1633 # available OSTs out of space
1634 pool_add $TESTNAME || error "Pool creation failed"
1635 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
1637 # without this, a previous delete can finish after we check free space
1638 wait_delete_completed
1641 $LFS setstripe -E 100M -E -1 -p $TESTNAME -z 64M $comp_file ||
1642 error "Create $comp_file failed"
1646 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1648 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
1650 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1651 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
1653 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=120 &&
1654 error "dd should fail with ENOSPC"
1656 flg_opts="--comp-flags init"
1657 found=$($LFS find --comp-start 0M -E 100M $flg_opts $comp_file | wc -l)
1658 [ $found -eq 1 ] || error "Write: First component not found"
1660 flg_opts="--comp-flags ^init"
1661 found=$($LFS find --comp-start 100M -E 100M $flg_opts $comp_file |wc -l)
1662 [ $found -eq 1 ] || error "Write: 0-length component not found"
1664 flg_opts="--comp-flags extension"
1665 found=$($LFS find --comp-start 100M -E EOF $flg_opts $comp_file | wc -l)
1666 [ $found -eq 1 ] || error "Write: third extension component not found"
1668 sel_layout_sanity $comp_file 3
1670 run_test 20c "Test inability to stripe new extension component"
1673 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1674 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1675 skip "skipped for lustre < $SEL_VER"
1677 local comp_file=$DIR/$tdir/$tfile
1678 test_mkdir -p $DIR/$tdir
1680 wait_delete_completed
1683 pool_add $TESTNAME || error "Pool creation failed"
1684 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1685 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
1686 error "Create $comp_file failed"
1688 replay_barrier $SINGLEMDS
1690 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1691 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1694 ost_watermarks_clear_enospc $tfile 0 $wms
1695 [ $RC -eq 0 ] || error "dd failed: $RC"
1697 $LFS getstripe $comp_file
1698 local flg_opts="--comp-start 64M -E 128M --comp-flags init"
1699 local found=$($LFS find $flg_opts $comp_file | wc -l)
1700 [ $found -eq 1 ] || error "Write: component (64M-128M) not found"
1702 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
1703 [ "$ost_idx" != "-1" ] && error "Write: EXT component disappeared"
1707 found=$($LFS find $flg_opts $comp_file | wc -l)
1708 [ $found -eq 1 ] || error "Failover: component (64M-128M) not found"
1710 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1711 [ "$ost_idx" != "-1" ] && error "Failover: EXT component disappeared"
1713 sel_layout_sanity $comp_file 3
1715 run_test 20d "Low on space + 0-length comp: force extension"
1718 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1719 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1720 skip "skipped for lustre < $SEL_VER"
1722 local comp_file=$DIR/$tdir/$tfile
1723 test_mkdir -p $DIR/$tdir
1725 wait_delete_completed
1728 pool_add $TESTNAME || error "Pool creation failed"
1729 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1731 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
1732 error "Create $comp_file failed"
1734 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1736 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1739 ost_watermarks_clear_enospc $tfile 0 $wms
1740 [ $RC -eq 0 ] || error "dd failed $RC"
1742 $LFS getstripe $comp_file
1743 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
1744 local found=$($LFS find $flg_opts $comp_file | wc -l)
1745 [ $found -eq 1 ] || error "Write: component (64M-EOF) not found"
1747 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
1748 [ "$ost_idx" != "" ] && error "Write: 0-length component still exists"
1749 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1750 [ "$ost_idx" != "" ] && error "Write: extension component still exists"
1752 sel_layout_sanity $comp_file 2
1754 run_test 20e "ENOSPC with next real comp: spillover and backward extension"
1756 # Simple DoM interaction test
1758 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1759 skip "skipped for lustre < $SEL_VER"
1761 local comp_file=$DIR/$tdir/$tfile
1765 test_mkdir -p $DIR/$tdir
1767 # simple, correct self-extending layout after DoM component
1768 $LFS setstripe -E 1M -L mdt -E -1 -z 64m $comp_file || \
1769 error "Create $comp_file failed"
1771 # Write to DoM component & to self-extending comp after it
1772 dd if=/dev/zero bs=1M count=12 of=$comp_file ||
1773 error "dd to extend failed"
1775 flg_opts="--comp-flags init"
1776 found=$($LFS find --comp-start 1M -E 65M $flg_opts $comp_file | wc -l)
1777 [ $found -eq 1 ] || error "Write: extended component not found"
1779 flg_opts="--comp-flags extension"
1780 found=$($LFS find --comp-start 65M $flg_opts $comp_file | wc -l)
1781 [ $found -eq 1 ] || error "Write: extension component not found"
1783 sel_layout_sanity $comp_file 3
1785 run_test 21a "Simple DoM interaction tests"
1787 # DoM + extension + removal
1789 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1790 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1791 skip "skipped for lustre < $SEL_VER"
1793 local comp_file=$DIR/$tdir/$tfile
1794 local ost_name=$(ostname_from_index 0)
1798 test_mkdir -p $DIR/$tdir
1800 # DoM, extendable component, further extendable component
1801 $LFS setstripe -E 1M -L mdt -E 256M -i 0 -z 64M -E -1 -z 128M \
1802 $comp_file || error "Create $comp_file failed"
1804 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1805 [ $found -eq 1 ] || error "Write: Zero length component not found"
1807 # This also demonstrates that we will avoid degraded OSTs
1808 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
1809 # sleep to guarantee we see the degradation
1812 # un-degrade on exit
1813 stack_trap "do_facet ost1 $LCTL set_param -n \
1814 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1816 # This should remove the first component after DoM and spill over to
1818 dd if=/dev/zero bs=1M count=2 of=$comp_file ||
1819 error "dd to remove+spill over failed"
1821 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1822 [ $found -eq 0 ] || error "Write: Zero length component still present"
1824 flg_opts="--comp-flags init"
1825 found=$($LFS find --comp-start 1M -E 129M $flg_opts $comp_file | wc -l)
1826 [ $found -eq 1 ] || error "Write: extended component not found"
1828 flg_opts="--comp-flags extension"
1829 found=$($LFS find --comp-start 129M -E EOF $flg_opts $comp_file |wc -l)
1830 [ $found -eq 1 ] || error "Write: extension component not found"
1832 sel_layout_sanity $comp_file 3
1834 run_test 21b "DoM followed by extendable component with removal"
1836 # Test of repeat component behavior with OOS/degraded OST
1838 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1839 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1840 skip "skipped for lustre < $SEL_VER"
1842 local comp_file=$DIR/$tdir/$tfile
1846 test_mkdir -p $DIR/$tdir
1848 $LFS setstripe -E -1 -c 1 -z 128M $comp_file ||
1849 error "Create $comp_file failed"
1851 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1852 local ost_name=$(ostname_from_index $ost_idx1)
1854 # write past end of first component, so it is extended
1855 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
1856 error "dd to extend failed"
1858 flg_opts="--comp-flags extension"
1859 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
1860 [ $found -eq 1 ] || error "Write: second component not found"
1862 # degrade OST for component 1
1863 do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
1864 obdfilter.$ost_name.degraded=1
1865 # sleep to guarantee we see the degradation
1868 # un-degrade on exit
1869 stack_trap "do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
1870 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1872 replay_barrier $SINGLEMDS
1874 # seek past the end of current comp & write, should cause a new comp
1875 # to be created (ie repeat previous comp)
1876 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
1877 error "dd to repeat failed"
1879 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1881 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1883 flg_opts="--comp-flags init"
1884 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1885 [ $found -eq 1 ] || error "Write: second component not found"
1887 flg_opts="--comp-flags extension"
1888 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1889 [ $found -eq 1 ] || error "Write: extension component not found"
1893 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1894 [ $ost_idx2_2 -ne $ost_idx2 ] && error "$ost_idx2_2 != $ost_idx2"
1896 flg_opts="--comp-flags init"
1897 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1898 [ $found -eq 1 ] || error "Failover: second component not found"
1900 flg_opts="--comp-flags extension"
1901 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1902 [ $found -eq 1 ] || error "Failover: extension component not found"
1904 sel_layout_sanity $comp_file 3
1906 run_test 22a "Test repeat component behavior with degraded OST"
1908 # Test repeat behavior with low space
1910 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1911 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1912 skip "skipped for lustre < $SEL_VER"
1914 local comp_file=$DIR/$tdir/$tfile
1918 test_mkdir -p $DIR/$tdir
1920 # without this, a previous delete can finish after we check free space
1921 wait_delete_completed
1924 $LFS setstripe -E -1 -c 1 -z 128M \
1925 $comp_file || error "Create $comp_file failed"
1927 # write past end of first component, so it is extended
1928 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
1929 error "dd to extend failed"
1931 flg_opts="--comp-flags extension"
1932 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
1933 [ $found -eq 1 ] || error "Write: Second component not found"
1935 # set our OST low on space
1936 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1937 local wms=$(ost_watermarks_set_low_space $ost_idx1 | grep "watermarks")
1939 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1941 # Write past end of current space, fail to extend, causing repeat
1942 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
1943 error "dd to repeat failed"
1945 $LFS getstripe $comp_file
1947 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1949 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $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 "Write: 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 "Write: Extension component not found"
1959 sel_layout_sanity $comp_file 3
1961 run_test 22b "Test simple 'out of space' condition with repeat"
1963 # This tests both "repeat" and "extend in place when repeat fails" aspects
1964 # of repeating components
1966 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1967 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1968 skip "skipped for lustre < $SEL_VER"
1970 local comp_file=$DIR/$tdir/$tfile
1974 test_mkdir -p $DIR/$tdir
1976 # pool is used to limit available OSTs to 0 and 1, so we can set all
1977 # available OSTs out of space
1978 pool_add $TESTNAME || error "Pool creation failed"
1979 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
1981 # without this, a previous delete can finish after we check free space
1982 wait_delete_completed
1985 $LFS setstripe -E -1 -z 64M -c 1 -p "$TESTNAME" $comp_file || \
1986 error "Create $comp_file failed"
1988 # write past end of first component, so it is extended
1989 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=80 conv=notrunc ||
1990 error "dd to extend failed"
1992 $LFS getstripe $comp_file
1994 flg_opts="--comp-flags extension"
1995 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1996 [ $found -eq 1 ] || error "Write: second component not found"
1998 # set our OST out of space
1999 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
2000 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
2002 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
2004 # This should create a repeat component on a new OST
2005 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=180 conv=notrunc ||
2006 error "dd to repeat failed"
2008 $LFS getstripe $comp_file
2010 local comp_cnt=$($LFS getstripe --component-count $comp_file)
2011 [ $comp_cnt -ne 3 ] && error "component count: $comp_cnt, should be 3"
2013 # New second component should be on a different OST
2014 local ost_idx2=$($LFS getstripe --comp-start=128m \
2015 --comp-end=192m --comp-flags=init -i $comp_file)
2017 [ $ost_idx1 -eq $ost_idx2 ] && error "2nd comp: same OST $ost_idx1"
2019 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
2021 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
2023 # now that the second OST is out of space (as is the first OST), we
2024 # attempt to extend. This should result in an extension of the
2025 # existing component, rather than a new component.
2026 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=240 conv=notrunc ||
2027 error "dd for forced extension failed"
2029 $LFS getstripe $comp_file
2031 # clear out of space on first OST
2032 ost_watermarks_clear_enospc $tfile $ost_idx1 $wms
2034 # finally, now that the first OST has space again, we attempt to
2035 # extend one last time. This should create a new component on the
2037 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 conv=notrunc ||
2038 error "dd for repeat on first OST failed"
2040 $LFS getstripe $comp_file
2042 flg_opts="--comp-flags init"
2043 found=$($LFS find --comp-start 128M $flg_opts $comp_file | wc -l)
2044 [ $found -eq 1 ] || error "Write: second component not found"
2046 flg_opts="--comp-flags init"
2047 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
2048 [ $found -eq 1 ] || error "Write: third component not found"
2050 flg_opts="--comp-flags extension"
2051 found=$($LFS find --comp-start 320M -E EOF $flg_opts $comp_file | wc -l)
2052 [ $found -eq 1 ] || error "Write: extension component not found"
2054 sel_layout_sanity $comp_file 4
2056 run_test 22c "Test repeat with out of space on > 1 OST"
2058 test_22d_post_check() {
2061 local flg_opts="--comp-flags init"
2062 local found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file |
2064 [ $found -eq 1 ] || {
2065 $LFS getstripe $comp_file
2066 error "$name: second component not found"
2069 flg_opts="--comp-flags extension"
2070 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
2071 [ $found -eq 1 ] || error "$name: third extension component not found"
2073 sel_layout_sanity $comp_file 2
2081 # write past end of first component
2082 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=70
2085 ost_watermarks_clear_enospc $tfile 0 $wms
2086 [ $RC -eq 0 ] || error "dd to force extend failed"
2088 test_22d_post_check $comp_file "Write"
2092 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2093 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2094 skip "skipped for lustre < $SEL_VER"
2096 local comp_file=$DIR/$tdir/$tfile
2100 test_mkdir -p $DIR/$tdir
2102 # without this, a previous delete can finish after we check free space
2103 wait_delete_completed
2106 # Pool allows us to force use of only certain OSTs
2107 pool_add $TESTNAME || error "Pool creation failed"
2108 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2110 # 1. Fail to extend due to OOS, try to repeat within the same pool,
2111 # fail to stripe (again OOS) the 0-length component, remove the
2112 # repeated one, force the extension on the original one.
2113 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2114 error "Create $comp_file failed"
2116 replay_barrier $SINGLEMDS
2118 # set our OST out of space
2119 local wms=$(ost_watermarks_set_enospc $tfile 0 | grep "watermarks")
2121 test_22d_pre $comp_file "$wms"
2123 test_22d_post_check $comp_file "Failover"
2125 # 2. repeat with low on space: 0-length repeated component will be
2126 # striped, but still fails to be extended; otherwise the same as (1).
2128 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2129 error "Create $comp_file failed"
2131 replay_barrier $SINGLEMDS
2133 # set our OST low on space
2134 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2136 test_22d_pre $comp_file "$wms"
2138 test_22d_post_check $comp_file "Failover"
2140 run_test 22d "out of/low on space + failed to repeat + forced extension"
2143 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2144 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2145 skip "skipped for lustre < $SEL_VER"
2147 local comp_file=$DIR/$tdir/$tfile
2148 test_mkdir -p $DIR/$tdir
2150 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2151 error "Create $comp_file failed"
2153 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2154 error "dd append failed"
2156 local flg_opts="--comp-start 0 -E EOF --comp-flags init"
2157 local found=$($LFS find $flg_opts $comp_file | wc -l)
2158 [ $found -eq 1 ] || error "Append: first component (0-EOF) not found"
2160 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2161 [ "$ost_idx" != "" ] && error "Append: second component still exists"
2163 sel_layout_sanity $comp_file 1
2165 run_test 23a "Append: remove EXT comp"
2168 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2169 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2170 skip "skipped for lustre < $SEL_VER"
2172 local comp_file=$DIR/$tdir/$tfile
2173 test_mkdir -p $DIR/$tdir
2175 $LFS setstripe -E 64m -E -1 -z 64M $comp_file ||
2176 error "Create $comp_file failed"
2178 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2179 error "dd append failed"
2181 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2182 local found=$($LFS find $flg_opts $comp_file | wc -l)
2183 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2185 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2186 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2188 sel_layout_sanity $comp_file 2
2190 run_test 23b "Append with 0-length comp: remove EXT comp"
2193 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2194 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2195 skip "skipped for lustre < $SEL_VER"
2197 local comp_file=$DIR/$tdir/$tfile
2198 test_mkdir -p $DIR/$tdir
2200 wait_delete_completed
2203 pool_add $TESTNAME || error "Pool creation failed"
2204 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2205 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
2206 error "Create $comp_file failed"
2208 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2209 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2212 ost_watermarks_clear_enospc $tfile 0 $wms
2213 [ $RC -eq 0 ] || error "dd append failed: $RC"
2215 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2216 local found=$($LFS find $flg_opts $comp_file | wc -l)
2217 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2219 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2220 [ "$ost_idx" != "" ] && error "Append: EXT component still exists"
2222 sel_layout_sanity $comp_file 2
2224 run_test 23c "Append with low on space + 0-length comp: force extension"
2227 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2228 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2229 skip "skipped for lustre < $SEL_VER"
2231 local comp_file=$DIR/$tdir/$tfile
2232 test_mkdir -p $DIR/$tdir
2234 $LFS setstripe -E 64m -E 640M -z 64M -E -1 $comp_file ||
2235 error "Create $comp_file failed"
2237 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2238 error "dd append failed"
2240 flg_opts="--comp-start 64M -E 640M --comp-flags init"
2241 found=$($LFS find $flg_opts $comp_file | wc -l)
2242 [ $found -eq 1 ] || error "Append: component (64M-640M) not found"
2244 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2245 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2247 sel_layout_sanity $comp_file 3
2249 run_test 23d "Append with 0-length comp + next real comp: remove EXT comp"
2252 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2253 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2254 skip "skipped for lustre < $SEL_VER"
2256 local comp_file=$DIR/$tdir/$tfile
2257 test_mkdir -p $DIR/$tdir
2259 wait_delete_completed
2262 pool_add $TESTNAME || error "Pool creation failed"
2263 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2265 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
2266 error "Create $comp_file failed"
2268 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2270 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2273 ost_watermarks_clear_enospc $tfile 0 $wms
2274 [ $RC -eq 0 ] || error "dd append failed $RC"
2276 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2277 local found=$($LFS find $flg_opts $comp_file | wc -l)
2278 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2280 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2281 [ "$ost_idx" != "" ] && error "Append: 0-length component still exists"
2282 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2283 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2285 sel_layout_sanity $comp_file 2
2287 run_test 23e "Append with next real comp: spillover and backward extension"
2290 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2291 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2292 skip "skipped for lustre < $SEL_VER"
2294 local comp_file=$DIR/$tdir/$tfile
2295 test_mkdir -p $DIR/$tdir
2297 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2298 error "Create $comp_file failed"
2300 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
2301 local wms=$(ost_watermarks_set_low_space $ost_idx | grep "watermarks")
2303 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2306 ost_watermarks_clear_enospc $tfile $ost_idx $wms
2307 [ $RC -eq 0 ] || error "dd append failed"
2309 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2310 local found=$($LFS find $flg_opts $comp_file | wc -l)
2311 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2313 ost_idx=$($LFS getstripe -I2 -i $comp_file)
2314 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2316 sel_layout_sanity $comp_file 2
2318 run_test 23f "Append with low on space: repeat and remove EXT comp"
2327 [ "$OSTCOUNT" -lt "3" ] && skip_env "needs >= 3 OSTs"
2329 trap cleanup_24 EXIT RETURN
2331 local file=$DIR/$tfile
2333 $LFS setstripe -E 1m -c1 -o0 -E eof -c2 -o1,2 $file ||
2334 error "setstripe on $file"
2336 dd if=/dev/zero of=$file bs=1M count=3 || error "dd failed for $file"
2339 filefrag -ves $file || error "filefrag $file failed"
2340 filefrag_op=$(filefrag -ve -k $file |
2341 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
2343 #Filesystem type is: bd00bd0
2344 #File size of /mnt/lustre/f24a.sanity-pfl is 3145728 (3072 blocks of 1024 bytes)
2345 # ext: device_logical: physical_offset: length: dev: flags:
2346 # 0: 0.. 1023: 1572864.. 1573887: 1024: 0000: net
2347 # 1: 0.. 1023: 1572864.. 1573887: 1024: 0002: net
2348 # 2: 1024.. 2047: 1573888.. 1574911: 1024: 0001: last,net
2349 #/mnt/lustre/f24a.sanity-pfl: 3 extents found
2351 last_lun=$(echo $filefrag_op | cut -d: -f5)
2356 for line in $filefrag_op; do
2357 frag_lun=$(echo $line | cut -d: -f5)
2358 ext_len=$(echo $line | cut -d: -f4)
2359 if [[ "$frag_lun" != "$last_lun" ]]; then
2360 if (( tot_len != 1024 )); then
2362 error "$file: OST$last_lun $tot_len != 1024"
2368 (( tot_len += ext_len ))
2371 if (( num_luns != 3 || tot_len != 1024 )); then
2373 error "$file: $num_luns != 3, $tot_len != 1024 on OST$last_lun"
2376 echo "FIEMAP on $file succeeded"
2378 run_test 24a "FIEMAP upon PFL file"
2381 check_and_cleanup_lustre