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"
857 local file=$DIR/$tdir/$tfile
858 local dir=$DIR/$tdir/dir
859 local temp=$DIR/$tdir/template
861 test_mkdir $DIR/$tdir
863 #####################################################################
865 # set stripe for source file
866 $LFS setstripe -E256M -S 1M -c2 -o0,1 -z 64M -E-1 -o1,0 -z 128M \
867 $file || error "Create $file failed"
870 verify_yaml_layout $file $file.copy $temp "1. PFL file"
872 #####################################################################
874 # set stripe for source dir
876 $LFS setstripe -E256M -S 1M -c2 -z 64M -E-1 -z 128M \
877 $dir || error "setstripe $dir failed"
880 echo "2. SEL template on dir"
881 verify_yaml_layout $dir $dir.copy $temp.dir "2. PFL dir"
883 run_test 16c "Verify setstripe/getstripe for SEL layout with YAML config file"
886 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
887 local file=$DIR/$tdir/$tfile
888 test_mkdir -p $DIR/$tdir
891 $LFS setstripe -E 1M -S 1M -E 2M -c 2 -E -1 -c -1 $file ||
892 error "Create $file failed"
894 local s1=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
895 local s2=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
896 local s3=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
897 echo "1st init: comp size 1:$s1 2:$s2 3:$s3"
900 $TRUNCATE $file $((1024*1024+1))
901 local s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
902 local s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
903 echo "2nd init: comp size 1:$s1n 2:$s2n 3:$s3"
905 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
906 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
909 $TRUNCATE $file $((1024*1024*2+1))
910 s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
911 s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
912 local s3n=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
913 echo "3rd init: comp size 1:$s1n 2:$s2n 3:$s3n"
915 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
916 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
917 [ $s3 -lt $s3n ] || error "3rd comp size $s3 should < $s3n"
919 run_test 17 "Verify LOVEA grows with more component inited"
921 check_distribution() {
925 local obj_min_one=$((OSTCOUNT - 1))
927 objs=$($LFS getstripe $file |
928 awk '/l_ost_idx:/ { print $5 }' | wc -l)
929 let ave=$((objs / OSTCOUNT))
931 # collect objects per OST distribution
932 $LFS getstripe $file | awk '/l_ost_idx:/ { print $5 }' | tr -d "," |
933 (inuse=( $(for i in $(seq 0 $obj_min_one); do echo 0; done) )
935 let inuse[$O]=$((1 + ${inuse[$O]}))
938 # verify object distribution varies no more than +-1
939 for idx in $(seq 0 $obj_min_one); do
940 let dif=$((${inuse[$idx]} - ave))
942 if [ "$dif" -gt 1 ]; then
943 echo "OST${idx}: ${inuse[$idx]} objects"
944 error "bad distribution on OST${idx}"
950 local file1=$DIR/${tfile}-1
951 local file2=$DIR/${tfile}-2
952 local file3=$DIR/${tfile}-3
954 rm -f $file1 $file2 $file3
956 $LFS setstripe -E 1m -S 1m $file1 ||
957 error "Create $file1 failed"
958 $LFS setstripe -E 1m -S 1m $file2 ||
959 error "Create $file2 failed"
960 $LFS setstripe -E 1m -S 1m $file3 ||
961 error "Create $file3 failed"
963 local objs=$((OSTCOUNT+1))
964 for comp in $(seq 1 $OSTCOUNT); do
965 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file1 ||
966 error "Add component to $file1 failed 2"
967 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file2 ||
968 error "Add component to $file2 failed 2"
969 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file3 ||
970 error "Add component to $file3 failed 2"
973 $LFS setstripe --component-add -E -1 -c -1 $file1 ||
974 error "Add component to $file1 failed 3"
975 $LFS setstripe --component-add -E -1 -c -1 $file2 ||
976 error "Add component to $file2 failed 3"
977 $LFS setstripe --component-add -E -1 -c -1 $file3 ||
978 error "Add component to $file3 failed 3"
980 # Instantiate all components
981 dd if=/dev/urandom of=$file1 bs=1M count=$((objs+1)) ||
982 error "dd failed for $file1"
983 dd if=/dev/urandom of=$file2 bs=1M count=$((objs+1)) ||
984 error "dd failed for $file2"
985 dd if=/dev/urandom of=$file3 bs=1M count=$((objs+1)) ||
986 error "dd failed for $file3"
988 check_distribution $file1
989 check_distribution $file2
990 check_distribution $file3
993 run_test 18 "check component distribution"
997 local already_created=${2:-0}
998 local rw_len=$((3 * 1024 * 1024)) # 3M
1002 if [ $already_created != 1 ]; then
1003 test_mkdir -p $DIR/$tdir
1004 $LFS setstripe --extension-size 64M -c 1 -E -1 $comp_file ||
1005 error "Create $comp_file failed"
1008 # write past end of first component, so it is extended
1009 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=127 conv=notrunc ||
1010 error "dd to extend failed"
1012 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1013 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1015 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1016 [ $ost_idx2 -ne "-1" ] && error "second component init $ost_idx2"
1018 flg_opts="--comp-flags init"
1019 found=$($LFS find --comp-start 0 -E 128M $flg_opts $comp_file | wc -l)
1020 [ $found -eq 1 ] || error "Write: Extended first component not found"
1022 flg_opts="--comp-flags extension"
1023 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1024 [ $found -eq 1 ] || error "Write: second component not found"
1026 found=$($LFS find -z 64M $comp_file | wc -l)
1027 [ $found -eq 1 ] || error "component not found by ext size"
1029 found=$($LFS find --extension-size +63M $comp_file | wc -l)
1030 [ $found -eq 1 ] || error "component not found by +ext size"
1032 found=$($LFS find --ext-size -65M $comp_file | wc -l)
1033 [ $found -eq 1 ] || error "component not found by -ext size"
1035 found=$($LFS find -z 65M $comp_file | wc -l)
1036 [ $found -eq 0 ] || error "component found by wrong ext size"
1038 found=$($LFS find -z +65M $comp_file | wc -l)
1039 [ $found -eq 0 ] || error "component found by wrong +ext size"
1041 found=$($LFS find -z -63M $comp_file | wc -l)
1042 [ $found -eq 0 ] || error "component found by wrong -ext size"
1044 found=$($LFS find ! -z 64M $comp_file | wc -l)
1045 [ $found -eq 0 ] || error "component found by negation of ext size"
1047 found=$($LFS find ! -z +63M $comp_file | wc -l)
1048 [ $found -eq 0 ] || error "component found by negation of +ext size"
1050 found=$($LFS find ! -z -65M $comp_file | wc -l)
1051 [ $found -eq 0 ] || error "component found by negation of -ext size"
1053 found=$($LFS find ! -z 65M $comp_file | wc -l)
1055 error "component not found by negation of wrong ext size"
1057 found=$($LFS find ! -z +65M $comp_file | wc -l)
1059 error "component not found by negation of wrong +ext size"
1061 found=$($LFS find ! -z -63M $comp_file | wc -l)
1063 error "component not found by negation of wrong -ext size"
1065 found=$($LFS find -S +1M $comp_file | wc -l)
1066 [ $found -eq 0 ] || error "component found by wrong +stripe size"
1068 found=$($LFS find -c 1 $comp_file | wc -l)
1069 [ $found -eq 1 ] || error "component not found by stripe count"
1071 small_write $comp_file $rw_len || error "Verify RW failed"
1073 sel_layout_sanity $comp_file 2
1076 # Self-extending PFL tests
1078 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1079 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1080 skip "skipped for lustre < $SEL_VER"
1082 test19_io_base $DIR/$tdir/$tfile
1084 run_test 19a "Simple test of extension behavior"
1086 # Same as 19a, but with default layout set on directory rather than on file
1088 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1089 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1090 skip "skipped for lustre < $SEL_VER"
1092 local comp_file=$DIR/$tdir/$tfile
1093 local comp_dir=$DIR/$tdir/$tdir
1097 test_mkdir -p $DIR/$tdir
1098 $LFS setstripe --ext-size 64M -c 1 -E -1 $DIR/$tdir ||
1099 error "Setstripe on $DIR/$tdir failed"
1101 # check inheritance for a sub-dir and a file
1102 test_mkdir $comp_dir
1103 found=$($LFS find --comp-start 0 -E 64M $comp_dir | wc -l)
1104 [ $found -eq 1 ] || error "Dir Inheritance: wrong first component size"
1106 flg_opts="--comp-flags extension"
1107 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_dir | wc -l)
1108 [ $found -eq 1 ] || error "Dir Inheritance: Second component not found"
1112 flg_opts="--comp-flags init"
1113 found=$($LFS find --comp-start 0 -E 64M $flg_opts $comp_file | wc -l)
1114 [ $found -eq 1 ] || error "File Inheritance: wrong first component size"
1116 flg_opts="--comp-flags extension"
1117 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_file | wc -l)
1118 [ $found -eq 1 ] || error "File Inheritance: Second component not found"
1120 test19_io_base $comp_file 1
1122 run_test 19b "Simple test of SEL as default layout"
1124 # Test behavior when seeking deep in a file
1126 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1127 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1128 skip "skipped for lustre < $SEL_VER"
1130 local comp_file=$DIR/$tdir/$tfile
1134 test_mkdir -p $DIR/$tdir
1136 $LFS setstripe -z 128M -E 1G -E -1 $comp_file ||
1137 error "Create $comp_file failed"
1139 # write past end of first component, so it is extended
1140 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 conv=notrunc ||
1141 error "dd to extend failed"
1143 flg_opts="--comp-flags init"
1144 found=$($LFS find --comp-start 0M -E 256M $flg_opts $comp_file | wc -l)
1145 [ $found -eq 1 ] || error "Write: first extension component not found"
1147 flg_opts="--comp-flags extension,^init"
1148 found=$($LFS find --comp-start 256M -E 1024M $flg_opts $comp_file |\
1150 [ $found -eq 1 ] || error "Write: second extension component not found"
1152 local end_1=$($LFS getstripe -I1 -E $comp_file)
1155 [ $end_1 -eq 268435456 ] ||
1156 error "end of first component $end_1 != 268435456"
1158 # Write past end of extension space component, in to normal component
1159 # should exhaust & remove extension component
1160 dd if=/dev/zero bs=1M count=1 seek=1100 of=$comp_file conv=notrunc ||
1161 error "dd distant seek failed"
1163 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1164 # the last component index is 3
1165 local ost_idx2=$($LFS getstripe -I3 -i $comp_file)
1167 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1169 local start1=$($LFS getstripe -I1 --comp-start $comp_file)
1170 local end1=$($LFS getstripe -I1 -E $comp_file)
1171 local start2=$($LFS getstripe -I3 --comp-start $comp_file)
1172 local end2=$($LFS getstripe -I3 -E $comp_file)
1174 [ $start1 -eq 0 ] || error "start of first component incorrect"
1175 [ $end1 -eq 1073741824 ] || error "end of first component incorrect"
1176 [ $start2 -eq 1073741824 ] ||
1177 error "start of second component incorrect"
1178 [ "$end2" = "EOF" ] || error "end of second component incorrect"
1180 flg_opts="--comp-flags extension"
1181 found=$($LFS find $flg_opts $comp_file | wc -l)
1182 [ $found -eq 0 ] || error "Seek Write: extension component exists"
1184 sel_layout_sanity $comp_file 2
1186 run_test 19c "Test self-extending layout seeking behavior"
1189 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1190 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1191 skip "skipped for lustre < $SEL_VER"
1193 local comp_file=$DIR/$tdir/$tfile
1197 test_mkdir -p $DIR/$tdir
1199 $LFS setstripe -E 128M -c 1 -z 64M -E -1 $comp_file ||
1200 error "Create $comp_file failed"
1202 # This will cause component 1 to be extended to 128M, then the
1203 # extension space component will be removed
1204 dd if=/dev/zero of=$comp_file bs=130M count=1 ||
1205 error "dd to extend failed"
1207 flg_opts="--comp-flags init"
1208 found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file | wc -l)
1209 [ $found -eq 1 ] || error "Write: first component not found"
1211 flg_opts="--comp-flags init"
1212 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1213 [ $found -eq 1 ] || error "Write: second component not found"
1215 sel_layout_sanity $comp_file 2
1217 # always remove large files in case of DO_CLEANUP=false
1218 rm -f $comp_file || error "Delete $comp_file failed"
1220 run_test 19d "Test write which completely spans extension space component"
1225 local comp2_flags=$($LFS getstripe -I2 --comp-flags $comp_file)
1226 local comp3_flags=$($LFS getstripe -I3 --comp-flags $comp_file)
1228 [ "$comp2_flags" != "init" ] && error "$comp2_flags != init"
1229 [ "$comp3_flags" != "extension" ] && error "$comp3_flags != extension"
1231 local flg_opts=" --comp-start 2M -E 66M --comp-flags init"
1232 local found=$($LFS find $flg_opts $comp_file | wc -l)
1233 [ $found -eq 1 ] || error "Write: extended second component not found"
1235 flg_opts="--comp-start 66M -E EOF --comp-flags extension"
1236 found=$($LFS find $flg_opts $comp_file | wc -l)
1237 [ $found -eq 1 ] || error "Write: third component not found"
1239 sel_layout_sanity $comp_file 3
1243 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1244 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1245 skip "skipped for lustre < $SEL_VER"
1247 local comp_file=$DIR/$tdir/$tfile
1248 local rw_len=$((3 * 1024 * 1024)) # 3M
1252 test_mkdir -p $DIR/$tdir
1254 $LFS setstripe -E 2m -E -1 -z 64M $comp_file ||
1255 error "Create $comp_file failed"
1257 replay_barrier $SINGLEMDS
1259 #instantiate & extend second component
1260 dd if=/dev/zero of=$comp_file bs=4M count=1 ||
1261 error "dd to extend failed"
1263 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1264 local ost_idx3=$($LFS getstripe -I3 -i $comp_file)
1266 [ $ost_idx2 -eq $ost_idx3 ] && error "$ost_idx2 == $ost_idx3"
1267 [ $ost_idx3 -ne "-1" ] && error "third component init $ost_idx3"
1269 test_19e_check $comp_file
1271 local f1=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1272 echo "before MDS recovery, the ost fid of 2nd component is $f1"
1276 local f2=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1277 echo "after MDS recovery, the ost fid of 2nd component is $f2"
1278 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
1280 # simply repeat all previous checks, but also verify components are on
1281 # the same OST as before
1283 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1284 local ost_idx3_2=$($LFS getstripe -I3 -i $comp_file)
1286 [ $ost_idx2_2 -eq $ost_idx3_2 ] && error "$ost_idx2_2 == $ost_idx3_2"
1287 [ $ost_idx3_2 -ne "-1" ] && error "second component init $ost_idx3_2"
1289 # verify OST id is the same after failover
1290 [ $ost_idx2 -ne $ost_idx2_2 ] &&
1291 error "$ost_idx2 != $ost_idx2_2, changed after failover"
1293 test_19e_check $comp_file
1295 run_test 19e "Replay of layout instantiation & extension"
1298 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1299 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1300 skip "skipped for lustre < $SEL_VER"
1302 local comp_file=$DIR/$tdir/$tfile
1306 test_mkdir -p $DIR/$tdir
1308 $LFS setstripe -E 256M --comp-flags extension -E -1 $comp_file
1310 [ $? != 0 ] || error "should not be able to manually set extension flag"
1313 run_test 19f "Rejection of invalid layouts"
1316 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1317 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1318 skip "skipped for lustre < $SEL_VER"
1320 local file1=$DIR/${tfile}-1
1321 local file2=$DIR/${tfile}-2
1323 test_mkdir -p $DIR/$tdir
1324 multiop $file1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1325 error "create failed $file1"
1326 multiop $file2 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1327 error "create failed $file2"
1329 $LFS setstripe --component-add -E 1G -c 1 $file1 ||
1330 error "comp-add [0,1G] failed $file1"
1331 $LFS setstripe --component-add -E 512M -z 128M $file1 &&
1332 error "comp-add [1G,1G],SEL[1G,512M] succeded $file1"
1333 $LFS setstripe --component-add -E 10G -z 128M $file1 ||
1334 error "comp-add [1G,1G],SEL[1G,10G] failed $file1"
1335 $LFS setstripe --component-add -E -1 $file1 ||
1336 error "comp-add [10G,-1] failed $file1"
1338 $LFS setstripe --component-add -E 1G -z 32M -c 1 $file2 &&
1339 error "comp-add with smal ext size succeeded $file1"
1340 $LFS setstripe --component-add -E 1G -z 100M -c 1 $file2 &&
1341 error "comp-add with not aligned ext size succeeded $file1"
1342 $LFS setstripe --component-add -E 1G -z 128M -c 1 $file2 ||
1343 error "comp-add [0,128M],SEL[128M,1G] failed $file1"
1344 $LFS setstripe --component-add -E 10G $file2 ||
1345 error "comp-add [1G,10G] failed $file1"
1346 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 ||
1347 error "comp-add [10G,10G],SEL[10G,-1] failed $file1"
1348 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 &&
1349 error "repeated comp-add [10G,10G],SEL[10G,-1] succeeded $file1"
1351 $LFS getstripe $file1
1352 flg_opts="--comp-flags init"
1353 found=$($LFS find --comp-start 0 -E 1G $flg_opts $file1 | wc -l)
1354 [ $found -eq 1 ] || error "First component not found $file1"
1356 flg_opts="--comp-flags ^init"
1357 found=$($LFS find --comp-start 1G -E 1G $flg_opts $file1 | wc -l)
1358 [ $found -eq 1 ] || error "Second component not found $file1"
1360 flg_opts="--comp-flags ^init,extension"
1361 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file1 | wc -l)
1362 [ $found -eq 1 ] || error "Third component not found $file1"
1364 flg_opts="--comp-flags ^init"
1365 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file1 | wc -l)
1366 [ $found -eq 1 ] || error "Fourth component not found $file1"
1368 $LFS getstripe $file2
1369 flg_opts="--comp-flags init"
1370 found=$($LFS find --comp-start 0 -E 128M $flg_opts $file2 | wc -l)
1371 [ $found -eq 1 ] || error "First component not found $file2"
1373 flg_opts="--comp-flags extension"
1374 found=$($LFS find --comp-start 128M -E 1G $flg_opts $file2 | wc -l)
1375 [ $found -eq 1 ] || error "Second component not found $file2"
1377 flg_opts="--comp-flags ^init"
1378 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file2 | wc -l)
1379 [ $found -eq 1 ] || error "Third component not found $file2"
1381 flg_opts="--comp-flags ^init"
1382 found=$($LFS find --comp-start 10G -E 10G $flg_opts $file2 | wc -l)
1383 [ $found -eq 1 ] || error "Fourth component not found $file2"
1385 flg_opts="--comp-flags ^init,extension"
1386 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file2 | wc -l)
1387 [ $found -eq 1 ] || error "Fifth component not found $file2"
1389 run_test 19g "component-add behaviour"
1391 # Test out of space behavior
1393 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1394 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1395 skip "skipped for lustre < $SEL_VER"
1397 local comp_file=$DIR/$tdir/$tfile
1401 test_mkdir -p $DIR/$tdir
1403 # without this, a previous delete can finish after we check free space
1404 wait_delete_completed
1407 # First component is on OST0
1408 $LFS setstripe -E 256M -i 0 -z 64M -E -1 -z 1G $comp_file ||
1409 error "Create $comp_file failed"
1411 # write past end of first component, so it is extended
1412 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=66 ||
1413 error "dd to extend failed"
1415 flg_opts="--comp-flags extension"
1416 found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file |wc -l)
1417 [ $found -eq 1 ] || error "Write: Second component not found"
1419 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1420 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1422 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1424 flg_opts="--comp-flags extension"
1425 # Write past current init comp, but we won't extend (because no space)
1426 dd if=/dev/zero of=$comp_file bs=1M count=10 seek=200 ||
1427 error "dd write past current comp failed"
1429 $LFS getstripe $comp_file
1431 flg_opts="--comp-flags init"
1432 found=$($LFS find --comp-start 128M -E 1152M $flg_opts $comp_file | \
1434 [ $found -eq 1 ] || error "Write: third component not found"
1436 flg_opts="--comp-flags extension"
1437 found=$($LFS find --comp-start 1152M -E EOF $flg_opts $comp_file |wc -l)
1438 [ $found -eq 1 ] || error "Write: fourth extension component not found"
1440 sel_layout_sanity $comp_file 3
1442 run_test 20a "Test out of space, spillover to defined component"
1445 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1446 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1447 skip "skipped for lustre < $SEL_VER"
1449 local comp_file=$DIR/$tdir/$tfile
1453 test_mkdir -p $DIR/$tdir
1455 # Pool allows us to force use of only certain OSTs
1456 pool_add $TESTNAME || error "Pool creation failed"
1457 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1459 # normal component to 10M, extendable component to 1G
1460 # further extendable to EOF
1461 $LFS setstripe -E 10M -E 1G -p $TESTNAME -z 64M -E -1 -p "" -z 512M \
1462 $comp_file || error "Create $comp_file failed"
1464 replay_barrier $SINGLEMDS
1466 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1467 [ $found -eq 1 ] || error "Zero length component not found"
1470 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1472 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1474 # write past end of first component
1475 # This should remove the next component, since OST0 is out of space
1476 # and it is striped there (pool contains only OST0)
1477 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=14 ||
1478 error "dd to extend/remove failed"
1480 $LFS getstripe $comp_file
1482 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1483 [ $found -eq 0 ] || error "Write: zero length component still present"
1485 flg_opts="--comp-flags init"
1486 found=$($LFS find --comp-start 10M -E 522M $flg_opts $comp_file | wc -l)
1487 [ $found -eq 1 ] || error "Write: second component not found"
1489 flg_opts="--comp-flags extension"
1490 found=$($LFS find --comp-start 522M -E EOF $flg_opts $comp_file | wc -l)
1491 [ $found -eq 1 ] || error "Write: third component not found"
1495 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1496 [ $found -eq 0 ] || error "Failover: 0-length component still present"
1498 flg_opts="--comp-flags init"
1499 found=$($LFS find --comp-start 10M -E 522M $flg_opts $comp_file | wc -l)
1500 [ $found -eq 1 ] || error "Failover: second component not found"
1502 flg_opts="--comp-flags extension"
1503 found=$($LFS find --comp-start 522M -E EOF $flg_opts $comp_file | wc -l)
1504 [ $found -eq 1 ] || error "Failover: third component not found"
1506 sel_layout_sanity $comp_file 3
1508 run_test 20b "Remove component without instantiation when there is no space"
1511 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1512 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1513 skip "skipped for lustre < $SEL_VER"
1515 local comp_file=$DIR/$tdir/$tfile
1519 test_mkdir -p $DIR/$tdir
1521 # pool is used to limit available OSTs to 0 and 1, so we can set all
1522 # available OSTs out of space
1523 pool_add $TESTNAME || error "Pool creation failed"
1524 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
1526 # without this, a previous delete can finish after we check free space
1527 wait_delete_completed
1530 $LFS setstripe -E 100M -E -1 -p $TESTNAME -z 64M $comp_file ||
1531 error "Create $comp_file failed"
1535 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1537 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
1539 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1540 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
1542 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=120 &&
1543 error "dd should fail with ENOSPC"
1545 flg_opts="--comp-flags init"
1546 found=$($LFS find --comp-start 0M -E 100M $flg_opts $comp_file | wc -l)
1547 [ $found -eq 1 ] || error "Write: First component not found"
1549 flg_opts="--comp-flags ^init"
1550 found=$($LFS find --comp-start 100M -E 100M $flg_opts $comp_file |wc -l)
1551 [ $found -eq 1 ] || error "Write: 0-length component not found"
1553 flg_opts="--comp-flags extension"
1554 found=$($LFS find --comp-start 100M -E EOF $flg_opts $comp_file | wc -l)
1555 [ $found -eq 1 ] || error "Write: third extension component not found"
1557 sel_layout_sanity $comp_file 3
1559 run_test 20c "Test inability to stripe new extension component"
1562 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1563 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1564 skip "skipped for lustre < $SEL_VER"
1566 local comp_file=$DIR/$tdir/$tfile
1567 test_mkdir -p $DIR/$tdir
1569 wait_delete_completed
1572 pool_add $TESTNAME || error "Pool creation failed"
1573 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1574 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
1575 error "Create $comp_file failed"
1577 replay_barrier $SINGLEMDS
1579 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1580 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1583 ost_watermarks_clear_enospc $tfile 0 $wms
1584 [ $RC -eq 0 ] || error "dd failed: $RC"
1586 $LFS getstripe $comp_file
1587 local flg_opts="--comp-start 64M -E 128M --comp-flags init"
1588 local found=$($LFS find $flg_opts $comp_file | wc -l)
1589 [ $found -eq 1 ] || error "Write: component (64M-128M) not found"
1591 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
1592 [ "$ost_idx" != "-1" ] && error "Write: EXT component disappeared"
1596 found=$($LFS find $flg_opts $comp_file | wc -l)
1597 [ $found -eq 1 ] || error "Failover: component (64M-128M) not found"
1599 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1600 [ "$ost_idx" != "-1" ] && error "Failover: EXT component disappeared"
1602 sel_layout_sanity $comp_file 3
1604 run_test 20d "Low on space + 0-length comp: force extension"
1607 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1608 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1609 skip "skipped for lustre < $SEL_VER"
1611 local comp_file=$DIR/$tdir/$tfile
1612 test_mkdir -p $DIR/$tdir
1614 wait_delete_completed
1617 pool_add $TESTNAME || error "Pool creation failed"
1618 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1620 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
1621 error "Create $comp_file failed"
1623 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1625 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1628 ost_watermarks_clear_enospc $tfile 0 $wms
1629 [ $RC -eq 0 ] || error "dd failed $RC"
1631 $LFS getstripe $comp_file
1632 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
1633 local found=$($LFS find $flg_opts $comp_file | wc -l)
1634 [ $found -eq 1 ] || error "Write: component (64M-EOF) not found"
1636 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
1637 [ "$ost_idx" != "" ] && error "Write: 0-length component still exists"
1638 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1639 [ "$ost_idx" != "" ] && error "Write: extension component still exists"
1641 sel_layout_sanity $comp_file 2
1643 run_test 20e "ENOSPC with next real comp: spillover and backward extension"
1645 # Simple DoM interaction test
1647 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1648 skip "skipped for lustre < $SEL_VER"
1650 local comp_file=$DIR/$tdir/$tfile
1654 test_mkdir -p $DIR/$tdir
1656 # simple, correct self-extending layout after DoM component
1657 $LFS setstripe -E 1M -L mdt -E -1 -z 64m $comp_file || \
1658 error "Create $comp_file failed"
1660 # Write to DoM component & to self-extending comp after it
1661 dd if=/dev/zero bs=1M count=12 of=$comp_file ||
1662 error "dd to extend failed"
1664 flg_opts="--comp-flags init"
1665 found=$($LFS find --comp-start 1M -E 65M $flg_opts $comp_file | wc -l)
1666 [ $found -eq 1 ] || error "Write: extended component not found"
1668 flg_opts="--comp-flags extension"
1669 found=$($LFS find --comp-start 65M $flg_opts $comp_file | wc -l)
1670 [ $found -eq 1 ] || error "Write: extension component not found"
1672 sel_layout_sanity $comp_file 3
1674 run_test 21a "Simple DoM interaction tests"
1676 # DoM + extension + removal
1678 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1679 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1680 skip "skipped for lustre < $SEL_VER"
1682 local comp_file=$DIR/$tdir/$tfile
1683 local ost_name=$(ostname_from_index 0)
1687 test_mkdir -p $DIR/$tdir
1689 # DoM, extendable component, further extendable component
1690 $LFS setstripe -E 1M -L mdt -E 256M -i 0 -z 64M -E -1 -z 1G \
1691 $comp_file || error "Create $comp_file failed"
1693 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1694 [ $found -eq 1 ] || error "Write: Zero length component not found"
1696 # This also demonstrates that we will avoid degraded OSTs
1697 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
1698 # sleep to guarantee we see the degradation
1701 # un-degrade on exit
1702 stack_trap "do_facet ost1 $LCTL set_param -n \
1703 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1705 # This should remove the first component after DoM and spill over to
1707 dd if=/dev/zero bs=1M count=2 of=$comp_file ||
1708 error "dd to remove+spill over failed"
1710 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1711 [ $found -eq 0 ] || error "Write: Zero length component still present"
1713 flg_opts="--comp-flags init"
1714 found=$($LFS find --comp-start 1M -E 1025M $flg_opts $comp_file | wc -l)
1715 [ $found -eq 1 ] || error "Write: extended component not found"
1717 flg_opts="--comp-flags extension"
1718 found=$($LFS find --comp-start 1025M -E EOF $flg_opts $comp_file |wc -l)
1719 [ $found -eq 1 ] || error "Write: extension component not found"
1721 sel_layout_sanity $comp_file 3
1723 run_test 21b "DoM followed by extendable component with removal"
1725 # Test of repeat component behavior with OOS/degraded OST
1727 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1728 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1729 skip "skipped for lustre < $SEL_VER"
1731 local comp_file=$DIR/$tdir/$tfile
1735 test_mkdir -p $DIR/$tdir
1737 $LFS setstripe -E -1 -c 1 -z 128M $comp_file ||
1738 error "Create $comp_file failed"
1740 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1741 local ost_name=$(ostname_from_index $ost_idx1)
1743 # write past end of first component, so it is extended
1744 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
1745 error "dd to extend failed"
1747 flg_opts="--comp-flags extension"
1748 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
1749 [ $found -eq 1 ] || error "Write: second component not found"
1751 # degrade OST for component 1
1752 do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
1753 obdfilter.$ost_name.degraded=1
1754 # sleep to guarantee we see the degradation
1757 # un-degrade on exit
1758 stack_trap "do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
1759 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1761 replay_barrier $SINGLEMDS
1763 # seek past the end of current comp & write, should cause a new comp
1764 # to be created (ie repeat previous comp)
1765 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
1766 error "dd to repeat failed"
1768 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1770 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1772 flg_opts="--comp-flags init"
1773 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1774 [ $found -eq 1 ] || error "Write: second component not found"
1776 flg_opts="--comp-flags extension"
1777 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1778 [ $found -eq 1 ] || error "Write: extension component not found"
1782 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1783 [ $ost_idx2_2 -ne $ost_idx2 ] && error "$ost_idx2_2 != $ost_idx2"
1785 flg_opts="--comp-flags init"
1786 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1787 [ $found -eq 1 ] || error "Failover: second component not found"
1789 flg_opts="--comp-flags extension"
1790 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1791 [ $found -eq 1 ] || error "Failover: extension component not found"
1793 sel_layout_sanity $comp_file 3
1795 run_test 22a "Test repeat component behavior with degraded OST"
1797 # Test repeat behavior with low space
1799 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1800 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1801 skip "skipped for lustre < $SEL_VER"
1803 local comp_file=$DIR/$tdir/$tfile
1807 test_mkdir -p $DIR/$tdir
1809 # without this, a previous delete can finish after we check free space
1810 wait_delete_completed
1813 $LFS setstripe -E -1 -c 1 -z 128M \
1814 $comp_file || error "Create $comp_file failed"
1816 # write past end of first component, so it is extended
1817 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
1818 error "dd to extend failed"
1820 flg_opts="--comp-flags extension"
1821 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
1822 [ $found -eq 1 ] || error "Write: Second component not found"
1824 # set our OST low on space
1825 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1826 local wms=$(ost_watermarks_set_low_space $ost_idx1 | grep "watermarks")
1828 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1830 # Write past end of current space, fail to extend, causing repeat
1831 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
1832 error "dd to repeat failed"
1834 $LFS getstripe $comp_file
1836 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1838 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1840 flg_opts="--comp-flags init"
1841 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1842 [ $found -eq 1 ] || error "Write: Second component not found"
1844 flg_opts="--comp-flags extension"
1845 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1846 [ $found -eq 1 ] || error "Write: Extension component not found"
1848 sel_layout_sanity $comp_file 3
1850 run_test 22b "Test simple 'out of space' condition with repeat"
1852 # This tests both "repeat" and "extend in place when repeat fails" aspects
1853 # of repeating components
1855 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1856 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1857 skip "skipped for lustre < $SEL_VER"
1859 local comp_file=$DIR/$tdir/$tfile
1863 test_mkdir -p $DIR/$tdir
1865 # pool is used to limit available OSTs to 0 and 1, so we can set all
1866 # available OSTs out of space
1867 pool_add $TESTNAME || error "Pool creation failed"
1868 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
1870 # without this, a previous delete can finish after we check free space
1871 wait_delete_completed
1874 $LFS setstripe -E -1 -z 64M -c 1 -p "$TESTNAME" $comp_file || \
1875 error "Create $comp_file failed"
1877 # write past end of first component, so it is extended
1878 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=80 conv=notrunc ||
1879 error "dd to extend failed"
1881 $LFS getstripe $comp_file
1883 flg_opts="--comp-flags extension"
1884 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1885 [ $found -eq 1 ] || error "Write: second component not found"
1887 # set our OST out of space
1888 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1889 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1891 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1893 # This should create a repeat component on a new OST
1894 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=180 conv=notrunc ||
1895 error "dd to repeat failed"
1897 $LFS getstripe $comp_file
1899 local comp_cnt=$($LFS getstripe --component-count $comp_file)
1900 [ $comp_cnt -ne 3 ] && error "component count: $comp_cnt, should be 3"
1902 # New second component should be on a different OST
1903 local ost_idx2=$($LFS getstripe --comp-start=128m \
1904 --comp-end=192m --comp-flags=init -i $comp_file)
1906 [ $ost_idx1 -eq $ost_idx2 ] && error "2nd comp: same OST $ost_idx1"
1908 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
1910 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
1912 # now that the second OST is out of space (as is the first OST), we
1913 # attempt to extend. This should result in an extension of the
1914 # existing component, rather than a new component.
1915 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=240 conv=notrunc ||
1916 error "dd for forced extension failed"
1918 $LFS getstripe $comp_file
1920 # clear out of space on first OST
1921 ost_watermarks_clear_enospc $tfile $ost_idx1 $wms
1923 # finally, now that the first OST has space again, we attempt to
1924 # extend one last time. This should create a new component on the
1926 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 conv=notrunc ||
1927 error "dd for repeat on first OST failed"
1929 $LFS getstripe $comp_file
1931 flg_opts="--comp-flags init"
1932 found=$($LFS find --comp-start 128M $flg_opts $comp_file | wc -l)
1933 [ $found -eq 1 ] || error "Write: second component not found"
1935 flg_opts="--comp-flags init"
1936 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1937 [ $found -eq 1 ] || error "Write: third component not found"
1939 flg_opts="--comp-flags extension"
1940 found=$($LFS find --comp-start 320M -E EOF $flg_opts $comp_file | wc -l)
1941 [ $found -eq 1 ] || error "Write: extension component not found"
1943 sel_layout_sanity $comp_file 4
1945 run_test 22c "Test repeat with out of space on > 1 OST"
1947 test_22d_post_check() {
1950 local flg_opts="--comp-flags init"
1951 local found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file |
1953 [ $found -eq 1 ] || {
1954 $LFS getstripe $comp_file
1955 error "$name: second component not found"
1958 flg_opts="--comp-flags extension"
1959 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1960 [ $found -eq 1 ] || error "$name: third extension component not found"
1962 sel_layout_sanity $comp_file 2
1970 # write past end of first component
1971 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=70
1974 ost_watermarks_clear_enospc $tfile 0 $wms
1975 [ $RC -eq 0 ] || error "dd to force extend failed"
1977 test_22d_post_check $comp_file "Write"
1981 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1982 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1983 skip "skipped for lustre < $SEL_VER"
1985 local comp_file=$DIR/$tdir/$tfile
1989 test_mkdir -p $DIR/$tdir
1991 # without this, a previous delete can finish after we check free space
1992 wait_delete_completed
1995 # Pool allows us to force use of only certain OSTs
1996 pool_add $TESTNAME || error "Pool creation failed"
1997 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1999 # 1. Fail to extend due to OOS, try to repeat within the same pool,
2000 # fail to stripe (again OOS) the 0-length component, remove the
2001 # repeated one, force the extension on the original one.
2002 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2003 error "Create $comp_file failed"
2005 replay_barrier $SINGLEMDS
2007 # set our OST out of space
2008 local wms=$(ost_watermarks_set_enospc $tfile 0 | grep "watermarks")
2010 test_22d_pre $comp_file "$wms"
2012 test_22d_post_check $comp_file "Failover"
2014 # 2. repeat with low on space: 0-length repeated component will be
2015 # striped, but still fails to be extended; otherwise the same as (1).
2017 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2018 error "Create $comp_file failed"
2020 replay_barrier $SINGLEMDS
2022 # set our OST low on space
2023 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2025 test_22d_pre $comp_file "$wms"
2027 test_22d_post_check $comp_file "Failover"
2029 run_test 22d "out of/low on space + failed to repeat + forced extension"
2032 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2033 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2034 skip "skipped for lustre < $SEL_VER"
2036 local comp_file=$DIR/$tdir/$tfile
2037 test_mkdir -p $DIR/$tdir
2039 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2040 error "Create $comp_file failed"
2042 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2043 error "dd append failed"
2045 local flg_opts="--comp-start 0 -E EOF --comp-flags init"
2046 local found=$($LFS find $flg_opts $comp_file | wc -l)
2047 [ $found -eq 1 ] || error "Append: first component (0-EOF) not found"
2049 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2050 [ "$ost_idx" != "" ] && error "Append: second component still exists"
2052 sel_layout_sanity $comp_file 1
2054 run_test 23a "Append: remove EXT comp"
2057 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2058 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2059 skip "skipped for lustre < $SEL_VER"
2061 local comp_file=$DIR/$tdir/$tfile
2062 test_mkdir -p $DIR/$tdir
2064 $LFS setstripe -E 64m -E -1 -z 64M $comp_file ||
2065 error "Create $comp_file failed"
2067 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2068 error "dd append failed"
2070 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2071 local found=$($LFS find $flg_opts $comp_file | wc -l)
2072 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2074 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2075 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2077 sel_layout_sanity $comp_file 2
2079 run_test 23b "Append with 0-length comp: remove EXT comp"
2082 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2083 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2084 skip "skipped for lustre < $SEL_VER"
2086 local comp_file=$DIR/$tdir/$tfile
2087 test_mkdir -p $DIR/$tdir
2089 wait_delete_completed
2092 pool_add $TESTNAME || error "Pool creation failed"
2093 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2094 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
2095 error "Create $comp_file failed"
2097 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2098 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2101 ost_watermarks_clear_enospc $tfile 0 $wms
2102 [ $RC -eq 0 ] || error "dd append failed: $RC"
2104 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2105 local found=$($LFS find $flg_opts $comp_file | wc -l)
2106 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2108 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2109 [ "$ost_idx" != "" ] && error "Append: EXT component still exists"
2111 sel_layout_sanity $comp_file 2
2113 run_test 23c "Append with low on space + 0-length comp: force extension"
2116 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2117 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2118 skip "skipped for lustre < $SEL_VER"
2120 local comp_file=$DIR/$tdir/$tfile
2121 test_mkdir -p $DIR/$tdir
2123 $LFS setstripe -E 64m -E 640M -z 64M -E -1 $comp_file ||
2124 error "Create $comp_file failed"
2126 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2127 error "dd append failed"
2129 flg_opts="--comp-start 64M -E 640M --comp-flags init"
2130 found=$($LFS find $flg_opts $comp_file | wc -l)
2131 [ $found -eq 1 ] || error "Append: component (64M-640M) not found"
2133 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2134 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2136 sel_layout_sanity $comp_file 3
2138 run_test 23d "Append with 0-length comp + next real comp: remove EXT comp"
2141 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2142 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2143 skip "skipped for lustre < $SEL_VER"
2145 local comp_file=$DIR/$tdir/$tfile
2146 test_mkdir -p $DIR/$tdir
2148 wait_delete_completed
2151 pool_add $TESTNAME || error "Pool creation failed"
2152 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2154 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
2155 error "Create $comp_file failed"
2157 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2159 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2162 ost_watermarks_clear_enospc $tfile 0 $wms
2163 [ $RC -eq 0 ] || error "dd append failed $RC"
2165 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2166 local found=$($LFS find $flg_opts $comp_file | wc -l)
2167 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2169 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2170 [ "$ost_idx" != "" ] && error "Append: 0-length component still exists"
2171 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2172 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2174 sel_layout_sanity $comp_file 2
2176 run_test 23e "Append with next real comp: spillover and backward extension"
2179 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2180 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2181 skip "skipped for lustre < $SEL_VER"
2183 local comp_file=$DIR/$tdir/$tfile
2184 test_mkdir -p $DIR/$tdir
2186 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2187 error "Create $comp_file failed"
2189 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
2190 local wms=$(ost_watermarks_set_low_space $ost_idx | grep "watermarks")
2192 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2195 ost_watermarks_clear_enospc $tfile $ost_idx $wms
2196 [ $RC -eq 0 ] || error "dd append failed"
2198 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2199 local found=$($LFS find $flg_opts $comp_file | wc -l)
2200 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2202 ost_idx=$($LFS getstripe -I2 -i $comp_file)
2203 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2205 sel_layout_sanity $comp_file 2
2207 run_test 23f "Append with low on space: repeat and remove EXT comp"
2210 check_and_cleanup_lustre