3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
9 LUSTRE=${LUSTRE:-$(dirname $0)/..}
10 . $LUSTRE/tests/test-framework.sh
14 # bug number for skipped test:
15 ALWAYS_EXCEPT="$SANITY_PFL_EXCEPT "
16 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
18 # Skip tests for PPC that fail frequently
19 if [[ $(uname -m) = ppc64 ]]; then
20 # bug number: LU-13186 LU-13205 LU-13207 LU-13186
21 ALWAYS_EXCEPT+=" 14 16a 16b 17"
24 if [[ "$ost1_FSTYPE" == "zfs" ]]; then
30 check_and_setup_lustre
32 if [[ "$MDS1_VERSION" -lt $(version_code 2.9.51) ]]; then
33 skip_env "Need MDS version at least 2.9.51"
36 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
37 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
38 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
41 rm -rf $DIR/[Rdfs][0-9]*
44 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
46 local comp_file=$DIR/$tdir/$tfile
47 local rw_len=$((3 * 1024 * 1024)) # 3M
52 $LFS setstripe -E 1m -S 1M -c 1 -E -1 -c 1 $comp_file ||
53 error "Create $comp_file failed"
55 #instantiate all components, so that objs are allocted
56 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
58 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
59 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
61 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
63 small_write $comp_file $rw_len || error "Verify RW failed"
65 rm -f $comp_file || error "Delete $comp_file failed"
67 run_test 0a "Create full components file, no reused OSTs"
70 [[ $($LCTL get_param mdc.*.import |
71 grep "connect_flags:.*overstriping") ]] ||
72 skip "server does not support overstriping"
73 large_xattr_enabled || skip_env "no large xattr support"
75 local comp_file=$DIR/$tdir/$tfile
79 # Create file with 1.1*LOV_MAX_STRIPE_COUNT stripes should succeed
80 $LFS setstripe -E 1m -C $((LOV_MAX_STRIPE_COUNT / 10)) -E -1 \
81 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
82 error "Create $comp_file failed"
84 rm -f $comp_file || error "Delete $comp_file failed"
86 # Create file with 2*LOV_MAX_STRIPE_COUNT stripes should fail
87 $LFS setstripe -E 1m -C $LOV_MAX_STRIPE_COUNT -E -1 -C $LOV_MAX_STRIPE_COUNT \
88 $comp_file && error "Create $comp_file succeeded"
90 rm -f $comp_file || error "Delete $comp_file failed"
92 run_test 0b "Verify comp stripe count limits"
95 local comp_file=$DIR/$tdir/$tfile
96 local rw_len=$((3 * 1024 * 1024)) # 3M
101 $LFS setstripe -E 1m -S 1m -o 0 -E -1 -o 0 $comp_file ||
102 error "Create $comp_file failed"
104 #instantiate all components, so that objs are allocted
105 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
107 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
108 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
110 [ $ost_idx1 -ne $ost_idx2 ] && error "$ost_idx1 != $ost_idx2"
112 small_write $comp_file $rw_len || error "Verify RW failed"
114 rm -f $comp_file || error "Delete $comp_file failed"
116 run_test 1a "Create full components file, reused OSTs"
118 # test overstriping (>1 stripe/OST within a component)
120 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
121 [[ $($LCTL get_param mdc.*.import |
122 grep "connect_flags:.*overstriping") ]] ||
123 skip "server does not support overstriping"
125 local comp_file=$DIR/$tdir/$tfile
126 local rw_len=$((3 * 1024 * 1024)) # 3M
128 test_mkdir $DIR/$tdir
130 $LFS setstripe -E 1m -S 1m -o 0,0 -E -1 -o 1,1,0,0 $comp_file ||
131 error "Create $comp_file failed"
133 #instantiate all components, so that objs are allocted
134 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=1M
136 $LFS getstripe $comp_file
137 local OSTS_1=$($LFS getstripe -I1 $comp_file | grep -o 'l_ost_idx.*' |
138 awk -e '{print $2}' | tr "\n" "\0")
139 local OSTS_2=$($LFS getstripe -I2 $comp_file | grep -o 'l_ost_idx.*' |
140 awk -e '{print $2}' | tr "\n" "\0")
144 [ "$OSTS_1" = "0,0," ] || error "incorrect OSTs($OSTS_1) in component 1"
145 [ "$OSTS_2" = "1,1,0,0," ] ||
146 error "incorrect OSTs($OSTS_2) in component 2"
148 small_write $comp_file $rw_len || error "Verify RW failed"
150 rm -f $comp_file || error "Delete $comp_file failed"
152 run_test 1b "Create full components file, overstriping in components"
154 # test overstriping with max stripe count
156 [[ $($LCTL get_param mdc.*.import |
157 grep "connect_flags:.*overstriping") ]] ||
158 skip "server does not support overstriping"
159 large_xattr_enabled || skip_env "no large xattr support"
161 local comp_file=$DIR/$tdir/$tfile
162 local rw_len=$((3 * 1024 * 1024)) # 3M
164 test_mkdir $DIR/$tdir
166 $LFS setstripe -E 1m -C 10 -E 10M -C 100 -E -1 \
167 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
168 error "Create $comp_file failed"
170 # Seek & write in to last component so all objects are allocated
171 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=20000
173 local count=$($LFS getstripe -c -I1 $DIR/$tdir/$tfile)
174 [ $count -eq 10 ] || error "comp1 stripe count $count, should be 10"
175 count=$($LFS getstripe -c -I2 $DIR/$tdir/$tfile)
176 [ $count -eq 100 ] || error "comp2 stripe count $count, should be 100"
177 count=$($LFS getstripe -c -I3 $DIR/$tdir/$tfile)
178 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
179 error "comp4 stripe count $count != $LOV_MAX_STRIPE_COUNT"
181 small_write $comp_file $rw_len || error "Verify RW failed"
183 rm -f $comp_file || error "Delete $comp_file failed"
185 run_test 1c "Test overstriping w/max stripe count"
188 local comp_file=$DIR/$tdir/$tfile
189 local rw_len=$((5 * 1024 * 1024)) # 5M
191 test_mkdir $DIR/$tdir
194 $LFS setstripe -E 1m -S 1m $comp_file ||
195 error "Create $comp_file failed"
197 check_component_count $comp_file 1
199 dd if=/dev/zero of=$comp_file bs=1M count=1 > /dev/null 2>&1 ||
200 error "Write first component failed"
201 dd if=$comp_file of=/dev/null bs=1M count=1 > /dev/null 2>&1 ||
202 error "Read first component failed"
204 dd if=/dev/zero of=$comp_file bs=1M count=2 > /dev/null 2>&1 &&
205 error "Write beyond component should fail"
206 dd if=$comp_file of=/dev/null bs=1M count=2 > /dev/null 2>&1 ||
207 error "Read beyond component should short read, not fail"
209 $LFS setstripe --component-add -E 2M -S 1M -c 1 $comp_file ||
210 error "Add component to $comp_file failed"
212 check_component_count $comp_file 2
214 $LFS setstripe --component-add -E -1 -c 3 $comp_file ||
215 error "Add last component to $comp_file failed"
217 check_component_count $comp_file 3
219 small_write $comp_file $rw_len || error "Verify RW failed"
221 rm -f $comp_file || error "Delete $comp_file failed"
223 run_test 2 "Add component to existing file"
225 del_comp_and_verify() {
232 if [ $id == "init" -o $id == "^init" ]; then
233 opt="--component-flags="
236 $LFS setstripe --component-del $opt$id $comp_file ||
237 error "Delete component $id from $comp_file failed"
239 local comp_cnt=$($LFS getstripe --component-count $comp_file)
240 if grep -q "has no stripe info" <<< "$comp_cnt" ; then
243 [ $comp_cnt -ne $left ] && error "$comp_cnt != $left"
245 $CHECKSTAT -s $size $comp_file || error "size != $size"
249 local comp_file=$DIR/$tdir/$tfile
251 test_mkdir $DIR/$tdir
254 $LFS setstripe -E 1M -S 1M -E 64M -c 2 -E -1 -c 3 $comp_file ||
255 error "Create $comp_file failed"
257 check_component_count $comp_file 3
259 dd if=/dev/zero of=$comp_file bs=1M count=2
261 $LFS setstripe --component-del -I 2 $comp_file &&
262 error "Component deletion makes hole"
264 del_comp_and_verify $comp_file 3 2 $((2 * 1024 * 1024))
265 del_comp_and_verify $comp_file 2 1 $((1 * 1024 * 1024))
266 del_comp_and_verify $comp_file 1 0 0
268 rm -f $comp_file || error "Delete $comp_file failed"
270 $LFS setstripe -E 1M -S 1M -E 16M -E -1 $comp_file ||
271 error "Create second $comp_file failed"
273 del_comp_and_verify $comp_file "^init" 1 0
274 del_comp_and_verify $comp_file "init" 0 0
275 rm -f $comp_file || error "Delete second $comp_file failed"
278 run_test 3 "Delete component from existing file"
281 skip "Not supported in PFL"
282 # In PFL project, only LCME_FL_INIT is supported, and it can't
283 # be altered by application.
285 run_test 4 "Modify component flags in existing file"
288 local parent=$DIR/$tdir
289 local comp_file=$DIR/$tdir/$tfile
290 local subdir=$parent/subdir
295 # set default layout to parent directory
296 $LFS setstripe -E 64M -c 2 -i 0 -E -1 -c 4 -i 0 $parent ||
297 error "Set default layout to $parent failed"
299 # create file under parent
300 touch $comp_file || error "Create $comp_file failed"
301 check_component_count $comp_file 2
303 #instantiate all components, so that objs are allocted
304 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=65k
306 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
307 [ $ost_idx -ne 0 ] &&
308 error "component 1 ost_idx $ost_idx != 0"
310 ost_idx=$($LFS getstripe -I2 -i $comp_file)
311 [ $ost_idx -ne 0 ] &&
312 error "component 2 ost_idx $ost_idx != 0"
314 # create subdir under parent
315 mkdir -p $subdir || error "Create subdir $subdir failed"
317 comp_cnt=$($LFS getstripe -d --component-count $subdir)
318 [ $comp_cnt -ne 2 ] && error "subdir $comp_cnt != 2"
320 # create file under subdir
321 touch $subdir/$tfile || error "Create $subdir/$tfile failed"
323 check_component_count $subdir/$tfile 2
325 # delete default layout setting from parent
326 $LFS setstripe -d $parent ||
327 error "Delete default layout from $parent failed"
329 comp_cnt=$($LFS getstripe -d --component-count $parent)
330 [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0"
332 rm -f $comp_file || error "Delete $comp_file failed"
333 rm -f $subdir/$tfile || error "Delete $subdir/$tfile failed"
334 rm -r $subdir || error "Delete subdir $subdir failed"
335 rmdir $parent || error "Delete dir $parent failed"
337 run_test 5 "Inherit composite layout from parent directory"
340 local comp_file=$DIR/$tdir/$tfile
342 test_mkdir $DIR/$tdir
345 $LFS setstripe -c 1 -S 128K $comp_file ||
346 error "Create v1 $comp_file failed"
348 check_component_count $comp_file 0
350 dd if=/dev/urandom of=$comp_file bs=1M count=5 oflag=sync ||
351 error "Write to v1 $comp_file failed"
353 local old_chksum=$(md5sum $comp_file)
355 # Migrate v1 to composite
356 $LFS migrate -E 1M -S 512K -c 1 -E -1 -S 1M -c 2 $comp_file ||
357 error "Migrate(v1 -> composite) $comp_file failed"
359 check_component_count $comp_file 2
361 local chksum=$(md5sum $comp_file)
362 [ "$old_chksum" != "$chksum" ] &&
363 error "(v1 -> compsoite) $old_chksum != $chksum"
365 # Migrate composite to composite
366 $LFS migrate -E 1M -S 1M -c 2 -E 4M -S 1M -c 2 \
367 -E -1 -S 3M -c 3 $comp_file ||
368 error "Migrate(compsoite -> composite) $comp_file failed"
370 check_component_count $comp_file 3
372 chksum=$(md5sum $comp_file)
373 [ "$old_chksum" != "$chksum" ] &&
374 error "(composite -> compsoite) $old_chksum != $chksum"
376 # Migrate composite to v1
377 $LFS migrate -c 2 -S 2M $comp_file ||
378 error "Migrate(composite -> v1) $comp_file failed"
380 check_component_count $comp_file 0
382 chksum=$(md5sum $comp_file)
383 [ "$old_chksum" != "$chksum" ] &&
384 error "(composite -> v1) $old_chksum != $chksum"
386 rm -f $comp_file || "Delete $comp_file failed"
388 run_test 6 "Migrate composite file"
391 test_mkdir $DIR/$tdir
392 chmod 0777 $DIR/$tdir || error "chmod $tdir failed"
394 local comp_file=$DIR/$tdir/$tfile
395 $RUNAS $LFS setstripe -E 1M -S 1M -c 1 $comp_file ||
396 error "Create composite file $comp_file failed"
398 $RUNAS $LFS setstripe --component-add -E 64M -c 4 $comp_file ||
399 error "Add component to $comp_file failed"
401 $RUNAS $LFS setstripe --component-del -I 2 $comp_file ||
402 error "Delete component from $comp_file failed"
404 $RUNAS $LFS setstripe --component-add -E -1 -c 5 $comp_file ||
405 error "Add last component to $comp_file failed"
407 rm $comp_file || "Delete composite failed"
409 run_test 7 "Add/Delete/Create composite file by non-privileged user"
412 local parent=$DIR/$tdir
417 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c 2 -S 2M \
418 -E -1 -c 4 -S 4M $parent ||
419 error "Set default layout to $parent failed"
421 sh rundbench -C -D $parent 2 || error "dbench failed"
423 rm -fr $parent || error "Delete dir $parent failed"
425 run_test 8 "Run dbench over composite files"
428 local comp_file=$DIR/$tdir/$tfile
430 test_mkdir $DIR/$tdir
433 $LFS setstripe -E 1M -S 1M -E -1 -c 1 $comp_file ||
434 error "Create $comp_file failed"
436 check_component_count $comp_file 2
438 replay_barrier $SINGLEMDS
440 # instantiate the 2nd component
441 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
443 local f1=$($LFS getstripe -I2 $comp_file |
444 awk '/l_fid:/ {print $7}')
445 echo "before MDS recovery, the ost fid of 2nd component is $f1"
448 local f2=$($LFS getstripe -I2 $comp_file |
449 awk '/l_fid:/ {print $7}')
450 echo "after MDS recovery, the ost fid of 2nd component is $f2"
451 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
453 run_test 9 "Replay layout extend object instantiation"
456 echo $($LFS getstripe $1 |
457 awk '$1 == "lcm_entry_count:" { printf("%d", $2) }
458 $1 == "lcme_extent.e_start:" { printf("[%#lx", $2) }
459 $1 == "lcme_extent.e_end:" { printf(",%s]", $2) }')
463 local parent=$DIR/$tdir
466 save_layout_restore_at_exit $MOUNT
470 # mount root on $MOUNT2 if FILESET is set
471 if [ -n "$FILESET" ]; then
472 FILESET="" mount_client $MOUNT2 ||
473 error "mount $MOUNT2 fail"
477 $LFS setstripe -d $root || error "clear root layout"
479 # set root composite layout
480 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c2 -S 2M \
481 -E -1 -c 4 -S 4M $root ||
482 error "Set root layout failed"
484 if [ "$root" == "$MOUNT2" ]; then
485 umount_client $MOUNT2 ||
486 error "umount $MOUNT2 fail"
490 # set a different layout for parent
491 $LFS setstripe -E -1 -c 1 -S 1M $parent ||
492 error "set $parent layout failed"
495 local f1_entry=$(component_dump $parent/file1)
497 # delete parent's layout
498 $LFS setstripe -d $parent || error "Clear $parent layout failed"
501 local f2_entry=$(component_dump $parent/file2)
503 # verify layout inheritance
505 local f1_expect="1[0,EOF]"
506 local f2_expect="3[0,2097152][0x200000,16777216][0x1000000,EOF]"
508 echo "f1 expect=$f1_expect"
509 echo "f1 get =$f1_entry"
510 echo "f2 expect=$f2_expect"
511 echo "f2 get =$f2_entry"
513 [ x$f1_expect != x$f1_entry ] &&
514 error "$parent/file1 does not inherite parent layout"
515 [ x$f2_expect != x$f2_entry ] &&
516 error "$parent/file2 does not inherite root layout"
520 run_test 10 "Inherit composite template from root"
523 local comp_file=$DIR/$tdir/$tfile
524 test_mkdir $DIR/$tdir
527 # only 1st component instantiated
528 $LFS setstripe -E 1M -S 1M -E 2M -E 3M -E -1 $comp_file ||
529 error "Create $comp_file failed"
531 local f1=$($LFS getstripe -I1 $comp_file | grep "l_fid")
532 [[ -z $f1 ]] && error "1: 1st component uninstantiated"
533 local f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
534 [[ -n $f2 ]] && error "1: 2nd component instantiated"
535 local f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
536 [[ -n $f3 ]] && error "1: 3rd component instantiated"
537 local f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
538 [[ -n $f4 ]] && error "1: 4th component instantiated"
540 # the first 2 components instantiated
541 # Truncate to exact start of new component - LU-12586
542 $TRUNCATE $comp_file $((1024*1024*1))
544 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
545 [[ -z $f2 ]] && error "2: 2nd component uninstantiated"
546 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
547 [[ -n $f3 ]] && error "2: 3rd component instantiated"
548 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
549 [[ -n $f4 ]] && error "2: 4th component instantiated"
551 # the first 3 components instantiated
552 $TRUNCATE $comp_file $((1024*1024*3 - 1))
553 $TRUNCATE $comp_file $((1024*1024*1+1))
555 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
556 [[ -z $f2 ]] && error "3: 2nd component uninstantiated"
557 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
558 [[ -z $f3 ]] && error "3: 3rd component uninstantiated"
559 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
560 [[ -n $f4 ]] && error "3: 4th component instantiated"
562 # all 4 components instantiated, using append write
563 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
565 rwv -f $comp_file -w -a -n 2 $((1024*1023)) 1
568 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
569 [[ -z $f4 ]] && error "4: 4th component uninstantiated"
573 run_test 11 "Verify component instantiation with write/truncate"
576 [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs"
578 local file=$DIR/$tdir/$tfile
579 test_mkdir $DIR/$tdir
582 # specify ost list for component
583 $LFS setstripe -E 1M -S 1M -c 2 -o 0,1 -E 2M -c 2 -o 1,2 \
584 -E 3M -c 2 -o 2,1 -E 4M -c 1 -i 2 -E -1 $file ||
585 error "Create $file failed"
587 # clear lod component cache
588 stop $SINGLEMDS || error "stop MDS"
589 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
590 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "start MDS"
592 # instantiate all components
593 $TRUNCATE $file $((1024*1024*4+1))
595 #verify object alloc order
596 local o1=$($LFS getstripe -I1 $file |
597 awk '/l_ost_idx:/ {printf("%d",$5)}')
598 [[ $o1 != "01" ]] && error "$o1 is not 01"
600 local o2=$($LFS getstripe -I2 $file |
601 awk '/l_ost_idx:/ {printf("%d",$5)}')
602 [[ $o2 != "12" ]] && error "$o2 is not 12"
604 local o3=$($LFS getstripe -I3 $file |
605 awk '/l_ost_idx:/ {printf("%d",$5)}')
606 [[ $o3 != "21" ]] && error "$o3 is not 21"
608 local o4=$($LFS getstripe -I4 $file |
609 awk '/l_ost_idx:/ {printf("%d",$5)}')
610 [[ $o4 != "2" ]] && error "$o4 is not 2"
614 run_test 12 "Verify ost list specification"
616 test_13() { # LU-9311
617 [ $OSTCOUNT -lt 8 ] && skip "needs >= 8 OSTs"
619 local file=$DIR/$tfile
621 local dd_size=$(($dd_count * 1024 * 1024))
625 $LFS setstripe -E 1M -S 1M -c 1 -E 2M -c 2 -E -1 -c -1 -i 1 $file ||
626 error "Create $file failed"
627 dd if=/dev/zero of=$file bs=1M count=$dd_count
628 real_size=$(stat -c %s $file)
629 [ $real_size -eq $dd_size ] ||
630 error "dd actually wrote $real_size != $dd_size bytes"
634 run_test 13 "shouldn't reprocess granted resent request"
637 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
638 local file=$DIR/$tdir/$tfile
639 test_mkdir -p $DIR/$tdir
642 $LFS setstripe -E1m -c1 -S1m --pool="pool1" -E2m \
643 -E4m -c2 -S2m --pool="pool2" -E-1 $file ||
644 error "Create $file failed"
646 # check --pool inheritance
648 pool="$($LFS getstripe -I2 --pool $file)"
649 [ x"$pool" != "xpool1" ] && $LFS getstripe -I2 $file &&
650 error "$file: component 2 doesn't have poolname pool1"
651 pool="$($LFS getstripe -I4 --pool $file)"
652 [ x"$pool" != "xpool2" ] && $LFS getstripe -I4 $file &&
653 error "$file: component 4 doesn't have poolname pool2"
655 #check --stripe-count inheritance
657 count="$($LFS getstripe -I2 -c $file)"
658 [ $count -ne 1 ] && $LFS getstripe -I2 $file &&
659 error "$file: component 2 doesn't have 1 stripe_count"
660 count="$($LFS getstripe -I4 -c $file)"
661 [ $count -ne 2 ] && $LFS getstripe -I4 $file &&
662 error "$file: component 4 doesn't have 2 stripe_count"
664 #check --stripe-size inheritance
666 size="$($LFS getstripe -I2 -S $file)"
667 [ $size -ne $((1024*1024)) ] && $LFS getstripe -I2 $file &&
668 error "$file: component 2 doesn't have 1M stripe_size"
669 size="$($LFS getstripe -I4 -S $file)"
670 [ $size -ne $((1024*1024*2)) ] && $LFS getstripe -I4 $file &&
671 error "$file: component 4 doesn't have 2M stripe_size"
675 run_test 14 "Verify setstripe poolname/stripe_count/stripe_size inheritance"
678 local parent=$DIR/$tdir
683 $LFS setstripe -d $parent || error "delete default layout"
685 $LFS setstripe -E 1M -S 1M -E 10M -E eof $parent/f1 || error "create f1"
686 $LFS setstripe -E 4M -E 20M -E eof $parent/f2 || error "create f2"
687 test_mkdir $parent/subdir
688 $LFS setstripe -E 6M -S 1M -c1 -E 30M -c4 -E eof -c -1 $parent/subdir ||
689 error "setstripe to subdir"
690 $LFS setstripe -E 8M -E eof $parent/subdir/f3 || error "create f3"
691 $LFS setstripe -c 1 $parent/subdir/f4 || error "create f4"
694 local found=$($LFS find --component-start +2M -E -15M $parent | wc -l)
695 [ $found -eq 0 ] || error "start+2M, end-15M, $found != 0"
698 found=$($LFS find --component-start +2M -E -35M $parent | wc -l)
699 [ $found -eq 2 ] || error "start+2M, end-35M, $found != 2"
702 found=$($LFS find --component-start +4M -E -eof $parent | wc -l)
703 [ $found -eq 1 ] || error "start+4M, end-eof, $found != 1"
705 local flg_opts="--component-flags init"
707 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
709 error "before write: start=1M, end=10M, flag=init, $found != 0"
711 dd if=/dev/zero of=$parent/f1 bs=1M count=2 ||
712 error "dd $parent/f1 failed"
715 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
717 error "after write: start=1M, end=10M, flag=init, $found != 1"
719 local ext_opts="--component-start -1M -E +5M"
720 # parent, subdir, f3, f4
721 found=$($LFS find $ext_opts $parent | wc -l)
722 [ $found -eq 4 ] || error "start-1M, end+5M, $found != 4"
724 local cnt_opts="--component-count +2"
726 found=$($LFS find $ext_opts $cnt_opts $parent | wc -l)
727 [ $found -eq 1 ] || error "start-1M, end+5M, count+2, $found != 1"
730 found=$($LFS find $ext_opts $cnt_opts $flg_opts $parent | wc -l)
732 error "start-1M, end+5M, count+2, flag=init, $found != 0"
735 found=$($LFS find $ext_opts ! $cnt_opts $flg_opts $parent | wc -l)
737 error "start-1M, end+5M, !count+2, flag=init, $found != 2"
739 # check last component stripe count
740 if [ $OSTCOUNT -gt 1 ]; then
741 touch $parent/subdir/f5
742 $TRUNCATE $parent/subdir/f5 $((32*1024*1024))
743 found=$($LFS find $parent/subdir -c $OSTCOUNT)
744 [[ "$found" == "$parent/subdir/f5" ]] ||
745 error "got '$found' with stripe_count=$OSTCOUNT, not f5"
748 run_test 15 "Verify component options for lfs find"
751 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
752 large_xattr_enabled || skip_env "ea_inode feature disabled"
754 local file=$DIR/$tdir/$tfile
755 local dir=$DIR/$tdir/dir
756 local temp=$DIR/$tdir/template
758 test_mkdir $DIR/$tdir
760 #####################################################################
762 # set stripe for source file
763 $LFS setstripe -E1m -S 1M -c2 -o0,1 -E2m -c2 -E3m -o1,0 -E4m -c1 -E-1 \
764 $file || error "Create $file failed"
767 verify_yaml_layout $file $file.copy $temp "1. PFL file"
769 #####################################################################
771 # set stripe for source file
773 $LFS setstripe -c2 -o0,1 -i1 $file || error "Create $file failed"
777 verify_yaml_layout $file $file.copy $temp "2. plain file"
779 #####################################################################
781 # set stripe for source dir
783 $LFS setstripe -E1m -S 1M -c2 -E2m -c1 -E-1 $dir ||
784 error "setstripe $dir failed"
788 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
790 #####################################################################
792 # set stripe for source dir
793 $LFS setstripe -c2 -i-1 $dir || error "setstripe $dir failed"
796 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
798 run_test 16a "Verify setstripe/getstripe with YAML config file"
801 [[ $($LCTL get_param mdc.*.import |
802 grep "connect_flags:.*overstriping") ]] ||
803 skip "server does not support overstriping"
804 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
805 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
806 skip_env "too many osts, skipping"
807 large_xattr_enabled || skip_env "ea_inode feature disabled"
809 local file=$DIR/$tdir/$tfile
810 local dir=$DIR/$tdir/dir
811 local temp=$DIR/$tdir/template
812 # We know OSTCOUNT < (LOV_MAX_STRIPE_COUNT / 2), so this is overstriping
813 local large_count=$((LOV_MAX_STRIPE_COUNT / 2 + 10))
816 test_mkdir $DIR/$tdir
818 #####################################################################
819 # 1. PFL file, overstriping in first comps
820 # set stripe for source file
821 $LFS setstripe -E1m -S 1M -o0,0 -E2m -o1,1 -E3m -C $large_count -E-1 \
822 $file || error "Create $file failed"
825 verify_yaml_layout $file $file.copy $temp "1. PFL file"
827 #####################################################################
828 # 2. plain file + overstriping
829 # set stripe for source file
831 $LFS setstripe -C $large_count -i1 $file || error "Create $file failed"
835 verify_yaml_layout $file $file.copy $temp "2. plain file"
837 #####################################################################
838 # 3. PFL dir + overstriping
839 # set stripe for source dir
841 $LFS setstripe -E1m -S 1M -o 0,0 -E2m -C $large_count -E-1 $dir ||
842 error "setstripe $dir failed"
846 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
848 #####################################################################
849 # 4. plain dir + overstriping
850 # set stripe for source dir
851 $LFS setstripe -C $large_count $dir || error "setstripe $dir failed"
854 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
856 run_test 16b "Verify setstripe/getstripe with YAML config file + overstriping"
859 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
861 local file=$DIR/$tdir/$tfile
862 local dir=$DIR/$tdir/dir
863 local temp=$DIR/$tdir/template
865 test_mkdir $DIR/$tdir
867 #####################################################################
869 # set stripe for source file
870 $LFS setstripe -E256M -S 1M -c2 -o0,1 -z 64M -E-1 -o1,0 -z 128M \
871 $file || error "Create $file failed"
874 verify_yaml_layout $file $file.copy $temp "1. PFL file"
876 #####################################################################
878 # set stripe for source dir
880 $LFS setstripe -E256M -S 1M -c2 -z 64M -E-1 -z 128M \
881 $dir || error "setstripe $dir failed"
884 echo "2. SEL template on dir"
885 verify_yaml_layout $dir $dir.copy $temp.dir "2. PFL dir"
887 run_test 16c "Verify setstripe/getstripe for SEL layout with YAML config file"
890 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
891 local file=$DIR/$tdir/$tfile
892 test_mkdir -p $DIR/$tdir
895 $LFS setstripe -E 1M -S 1M -E 2M -c 2 -E -1 -c -1 $file ||
896 error "Create $file failed"
898 local s1=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
899 local s2=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
900 local s3=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
901 echo "1st init: comp size 1:$s1 2:$s2 3:$s3"
904 $TRUNCATE $file $((1024*1024+1))
905 local s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
906 local s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
907 echo "2nd init: comp size 1:$s1n 2:$s2n 3:$s3"
909 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
910 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
913 $TRUNCATE $file $((1024*1024*2+1))
914 s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
915 s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
916 local s3n=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
917 echo "3rd init: comp size 1:$s1n 2:$s2n 3:$s3n"
919 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
920 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
921 [ $s3 -lt $s3n ] || error "3rd comp size $s3 should < $s3n"
923 run_test 17 "Verify LOVEA grows with more component inited"
925 check_distribution() {
929 local obj_min_one=$((OSTCOUNT - 1))
931 objs=$($LFS getstripe $file |
932 awk '/l_ost_idx:/ { print $5 }' | wc -l)
933 let ave=$((objs / OSTCOUNT))
935 # collect objects per OST distribution
936 $LFS getstripe $file | awk '/l_ost_idx:/ { print $5 }' | tr -d "," |
937 (inuse=( $(for i in $(seq 0 $obj_min_one); do echo 0; done) )
939 let inuse[$O]=$((1 + ${inuse[$O]}))
942 # verify object distribution varies no more than +-1
943 for idx in $(seq 0 $obj_min_one); do
944 let dif=$((${inuse[$idx]} - ave))
946 if [ "$dif" -gt 1 ]; then
947 echo "OST${idx}: ${inuse[$idx]} objects"
948 error "bad distribution on OST${idx}"
954 local file1=$DIR/${tfile}-1
955 local file2=$DIR/${tfile}-2
956 local file3=$DIR/${tfile}-3
958 rm -f $file1 $file2 $file3
960 $LFS setstripe -E 1m -S 1m $file1 ||
961 error "Create $file1 failed"
962 $LFS setstripe -E 1m -S 1m $file2 ||
963 error "Create $file2 failed"
964 $LFS setstripe -E 1m -S 1m $file3 ||
965 error "Create $file3 failed"
967 local objs=$((OSTCOUNT+1))
968 for comp in $(seq 1 $OSTCOUNT); do
969 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file1 ||
970 error "Add component to $file1 failed 2"
971 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file2 ||
972 error "Add component to $file2 failed 2"
973 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file3 ||
974 error "Add component to $file3 failed 2"
977 $LFS setstripe --component-add -E -1 -c -1 $file1 ||
978 error "Add component to $file1 failed 3"
979 $LFS setstripe --component-add -E -1 -c -1 $file2 ||
980 error "Add component to $file2 failed 3"
981 $LFS setstripe --component-add -E -1 -c -1 $file3 ||
982 error "Add component to $file3 failed 3"
984 # Instantiate all components
985 dd if=/dev/urandom of=$file1 bs=1M count=$((objs+1)) ||
986 error "dd failed for $file1"
987 dd if=/dev/urandom of=$file2 bs=1M count=$((objs+1)) ||
988 error "dd failed for $file2"
989 dd if=/dev/urandom of=$file3 bs=1M count=$((objs+1)) ||
990 error "dd failed for $file3"
992 check_distribution $file1
993 check_distribution $file2
994 check_distribution $file3
997 run_test 18 "check component distribution"
1001 local already_created=${2:-0}
1002 local rw_len=$((3 * 1024 * 1024)) # 3M
1006 if [ $already_created != 1 ]; then
1007 test_mkdir -p $DIR/$tdir
1008 $LFS setstripe --extension-size 64M -c 1 -E -1 $comp_file ||
1009 error "Create $comp_file failed"
1012 # write past end of first component, so it is extended
1013 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=127 conv=notrunc ||
1014 error "dd to extend failed"
1016 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1017 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1019 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1020 [ $ost_idx2 -ne "-1" ] && error "second component init $ost_idx2"
1022 flg_opts="--comp-flags init"
1023 found=$($LFS find --comp-start 0 -E 128M $flg_opts $comp_file | wc -l)
1024 [ $found -eq 1 ] || error "Write: Extended first component not found"
1026 flg_opts="--comp-flags extension"
1027 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1028 [ $found -eq 1 ] || error "Write: second component not found"
1030 found=$($LFS find -z 64M $comp_file | wc -l)
1031 [ $found -eq 1 ] || error "component not found by ext size"
1033 found=$($LFS find --extension-size +63M $comp_file | wc -l)
1034 [ $found -eq 1 ] || error "component not found by +ext size"
1036 found=$($LFS find --ext-size -65M $comp_file | wc -l)
1037 [ $found -eq 1 ] || error "component not found by -ext size"
1039 found=$($LFS find -z 65M $comp_file | wc -l)
1040 [ $found -eq 0 ] || error "component found by wrong ext size"
1042 found=$($LFS find -z +65M $comp_file | wc -l)
1043 [ $found -eq 0 ] || error "component found by wrong +ext size"
1045 found=$($LFS find -z -63M $comp_file | wc -l)
1046 [ $found -eq 0 ] || error "component found by wrong -ext size"
1048 found=$($LFS find ! -z 64M $comp_file | wc -l)
1049 [ $found -eq 0 ] || error "component found by negation of ext size"
1051 found=$($LFS find ! -z +63M $comp_file | wc -l)
1052 [ $found -eq 0 ] || error "component found by negation of +ext size"
1054 found=$($LFS find ! -z -65M $comp_file | wc -l)
1055 [ $found -eq 0 ] || error "component found by negation of -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 +65M $comp_file | wc -l)
1063 error "component not found by negation of wrong +ext size"
1065 found=$($LFS find ! -z -63M $comp_file | wc -l)
1067 error "component not found by negation of wrong -ext size"
1069 found=$($LFS find -S +1M $comp_file | wc -l)
1070 [ $found -eq 0 ] || error "component found by wrong +stripe size"
1072 found=$($LFS find -c 1 $comp_file | wc -l)
1073 [ $found -eq 1 ] || error "component not found by stripe count"
1075 small_write $comp_file $rw_len || error "Verify RW failed"
1077 sel_layout_sanity $comp_file 2
1080 # Self-extending PFL tests
1082 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1083 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1084 skip "skipped for lustre < $SEL_VER"
1086 test19_io_base $DIR/$tdir/$tfile
1088 run_test 19a "Simple test of extension behavior"
1090 # Same as 19a, but with default layout set on directory rather than on file
1092 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1093 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1094 skip "skipped for lustre < $SEL_VER"
1096 local comp_file=$DIR/$tdir/$tfile
1097 local comp_dir=$DIR/$tdir/$tdir
1101 test_mkdir -p $DIR/$tdir
1102 $LFS setstripe --ext-size 64M -c 1 -E -1 $DIR/$tdir ||
1103 error "Setstripe on $DIR/$tdir failed"
1105 # check inheritance for a sub-dir and a file
1106 test_mkdir $comp_dir
1107 found=$($LFS find --comp-start 0 -E 64M $comp_dir | wc -l)
1108 [ $found -eq 1 ] || error "Dir Inheritance: wrong first component size"
1110 flg_opts="--comp-flags extension"
1111 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_dir | wc -l)
1112 [ $found -eq 1 ] || error "Dir Inheritance: Second component not found"
1116 flg_opts="--comp-flags init"
1117 found=$($LFS find --comp-start 0 -E 64M $flg_opts $comp_file | wc -l)
1118 [ $found -eq 1 ] || error "File Inheritance: wrong first component size"
1120 flg_opts="--comp-flags extension"
1121 found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_file | wc -l)
1122 [ $found -eq 1 ] || error "File Inheritance: Second component not found"
1124 test19_io_base $comp_file 1
1126 run_test 19b "Simple test of SEL as default layout"
1128 # Test behavior when seeking deep in a file
1130 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1131 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1132 skip "skipped for lustre < $SEL_VER"
1134 local comp_file=$DIR/$tdir/$tfile
1138 test_mkdir -p $DIR/$tdir
1140 $LFS setstripe -z 128M -E 1G -E -1 $comp_file ||
1141 error "Create $comp_file failed"
1143 # write past end of first component, so it is extended
1144 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 conv=notrunc ||
1145 error "dd to extend failed"
1147 flg_opts="--comp-flags init"
1148 found=$($LFS find --comp-start 0M -E 256M $flg_opts $comp_file | wc -l)
1149 [ $found -eq 1 ] || error "Write: first extension component not found"
1151 flg_opts="--comp-flags extension,^init"
1152 found=$($LFS find --comp-start 256M -E 1024M $flg_opts $comp_file |\
1154 [ $found -eq 1 ] || error "Write: second extension component not found"
1156 local end_1=$($LFS getstripe -I1 -E $comp_file)
1159 [ $end_1 -eq 268435456 ] ||
1160 error "end of first component $end_1 != 268435456"
1162 # Write past end of extension space component, in to normal component
1163 # should exhaust & remove extension component
1164 dd if=/dev/zero bs=1M count=1 seek=1100 of=$comp_file conv=notrunc ||
1165 error "dd distant seek failed"
1167 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1168 # the last component index is 3
1169 local ost_idx2=$($LFS getstripe -I3 -i $comp_file)
1171 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1173 local start1=$($LFS getstripe -I1 --comp-start $comp_file)
1174 local end1=$($LFS getstripe -I1 -E $comp_file)
1175 local start2=$($LFS getstripe -I3 --comp-start $comp_file)
1176 local end2=$($LFS getstripe -I3 -E $comp_file)
1178 [ $start1 -eq 0 ] || error "start of first component incorrect"
1179 [ $end1 -eq 1073741824 ] || error "end of first component incorrect"
1180 [ $start2 -eq 1073741824 ] ||
1181 error "start of second component incorrect"
1182 [ "$end2" = "EOF" ] || error "end of second component incorrect"
1184 flg_opts="--comp-flags extension"
1185 found=$($LFS find $flg_opts $comp_file | wc -l)
1186 [ $found -eq 0 ] || error "Seek Write: extension component exists"
1188 sel_layout_sanity $comp_file 2
1190 run_test 19c "Test self-extending layout seeking behavior"
1193 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1194 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1195 skip "skipped for lustre < $SEL_VER"
1197 local comp_file=$DIR/$tdir/$tfile
1201 test_mkdir -p $DIR/$tdir
1203 $LFS setstripe -E 128M -c 1 -z 64M -E -1 $comp_file ||
1204 error "Create $comp_file failed"
1206 # This will cause component 1 to be extended to 128M, then the
1207 # extension space component will be removed
1208 dd if=/dev/zero of=$comp_file bs=130M count=1 ||
1209 error "dd to extend failed"
1211 flg_opts="--comp-flags init"
1212 found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file | wc -l)
1213 [ $found -eq 1 ] || error "Write: first component not found"
1215 flg_opts="--comp-flags init"
1216 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1217 [ $found -eq 1 ] || error "Write: second component not found"
1219 sel_layout_sanity $comp_file 2
1221 # always remove large files in case of DO_CLEANUP=false
1222 rm -f $comp_file || error "Delete $comp_file failed"
1224 run_test 19d "Test write which completely spans extension space component"
1229 local comp2_flags=$($LFS getstripe -I2 --comp-flags $comp_file)
1230 local comp3_flags=$($LFS getstripe -I3 --comp-flags $comp_file)
1232 [ "$comp2_flags" != "init" ] && error "$comp2_flags != init"
1233 [ "$comp3_flags" != "extension" ] && error "$comp3_flags != extension"
1235 local flg_opts=" --comp-start 2M -E 66M --comp-flags init"
1236 local found=$($LFS find $flg_opts $comp_file | wc -l)
1237 [ $found -eq 1 ] || error "Write: extended second component not found"
1239 flg_opts="--comp-start 66M -E EOF --comp-flags extension"
1240 found=$($LFS find $flg_opts $comp_file | wc -l)
1241 [ $found -eq 1 ] || error "Write: third component not found"
1243 sel_layout_sanity $comp_file 3
1247 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1248 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1249 skip "skipped for lustre < $SEL_VER"
1251 local comp_file=$DIR/$tdir/$tfile
1252 local rw_len=$((3 * 1024 * 1024)) # 3M
1256 test_mkdir -p $DIR/$tdir
1258 $LFS setstripe -E 2m -E -1 -z 64M $comp_file ||
1259 error "Create $comp_file failed"
1261 replay_barrier $SINGLEMDS
1263 #instantiate & extend second component
1264 dd if=/dev/zero of=$comp_file bs=4M count=1 ||
1265 error "dd to extend failed"
1267 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1268 local ost_idx3=$($LFS getstripe -I3 -i $comp_file)
1270 [ $ost_idx2 -eq $ost_idx3 ] && error "$ost_idx2 == $ost_idx3"
1271 [ $ost_idx3 -ne "-1" ] && error "third component init $ost_idx3"
1273 test_19e_check $comp_file
1275 local f1=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1276 echo "before MDS recovery, the ost fid of 2nd component is $f1"
1280 local f2=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1281 echo "after MDS recovery, the ost fid of 2nd component is $f2"
1282 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
1284 # simply repeat all previous checks, but also verify components are on
1285 # the same OST as before
1287 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1288 local ost_idx3_2=$($LFS getstripe -I3 -i $comp_file)
1290 [ $ost_idx2_2 -eq $ost_idx3_2 ] && error "$ost_idx2_2 == $ost_idx3_2"
1291 [ $ost_idx3_2 -ne "-1" ] && error "second component init $ost_idx3_2"
1293 # verify OST id is the same after failover
1294 [ $ost_idx2 -ne $ost_idx2_2 ] &&
1295 error "$ost_idx2 != $ost_idx2_2, changed after failover"
1297 test_19e_check $comp_file
1299 run_test 19e "Replay of layout instantiation & extension"
1302 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1303 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1304 skip "skipped for lustre < $SEL_VER"
1306 local comp_file=$DIR/$tdir/$tfile
1310 test_mkdir -p $DIR/$tdir
1312 $LFS setstripe -E 256M --comp-flags extension -E -1 $comp_file
1314 [ $? != 0 ] || error "should not be able to manually set extension flag"
1317 run_test 19f "Rejection of invalid layouts"
1320 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1321 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1322 skip "skipped for lustre < $SEL_VER"
1324 local file1=$DIR/${tfile}-1
1325 local file2=$DIR/${tfile}-2
1327 test_mkdir -p $DIR/$tdir
1328 multiop $file1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1329 error "create failed $file1"
1330 multiop $file2 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1331 error "create failed $file2"
1333 $LFS setstripe --component-add -E 1G -c 1 $file1 ||
1334 error "comp-add [0,1G] failed $file1"
1335 $LFS setstripe --component-add -E 512M -z 128M $file1 &&
1336 error "comp-add [1G,1G],SEL[1G,512M] succeded $file1"
1337 $LFS setstripe --component-add -E 10G -z 128M $file1 ||
1338 error "comp-add [1G,1G],SEL[1G,10G] failed $file1"
1339 $LFS setstripe --component-add -E -1 $file1 ||
1340 error "comp-add [10G,-1] failed $file1"
1342 $LFS setstripe --component-add -E 1G -z 32M -c 1 $file2 &&
1343 error "comp-add with smal ext size succeeded $file1"
1344 $LFS setstripe --component-add -E 1G -z 100M -c 1 $file2 &&
1345 error "comp-add with not aligned ext size succeeded $file1"
1346 $LFS setstripe --component-add -E 1G -z 128M -c 1 $file2 ||
1347 error "comp-add [0,128M],SEL[128M,1G] failed $file1"
1348 $LFS setstripe --component-add -E 10G $file2 ||
1349 error "comp-add [1G,10G] failed $file1"
1350 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 ||
1351 error "comp-add [10G,10G],SEL[10G,-1] failed $file1"
1352 $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 &&
1353 error "repeated comp-add [10G,10G],SEL[10G,-1] succeeded $file1"
1355 $LFS getstripe $file1
1356 flg_opts="--comp-flags init"
1357 found=$($LFS find --comp-start 0 -E 1G $flg_opts $file1 | wc -l)
1358 [ $found -eq 1 ] || error "First component not found $file1"
1360 flg_opts="--comp-flags ^init"
1361 found=$($LFS find --comp-start 1G -E 1G $flg_opts $file1 | wc -l)
1362 [ $found -eq 1 ] || error "Second component not found $file1"
1364 flg_opts="--comp-flags ^init,extension"
1365 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file1 | wc -l)
1366 [ $found -eq 1 ] || error "Third component not found $file1"
1368 flg_opts="--comp-flags ^init"
1369 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file1 | wc -l)
1370 [ $found -eq 1 ] || error "Fourth component not found $file1"
1372 $LFS getstripe $file2
1373 flg_opts="--comp-flags init"
1374 found=$($LFS find --comp-start 0 -E 128M $flg_opts $file2 | wc -l)
1375 [ $found -eq 1 ] || error "First component not found $file2"
1377 flg_opts="--comp-flags extension"
1378 found=$($LFS find --comp-start 128M -E 1G $flg_opts $file2 | wc -l)
1379 [ $found -eq 1 ] || error "Second component not found $file2"
1381 flg_opts="--comp-flags ^init"
1382 found=$($LFS find --comp-start 1G -E 10G $flg_opts $file2 | wc -l)
1383 [ $found -eq 1 ] || error "Third component not found $file2"
1385 flg_opts="--comp-flags ^init"
1386 found=$($LFS find --comp-start 10G -E 10G $flg_opts $file2 | wc -l)
1387 [ $found -eq 1 ] || error "Fourth component not found $file2"
1389 flg_opts="--comp-flags ^init,extension"
1390 found=$($LFS find --comp-start 10G -E EOF $flg_opts $file2 | wc -l)
1391 [ $found -eq 1 ] || error "Fifth component not found $file2"
1393 run_test 19g "component-add behaviour"
1395 # Test out of space behavior
1397 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1398 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1399 skip "skipped for lustre < $SEL_VER"
1401 local comp_file=$DIR/$tdir/$tfile
1405 test_mkdir -p $DIR/$tdir
1407 # without this, a previous delete can finish after we check free space
1408 wait_delete_completed
1411 # First component is on OST0
1412 $LFS setstripe -E 256M -i 0 -z 64M -E -1 -z 128M $comp_file ||
1413 error "Create $comp_file failed"
1415 # write past end of first component, so it is extended
1416 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=66 ||
1417 error "dd to extend failed"
1419 flg_opts="--comp-flags extension"
1420 found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file |wc -l)
1421 [ $found -eq 1 ] || error "Write: Second component not found"
1423 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1424 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1426 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1428 flg_opts="--comp-flags extension"
1429 # Write past current init comp, but we won't extend (because no space)
1430 dd if=/dev/zero of=$comp_file bs=1M count=10 seek=200 ||
1431 error "dd write past current comp failed"
1433 $LFS getstripe $comp_file
1435 flg_opts="--comp-flags init"
1436 found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file | \
1438 [ $found -eq 1 ] || error "Write: third component not found"
1440 flg_opts="--comp-flags extension"
1441 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file |wc -l)
1442 [ $found -eq 1 ] || error "Write: fourth extension component not found"
1444 sel_layout_sanity $comp_file 3
1446 run_test 20a "Test out of space, spillover to defined component"
1449 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1450 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1451 skip "skipped for lustre < $SEL_VER"
1453 local comp_file=$DIR/$tdir/$tfile
1457 test_mkdir -p $DIR/$tdir
1459 # Pool allows us to force use of only certain OSTs
1460 pool_add $TESTNAME || error "Pool creation failed"
1461 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1463 # normal component to 10M, extendable component to 1G
1464 # further extendable to EOF
1465 $LFS setstripe -E 10M -E 1G -p $TESTNAME -z 64M -E -1 -p "" -z 128M \
1466 $comp_file || error "Create $comp_file failed"
1468 replay_barrier $SINGLEMDS
1470 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1471 [ $found -eq 1 ] || error "Zero length component not found"
1474 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1476 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1478 # write past end of first component
1479 # This should remove the next component, since OST0 is out of space
1480 # and it is striped there (pool contains only OST0)
1481 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=14 ||
1482 error "dd to extend/remove failed"
1484 $LFS getstripe $comp_file
1486 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1487 [ $found -eq 0 ] || error "Write: zero length component still present"
1489 flg_opts="--comp-flags init"
1490 found=$($LFS find --comp-start 10M -E 138M $flg_opts $comp_file | wc -l)
1491 [ $found -eq 1 ] || error "Write: second component not found"
1493 flg_opts="--comp-flags extension"
1494 found=$($LFS find --comp-start 138M -E EOF $flg_opts $comp_file | wc -l)
1495 [ $found -eq 1 ] || error "Write: third component not found"
1499 found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1500 [ $found -eq 0 ] || error "Failover: 0-length component still present"
1502 flg_opts="--comp-flags init"
1503 found=$($LFS find --comp-start 10M -E 138M $flg_opts $comp_file | wc -l)
1504 [ $found -eq 1 ] || error "Failover: second component not found"
1506 flg_opts="--comp-flags extension"
1507 found=$($LFS find --comp-start 138M -E EOF $flg_opts $comp_file | wc -l)
1508 [ $found -eq 1 ] || error "Failover: third component not found"
1510 sel_layout_sanity $comp_file 3
1512 run_test 20b "Remove component without instantiation when there is no space"
1515 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1516 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1517 skip "skipped for lustre < $SEL_VER"
1519 local comp_file=$DIR/$tdir/$tfile
1523 test_mkdir -p $DIR/$tdir
1525 # pool is used to limit available OSTs to 0 and 1, so we can set all
1526 # available OSTs out of space
1527 pool_add $TESTNAME || error "Pool creation failed"
1528 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
1530 # without this, a previous delete can finish after we check free space
1531 wait_delete_completed
1534 $LFS setstripe -E 100M -E -1 -p $TESTNAME -z 64M $comp_file ||
1535 error "Create $comp_file failed"
1539 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1541 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
1543 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1544 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
1546 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=120 &&
1547 error "dd should fail with ENOSPC"
1549 flg_opts="--comp-flags init"
1550 found=$($LFS find --comp-start 0M -E 100M $flg_opts $comp_file | wc -l)
1551 [ $found -eq 1 ] || error "Write: First component not found"
1553 flg_opts="--comp-flags ^init"
1554 found=$($LFS find --comp-start 100M -E 100M $flg_opts $comp_file |wc -l)
1555 [ $found -eq 1 ] || error "Write: 0-length component not found"
1557 flg_opts="--comp-flags extension"
1558 found=$($LFS find --comp-start 100M -E EOF $flg_opts $comp_file | wc -l)
1559 [ $found -eq 1 ] || error "Write: third extension component not found"
1561 sel_layout_sanity $comp_file 3
1563 run_test 20c "Test inability to stripe new extension component"
1566 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1567 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1568 skip "skipped for lustre < $SEL_VER"
1570 local comp_file=$DIR/$tdir/$tfile
1571 test_mkdir -p $DIR/$tdir
1573 wait_delete_completed
1576 pool_add $TESTNAME || error "Pool creation failed"
1577 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1578 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
1579 error "Create $comp_file failed"
1581 replay_barrier $SINGLEMDS
1583 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1584 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1587 ost_watermarks_clear_enospc $tfile 0 $wms
1588 [ $RC -eq 0 ] || error "dd failed: $RC"
1590 $LFS getstripe $comp_file
1591 local flg_opts="--comp-start 64M -E 128M --comp-flags init"
1592 local found=$($LFS find $flg_opts $comp_file | wc -l)
1593 [ $found -eq 1 ] || error "Write: component (64M-128M) not found"
1595 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
1596 [ "$ost_idx" != "-1" ] && error "Write: EXT component disappeared"
1600 found=$($LFS find $flg_opts $comp_file | wc -l)
1601 [ $found -eq 1 ] || error "Failover: component (64M-128M) not found"
1603 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1604 [ "$ost_idx" != "-1" ] && error "Failover: EXT component disappeared"
1606 sel_layout_sanity $comp_file 3
1608 run_test 20d "Low on space + 0-length comp: force extension"
1611 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1612 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1613 skip "skipped for lustre < $SEL_VER"
1615 local comp_file=$DIR/$tdir/$tfile
1616 test_mkdir -p $DIR/$tdir
1618 wait_delete_completed
1621 pool_add $TESTNAME || error "Pool creation failed"
1622 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1624 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
1625 error "Create $comp_file failed"
1627 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1629 dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1632 ost_watermarks_clear_enospc $tfile 0 $wms
1633 [ $RC -eq 0 ] || error "dd failed $RC"
1635 $LFS getstripe $comp_file
1636 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
1637 local found=$($LFS find $flg_opts $comp_file | wc -l)
1638 [ $found -eq 1 ] || error "Write: component (64M-EOF) not found"
1640 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
1641 [ "$ost_idx" != "" ] && error "Write: 0-length component still exists"
1642 ost_idx=$($LFS getstripe -I3 -i $comp_file)
1643 [ "$ost_idx" != "" ] && error "Write: extension component still exists"
1645 sel_layout_sanity $comp_file 2
1647 run_test 20e "ENOSPC with next real comp: spillover and backward extension"
1649 # Simple DoM interaction test
1651 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1652 skip "skipped for lustre < $SEL_VER"
1654 local comp_file=$DIR/$tdir/$tfile
1658 test_mkdir -p $DIR/$tdir
1660 # simple, correct self-extending layout after DoM component
1661 $LFS setstripe -E 1M -L mdt -E -1 -z 64m $comp_file || \
1662 error "Create $comp_file failed"
1664 # Write to DoM component & to self-extending comp after it
1665 dd if=/dev/zero bs=1M count=12 of=$comp_file ||
1666 error "dd to extend failed"
1668 flg_opts="--comp-flags init"
1669 found=$($LFS find --comp-start 1M -E 65M $flg_opts $comp_file | wc -l)
1670 [ $found -eq 1 ] || error "Write: extended component not found"
1672 flg_opts="--comp-flags extension"
1673 found=$($LFS find --comp-start 65M $flg_opts $comp_file | wc -l)
1674 [ $found -eq 1 ] || error "Write: extension component not found"
1676 sel_layout_sanity $comp_file 3
1678 run_test 21a "Simple DoM interaction tests"
1680 # DoM + extension + removal
1682 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1683 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1684 skip "skipped for lustre < $SEL_VER"
1686 local comp_file=$DIR/$tdir/$tfile
1687 local ost_name=$(ostname_from_index 0)
1691 test_mkdir -p $DIR/$tdir
1693 # DoM, extendable component, further extendable component
1694 $LFS setstripe -E 1M -L mdt -E 256M -i 0 -z 64M -E -1 -z 128M \
1695 $comp_file || error "Create $comp_file failed"
1697 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1698 [ $found -eq 1 ] || error "Write: Zero length component not found"
1700 # This also demonstrates that we will avoid degraded OSTs
1701 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
1702 # sleep to guarantee we see the degradation
1705 # un-degrade on exit
1706 stack_trap "do_facet ost1 $LCTL set_param -n \
1707 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1709 # This should remove the first component after DoM and spill over to
1711 dd if=/dev/zero bs=1M count=2 of=$comp_file ||
1712 error "dd to remove+spill over failed"
1714 found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1715 [ $found -eq 0 ] || error "Write: Zero length component still present"
1717 flg_opts="--comp-flags init"
1718 found=$($LFS find --comp-start 1M -E 129M $flg_opts $comp_file | wc -l)
1719 [ $found -eq 1 ] || error "Write: extended component not found"
1721 flg_opts="--comp-flags extension"
1722 found=$($LFS find --comp-start 129M -E EOF $flg_opts $comp_file |wc -l)
1723 [ $found -eq 1 ] || error "Write: extension component not found"
1725 sel_layout_sanity $comp_file 3
1727 run_test 21b "DoM followed by extendable component with removal"
1729 # Test of repeat component behavior with OOS/degraded OST
1731 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1732 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1733 skip "skipped for lustre < $SEL_VER"
1735 local comp_file=$DIR/$tdir/$tfile
1739 test_mkdir -p $DIR/$tdir
1741 $LFS setstripe -E -1 -c 1 -z 128M $comp_file ||
1742 error "Create $comp_file failed"
1744 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1745 local ost_name=$(ostname_from_index $ost_idx1)
1747 # write past end of first component, so it is extended
1748 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
1749 error "dd to extend failed"
1751 flg_opts="--comp-flags extension"
1752 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
1753 [ $found -eq 1 ] || error "Write: second component not found"
1755 # degrade OST for component 1
1756 do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
1757 obdfilter.$ost_name.degraded=1
1758 # sleep to guarantee we see the degradation
1761 # un-degrade on exit
1762 stack_trap "do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
1763 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1765 replay_barrier $SINGLEMDS
1767 # seek past the end of current comp & write, should cause a new comp
1768 # to be created (ie repeat previous comp)
1769 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
1770 error "dd to repeat failed"
1772 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1774 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1776 flg_opts="--comp-flags init"
1777 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1778 [ $found -eq 1 ] || error "Write: second component not found"
1780 flg_opts="--comp-flags extension"
1781 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1782 [ $found -eq 1 ] || error "Write: extension component not found"
1786 local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1787 [ $ost_idx2_2 -ne $ost_idx2 ] && error "$ost_idx2_2 != $ost_idx2"
1789 flg_opts="--comp-flags init"
1790 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1791 [ $found -eq 1 ] || error "Failover: second component not found"
1793 flg_opts="--comp-flags extension"
1794 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1795 [ $found -eq 1 ] || error "Failover: extension component not found"
1797 sel_layout_sanity $comp_file 3
1799 run_test 22a "Test repeat component behavior with degraded OST"
1801 # Test repeat behavior with low space
1803 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1804 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1805 skip "skipped for lustre < $SEL_VER"
1807 local comp_file=$DIR/$tdir/$tfile
1811 test_mkdir -p $DIR/$tdir
1813 # without this, a previous delete can finish after we check free space
1814 wait_delete_completed
1817 $LFS setstripe -E -1 -c 1 -z 128M \
1818 $comp_file || error "Create $comp_file failed"
1820 # write past end of first component, so it is extended
1821 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
1822 error "dd to extend failed"
1824 flg_opts="--comp-flags extension"
1825 found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
1826 [ $found -eq 1 ] || error "Write: Second component not found"
1828 # set our OST low on space
1829 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1830 local wms=$(ost_watermarks_set_low_space $ost_idx1 | grep "watermarks")
1832 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1834 # Write past end of current space, fail to extend, causing repeat
1835 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
1836 error "dd to repeat failed"
1838 $LFS getstripe $comp_file
1840 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1842 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1844 flg_opts="--comp-flags init"
1845 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1846 [ $found -eq 1 ] || error "Write: Second component not found"
1848 flg_opts="--comp-flags extension"
1849 found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1850 [ $found -eq 1 ] || error "Write: Extension component not found"
1852 sel_layout_sanity $comp_file 3
1854 run_test 22b "Test simple 'out of space' condition with repeat"
1856 # This tests both "repeat" and "extend in place when repeat fails" aspects
1857 # of repeating components
1859 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1860 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1861 skip "skipped for lustre < $SEL_VER"
1863 local comp_file=$DIR/$tdir/$tfile
1867 test_mkdir -p $DIR/$tdir
1869 # pool is used to limit available OSTs to 0 and 1, so we can set all
1870 # available OSTs out of space
1871 pool_add $TESTNAME || error "Pool creation failed"
1872 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
1874 # without this, a previous delete can finish after we check free space
1875 wait_delete_completed
1878 $LFS setstripe -E -1 -z 64M -c 1 -p "$TESTNAME" $comp_file || \
1879 error "Create $comp_file failed"
1881 # write past end of first component, so it is extended
1882 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=80 conv=notrunc ||
1883 error "dd to extend failed"
1885 $LFS getstripe $comp_file
1887 flg_opts="--comp-flags extension"
1888 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1889 [ $found -eq 1 ] || error "Write: second component not found"
1891 # set our OST out of space
1892 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1893 local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1895 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1897 # This should create a repeat component on a new OST
1898 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=180 conv=notrunc ||
1899 error "dd to repeat failed"
1901 $LFS getstripe $comp_file
1903 local comp_cnt=$($LFS getstripe --component-count $comp_file)
1904 [ $comp_cnt -ne 3 ] && error "component count: $comp_cnt, should be 3"
1906 # New second component should be on a different OST
1907 local ost_idx2=$($LFS getstripe --comp-start=128m \
1908 --comp-end=192m --comp-flags=init -i $comp_file)
1910 [ $ost_idx1 -eq $ost_idx2 ] && error "2nd comp: same OST $ost_idx1"
1912 local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
1914 stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
1916 # now that the second OST is out of space (as is the first OST), we
1917 # attempt to extend. This should result in an extension of the
1918 # existing component, rather than a new component.
1919 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=240 conv=notrunc ||
1920 error "dd for forced extension failed"
1922 $LFS getstripe $comp_file
1924 # clear out of space on first OST
1925 ost_watermarks_clear_enospc $tfile $ost_idx1 $wms
1927 # finally, now that the first OST has space again, we attempt to
1928 # extend one last time. This should create a new component on the
1930 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 conv=notrunc ||
1931 error "dd for repeat on first OST failed"
1933 $LFS getstripe $comp_file
1935 flg_opts="--comp-flags init"
1936 found=$($LFS find --comp-start 128M $flg_opts $comp_file | wc -l)
1937 [ $found -eq 1 ] || error "Write: second component not found"
1939 flg_opts="--comp-flags init"
1940 found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1941 [ $found -eq 1 ] || error "Write: third component not found"
1943 flg_opts="--comp-flags extension"
1944 found=$($LFS find --comp-start 320M -E EOF $flg_opts $comp_file | wc -l)
1945 [ $found -eq 1 ] || error "Write: extension component not found"
1947 sel_layout_sanity $comp_file 4
1949 run_test 22c "Test repeat with out of space on > 1 OST"
1951 test_22d_post_check() {
1954 local flg_opts="--comp-flags init"
1955 local found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file |
1957 [ $found -eq 1 ] || {
1958 $LFS getstripe $comp_file
1959 error "$name: second component not found"
1962 flg_opts="--comp-flags extension"
1963 found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1964 [ $found -eq 1 ] || error "$name: third extension component not found"
1966 sel_layout_sanity $comp_file 2
1974 # write past end of first component
1975 dd if=/dev/zero of=$comp_file bs=1M count=1 seek=70
1978 ost_watermarks_clear_enospc $tfile 0 $wms
1979 [ $RC -eq 0 ] || error "dd to force extend failed"
1981 test_22d_post_check $comp_file "Write"
1985 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1986 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1987 skip "skipped for lustre < $SEL_VER"
1989 local comp_file=$DIR/$tdir/$tfile
1993 test_mkdir -p $DIR/$tdir
1995 # without this, a previous delete can finish after we check free space
1996 wait_delete_completed
1999 # Pool allows us to force use of only certain OSTs
2000 pool_add $TESTNAME || error "Pool creation failed"
2001 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2003 # 1. Fail to extend due to OOS, try to repeat within the same pool,
2004 # fail to stripe (again OOS) the 0-length component, remove the
2005 # repeated one, force the extension on the original one.
2006 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2007 error "Create $comp_file failed"
2009 replay_barrier $SINGLEMDS
2011 # set our OST out of space
2012 local wms=$(ost_watermarks_set_enospc $tfile 0 | grep "watermarks")
2014 test_22d_pre $comp_file "$wms"
2016 test_22d_post_check $comp_file "Failover"
2018 # 2. repeat with low on space: 0-length repeated component will be
2019 # striped, but still fails to be extended; otherwise the same as (1).
2021 $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2022 error "Create $comp_file failed"
2024 replay_barrier $SINGLEMDS
2026 # set our OST low on space
2027 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2029 test_22d_pre $comp_file "$wms"
2031 test_22d_post_check $comp_file "Failover"
2033 run_test 22d "out of/low on space + failed to repeat + forced extension"
2036 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2037 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2038 skip "skipped for lustre < $SEL_VER"
2040 local comp_file=$DIR/$tdir/$tfile
2041 test_mkdir -p $DIR/$tdir
2043 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2044 error "Create $comp_file failed"
2046 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2047 error "dd append failed"
2049 local flg_opts="--comp-start 0 -E EOF --comp-flags init"
2050 local found=$($LFS find $flg_opts $comp_file | wc -l)
2051 [ $found -eq 1 ] || error "Append: first component (0-EOF) not found"
2053 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2054 [ "$ost_idx" != "" ] && error "Append: second component still exists"
2056 sel_layout_sanity $comp_file 1
2058 run_test 23a "Append: remove EXT comp"
2061 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2062 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2063 skip "skipped for lustre < $SEL_VER"
2065 local comp_file=$DIR/$tdir/$tfile
2066 test_mkdir -p $DIR/$tdir
2068 $LFS setstripe -E 64m -E -1 -z 64M $comp_file ||
2069 error "Create $comp_file failed"
2071 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2072 error "dd append failed"
2074 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2075 local found=$($LFS find $flg_opts $comp_file | wc -l)
2076 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2078 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2079 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2081 sel_layout_sanity $comp_file 2
2083 run_test 23b "Append with 0-length comp: remove EXT comp"
2086 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2087 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2088 skip "skipped for lustre < $SEL_VER"
2090 local comp_file=$DIR/$tdir/$tfile
2091 test_mkdir -p $DIR/$tdir
2093 wait_delete_completed
2096 pool_add $TESTNAME || error "Pool creation failed"
2097 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2098 $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
2099 error "Create $comp_file failed"
2101 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2102 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2105 ost_watermarks_clear_enospc $tfile 0 $wms
2106 [ $RC -eq 0 ] || error "dd append failed: $RC"
2108 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2109 local found=$($LFS find $flg_opts $comp_file | wc -l)
2110 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2112 local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2113 [ "$ost_idx" != "" ] && error "Append: EXT component still exists"
2115 sel_layout_sanity $comp_file 2
2117 run_test 23c "Append with low on space + 0-length comp: force extension"
2120 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2121 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2122 skip "skipped for lustre < $SEL_VER"
2124 local comp_file=$DIR/$tdir/$tfile
2125 test_mkdir -p $DIR/$tdir
2127 $LFS setstripe -E 64m -E 640M -z 64M -E -1 $comp_file ||
2128 error "Create $comp_file failed"
2130 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2131 error "dd append failed"
2133 flg_opts="--comp-start 64M -E 640M --comp-flags init"
2134 found=$($LFS find $flg_opts $comp_file | wc -l)
2135 [ $found -eq 1 ] || error "Append: component (64M-640M) not found"
2137 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2138 [ "$ost_idx" != "" ] && error "Append: third component still exists"
2140 sel_layout_sanity $comp_file 3
2142 run_test 23d "Append with 0-length comp + next real comp: remove EXT comp"
2145 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2146 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2147 skip "skipped for lustre < $SEL_VER"
2149 local comp_file=$DIR/$tdir/$tfile
2150 test_mkdir -p $DIR/$tdir
2152 wait_delete_completed
2155 pool_add $TESTNAME || error "Pool creation failed"
2156 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2158 $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
2159 error "Create $comp_file failed"
2161 local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2163 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2166 ost_watermarks_clear_enospc $tfile 0 $wms
2167 [ $RC -eq 0 ] || error "dd append failed $RC"
2169 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2170 local found=$($LFS find $flg_opts $comp_file | wc -l)
2171 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2173 local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2174 [ "$ost_idx" != "" ] && error "Append: 0-length component still exists"
2175 ost_idx=$($LFS getstripe -I3 -i $comp_file)
2176 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2178 sel_layout_sanity $comp_file 2
2180 run_test 23e "Append with next real comp: spillover and backward extension"
2183 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2184 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2185 skip "skipped for lustre < $SEL_VER"
2187 local comp_file=$DIR/$tdir/$tfile
2188 test_mkdir -p $DIR/$tdir
2190 $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2191 error "Create $comp_file failed"
2193 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
2194 local wms=$(ost_watermarks_set_low_space $ost_idx | grep "watermarks")
2196 dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2199 ost_watermarks_clear_enospc $tfile $ost_idx $wms
2200 [ $RC -eq 0 ] || error "dd append failed"
2202 local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2203 local found=$($LFS find $flg_opts $comp_file | wc -l)
2204 [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2206 ost_idx=$($LFS getstripe -I2 -i $comp_file)
2207 [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2209 sel_layout_sanity $comp_file 2
2211 run_test 23f "Append with low on space: repeat and remove EXT comp"
2220 [ "$OSTCOUNT" -lt "3" ] && skip_env "needs >= 3 OSTs"
2222 trap cleanup_24 EXIT RETURN
2224 local file=$DIR/$tfile
2226 $LFS setstripe -E 1m -c1 -o0 -E eof -c2 -o1,2 $file ||
2227 error "setstripe on $file"
2229 dd if=/dev/zero of=$file bs=1M count=3 || error "dd failed for $file"
2232 filefrag -ves $file || error "filefrag $file failed"
2233 filefrag_op=$(filefrag -ve -k $file |
2234 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
2236 #Filesystem type is: bd00bd0
2237 #File size of /mnt/lustre/f24a.sanity-pfl is 3145728 (3072 blocks of 1024 bytes)
2238 # ext: device_logical: physical_offset: length: dev: flags:
2239 # 0: 0.. 1023: 1572864.. 1573887: 1024: 0000: net
2240 # 1: 0.. 1023: 1572864.. 1573887: 1024: 0002: net
2241 # 2: 1024.. 2047: 1573888.. 1574911: 1024: 0001: last,net
2242 #/mnt/lustre/f24a.sanity-pfl: 3 extents found
2244 last_lun=$(echo $filefrag_op | cut -d: -f5)
2249 for line in $filefrag_op; do
2250 frag_lun=$(echo $line | cut -d: -f5)
2251 ext_len=$(echo $line | cut -d: -f4)
2252 if [[ "$frag_lun" != "$last_lun" ]]; then
2253 if (( tot_len != 1024 )); then
2255 error "$file: OST$last_lun $tot_len != 1024"
2261 (( tot_len += ext_len ))
2264 if (( num_luns != 3 || tot_len != 1024 )); then
2266 error "$file: $num_luns != 3, $tot_len != 1024 on OST$last_lun"
2269 echo "FIEMAP on $file succeeded"
2271 run_test 24a "FIEMAP upon PFL file"
2274 check_and_cleanup_lustre