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"
26 check_and_setup_lustre
28 if [[ "$MDS1_VERSION" -lt $(version_code 2.9.51) ]]; then
29 skip_env "Need MDS version at least 2.9.51"
32 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
33 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
34 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
37 rm -rf $DIR/[Rdfs][0-9]*
40 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
42 local comp_file=$DIR/$tdir/$tfile
43 local rw_len=$((3 * 1024 * 1024)) # 3M
48 $LFS setstripe -E 1m -S 1M -c 1 -E -1 -c 1 $comp_file ||
49 error "Create $comp_file failed"
51 #instantiate all components, so that objs are allocted
52 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
54 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
55 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
57 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
59 small_write $comp_file $rw_len || error "Verify RW failed"
61 rm -f $comp_file || error "Delete $comp_file failed"
63 run_test 0a "Create full components file, no reused OSTs"
66 [[ $($LCTL get_param mdc.*.import |
67 grep "connect_flags:.*overstriping") ]] ||
68 skip "server does not support overstriping"
69 large_xattr_enabled || skip_env "no large xattr support"
71 local comp_file=$DIR/$tdir/$tfile
75 # Create file with 1.1*LOV_MAX_STRIPE_COUNT stripes should succeed
76 $LFS setstripe -E 1m -C $((LOV_MAX_STRIPE_COUNT / 10)) -E -1 \
77 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
78 error "Create $comp_file failed"
80 rm -f $comp_file || error "Delete $comp_file failed"
82 # Create file with 2*LOV_MAX_STRIPE_COUNT stripes should fail
83 $LFS setstripe -E 1m -C $LOV_MAX_STRIPE_COUNT -E -1 -C $LOV_MAX_STRIPE_COUNT \
84 $comp_file && error "Create $comp_file succeeded"
86 rm -f $comp_file || error "Delete $comp_file failed"
88 run_test 0b "Verify comp stripe count limits"
91 local comp_file=$DIR/$tdir/$tfile
92 local rw_len=$((3 * 1024 * 1024)) # 3M
97 $LFS setstripe -E 1m -S 1m -o 0 -E -1 -o 0 $comp_file ||
98 error "Create $comp_file failed"
100 #instantiate all components, so that objs are allocted
101 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
103 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
104 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
106 [ $ost_idx1 -ne $ost_idx2 ] && error "$ost_idx1 != $ost_idx2"
108 small_write $comp_file $rw_len || error "Verify RW failed"
110 rm -f $comp_file || error "Delete $comp_file failed"
112 run_test 1a "Create full components file, reused OSTs"
114 # test overstriping (>1 stripe/OST within a component)
116 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
117 [[ $($LCTL get_param mdc.*.import |
118 grep "connect_flags:.*overstriping") ]] ||
119 skip "server does not support overstriping"
121 local comp_file=$DIR/$tdir/$tfile
122 local rw_len=$((3 * 1024 * 1024)) # 3M
124 test_mkdir $DIR/$tdir
126 $LFS setstripe -E 1m -S 1m -o 0,0 -E -1 -o 1,1,0,0 $comp_file ||
127 error "Create $comp_file failed"
129 #instantiate all components, so that objs are allocted
130 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=1M
132 $LFS getstripe $comp_file
133 local OSTS_1=$($LFS getstripe -I1 $comp_file | grep -o 'l_ost_idx.*' |
134 awk -e '{print $2}' | tr "\n" "\0")
135 local OSTS_2=$($LFS getstripe -I2 $comp_file | grep -o 'l_ost_idx.*' |
136 awk -e '{print $2}' | tr "\n" "\0")
140 [ "$OSTS_1" = "0,0," ] || error "incorrect OSTs($OSTS_1) in component 1"
141 [ "$OSTS_2" = "1,1,0,0," ] ||
142 error "incorrect OSTs($OSTS_2) in component 2"
144 small_write $comp_file $rw_len || error "Verify RW failed"
146 rm -f $comp_file || error "Delete $comp_file failed"
148 run_test 1b "Create full components file, overstriping in components"
150 # test overstriping with max stripe count
152 [[ $($LCTL get_param mdc.*.import |
153 grep "connect_flags:.*overstriping") ]] ||
154 skip "server does not support overstriping"
155 large_xattr_enabled || skip_env "no large xattr support"
157 local comp_file=$DIR/$tdir/$tfile
158 local rw_len=$((3 * 1024 * 1024)) # 3M
160 test_mkdir $DIR/$tdir
162 $LFS setstripe -E 1m -C 10 -E 10M -C 100 -E -1 \
163 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
164 error "Create $comp_file failed"
166 # Seek & write in to last component so all objects are allocated
167 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=20000
169 local count=$($LFS getstripe -c -I1 $DIR/$tdir/$tfile)
170 [ $count -eq 10 ] || error "comp1 stripe count $count, should be 10"
171 count=$($LFS getstripe -c -I2 $DIR/$tdir/$tfile)
172 [ $count -eq 100 ] || error "comp2 stripe count $count, should be 100"
173 count=$($LFS getstripe -c -I3 $DIR/$tdir/$tfile)
174 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
175 error "comp4 stripe count $count != $LOV_MAX_STRIPE_COUNT"
177 small_write $comp_file $rw_len || error "Verify RW failed"
179 rm -f $comp_file || error "Delete $comp_file failed"
181 run_test 1c "Test overstriping w/max stripe count"
184 local comp_file=$DIR/$tdir/$tfile
185 local rw_len=$((5 * 1024 * 1024)) # 5M
187 test_mkdir $DIR/$tdir
190 $LFS setstripe -E 1m -S 1m $comp_file ||
191 error "Create $comp_file failed"
193 check_component_count $comp_file 1
195 dd if=/dev/zero of=$comp_file bs=1M count=1 > /dev/null 2>&1 ||
196 error "Write first component failed"
197 dd if=$comp_file of=/dev/null bs=1M count=1 > /dev/null 2>&1 ||
198 error "Read first component failed"
200 dd if=/dev/zero of=$comp_file bs=1M count=2 > /dev/null 2>&1 &&
201 error "Write beyond component should fail"
202 dd if=$comp_file of=/dev/null bs=1M count=2 > /dev/null 2>&1 ||
203 error "Read beyond component should short read, not fail"
205 $LFS setstripe --component-add -E 2M -S 1M -c 1 $comp_file ||
206 error "Add component to $comp_file failed"
208 check_component_count $comp_file 2
210 $LFS setstripe --component-add -E -1 -c 3 $comp_file ||
211 error "Add last component to $comp_file failed"
213 check_component_count $comp_file 3
215 small_write $comp_file $rw_len || error "Verify RW failed"
217 rm -f $comp_file || error "Delete $comp_file failed"
219 run_test 2 "Add component to existing file"
221 del_comp_and_verify() {
228 if [ $id == "init" -o $id == "^init" ]; then
229 opt="--component-flags="
232 $LFS setstripe --component-del $opt$id $comp_file ||
233 error "Delete component $id from $comp_file failed"
235 local comp_cnt=$($LFS getstripe --component-count $comp_file)
236 if grep -q "has no stripe info" <<< "$comp_cnt" ; then
239 [ $comp_cnt -ne $left ] && error "$comp_cnt != $left"
241 $CHECKSTAT -s $size $comp_file || error "size != $size"
245 local comp_file=$DIR/$tdir/$tfile
247 test_mkdir $DIR/$tdir
250 $LFS setstripe -E 1M -S 1M -E 64M -c 2 -E -1 -c 3 $comp_file ||
251 error "Create $comp_file failed"
253 check_component_count $comp_file 3
255 dd if=/dev/zero of=$comp_file bs=1M count=2
257 $LFS setstripe --component-del -I 2 $comp_file &&
258 error "Component deletion makes hole"
260 del_comp_and_verify $comp_file 3 2 $((2 * 1024 * 1024))
261 del_comp_and_verify $comp_file 2 1 $((1 * 1024 * 1024))
262 del_comp_and_verify $comp_file 1 0 0
264 rm -f $comp_file || error "Delete $comp_file failed"
266 $LFS setstripe -E 1M -S 1M -E 16M -E -1 $comp_file ||
267 error "Create second $comp_file failed"
269 del_comp_and_verify $comp_file "^init" 1 0
270 del_comp_and_verify $comp_file "init" 0 0
271 rm -f $comp_file || error "Delete second $comp_file failed"
274 run_test 3 "Delete component from existing file"
277 skip "Not supported in PFL"
278 # In PFL project, only LCME_FL_INIT is supported, and it can't
279 # be altered by application.
281 run_test 4 "Modify component flags in existing file"
284 local parent=$DIR/$tdir
285 local comp_file=$DIR/$tdir/$tfile
286 local subdir=$parent/subdir
291 # set default layout to parent directory
292 $LFS setstripe -E 64M -c 2 -i 0 -E -1 -c 4 -i 0 $parent ||
293 error "Set default layout to $parent failed"
295 # create file under parent
296 touch $comp_file || error "Create $comp_file failed"
297 check_component_count $comp_file 2
299 #instantiate all components, so that objs are allocted
300 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=65k
302 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
303 [ $ost_idx -ne 0 ] &&
304 error "component 1 ost_idx $ost_idx != 0"
306 ost_idx=$($LFS getstripe -I2 -i $comp_file)
307 [ $ost_idx -ne 0 ] &&
308 error "component 2 ost_idx $ost_idx != 0"
310 # create subdir under parent
311 mkdir -p $subdir || error "Create subdir $subdir failed"
313 comp_cnt=$($LFS getstripe -d --component-count $subdir)
314 [ $comp_cnt -ne 2 ] && error "subdir $comp_cnt != 2"
316 # create file under subdir
317 touch $subdir/$tfile || error "Create $subdir/$tfile failed"
319 check_component_count $subdir/$tfile 2
321 # delete default layout setting from parent
322 $LFS setstripe -d $parent ||
323 error "Delete default layout from $parent failed"
325 comp_cnt=$($LFS getstripe -d --component-count $parent)
326 [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0"
328 rm -f $comp_file || error "Delete $comp_file failed"
329 rm -f $subdir/$tfile || error "Delete $subdir/$tfile failed"
330 rm -r $subdir || error "Delete subdir $subdir failed"
331 rmdir $parent || error "Delete dir $parent failed"
333 run_test 5 "Inherit composite layout from parent directory"
336 local comp_file=$DIR/$tdir/$tfile
338 test_mkdir $DIR/$tdir
341 $LFS setstripe -c 1 -S 128K $comp_file ||
342 error "Create v1 $comp_file failed"
344 check_component_count $comp_file 0
346 dd if=/dev/urandom of=$comp_file bs=1M count=5 oflag=sync ||
347 error "Write to v1 $comp_file failed"
349 local old_chksum=$(md5sum $comp_file)
351 # Migrate v1 to composite
352 $LFS migrate -E 1M -S 512K -c 1 -E -1 -S 1M -c 2 $comp_file ||
353 error "Migrate(v1 -> composite) $comp_file failed"
355 check_component_count $comp_file 2
357 local chksum=$(md5sum $comp_file)
358 [ "$old_chksum" != "$chksum" ] &&
359 error "(v1 -> compsoite) $old_chksum != $chksum"
361 # Migrate composite to composite
362 $LFS migrate -E 1M -S 1M -c 2 -E 4M -S 1M -c 2 \
363 -E -1 -S 3M -c 3 $comp_file ||
364 error "Migrate(compsoite -> composite) $comp_file failed"
366 check_component_count $comp_file 3
368 chksum=$(md5sum $comp_file)
369 [ "$old_chksum" != "$chksum" ] &&
370 error "(composite -> compsoite) $old_chksum != $chksum"
372 # Migrate composite to v1
373 $LFS migrate -c 2 -S 2M $comp_file ||
374 error "Migrate(composite -> v1) $comp_file failed"
376 check_component_count $comp_file 0
378 chksum=$(md5sum $comp_file)
379 [ "$old_chksum" != "$chksum" ] &&
380 error "(composite -> v1) $old_chksum != $chksum"
382 rm -f $comp_file || "Delete $comp_file failed"
384 run_test 6 "Migrate composite file"
387 test_mkdir $DIR/$tdir
388 chmod 0777 $DIR/$tdir || error "chmod $tdir failed"
390 local comp_file=$DIR/$tdir/$tfile
391 $RUNAS $LFS setstripe -E 1M -S 1M -c 1 $comp_file ||
392 error "Create composite file $comp_file failed"
394 $RUNAS $LFS setstripe --component-add -E 64M -c 4 $comp_file ||
395 error "Add component to $comp_file failed"
397 $RUNAS $LFS setstripe --component-del -I 2 $comp_file ||
398 error "Delete component from $comp_file failed"
400 $RUNAS $LFS setstripe --component-add -E -1 -c 5 $comp_file ||
401 error "Add last component to $comp_file failed"
403 rm $comp_file || "Delete composite failed"
405 run_test 7 "Add/Delete/Create composite file by non-privileged user"
408 local parent=$DIR/$tdir
413 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c 2 -S 2M \
414 -E -1 -c 4 -S 4M $parent ||
415 error "Set default layout to $parent failed"
417 sh rundbench -C -D $parent 2 || error "dbench failed"
419 rm -fr $parent || error "Delete dir $parent failed"
421 run_test 8 "Run dbench over composite files"
424 local comp_file=$DIR/$tdir/$tfile
426 test_mkdir $DIR/$tdir
429 $LFS setstripe -E 1M -S 1M -E -1 -c 1 $comp_file ||
430 error "Create $comp_file failed"
432 check_component_count $comp_file 2
434 replay_barrier $SINGLEMDS
436 # instantiate the 2nd component
437 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
439 local f1=$($LFS getstripe -I2 $comp_file |
440 awk '/l_fid:/ {print $7}')
441 echo "before MDS recovery, the ost fid of 2nd component is $f1"
444 local f2=$($LFS getstripe -I2 $comp_file |
445 awk '/l_fid:/ {print $7}')
446 echo "after MDS recovery, the ost fid of 2nd component is $f2"
447 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
449 run_test 9 "Replay layout extend object instantiation"
452 echo $($LFS getstripe $1 |
453 awk '$1 == "lcm_entry_count:" { printf("%d", $2) }
454 $1 == "lcme_extent.e_start:" { printf("[%#lx", $2) }
455 $1 == "lcme_extent.e_end:" { printf(",%s]", $2) }')
459 local parent=$DIR/$tdir
462 save_layout_restore_at_exit $MOUNT
466 # mount root on $MOUNT2 if FILESET is set
467 if [ -n "$FILESET" ]; then
468 FILESET="" mount_client $MOUNT2 ||
469 error "mount $MOUNT2 fail"
473 $LFS setstripe -d $root || error "clear root layout"
475 # set root composite layout
476 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c2 -S 2M \
477 -E -1 -c 4 -S 4M $root ||
478 error "Set root layout failed"
480 if [ "$root" == "$MOUNT2" ]; then
481 umount_client $MOUNT2 ||
482 error "umount $MOUNT2 fail"
486 # set a different layout for parent
487 $LFS setstripe -E -1 -c 1 -S 1M $parent ||
488 error "set $parent layout failed"
491 local f1_entry=$(component_dump $parent/file1)
493 # delete parent's layout
494 $LFS setstripe -d $parent || error "Clear $parent layout failed"
497 local f2_entry=$(component_dump $parent/file2)
499 # verify layout inheritance
501 local f1_expect="1[0,EOF]"
502 local f2_expect="3[0,2097152][0x200000,16777216][0x1000000,EOF]"
504 echo "f1 expect=$f1_expect"
505 echo "f1 get =$f1_entry"
506 echo "f2 expect=$f2_expect"
507 echo "f2 get =$f2_entry"
509 [ x$f1_expect != x$f1_entry ] &&
510 error "$parent/file1 does not inherite parent layout"
511 [ x$f2_expect != x$f2_entry ] &&
512 error "$parent/file2 does not inherite root layout"
516 run_test 10 "Inherit composite template from root"
519 local comp_file=$DIR/$tdir/$tfile
520 test_mkdir $DIR/$tdir
523 # only 1st component instantiated
524 $LFS setstripe -E 1M -S 1M -E 2M -E 3M -E -1 $comp_file ||
525 error "Create $comp_file failed"
527 local f1=$($LFS getstripe -I1 $comp_file | grep "l_fid")
528 [[ -z $f1 ]] && error "1: 1st component uninstantiated"
529 local f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
530 [[ -n $f2 ]] && error "1: 2nd component instantiated"
531 local f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
532 [[ -n $f3 ]] && error "1: 3rd component instantiated"
533 local f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
534 [[ -n $f4 ]] && error "1: 4th component instantiated"
536 # the first 2 components instantiated
537 # Truncate to exact start of new component - LU-12586
538 $TRUNCATE $comp_file $((1024*1024*1))
540 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
541 [[ -z $f2 ]] && error "2: 2nd component uninstantiated"
542 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
543 [[ -n $f3 ]] && error "2: 3rd component instantiated"
544 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
545 [[ -n $f4 ]] && error "2: 4th component instantiated"
547 # the first 3 components instantiated
548 $TRUNCATE $comp_file $((1024*1024*3 - 1))
549 $TRUNCATE $comp_file $((1024*1024*1+1))
551 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
552 [[ -z $f2 ]] && error "3: 2nd component uninstantiated"
553 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
554 [[ -z $f3 ]] && error "3: 3rd component uninstantiated"
555 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
556 [[ -n $f4 ]] && error "3: 4th component instantiated"
558 # all 4 components instantiated, using append write
559 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
561 rwv -f $comp_file -w -a -n 2 $((1024*1023)) 1
564 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
565 [[ -z $f4 ]] && error "4: 4th component uninstantiated"
569 run_test 11 "Verify component instantiation with write/truncate"
572 [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs"
574 local file=$DIR/$tdir/$tfile
575 test_mkdir $DIR/$tdir
578 # specify ost list for component
579 $LFS setstripe -E 1M -S 1M -c 2 -o 0,1 -E 2M -c 2 -o 1,2 \
580 -E 3M -c 2 -o 2,1 -E 4M -c 1 -i 2 -E -1 $file ||
581 error "Create $file failed"
583 # clear lod component cache
584 stop $SINGLEMDS || error "stop MDS"
585 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
586 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "start MDS"
588 # instantiate all components
589 $TRUNCATE $file $((1024*1024*4+1))
591 #verify object alloc order
592 local o1=$($LFS getstripe -I1 $file |
593 awk '/l_ost_idx:/ {printf("%d",$5)}')
594 [[ $o1 != "01" ]] && error "$o1 is not 01"
596 local o2=$($LFS getstripe -I2 $file |
597 awk '/l_ost_idx:/ {printf("%d",$5)}')
598 [[ $o2 != "12" ]] && error "$o2 is not 12"
600 local o3=$($LFS getstripe -I3 $file |
601 awk '/l_ost_idx:/ {printf("%d",$5)}')
602 [[ $o3 != "21" ]] && error "$o3 is not 21"
604 local o4=$($LFS getstripe -I4 $file |
605 awk '/l_ost_idx:/ {printf("%d",$5)}')
606 [[ $o4 != "2" ]] && error "$o4 is not 2"
610 run_test 12 "Verify ost list specification"
612 test_13() { # LU-9311
613 [ $OSTCOUNT -lt 8 ] && skip "needs >= 8 OSTs"
615 local file=$DIR/$tfile
617 local dd_size=$(($dd_count * 1024 * 1024))
621 $LFS setstripe -E 1M -S 1M -c 1 -E 2M -c 2 -E -1 -c -1 -i 1 $file ||
622 error "Create $file failed"
623 dd if=/dev/zero of=$file bs=1M count=$dd_count
624 real_size=$(stat -c %s $file)
625 [ $real_size -eq $dd_size ] ||
626 error "dd actually wrote $real_size != $dd_size bytes"
630 run_test 13 "shouldn't reprocess granted resent request"
633 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
634 local file=$DIR/$tdir/$tfile
635 test_mkdir -p $DIR/$tdir
638 $LFS setstripe -E1m -c1 -S1m --pool="pool1" -E2m \
639 -E4m -c2 -S2m --pool="pool2" -E-1 $file ||
640 error "Create $file failed"
642 # check --pool inheritance
644 pool="$($LFS getstripe -I2 --pool $file)"
645 [ x"$pool" != "xpool1" ] && $LFS getstripe -I2 $file &&
646 error "$file: component 2 doesn't have poolname pool1"
647 pool="$($LFS getstripe -I4 --pool $file)"
648 [ x"$pool" != "xpool2" ] && $LFS getstripe -I4 $file &&
649 error "$file: component 4 doesn't have poolname pool2"
651 #check --stripe-count inheritance
653 count="$($LFS getstripe -I2 -c $file)"
654 [ $count -ne 1 ] && $LFS getstripe -I2 $file &&
655 error "$file: component 2 doesn't have 1 stripe_count"
656 count="$($LFS getstripe -I4 -c $file)"
657 [ $count -ne 2 ] && $LFS getstripe -I4 $file &&
658 error "$file: component 4 doesn't have 2 stripe_count"
660 #check --stripe-size inheritance
662 size="$($LFS getstripe -I2 -S $file)"
663 [ $size -ne $((1024*1024)) ] && $LFS getstripe -I2 $file &&
664 error "$file: component 2 doesn't have 1M stripe_size"
665 size="$($LFS getstripe -I4 -S $file)"
666 [ $size -ne $((1024*1024*2)) ] && $LFS getstripe -I4 $file &&
667 error "$file: component 4 doesn't have 2M stripe_size"
671 run_test 14 "Verify setstripe poolname/stripe_count/stripe_size inheritance"
674 local parent=$DIR/$tdir
679 $LFS setstripe -d $parent || error "delete default layout"
681 $LFS setstripe -E 1M -S 1M -E 10M -E eof $parent/f1 || error "create f1"
682 $LFS setstripe -E 4M -E 20M -E eof $parent/f2 || error "create f2"
683 test_mkdir $parent/subdir
684 $LFS setstripe -E 6M -S 1M -c1 -E 30M -c4 -E eof -c -1 $parent/subdir ||
685 error "setstripe to subdir"
686 $LFS setstripe -E 8M -E eof $parent/subdir/f3 || error "create f3"
687 $LFS setstripe -c 1 $parent/subdir/f4 || error "create f4"
690 local found=$($LFS find --component-start +2M -E -15M $parent | wc -l)
691 [ $found -eq 0 ] || error "start+2M, end-15M, $found != 0"
694 found=$($LFS find --component-start +2M -E -35M $parent | wc -l)
695 [ $found -eq 2 ] || error "start+2M, end-35M, $found != 2"
698 found=$($LFS find --component-start +4M -E -eof $parent | wc -l)
699 [ $found -eq 1 ] || error "start+4M, end-eof, $found != 1"
701 local flg_opts="--component-flags init"
703 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
705 error "before write: start=1M, end=10M, flag=init, $found != 0"
707 dd if=/dev/zero of=$parent/f1 bs=1M count=2 ||
708 error "dd $parent/f1 failed"
711 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
713 error "after write: start=1M, end=10M, flag=init, $found != 1"
715 local ext_opts="--component-start -1M -E +5M"
716 # parent, subdir, f3, f4
717 found=$($LFS find $ext_opts $parent | wc -l)
718 [ $found -eq 4 ] || error "start-1M, end+5M, $found != 4"
720 local cnt_opts="--component-count +2"
722 found=$($LFS find $ext_opts $cnt_opts $parent | wc -l)
723 [ $found -eq 1 ] || error "start-1M, end+5M, count+2, $found != 1"
726 found=$($LFS find $ext_opts $cnt_opts $flg_opts $parent | wc -l)
728 error "start-1M, end+5M, count+2, flag=init, $found != 0"
731 found=$($LFS find $ext_opts ! $cnt_opts $flg_opts $parent | wc -l)
733 error "start-1M, end+5M, !count+2, flag=init, $found != 2"
735 # check last component stripe count
736 if [ $OSTCOUNT -gt 1 ]; then
737 touch $parent/subdir/f5
738 $TRUNCATE $parent/subdir/f5 $((32*1024*1024))
739 found=$($LFS find $parent/subdir -c $OSTCOUNT)
740 [[ "$found" == "$parent/subdir/f5" ]] ||
741 error "got '$found' with stripe_count=$OSTCOUNT, not f5"
744 run_test 15 "Verify component options for lfs find"
747 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
748 large_xattr_enabled || skip_env "ea_inode feature disabled"
750 local file=$DIR/$tdir/$tfile
751 local dir=$DIR/$tdir/dir
752 local temp=$DIR/$tdir/template
754 test_mkdir $DIR/$tdir
756 #####################################################################
758 # set stripe for source file
759 $LFS setstripe -E1m -S 1M -c2 -o0,1 -E2m -c2 -E3m -o1,0 -E4m -c1 -E-1 \
760 $file || error "Create $file failed"
763 verify_yaml_layout $file $file.copy $temp "1. PFL file"
765 #####################################################################
767 # set stripe for source file
769 $LFS setstripe -c2 -o0,1 -i1 $file || error "Create $file failed"
773 verify_yaml_layout $file $file.copy $temp "2. plain file"
775 #####################################################################
777 # set stripe for source dir
779 $LFS setstripe -E1m -S 1M -c2 -E2m -c1 -E-1 $dir ||
780 error "setstripe $dir failed"
784 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
786 #####################################################################
788 # set stripe for source dir
789 $LFS setstripe -c2 -i-1 $dir || error "setstripe $dir failed"
792 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
794 run_test 16a "Verify setstripe/getstripe with YAML config file"
797 [[ $($LCTL get_param mdc.*.import |
798 grep "connect_flags:.*overstriping") ]] ||
799 skip "server does not support overstriping"
800 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
801 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
802 skip_env "too many osts, skipping"
803 large_xattr_enabled || skip_env "ea_inode feature disabled"
805 local file=$DIR/$tdir/$tfile
806 local dir=$DIR/$tdir/dir
807 local temp=$DIR/$tdir/template
808 # We know OSTCOUNT < (LOV_MAX_STRIPE_COUNT / 2), so this is overstriping
809 local large_count=$((LOV_MAX_STRIPE_COUNT / 2 + 10))
812 test_mkdir $DIR/$tdir
814 #####################################################################
815 # 1. PFL file, overstriping in first comps
816 # set stripe for source file
817 $LFS setstripe -E1m -S 1M -o0,0 -E2m -o1,1 -E3m -C $large_count -E-1 \
818 $file || error "Create $file failed"
821 verify_yaml_layout $file $file.copy $temp "1. PFL file"
823 #####################################################################
824 # 2. plain file + overstriping
825 # set stripe for source file
827 $LFS setstripe -C $large_count -i1 $file || error "Create $file failed"
831 verify_yaml_layout $file $file.copy $temp "2. plain file"
833 #####################################################################
834 # 3. PFL dir + overstriping
835 # set stripe for source dir
837 $LFS setstripe -E1m -S 1M -o 0,0 -E2m -C $large_count -E-1 $dir ||
838 error "setstripe $dir failed"
842 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
844 #####################################################################
845 # 4. plain dir + overstriping
846 # set stripe for source dir
847 $LFS setstripe -C $large_count $dir || error "setstripe $dir failed"
850 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
852 run_test 16b "Verify setstripe/getstripe with YAML config file + overstriping"
855 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
856 local file=$DIR/$tdir/$tfile
857 test_mkdir -p $DIR/$tdir
860 $LFS setstripe -E 1M -S 1M -E 2M -c 2 -E -1 -c -1 $file ||
861 error "Create $file failed"
863 local s1=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
864 local s2=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
865 local s3=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
866 echo "1st init: comp size 1:$s1 2:$s2 3:$s3"
869 $TRUNCATE $file $((1024*1024+1))
870 local s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
871 local s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
872 echo "2nd init: comp size 1:$s1n 2:$s2n 3:$s3"
874 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
875 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
878 $TRUNCATE $file $((1024*1024*2+1))
879 s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
880 s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
881 local s3n=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
882 echo "3rd init: comp size 1:$s1n 2:$s2n 3:$s3n"
884 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
885 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
886 [ $s3 -lt $s3n ] || error "3rd comp size $s3 should < $s3n"
888 run_test 17 "Verify LOVEA grows with more component inited"
890 check_distribution() {
894 local obj_min_one=$((OSTCOUNT - 1))
896 objs=$($LFS getstripe $file |
897 awk '/l_ost_idx:/ { print $5 }' | wc -l)
898 let ave=$((objs / OSTCOUNT))
900 # collect objects per OST distribution
901 $LFS getstripe $file | awk '/l_ost_idx:/ { print $5 }' | tr -d "," |
902 (inuse=( $(for i in $(seq 0 $obj_min_one); do echo 0; done) )
904 let inuse[$O]=$((1 + ${inuse[$O]}))
907 # verify object distribution varies no more than +-1
908 for idx in $(seq 0 $obj_min_one); do
909 let dif=$((${inuse[$idx]} - ave))
911 if [ "$dif" -gt 1 ]; then
912 echo "OST${idx}: ${inuse[$idx]} objects"
913 error "bad distribution on OST${idx}"
919 local file1=$DIR/${tfile}-1
920 local file2=$DIR/${tfile}-2
921 local file3=$DIR/${tfile}-3
923 rm -f $file1 $file2 $file3
925 $LFS setstripe -E 1m -S 1m $file1 ||
926 error "Create $file1 failed"
927 $LFS setstripe -E 1m -S 1m $file2 ||
928 error "Create $file2 failed"
929 $LFS setstripe -E 1m -S 1m $file3 ||
930 error "Create $file3 failed"
932 local objs=$((OSTCOUNT+1))
933 for comp in $(seq 1 $OSTCOUNT); do
934 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file1 ||
935 error "Add component to $file1 failed 2"
936 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file2 ||
937 error "Add component to $file2 failed 2"
938 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file3 ||
939 error "Add component to $file3 failed 2"
942 $LFS setstripe --component-add -E -1 -c -1 $file1 ||
943 error "Add component to $file1 failed 3"
944 $LFS setstripe --component-add -E -1 -c -1 $file2 ||
945 error "Add component to $file2 failed 3"
946 $LFS setstripe --component-add -E -1 -c -1 $file3 ||
947 error "Add component to $file3 failed 3"
949 # Instantiate all components
950 dd if=/dev/urandom of=$file1 bs=1M count=$((objs+1)) ||
951 error "dd failed for $file1"
952 dd if=/dev/urandom of=$file2 bs=1M count=$((objs+1)) ||
953 error "dd failed for $file2"
954 dd if=/dev/urandom of=$file3 bs=1M count=$((objs+1)) ||
955 error "dd failed for $file3"
957 check_distribution $file1
958 check_distribution $file2
959 check_distribution $file3
962 run_test 18 "check component distribution"
966 local already_created=${2:-0}
967 local rw_len=$((3 * 1024 * 1024)) # 3M
971 if [ $already_created != 1 ]; then
972 test_mkdir -p $DIR/$tdir
973 $LFS setstripe --extension-size 64M -c 1 -E -1 $comp_file ||
974 error "Create $comp_file failed"
977 # write past end of first component, so it is extended
978 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=127 conv=notrunc ||
979 error "dd to extend failed"
981 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
982 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
984 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
985 [ $ost_idx2 -ne "-1" ] && error "second component init $ost_idx2"
987 flg_opts="--comp-flags init"
988 found=$($LFS find --comp-start 0 -E 128M $flg_opts $comp_file | wc -l)
989 [ $found -eq 1 ] || error "Write: Extended first component not found"
991 flg_opts="--comp-flags extension"
992 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
993 [ $found -eq 1 ] || error "Write: second component not found"
995 found=$($LFS find -z 64M $comp_file | wc -l)
996 [ $found -eq 1 ] || error "component not found by ext size"
998 found=$($LFS find --extension-size +63M $comp_file | wc -l)
999 [ $found -eq 1 ] || error "component not found by +ext size"
1001 found=$($LFS find --ext-size -65M $comp_file | wc -l)
1002 [ $found -eq 1 ] || error "component not found by -ext size"
1004 found=$($LFS find -z 65M $comp_file | wc -l)
1005 [ $found -eq 0 ] || error "component found by wrong ext size"
1007 found=$($LFS find -z +65M $comp_file | wc -l)
1008 [ $found -eq 0 ] || error "component found by wrong +ext size"
1010 found=$($LFS find -z -63M $comp_file | wc -l)
1011 [ $found -eq 0 ] || error "component found by wrong -ext size"
1013 found=$($LFS find ! -z 64M $comp_file | wc -l)
1014 [ $found -eq 0 ] || error "component found by negation of ext size"
1016 found=$($LFS find ! -z +63M $comp_file | wc -l)
1017 [ $found -eq 0 ] || error "component found by negation of +ext size"
1019 found=$($LFS find ! -z -65M $comp_file | wc -l)
1020 [ $found -eq 0 ] || error "component found by negation of -ext size"
1022 found=$($LFS find ! -z 65M $comp_file | wc -l)
1024 error "component not found by negation of wrong ext size"
1026 found=$($LFS find ! -z +65M $comp_file | wc -l)
1028 error "component not found by negation of wrong +ext size"
1030 found=$($LFS find ! -z -63M $comp_file | wc -l)
1032 error "component not found by negation of wrong -ext size"
1034 found=$($LFS find -S +1M $comp_file | wc -l)
1035 [ $found -eq 0 ] || error "component found by wrong +stripe size"
1037 found=$($LFS find -c 1 $comp_file | wc -l)
1038 [ $found -eq 1 ] || error "component not found by stripe count"
1040 small_write $comp_file $rw_len || error "Verify RW failed"
1042 sel_layout_sanity $comp_file 2
1045 # Self-extending PFL tests
1047 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1048 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1049 skip "skipped for lustre < $SEL_VER"
1051 test19_io_base $DIR/$tdir/$tfile
1053 run_test 19a "Simple test of extension behavior"
1055 # Same as 19a, but with default layout set on directory rather than on file
1057 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1058 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1059 skip "skipped for lustre < $SEL_VER"
1061 local comp_file=$DIR/$tdir/$tfile
1062 local comp_dir=$DIR/$tdir/$tdir
1066 test_mkdir -p $DIR/$tdir
1067 $LFS setstripe --ext-size 64M -c 1 -E -1 $DIR/$tdir ||
1068 error "Setstripe on $DIR/$tdir failed"
1070 # check inheritance for a sub-dir and a file
1071 test_mkdir $comp_dir
1072 found=$($LFS find --comp-start 0 -E 64M $comp_dir | wc -l)
1073 [ $found -eq 1 ] || error "Dir Inheritance: wrong first component size"
1075 flg_opts="--comp-flags extension"
1076 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_dir | wc -l)
1077 [ $found -eq 1 ] || error "Dir Inheritance: Second component not found"
1081 flg_opts="--comp-flags init"
1082 found=$($LFS find --comp-start 0 -E 64M $flg_opts $comp_file | wc -l)
1083 [ $found -eq 1 ] || error "File Inheritance: wrong first component size"
1085 flg_opts="--comp-flags extension"
1086 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_file | wc -l)
1087 [ $found -eq 1 ] || error "File Inheritance: Second component not found"
1089 test19_io_base $comp_file 1
1091 run_test 19b "Simple test of SEL as default layout"
1093 # Test behavior when seeking deep in a file
1095 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1096 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1097 skip "skipped for lustre < $SEL_VER"
1099 local comp_file=$DIR/$tdir/$tfile
1103 test_mkdir -p $DIR/$tdir
1105 $LFS setstripe -z 128M -E 1G -E -1 $comp_file ||
1106 error "Create $comp_file failed"
1108 # write past end of first component, so it is extended
1109 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 conv=notrunc ||
1110 error "dd to extend failed"
1112 flg_opts="--comp-flags init"
1113 found=$($LFS find --comp-start 0M -E 256M $flg_opts $comp_file | wc -l)
1114 [ $found -eq 1 ] || error "Write: first extension component not found"
1116 flg_opts="--comp-flags extension,^init"
1117 found=$($LFS find --comp-start 256M -E 1024M $flg_opts $comp_file |\
1119 [ $found -eq 1 ] || error "Write: second extension component not found"
1121 local end_1=$($LFS getstripe -I1 -E $comp_file)
1124 [ $end_1 -eq 268435456 ] ||
1125 error "end of first component $end_1 != 268435456"
1127 # Write past end of extension space component, in to normal component
1128 # should exhaust & remove extension component
1129 dd if=/dev/zero bs=1M count=1 seek=1100 of=$comp_file conv=notrunc ||
1130 error "dd distant seek failed"
1132 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1133 # the last component index is 3
1134 local ost_idx2=$($LFS getstripe -I3 -i $comp_file)
1136 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1138 local start1=$($LFS getstripe -I1 --comp-start $comp_file)
1139 local end1=$($LFS getstripe -I1 -E $comp_file)
1140 local start2=$($LFS getstripe -I3 --comp-start $comp_file)
1141 local end2=$($LFS getstripe -I3 -E $comp_file)
1143 [ $start1 -eq 0 ] || error "start of first component incorrect"
1144 [ $end1 -eq 1073741824 ] || error "end of first component incorrect"
1145 [ $start2 -eq 1073741824 ] ||
1146 error "start of second component incorrect"
1147 [ "$end2" = "EOF" ] || error "end of second component incorrect"
1149 flg_opts="--comp-flags extension"
1150 found=$($LFS find $flg_opts $comp_file | wc -l)
1151 [ $found -eq 0 ] || error "Seek Write: extension component exists"
1153 sel_layout_sanity $comp_file 2
1155 run_test 19c "Test self-extending layout seeking behavior"
1158 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1159 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1160 skip "skipped for lustre < $SEL_VER"
1162 local comp_file=$DIR/$tdir/$tfile
1166 test_mkdir -p $DIR/$tdir
1168 $LFS setstripe -E 128M -c 1 -z 64M -E -1 $comp_file ||
1169 error "Create $comp_file failed"
1171 # This will cause component 1 to be extended to 128M, then the
1172 # extension space component will be removed
1173 dd if=/dev/zero of=$comp_file bs=130M count=1 ||
1174 error "dd to extend failed"
1176 flg_opts="--comp-flags init"
1177 found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file | wc -l)
1178 [ $found -eq 1 ] || error "Write: first component not found"
1180 flg_opts="--comp-flags init"
1181 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1182 [ $found -eq 1 ] || error "Write: second component not found"
1184 sel_layout_sanity $comp_file 2
1186 # always remove large files in case of DO_CLEANUP=false
1187 rm -f $comp_file || error "Delete $comp_file failed"
1189 run_test 19d "Test write which completely spans extension space component"
1194 local comp2_flags=$($LFS getstripe -I2 --comp-flags $comp_file)
1195 local comp3_flags=$($LFS getstripe -I3 --comp-flags $comp_file)
1197 [ "$comp2_flags" != "init" ] && error "$comp2_flags != init"
1198 [ "$comp3_flags" != "extension" ] && error "$comp3_flags != extension"
1200 local flg_opts=" --comp-start 2M -E 66M --comp-flags init"
1201 local found=$($LFS find $flg_opts $comp_file | wc -l)
1202 [ $found -eq 1 ] || error "Write: extended second component not found"
1204 flg_opts="--comp-start 66M -E EOF --comp-flags extension"
1205 found=$($LFS find $flg_opts $comp_file | wc -l)
1206 [ $found -eq 1 ] || error "Write: third component not found"
1208 sel_layout_sanity $comp_file 3
1212 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1213 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1214 skip "skipped for lustre < $SEL_VER"
1216 local comp_file=$DIR/$tdir/$tfile
1217 local rw_len=$((3 * 1024 * 1024)) # 3M
1221 test_mkdir -p $DIR/$tdir
1223 $LFS setstripe -E 2m -E -1 -z 64M $comp_file ||
1224 error "Create $comp_file failed"
1226 replay_barrier $SINGLEMDS
1228 #instantiate & extend second component
1229 dd if=/dev/zero of=$comp_file bs=4M count=1 ||
1230 error "dd to extend failed"
1232 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1233 local ost_idx3=$($LFS getstripe -I3 -i $comp_file)
1235 [ $ost_idx2 -eq $ost_idx3 ] && error "$ost_idx2 == $ost_idx3"
1236 [ $ost_idx3 -ne "-1" ] && error "third component init $ost_idx3"
1238 test_19e_check $comp_file
1240 local f1=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1241 echo "before MDS recovery, the ost fid of 2nd component is $f1"
1245 local f2=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1246 echo "after MDS recovery, the ost fid of 2nd component is $f2"
1247 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
1249 # simply repeat all previous checks, but also verify components are on
1250 # the same OST as before
1252 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1253 local ost_idx3_2=$($LFS getstripe -I3 -i $comp_file)
1255 [ $ost_idx2_2 -eq $ost_idx3_2 ] && error "$ost_idx2_2 == $ost_idx3_2"
1256 [ $ost_idx3_2 -ne "-1" ] && error "second component init $ost_idx3_2"
1258 # verify OST id is the same after failover
1259 [ $ost_idx2 -ne $ost_idx2_2 ] &&
1260 error "$ost_idx2 != $ost_idx2_2, changed after failover"
1262 test_19e_check $comp_file
1264 run_test 19e "Replay of layout instantiation & extension"
1267 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1268 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1269 skip "skipped for lustre < $SEL_VER"
1271 local comp_file=$DIR/$tdir/$tfile
1275 test_mkdir -p $DIR/$tdir
1277 $LFS setstripe -E 256M --comp-flags extension -E -1 $comp_file
1279 [ $? != 0 ] || error "should not be able to manually set extension flag"
1282 run_test 19f "Rejection of invalid layouts"
1285 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1286 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1287 skip "skipped for lustre < $SEL_VER"
1289 local file1=$DIR/${tfile}-1
1290 local file2=$DIR/${tfile}-2
1292 test_mkdir -p $DIR/$tdir
1293 multiop $file1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1294 error "create failed $file1"
1295 multiop $file2 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1296 error "create failed $file2"
1298 $LFS setstripe --component-add -E 1G -c 1 $file1 ||
1299 error "comp-add [0,1G] failed $file1"
1300 $LFS setstripe --component-add -E 512M -z 128M $file1 &&
1301 error "comp-add [1G,1G],SEL[1G,512M] succeded $file1"
1302 $LFS setstripe --component-add -E 10G -z 128M $file1 ||
1303 error "comp-add [1G,1G],SEL[1G,10G] failed $file1"
1304 $LFS setstripe --component-add -E -1 $file1 ||
1305 error "comp-add [10G,-1] failed $file1"
1307 $LFS setstripe --component-add -E 1G -z 32M -c 1 $file2 &&
1308 error "comp-add with smal ext size succeeded $file1"
1309 $LFS setstripe --component-add -E 1G -z 100M -c 1 $file2 &&
1310 error "comp-add with not aligned ext size succeeded $file1"
1311 $LFS setstripe --component-add -E 1G -z 128M -c 1 $file2 ||
1312 error "comp-add [0,128M],SEL[128M,1G] failed $file1"
1313 $LFS setstripe --component-add -E 10G $file2 ||
1314 error "comp-add [1G,10G] failed $file1"
1315 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 ||
1316 error "comp-add [10G,10G],SEL[10G,-1] failed $file1"
1317 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 &&
1318 error "repeated comp-add [10G,10G],SEL[10G,-1] succeeded $file1"
1320 $LFS getstripe $file1
1321 flg_opts="--comp-flags init"
1322 found=$($LFS find --comp-start 0 -E 1G $flg_opts $file1 | wc -l)
1323 [ $found -eq 1 ] || error "First component not found $file1"
1325 flg_opts="--comp-flags ^init"
1326 found=$($LFS find --comp-start 1G -E 1G $flg_opts $file1 | wc -l)
1327 [ $found -eq 1 ] || error "Second component not found $file1"
1329 flg_opts="--comp-flags ^init,extension"
1330 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file1 | wc -l)
1331 [ $found -eq 1 ] || error "Third component not found $file1"
1333 flg_opts="--comp-flags ^init"
1334 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file1 | wc -l)
1335 [ $found -eq 1 ] || error "Fourth component not found $file1"
1337 $LFS getstripe $file2
1338 flg_opts="--comp-flags init"
1339 found=$($LFS find --comp-start 0 -E 128M $flg_opts $file2 | wc -l)
1340 [ $found -eq 1 ] || error "First component not found $file2"
1342 flg_opts="--comp-flags extension"
1343 found=$($LFS find --comp-start 128M -E 1G $flg_opts $file2 | wc -l)
1344 [ $found -eq 1 ] || error "Second component not found $file2"
1346 flg_opts="--comp-flags ^init"
1347 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file2 | wc -l)
1348 [ $found -eq 1 ] || error "Third component not found $file2"
1350 flg_opts="--comp-flags ^init"
1351 found=$($LFS find --comp-start 10G -E 10G $flg_opts $file2 | wc -l)
1352 [ $found -eq 1 ] || error "Fourth component not found $file2"
1354 flg_opts="--comp-flags ^init,extension"
1355 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file2 | wc -l)
1356 [ $found -eq 1 ] || error "Fifth component not found $file2"
1358 run_test 19g "component-add behaviour"
1360 # Test out of space behavior
1362 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1363 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1364 skip "skipped for lustre < $SEL_VER"
1366 local comp_file=$DIR/$tdir/$tfile
1370 test_mkdir -p $DIR/$tdir
1372 # without this, a previous delete can finish after we check free space
1373 wait_delete_completed
1376 # First component is on OST0
1377 $LFS setstripe -E 256M -i 0 -z 64M -E -1 -z 1G $comp_file ||
1378 error "Create $comp_file failed"
1380 # write past end of first component, so it is extended
1381 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=66 ||
1382 error "dd to extend failed"
1384 flg_opts="--comp-flags extension"
1385 found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file |wc -l)
1386 [ $found -eq 1 ] || error "Write: Second component not found"
1388 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1389 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1391 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1393 flg_opts="--comp-flags extension"
1394 # Write past current init comp, but we won't extend (because no space)
1395 dd if=/dev/zero of=$comp_file bs=1M count=10 seek=200 ||
1396 error "dd write past current comp failed"
1398 $LFS getstripe $comp_file
1400 flg_opts="--comp-flags init"
1401 found=$($LFS find --comp-start 128M -E 1152M $flg_opts $comp_file | \
1403 [ $found -eq 1 ] || error "Write: third component not found"
1405 flg_opts="--comp-flags extension"
1406 found=$($LFS find --comp-start 1152M -E EOF $flg_opts $comp_file |wc -l)
1407 [ $found -eq 1 ] || error "Write: fourth extension component not found"
1409 sel_layout_sanity $comp_file 3
1411 run_test 20a "Test out of space, spillover to defined component"
1414 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1415 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1416 skip "skipped for lustre < $SEL_VER"
1418 local comp_file=$DIR/$tdir/$tfile
1422 test_mkdir -p $DIR/$tdir
1424 # Pool allows us to force use of only certain OSTs
1425 pool_add $TESTNAME || error "Pool creation failed"
1426 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1428 # normal component to 10M, extendable component to 1G
1429 # further extendable to EOF
1430 $LFS setstripe -E 10M -E 1G -p $TESTNAME -z 64M -E -1 -p "" -z 512M \
1431 $comp_file || error "Create $comp_file failed"
1433 replay_barrier $SINGLEMDS
1435 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1436 [ $found -eq 1 ] || error "Zero length component not found"
1439 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1441 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1443 # write past end of first component
1444 # This should remove the next component, since OST0 is out of space
1445 # and it is striped there (pool contains only OST0)
1446 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=14 ||
1447 error "dd to extend/remove failed"
1449 $LFS getstripe $comp_file
1451 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1452 [ $found -eq 0 ] || error "Write: zero length component still present"
1454 flg_opts="--comp-flags init"
1455 found=$($LFS find --comp-start 10M -E 522M $flg_opts $comp_file | wc -l)
1456 [ $found -eq 1 ] || error "Write: second component not found"
1458 flg_opts="--comp-flags extension"
1459 found=$($LFS find --comp-start 522M -E EOF $flg_opts $comp_file | wc -l)
1460 [ $found -eq 1 ] || error "Write: third component not found"
1464 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1465 [ $found -eq 0 ] || error "Failover: 0-length component still present"
1467 flg_opts="--comp-flags init"
1468 found=$($LFS find --comp-start 10M -E 522M $flg_opts $comp_file | wc -l)
1469 [ $found -eq 1 ] || error "Failover: second component not found"
1471 flg_opts="--comp-flags extension"
1472 found=$($LFS find --comp-start 522M -E EOF $flg_opts $comp_file | wc -l)
1473 [ $found -eq 1 ] || error "Failover: third component not found"
1475 sel_layout_sanity $comp_file 3
1477 run_test 20b "Remove component without instantiation when there is no space"
1480 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1481 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1482 skip "skipped for lustre < $SEL_VER"
1484 local comp_file=$DIR/$tdir/$tfile
1488 test_mkdir -p $DIR/$tdir
1490 # pool is used to limit available OSTs to 0 and 1, so we can set all
1491 # available OSTs out of space
1492 pool_add $TESTNAME || error "Pool creation failed"
1493 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
1495 # without this, a previous delete can finish after we check free space
1496 wait_delete_completed
1499 $LFS setstripe -E 100M -E -1 -p $TESTNAME -z 64M $comp_file ||
1500 error "Create $comp_file failed"
1504 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1506 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
1508 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1509 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
1511 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=120 &&
1512 error "dd should fail with ENOSPC"
1514 flg_opts="--comp-flags init"
1515 found=$($LFS find --comp-start 0M -E 100M $flg_opts $comp_file | wc -l)
1516 [ $found -eq 1 ] || error "Write: First component not found"
1518 flg_opts="--comp-flags ^init"
1519 found=$($LFS find --comp-start 100M -E 100M $flg_opts $comp_file |wc -l)
1520 [ $found -eq 1 ] || error "Write: 0-length component not found"
1522 flg_opts="--comp-flags extension"
1523 found=$($LFS find --comp-start 100M -E EOF $flg_opts $comp_file | wc -l)
1524 [ $found -eq 1 ] || error "Write: third extension component not found"
1526 sel_layout_sanity $comp_file 3
1528 run_test 20c "Test inability to stripe new extension component"
1531 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1532 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1533 skip "skipped for lustre < $SEL_VER"
1535 local comp_file=$DIR/$tdir/$tfile
1536 test_mkdir -p $DIR/$tdir
1538 wait_delete_completed
1541 pool_add $TESTNAME || error "Pool creation failed"
1542 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1543 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
1544 error "Create $comp_file failed"
1546 replay_barrier $SINGLEMDS
1548 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1549 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1552 ost_watermarks_clear_enospc $tfile 0 $wms
1553 [ $RC -eq 0 ] || error "dd failed: $RC"
1555 $LFS getstripe $comp_file
1556 local flg_opts="--comp-start 64M -E 128M --comp-flags init"
1557 local found=$($LFS find $flg_opts $comp_file | wc -l)
1558 [ $found -eq 1 ] || error "Write: component (64M-128M) not found"
1560 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
1561 [ "$ost_idx" != "-1" ] && error "Write: EXT component disappeared"
1565 found=$($LFS find $flg_opts $comp_file | wc -l)
1566 [ $found -eq 1 ] || error "Failover: component (64M-128M) not found"
1568 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1569 [ "$ost_idx" != "-1" ] && error "Failover: EXT component disappeared"
1571 sel_layout_sanity $comp_file 3
1573 run_test 20d "Low on space + 0-length comp: force extension"
1576 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1577 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1578 skip "skipped for lustre < $SEL_VER"
1580 local comp_file=$DIR/$tdir/$tfile
1581 test_mkdir -p $DIR/$tdir
1583 wait_delete_completed
1586 pool_add $TESTNAME || error "Pool creation failed"
1587 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1589 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
1590 error "Create $comp_file failed"
1592 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1594 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1597 ost_watermarks_clear_enospc $tfile 0 $wms
1598 [ $RC -eq 0 ] || error "dd failed $RC"
1600 $LFS getstripe $comp_file
1601 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
1602 local found=$($LFS find $flg_opts $comp_file | wc -l)
1603 [ $found -eq 1 ] || error "Write: component (64M-EOF) not found"
1605 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
1606 [ "$ost_idx" != "" ] && error "Write: 0-length component still exists"
1607 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1608 [ "$ost_idx" != "" ] && error "Write: extension component still exists"
1610 sel_layout_sanity $comp_file 2
1612 run_test 20e "ENOSPC with next real comp: spillover and backward extension"
1614 # Simple DoM interaction test
1616 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1617 skip "skipped for lustre < $SEL_VER"
1619 local comp_file=$DIR/$tdir/$tfile
1623 test_mkdir -p $DIR/$tdir
1625 # simple, correct self-extending layout after DoM component
1626 $LFS setstripe -E 1M -L mdt -E -1 -z 64m $comp_file || \
1627 error "Create $comp_file failed"
1629 # Write to DoM component & to self-extending comp after it
1630 dd if=/dev/zero bs=1M count=12 of=$comp_file ||
1631 error "dd to extend failed"
1633 flg_opts="--comp-flags init"
1634 found=$($LFS find --comp-start 1M -E 65M $flg_opts $comp_file | wc -l)
1635 [ $found -eq 1 ] || error "Write: extended component not found"
1637 flg_opts="--comp-flags extension"
1638 found=$($LFS find --comp-start 65M $flg_opts $comp_file | wc -l)
1639 [ $found -eq 1 ] || error "Write: extension component not found"
1641 sel_layout_sanity $comp_file 3
1643 run_test 21a "Simple DoM interaction tests"
1645 # DoM + extension + removal
1647 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1648 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1649 skip "skipped for lustre < $SEL_VER"
1651 local comp_file=$DIR/$tdir/$tfile
1652 local ost_name=$(ostname_from_index 0)
1656 test_mkdir -p $DIR/$tdir
1658 # DoM, extendable component, further extendable component
1659 $LFS setstripe -E 1M -L mdt -E 256M -i 0 -z 64M -E -1 -z 1G \
1660 $comp_file || error "Create $comp_file failed"
1662 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1663 [ $found -eq 1 ] || error "Write: Zero length component not found"
1665 # This also demonstrates that we will avoid degraded OSTs
1666 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
1667 # sleep to guarantee we see the degradation
1670 # un-degrade on exit
1671 stack_trap "do_facet ost1 $LCTL set_param -n \
1672 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1674 # This should remove the first component after DoM and spill over to
1676 dd if=/dev/zero bs=1M count=2 of=$comp_file ||
1677 error "dd to remove+spill over failed"
1679 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1680 [ $found -eq 0 ] || error "Write: Zero length component still present"
1682 flg_opts="--comp-flags init"
1683 found=$($LFS find --comp-start 1M -E 1025M $flg_opts $comp_file | wc -l)
1684 [ $found -eq 1 ] || error "Write: extended component not found"
1686 flg_opts="--comp-flags extension"
1687 found=$($LFS find --comp-start 1025M -E EOF $flg_opts $comp_file |wc -l)
1688 [ $found -eq 1 ] || error "Write: extension component not found"
1690 sel_layout_sanity $comp_file 3
1692 run_test 21b "DoM followed by extendable component with removal"
1694 # Test of repeat component behavior with OOS/degraded OST
1696 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1697 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1698 skip "skipped for lustre < $SEL_VER"
1700 local comp_file=$DIR/$tdir/$tfile
1704 test_mkdir -p $DIR/$tdir
1706 $LFS setstripe -E -1 -c 1 -z 128M $comp_file ||
1707 error "Create $comp_file failed"
1709 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1710 local ost_name=$(ostname_from_index $ost_idx1)
1712 # write past end of first component, so it is extended
1713 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
1714 error "dd to extend failed"
1716 flg_opts="--comp-flags extension"
1717 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
1718 [ $found -eq 1 ] || error "Write: second component not found"
1720 # degrade OST for component 1
1721 do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
1722 obdfilter.$ost_name.degraded=1
1723 # sleep to guarantee we see the degradation
1726 # un-degrade on exit
1727 stack_trap "do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
1728 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1730 replay_barrier $SINGLEMDS
1732 # seek past the end of current comp & write, should cause a new comp
1733 # to be created (ie repeat previous comp)
1734 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
1735 error "dd to repeat failed"
1737 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1739 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1741 flg_opts="--comp-flags init"
1742 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1743 [ $found -eq 1 ] || error "Write: second component not found"
1745 flg_opts="--comp-flags extension"
1746 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1747 [ $found -eq 1 ] || error "Write: extension component not found"
1751 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1752 [ $ost_idx2_2 -ne $ost_idx2 ] && error "$ost_idx2_2 != $ost_idx2"
1754 flg_opts="--comp-flags init"
1755 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1756 [ $found -eq 1 ] || error "Failover: second component not found"
1758 flg_opts="--comp-flags extension"
1759 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1760 [ $found -eq 1 ] || error "Failover: extension component not found"
1762 sel_layout_sanity $comp_file 3
1764 run_test 22a "Test repeat component behavior with degraded OST"
1766 # Test repeat behavior with low space
1768 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1769 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1770 skip "skipped for lustre < $SEL_VER"
1772 local comp_file=$DIR/$tdir/$tfile
1776 test_mkdir -p $DIR/$tdir
1778 # without this, a previous delete can finish after we check free space
1779 wait_delete_completed
1782 $LFS setstripe -E -1 -c 1 -z 128M \
1783 $comp_file || error "Create $comp_file failed"
1785 # write past end of first component, so it is extended
1786 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
1787 error "dd to extend failed"
1789 flg_opts="--comp-flags extension"
1790 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
1791 [ $found -eq 1 ] || error "Write: Second component not found"
1793 # set our OST low on space
1794 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1795 local wms=$(ost_watermarks_set_low_space $ost_idx1 | grep "watermarks")
1797 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1799 # Write past end of current space, fail to extend, causing repeat
1800 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
1801 error "dd to repeat failed"
1803 $LFS getstripe $comp_file
1805 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1807 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1809 flg_opts="--comp-flags init"
1810 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1811 [ $found -eq 1 ] || error "Write: Second component not found"
1813 flg_opts="--comp-flags extension"
1814 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1815 [ $found -eq 1 ] || error "Write: Extension component not found"
1817 sel_layout_sanity $comp_file 3
1819 run_test 22b "Test simple 'out of space' condition with repeat"
1821 # This tests both "repeat" and "extend in place when repeat fails" aspects
1822 # of repeating components
1824 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1825 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1826 skip "skipped for lustre < $SEL_VER"
1828 local comp_file=$DIR/$tdir/$tfile
1832 test_mkdir -p $DIR/$tdir
1834 # pool is used to limit available OSTs to 0 and 1, so we can set all
1835 # available OSTs out of space
1836 pool_add $TESTNAME || error "Pool creation failed"
1837 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
1839 # without this, a previous delete can finish after we check free space
1840 wait_delete_completed
1843 $LFS setstripe -E -1 -z 64M -c 1 -p "$TESTNAME" $comp_file || \
1844 error "Create $comp_file failed"
1846 # write past end of first component, so it is extended
1847 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=80 conv=notrunc ||
1848 error "dd to extend failed"
1850 $LFS getstripe $comp_file
1852 flg_opts="--comp-flags extension"
1853 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1854 [ $found -eq 1 ] || error "Write: second component not found"
1856 # set our OST out of space
1857 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1858 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1860 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1862 # This should create a repeat component on a new OST
1863 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=180 conv=notrunc ||
1864 error "dd to repeat failed"
1866 $LFS getstripe $comp_file
1868 local comp_cnt=$($LFS getstripe --component-count $comp_file)
1869 [ $comp_cnt -ne 3 ] && error "component count: $comp_cnt, should be 3"
1871 # New second component should be on a different OST
1872 local ost_idx2=$($LFS getstripe --comp-start=128m \
1873 --comp-end=192m --comp-flags=init -i $comp_file)
1875 [ $ost_idx1 -eq $ost_idx2 ] && error "2nd comp: same OST $ost_idx1"
1877 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
1879 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
1881 # now that the second OST is out of space (as is the first OST), we
1882 # attempt to extend. This should result in an extension of the
1883 # existing component, rather than a new component.
1884 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=240 conv=notrunc ||
1885 error "dd for forced extension failed"
1887 $LFS getstripe $comp_file
1889 # clear out of space on first OST
1890 ost_watermarks_clear_enospc $tfile $ost_idx1 $wms
1892 # finally, now that the first OST has space again, we attempt to
1893 # extend one last time. This should create a new component on the
1895 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 conv=notrunc ||
1896 error "dd for repeat on first OST failed"
1898 $LFS getstripe $comp_file
1900 flg_opts="--comp-flags init"
1901 found=$($LFS find --comp-start 128M $flg_opts $comp_file | wc -l)
1902 [ $found -eq 1 ] || error "Write: second component not found"
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: third component not found"
1908 flg_opts="--comp-flags extension"
1909 found=$($LFS find --comp-start 320M -E EOF $flg_opts $comp_file | wc -l)
1910 [ $found -eq 1 ] || error "Write: extension component not found"
1912 sel_layout_sanity $comp_file 4
1914 run_test 22c "Test repeat with out of space on > 1 OST"
1916 test_22d_post_check() {
1919 local flg_opts="--comp-flags init"
1920 local found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file |
1922 [ $found -eq 1 ] || {
1923 $LFS getstripe $comp_file
1924 error "$name: second component not found"
1927 flg_opts="--comp-flags extension"
1928 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1929 [ $found -eq 1 ] || error "$name: third extension component not found"
1931 sel_layout_sanity $comp_file 2
1939 # write past end of first component
1940 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=70
1943 ost_watermarks_clear_enospc $tfile 0 $wms
1944 [ $RC -eq 0 ] || error "dd to force extend failed"
1946 test_22d_post_check $comp_file "Write"
1950 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1951 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1952 skip "skipped for lustre < $SEL_VER"
1954 local comp_file=$DIR/$tdir/$tfile
1958 test_mkdir -p $DIR/$tdir
1960 # without this, a previous delete can finish after we check free space
1961 wait_delete_completed
1964 # Pool allows us to force use of only certain OSTs
1965 pool_add $TESTNAME || error "Pool creation failed"
1966 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1968 # 1. Fail to extend due to OOS, try to repeat within the same pool,
1969 # fail to stripe (again OOS) the 0-length component, remove the
1970 # repeated one, force the extension on the original one.
1971 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
1972 error "Create $comp_file failed"
1974 replay_barrier $SINGLEMDS
1976 # set our OST out of space
1977 local wms=$(ost_watermarks_set_enospc $tfile 0 | grep "watermarks")
1979 test_22d_pre $comp_file "$wms"
1981 test_22d_post_check $comp_file "Failover"
1983 # 2. repeat with low on space: 0-length repeated component will be
1984 # striped, but still fails to be extended; otherwise the same as (1).
1986 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
1987 error "Create $comp_file failed"
1989 replay_barrier $SINGLEMDS
1991 # set our OST low on space
1992 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1994 test_22d_pre $comp_file "$wms"
1996 test_22d_post_check $comp_file "Failover"
1998 run_test 22d "out of/low on space + failed to repeat + forced extension"
2001 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2002 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2003 skip "skipped for lustre < $SEL_VER"
2005 local comp_file=$DIR/$tdir/$tfile
2006 test_mkdir -p $DIR/$tdir
2008 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2009 error "Create $comp_file failed"
2011 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2012 error "dd append failed"
2014 local flg_opts="--comp-start 0 -E EOF --comp-flags init"
2015 local found=$($LFS find $flg_opts $comp_file | wc -l)
2016 [ $found -eq 1 ] || error "Append: first component (0-EOF) not found"
2018 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2019 [ "$ost_idx" != "" ] && error "Append: second component still exists"
2021 sel_layout_sanity $comp_file 1
2023 run_test 23a "Append: remove EXT comp"
2026 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2027 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2028 skip "skipped for lustre < $SEL_VER"
2030 local comp_file=$DIR/$tdir/$tfile
2031 test_mkdir -p $DIR/$tdir
2033 $LFS setstripe -E 64m -E -1 -z 64M $comp_file ||
2034 error "Create $comp_file failed"
2036 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2037 error "dd append failed"
2039 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2040 local found=$($LFS find $flg_opts $comp_file | wc -l)
2041 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2043 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2044 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2046 sel_layout_sanity $comp_file 2
2048 run_test 23b "Append with 0-length comp: remove EXT comp"
2051 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2052 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2053 skip "skipped for lustre < $SEL_VER"
2055 local comp_file=$DIR/$tdir/$tfile
2056 test_mkdir -p $DIR/$tdir
2058 wait_delete_completed
2061 pool_add $TESTNAME || error "Pool creation failed"
2062 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2063 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
2064 error "Create $comp_file failed"
2066 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2067 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2070 ost_watermarks_clear_enospc $tfile 0 $wms
2071 [ $RC -eq 0 ] || error "dd append failed: $RC"
2073 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2074 local found=$($LFS find $flg_opts $comp_file | wc -l)
2075 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2077 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2078 [ "$ost_idx" != "" ] && error "Append: EXT component still exists"
2080 sel_layout_sanity $comp_file 2
2082 run_test 23c "Append with low on space + 0-length comp: force extension"
2085 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2086 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2087 skip "skipped for lustre < $SEL_VER"
2089 local comp_file=$DIR/$tdir/$tfile
2090 test_mkdir -p $DIR/$tdir
2092 $LFS setstripe -E 64m -E 640M -z 64M -E -1 $comp_file ||
2093 error "Create $comp_file failed"
2095 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2096 error "dd append failed"
2098 flg_opts="--comp-start 64M -E 640M --comp-flags init"
2099 found=$($LFS find $flg_opts $comp_file | wc -l)
2100 [ $found -eq 1 ] || error "Append: component (64M-640M) not found"
2102 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2103 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2105 sel_layout_sanity $comp_file 3
2107 run_test 23d "Append with 0-length comp + next real comp: remove EXT comp"
2110 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2111 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2112 skip "skipped for lustre < $SEL_VER"
2114 local comp_file=$DIR/$tdir/$tfile
2115 test_mkdir -p $DIR/$tdir
2117 wait_delete_completed
2120 pool_add $TESTNAME || error "Pool creation failed"
2121 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2123 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
2124 error "Create $comp_file failed"
2126 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2128 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2131 ost_watermarks_clear_enospc $tfile 0 $wms
2132 [ $RC -eq 0 ] || error "dd append failed $RC"
2134 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2135 local found=$($LFS find $flg_opts $comp_file | wc -l)
2136 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2138 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2139 [ "$ost_idx" != "" ] && error "Append: 0-length component still exists"
2140 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2141 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2143 sel_layout_sanity $comp_file 2
2145 run_test 23e "Append with next real comp: spillover and backward extension"
2148 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2149 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2150 skip "skipped for lustre < $SEL_VER"
2152 local comp_file=$DIR/$tdir/$tfile
2153 test_mkdir -p $DIR/$tdir
2155 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2156 error "Create $comp_file failed"
2158 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
2159 local wms=$(ost_watermarks_set_low_space $ost_idx | grep "watermarks")
2161 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2164 ost_watermarks_clear_enospc $tfile $ost_idx $wms
2165 [ $RC -eq 0 ] || error "dd append failed"
2167 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2168 local found=$($LFS find $flg_opts $comp_file | wc -l)
2169 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2171 ost_idx=$($LFS getstripe -I2 -i $comp_file)
2172 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2174 sel_layout_sanity $comp_file 2
2176 run_test 23f "Append with low on space: repeat and remove EXT comp"
2179 check_and_cleanup_lustre