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!
20 check_and_setup_lustre
22 if [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.51) ]]; then
23 skip_env "Need MDS version at least 2.9.51"
26 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
27 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
28 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
31 rm -rf $DIR/[Rdfs][0-9]*
34 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
36 local comp_file=$DIR/$tdir/$tfile
37 local rw_len=$((3 * 1024 * 1024)) # 3M
42 $LFS setstripe -E 1m -S 1M -c 1 -E -1 -c 1 $comp_file ||
43 error "Create $comp_file failed"
45 #instantiate all components, so that objs are allocted
46 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
48 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
49 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
51 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
53 small_write $comp_file $rw_len || error "Verify RW failed"
55 rm -f $comp_file || error "Delete $comp_file failed"
57 run_test 0a "Create full components file, no reused OSTs"
60 [[ $($LCTL get_param mdc.*.import |
61 grep "connect_flags:.*overstriping") ]] ||
62 skip "server does not support overstriping"
63 large_xattr_enabled || skip_env "no large xattr support"
65 local comp_file=$DIR/$tdir/$tfile
69 # Create file with 1.1*LOV_MAX_STRIPE_COUNT stripes should succeed
70 $LFS setstripe -E 1m -C $((LOV_MAX_STRIPE_COUNT / 10)) -E -1 \
71 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
72 error "Create $comp_file failed"
74 rm -f $comp_file || error "Delete $comp_file failed"
76 # Create file with 2*LOV_MAX_STRIPE_COUNT stripes should fail
77 $LFS setstripe -E 1m -C $LOV_MAX_STRIPE_COUNT -E -1 -C $LOV_MAX_STRIPE_COUNT \
78 $comp_file && error "Create $comp_file succeeded"
80 rm -f $comp_file || error "Delete $comp_file failed"
82 run_test 0b "Verify comp stripe count limits"
85 local comp_file=$DIR/$tdir/$tfile
86 local rw_len=$((3 * 1024 * 1024)) # 3M
91 $LFS setstripe -E 1m -S 1m -o 0 -E -1 -o 0 $comp_file ||
92 error "Create $comp_file failed"
94 #instantiate all components, so that objs are allocted
95 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
97 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
98 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
100 [ $ost_idx1 -ne $ost_idx2 ] && error "$ost_idx1 != $ost_idx2"
102 small_write $comp_file $rw_len || error "Verify RW failed"
104 rm -f $comp_file || error "Delete $comp_file failed"
106 run_test 1a "Create full components file, reused OSTs"
108 # test overstriping (>1 stripe/OST within a component)
110 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
111 [[ $($LCTL get_param mdc.*.import |
112 grep "connect_flags:.*overstriping") ]] ||
113 skip "server does not support overstriping"
115 local comp_file=$DIR/$tdir/$tfile
116 local rw_len=$((3 * 1024 * 1024)) # 3M
118 test_mkdir $DIR/$tdir
120 $LFS setstripe -E 1m -S 1m -o 0,0 -E -1 -o 1,1,0,0 $comp_file ||
121 error "Create $comp_file failed"
123 #instantiate all components, so that objs are allocted
124 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=1M
126 $LFS getstripe $comp_file
127 local OSTS_1=$($LFS getstripe -I1 $comp_file | grep -o 'l_ost_idx.*' |
128 awk -e '{print $2}' | tr "\n" "\0")
129 local OSTS_2=$($LFS getstripe -I2 $comp_file | grep -o 'l_ost_idx.*' |
130 awk -e '{print $2}' | tr "\n" "\0")
134 [ "$OSTS_1" = "0,0," ] || error "incorrect OSTs($OSTS_1) in component 1"
135 [ "$OSTS_2" = "1,1,0,0," ] ||
136 error "incorrect OSTs($OSTS_2) in component 2"
138 small_write $comp_file $rw_len || error "Verify RW failed"
140 rm -f $comp_file || error "Delete $comp_file failed"
142 run_test 1b "Create full components file, overstriping in components"
144 # test overstriping with max stripe count
146 [[ $($LCTL get_param mdc.*.import |
147 grep "connect_flags:.*overstriping") ]] ||
148 skip "server does not support overstriping"
149 large_xattr_enabled || skip_env "no large xattr support"
151 local comp_file=$DIR/$tdir/$tfile
152 local rw_len=$((3 * 1024 * 1024)) # 3M
154 test_mkdir $DIR/$tdir
156 $LFS setstripe -E 1m -C 10 -E 10M -C 100 -E -1 \
157 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
158 error "Create $comp_file failed"
160 # Seek & write in to last component so all objects are allocated
161 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=20000
163 local count=$($LFS getstripe -c -I1 $DIR/$tdir/$tfile)
164 [ $count -eq 10 ] || error "comp1 stripe count $count, should be 10"
165 count=$($LFS getstripe -c -I2 $DIR/$tdir/$tfile)
166 [ $count -eq 100 ] || error "comp2 stripe count $count, should be 100"
167 count=$($LFS getstripe -c -I3 $DIR/$tdir/$tfile)
168 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
169 error "comp4 stripe count $count != $LOV_MAX_STRIPE_COUNT"
171 small_write $comp_file $rw_len || error "Verify RW failed"
173 rm -f $comp_file || error "Delete $comp_file failed"
175 run_test 1c "Test overstriping w/max stripe count"
177 check_component_count() {
178 local comp_cnt=$($LFS getstripe --component-count $1)
179 [ $comp_cnt -ne $2 ] && error "$1, component count $comp_cnt != $2"
183 local comp_file=$DIR/$tdir/$tfile
184 local rw_len=$((5 * 1024 * 1024)) # 5M
186 test_mkdir $DIR/$tdir
189 $LFS setstripe -E 1m -S 1m $comp_file ||
190 error "Create $comp_file failed"
192 check_component_count $comp_file 1
194 dd if=/dev/zero of=$comp_file bs=1M count=1 > /dev/null 2>&1 ||
195 error "Write first component failed"
196 dd if=$comp_file of=/dev/null bs=1M count=1 > /dev/null 2>&1 ||
197 error "Read first component failed"
199 dd if=/dev/zero of=$comp_file bs=1M count=2 > /dev/null 2>&1 &&
200 error "Write beyond component should fail"
201 dd if=$comp_file of=/dev/null bs=1M count=2 > /dev/null 2>&1 ||
202 error "Read beyond component should short read, not fail"
204 $LFS setstripe --component-add -E 2M -S 1M -c 1 $comp_file ||
205 error "Add component to $comp_file failed"
207 check_component_count $comp_file 2
209 $LFS setstripe --component-add -E -1 -c 3 $comp_file ||
210 error "Add last component to $comp_file failed"
212 check_component_count $comp_file 3
214 small_write $comp_file $rw_len || error "Verify RW failed"
216 rm -f $comp_file || error "Delete $comp_file failed"
218 run_test 2 "Add component to existing file"
220 del_comp_and_verify() {
227 if [ $id == "init" -o $id == "^init" ]; then
228 opt="--component-flags="
231 $LFS setstripe --component-del $opt$id $comp_file ||
232 error "Delete component $id from $comp_file failed"
234 local comp_cnt=$($LFS getstripe --component-count $comp_file)
235 if grep -q "has no stripe info" <<< "$comp_cnt" ; then
238 [ $comp_cnt -ne $left ] && error "$comp_cnt != $left"
240 $CHECKSTAT -s $size $comp_file || error "size != $size"
244 local comp_file=$DIR/$tdir/$tfile
246 test_mkdir $DIR/$tdir
249 $LFS setstripe -E 1M -S 1M -E 64M -c 2 -E -1 -c 3 $comp_file ||
250 error "Create $comp_file failed"
252 check_component_count $comp_file 3
254 dd if=/dev/zero of=$comp_file bs=1M count=2
256 $LFS setstripe --component-del -I 2 $comp_file &&
257 error "Component deletion makes hole"
259 del_comp_and_verify $comp_file 3 2 $((2 * 1024 * 1024))
260 del_comp_and_verify $comp_file 2 1 $((1 * 1024 * 1024))
261 del_comp_and_verify $comp_file 1 0 0
263 rm -f $comp_file || error "Delete $comp_file failed"
265 $LFS setstripe -E 1M -S 1M -E 16M -E -1 $comp_file ||
266 error "Create second $comp_file failed"
268 del_comp_and_verify $comp_file "^init" 1 0
269 del_comp_and_verify $comp_file "init" 0 0
270 rm -f $comp_file || error "Delete second $comp_file failed"
273 run_test 3 "Delete component from existing file"
276 skip "Not supported in PFL"
277 # In PFL project, only LCME_FL_INIT is supported, and it can't
278 # be altered by application.
280 run_test 4 "Modify component flags in existing file"
283 local parent=$DIR/$tdir
284 local comp_file=$DIR/$tdir/$tfile
285 local subdir=$parent/subdir
290 # set default layout to parent directory
291 $LFS setstripe -E 64M -c 2 -i 0 -E -1 -c 4 -i 0 $parent ||
292 error "Set default layout to $parent failed"
294 # create file under parent
295 touch $comp_file || error "Create $comp_file failed"
296 check_component_count $comp_file 2
298 #instantiate all components, so that objs are allocted
299 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=65k
301 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
302 [ $ost_idx -ne 0 ] &&
303 error "component 1 ost_idx $ost_idx != 0"
305 ost_idx=$($LFS getstripe -I2 -i $comp_file)
306 [ $ost_idx -ne 0 ] &&
307 error "component 2 ost_idx $ost_idx != 0"
309 # create subdir under parent
310 mkdir -p $subdir || error "Create subdir $subdir failed"
312 comp_cnt=$($LFS getstripe -d --component-count $subdir)
313 [ $comp_cnt -ne 2 ] && error "subdir $comp_cnt != 2"
315 # create file under subdir
316 touch $subdir/$tfile || error "Create $subdir/$tfile failed"
318 check_component_count $subdir/$tfile 2
320 # delete default layout setting from parent
321 $LFS setstripe -d $parent ||
322 error "Delete default layout from $parent failed"
324 comp_cnt=$($LFS getstripe -d --component-count $parent)
325 [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0"
327 rm -f $comp_file || error "Delete $comp_file failed"
328 rm -f $subdir/$tfile || error "Delete $subdir/$tfile failed"
329 rm -r $subdir || error "Delete subdir $subdir failed"
330 rmdir $parent || error "Delete dir $parent failed"
332 run_test 5 "Inherit composite layout from parent directory"
335 local comp_file=$DIR/$tdir/$tfile
337 test_mkdir $DIR/$tdir
340 $LFS setstripe -c 1 -S 128K $comp_file ||
341 error "Create v1 $comp_file failed"
343 check_component_count $comp_file 0
345 dd if=/dev/urandom of=$comp_file bs=1M count=5 oflag=sync ||
346 error "Write to v1 $comp_file failed"
348 local old_chksum=$(md5sum $comp_file)
350 # Migrate v1 to composite
351 $LFS migrate -E 1M -S 512K -c 1 -E -1 -S 1M -c 2 $comp_file ||
352 error "Migrate(v1 -> composite) $comp_file failed"
354 check_component_count $comp_file 2
356 local chksum=$(md5sum $comp_file)
357 [ "$old_chksum" != "$chksum" ] &&
358 error "(v1 -> compsoite) $old_chksum != $chksum"
360 # Migrate composite to composite
361 $LFS migrate -E 1M -S 1M -c 2 -E 4M -S 1M -c 2 \
362 -E -1 -S 3M -c 3 $comp_file ||
363 error "Migrate(compsoite -> composite) $comp_file failed"
365 check_component_count $comp_file 3
367 chksum=$(md5sum $comp_file)
368 [ "$old_chksum" != "$chksum" ] &&
369 error "(composite -> compsoite) $old_chksum != $chksum"
371 # Migrate composite to v1
372 $LFS migrate -c 2 -S 2M $comp_file ||
373 error "Migrate(composite -> v1) $comp_file failed"
375 check_component_count $comp_file 0
377 chksum=$(md5sum $comp_file)
378 [ "$old_chksum" != "$chksum" ] &&
379 error "(composite -> v1) $old_chksum != $chksum"
381 rm -f $comp_file || "Delete $comp_file failed"
383 run_test 6 "Migrate composite file"
386 test_mkdir $DIR/$tdir
387 chmod 0777 $DIR/$tdir || error "chmod $tdir failed"
389 local comp_file=$DIR/$tdir/$tfile
390 $RUNAS $LFS setstripe -E 1M -S 1M -c 1 $comp_file ||
391 error "Create composite file $comp_file failed"
393 $RUNAS $LFS setstripe --component-add -E 64M -c 4 $comp_file ||
394 error "Add component to $comp_file failed"
396 $RUNAS $LFS setstripe --component-del -I 2 $comp_file ||
397 error "Delete component from $comp_file failed"
399 $RUNAS $LFS setstripe --component-add -E -1 -c 5 $comp_file ||
400 error "Add last component to $comp_file failed"
402 rm $comp_file || "Delete composite failed"
404 run_test 7 "Add/Delete/Create composite file by non-privileged user"
407 local parent=$DIR/$tdir
412 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c 2 -S 2M \
413 -E -1 -c 4 -S 4M $parent ||
414 error "Set default layout to $parent failed"
416 sh rundbench -C -D $parent 2 || error "dbench failed"
418 rm -fr $parent || error "Delete dir $parent failed"
420 run_test 8 "Run dbench over composite files"
423 local comp_file=$DIR/$tdir/$tfile
425 test_mkdir $DIR/$tdir
428 $LFS setstripe -E 1M -S 1M -E -1 -c 1 $comp_file ||
429 error "Create $comp_file failed"
431 check_component_count $comp_file 2
433 replay_barrier $SINGLEMDS
435 # instantiate the 2nd component
436 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
438 local f1=$($LFS getstripe -I2 $comp_file |
439 awk '/l_fid:/ {print $7}')
440 echo "before MDS recovery, the ost fid of 2nd component is $f1"
443 local f2=$($LFS getstripe -I2 $comp_file |
444 awk '/l_fid:/ {print $7}')
445 echo "after MDS recovery, the ost fid of 2nd component is $f2"
446 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
448 run_test 9 "Replay layout extend object instantiation"
451 echo $($LFS getstripe $1 |
452 awk '$1 == "lcm_entry_count:" { printf("%d", $2) }
453 $1 == "lcme_extent.e_start:" { printf("[%#lx", $2) }
454 $1 == "lcme_extent.e_end:" { printf(",%s]", $2) }')
458 local parent=$DIR/$tdir
461 save_layout_restore_at_exit $MOUNT
465 # mount root on $MOUNT2 if FILESET is set
466 if [ -n "$FILESET" ]; then
467 FILESET="" mount_client $MOUNT2 ||
468 error "mount $MOUNT2 fail"
472 $LFS setstripe -d $root || error "clear root layout"
474 # set root composite layout
475 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c2 -S 2M \
476 -E -1 -c 4 -S 4M $root ||
477 error "Set root layout failed"
479 if [ "$root" == "$MOUNT2" ]; then
480 umount_client $MOUNT2 ||
481 error "umount $MOUNT2 fail"
485 # set a different layout for parent
486 $LFS setstripe -E -1 -c 1 -S 1M $parent ||
487 error "set $parent layout failed"
490 local f1_entry=$(component_dump $parent/file1)
492 # delete parent's layout
493 $LFS setstripe -d $parent || error "Clear $parent layout failed"
496 local f2_entry=$(component_dump $parent/file2)
498 # verify layout inheritance
500 local f1_expect="1[0,EOF]"
501 local f2_expect="3[0,2097152][0x200000,16777216][0x1000000,EOF]"
503 echo "f1 expect=$f1_expect"
504 echo "f1 get =$f1_entry"
505 echo "f2 expect=$f2_expect"
506 echo "f2 get =$f2_entry"
508 [ x$f1_expect != x$f1_entry ] &&
509 error "$parent/file1 does not inherite parent layout"
510 [ x$f2_expect != x$f2_entry ] &&
511 error "$parent/file2 does not inherite root layout"
515 run_test 10 "Inherit composite template from root"
518 local comp_file=$DIR/$tdir/$tfile
519 test_mkdir $DIR/$tdir
522 # only 1st component instantiated
523 $LFS setstripe -E 1M -S 1M -E 2M -E 3M -E -1 $comp_file ||
524 error "Create $comp_file failed"
526 local f1=$($LFS getstripe -I1 $comp_file | grep "l_fid")
527 [[ -z $f1 ]] && error "1: 1st component uninstantiated"
528 local f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
529 [[ -n $f2 ]] && error "1: 2nd component instantiated"
530 local f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
531 [[ -n $f3 ]] && error "1: 3rd component instantiated"
532 local f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
533 [[ -n $f4 ]] && error "1: 4th component instantiated"
535 # the first 2 components instantiated
536 $TRUNCATE $comp_file $((1024*1024*1+1))
538 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
539 [[ -z $f2 ]] && error "2: 2nd component uninstantiated"
540 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
541 [[ -n $f3 ]] && error "2: 3rd component instantiated"
542 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
543 [[ -n $f4 ]] && error "2: 4th component instantiated"
545 # the first 3 components instantiated
546 $TRUNCATE $comp_file $((1024*1024*3))
547 $TRUNCATE $comp_file $((1024*1024*1+1))
549 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
550 [[ -z $f2 ]] && error "3: 2nd component uninstantiated"
551 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
552 [[ -z $f3 ]] && error "3: 3rd component uninstantiated"
553 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
554 [[ -n $f4 ]] && error "3: 4th component instantiated"
556 # all 4 components instantiated, using append write
557 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
559 rwv -f $comp_file -w -a -n 2 $((1024*1023)) 1
562 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
563 [[ -z $f4 ]] && error "4: 4th component uninstantiated"
567 run_test 11 "Verify component instantiation with write/truncate"
570 [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs"
572 local file=$DIR/$tdir/$tfile
573 test_mkdir $DIR/$tdir
576 # specify ost list for component
577 $LFS setstripe -E 1M -S 1M -c 2 -o 0,1 -E 2M -c 2 -o 1,2 \
578 -E 3M -c 2 -o 2,1 -E 4M -c 1 -i 2 -E -1 $file ||
579 error "Create $file failed"
581 # clear lod component cache
582 stop $SINGLEMDS || error "stop MDS"
583 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
584 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "start MDS"
586 # instantiate all components
587 $TRUNCATE $file $((1024*1024*4+1))
589 #verify object alloc order
590 local o1=$($LFS getstripe -I1 $file |
591 awk '/l_ost_idx:/ {printf("%d",$5)}')
592 [[ $o1 != "01" ]] && error "$o1 is not 01"
594 local o2=$($LFS getstripe -I2 $file |
595 awk '/l_ost_idx:/ {printf("%d",$5)}')
596 [[ $o2 != "12" ]] && error "$o2 is not 12"
598 local o3=$($LFS getstripe -I3 $file |
599 awk '/l_ost_idx:/ {printf("%d",$5)}')
600 [[ $o3 != "21" ]] && error "$o3 is not 21"
602 local o4=$($LFS getstripe -I4 $file |
603 awk '/l_ost_idx:/ {printf("%d",$5)}')
604 [[ $o4 != "2" ]] && error "$o4 is not 2"
608 run_test 12 "Verify ost list specification"
610 test_13() { # LU-9311
611 [ $OSTCOUNT -lt 8 ] && skip "needs >= 8 OSTs"
613 local file=$DIR/$tfile
615 local dd_size=$(($dd_count * 1024 * 1024))
619 $LFS setstripe -E 1M -S 1M -c 1 -E 2M -c 2 -E -1 -c -1 -i 1 $file ||
620 error "Create $file failed"
621 dd if=/dev/zero of=$file bs=1M count=$dd_count
622 real_size=$(stat -c %s $file)
623 [ $real_size -eq $dd_size ] ||
624 error "dd actually wrote $real_size != $dd_size bytes"
628 run_test 13 "shouldn't reprocess granted resent request"
631 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
632 local file=$DIR/$tdir/$tfile
633 test_mkdir -p $DIR/$tdir
636 $LFS setstripe -E1m -c1 -S1m --pool="pool1" -E2m \
637 -E4m -c2 -S2m --pool="pool2" -E-1 $file ||
638 error "Create $file failed"
640 # check --pool inheritance
642 pool="$($LFS getstripe -I2 --pool $file)"
643 [ x"$pool" != "xpool1" ] && $LFS getstripe -I2 $file &&
644 error "$file: component 2 doesn't have poolname pool1"
645 pool="$($LFS getstripe -I4 --pool $file)"
646 [ x"$pool" != "xpool2" ] && $LFS getstripe -I4 $file &&
647 error "$file: component 4 doesn't have poolname pool2"
649 #check --stripe-count inheritance
651 count="$($LFS getstripe -I2 -c $file)"
652 [ $count -ne 1 ] && $LFS getstripe -I2 $file &&
653 error "$file: component 2 doesn't have 1 stripe_count"
654 count="$($LFS getstripe -I4 -c $file)"
655 [ $count -ne 2 ] && $LFS getstripe -I4 $file &&
656 error "$file: component 4 doesn't have 2 stripe_count"
658 #check --stripe-size inheritance
660 size="$($LFS getstripe -I2 -S $file)"
661 [ $size -ne $((1024*1024)) ] && $LFS getstripe -I2 $file &&
662 error "$file: component 2 doesn't have 1M stripe_size"
663 size="$($LFS getstripe -I4 -S $file)"
664 [ $size -ne $((1024*1024*2)) ] && $LFS getstripe -I4 $file &&
665 error "$file: component 4 doesn't have 2M stripe_size"
669 run_test 14 "Verify setstripe poolname/stripe_count/stripe_size inheritance"
672 local parent=$DIR/$tdir
677 $LFS setstripe -d $parent || error "delete default layout"
679 $LFS setstripe -E 1M -S 1M -E 10M -E eof $parent/f1 || error "create f1"
680 $LFS setstripe -E 4M -E 20M -E eof $parent/f2 || error "create f2"
681 test_mkdir $parent/subdir
682 $LFS setstripe -E 6M -S 1M -E 30M -E eof $parent/subdir ||
683 error "setstripe to subdir"
684 $LFS setstripe -E 8M -E eof $parent/subdir/f3 || error "create f3"
685 $LFS setstripe -c 1 $parent/subdir/f4 || error "create f4"
688 local found=$($LFS find --component-start +2M -E -15M $parent | wc -l)
689 [ $found -eq 0 ] || error "start+2M, end-15M, $found != 0"
692 found=$($LFS find --component-start +2M -E -35M $parent | wc -l)
693 [ $found -eq 2 ] || error "start+2M, end-35M, $found != 2"
696 found=$($LFS find --component-start +4M -E -eof $parent | wc -l)
697 [ $found -eq 1 ] || error "start+4M, end-eof, $found != 1"
699 local flg_opts="--component-flags init"
701 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
703 error "before write: start=1M, end=10M, flag=init, $found != 0"
705 dd if=/dev/zero of=$parent/f1 bs=1M count=2 ||
706 error "dd $parent/f1 failed"
709 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
711 error "after write: start=1M, end=10M, flag=init, $found != 1"
713 local ext_opts="--component-start -1M -E +5M"
714 # parent, subdir, f3, f4
715 found=$($LFS find $ext_opts $parent | wc -l)
716 [ $found -eq 4 ] || error "start-1M, end+5M, $found != 4"
718 local cnt_opts="--component-count +2"
720 found=$($LFS find $ext_opts $cnt_opts $parent | wc -l)
721 [ $found -eq 1 ] || error "start-1M, end+5M, count+2, $found != 1"
724 found=$($LFS find $ext_opts $cnt_opts $flg_opts $parent | wc -l)
726 error "start-1M, end+5M, count+2, flag=init, $found != 0"
729 found=$($LFS find $ext_opts ! $cnt_opts $flg_opts $parent | wc -l)
731 error "start-1M, end+5M, !count+2, flag=init, $found != 2"
733 run_test 15 "Verify component options for lfs find"
736 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
737 large_xattr_enabled || skip_env "ea_inode feature disabled"
739 local file=$DIR/$tdir/$tfile
740 local dir=$DIR/$tdir/dir
741 local temp=$DIR/$tdir/template
743 test_mkdir $DIR/$tdir
745 #####################################################################
747 # set stripe for source file
748 $LFS setstripe -E1m -S 1M -c2 -o0,1 -E2m -c2 -E3m -o1,0 -E4m -c1 -E-1 \
749 $file || error "Create $file failed"
752 verify_yaml_layout $file $file.copy $temp "1. PFL file"
754 #####################################################################
756 # set stripe for source file
758 $LFS setstripe -c2 -o0,1 -i1 $file || error "Create $file failed"
762 verify_yaml_layout $file $file.copy $temp "2. plain file"
764 #####################################################################
766 # set stripe for source dir
768 $LFS setstripe -E1m -S 1M -c2 -E2m -c1 -E-1 $dir ||
769 error "setstripe $dir failed"
773 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
775 #####################################################################
777 # set stripe for source dir
778 $LFS setstripe -c2 -i-1 $dir || error "setstripe $dir failed"
781 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
783 run_test 16a "Verify setstripe/getstripe with YAML config file"
786 [[ $($LCTL get_param mdc.*.import |
787 grep "connect_flags:.*overstriping") ]] ||
788 skip "server does not support overstriping"
789 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
790 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
791 skip_env "too many osts, skipping"
792 large_xattr_enabled || skip_env "ea_inode feature disabled"
794 local file=$DIR/$tdir/$tfile
795 local dir=$DIR/$tdir/dir
796 local temp=$DIR/$tdir/template
797 # We know OSTCOUNT < (LOV_MAX_STRIPE_COUNT / 2), so this is overstriping
798 local large_count=$((LOV_MAX_STRIPE_COUNT / 2 + 10))
801 test_mkdir $DIR/$tdir
803 #####################################################################
804 # 1. PFL file, overstriping in first comps
805 # set stripe for source file
806 $LFS setstripe -E1m -S 1M -o0,0 -E2m -o1,1 -E3m -C $large_count -E-1 \
807 $file || error "Create $file failed"
810 verify_yaml_layout $file $file.copy $temp "1. PFL file"
812 #####################################################################
813 # 2. plain file + overstriping
814 # set stripe for source file
816 $LFS setstripe -C $large_count -i1 $file || error "Create $file failed"
820 verify_yaml_layout $file $file.copy $temp "2. plain file"
822 #####################################################################
823 # 3. PFL dir + overstriping
824 # set stripe for source dir
826 $LFS setstripe -E1m -S 1M -o 0,0 -E2m -C $large_count -E-1 $dir ||
827 error "setstripe $dir failed"
831 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
833 #####################################################################
834 # 4. plain dir + overstriping
835 # set stripe for source dir
836 $LFS setstripe -C $large_count $dir || error "setstripe $dir failed"
839 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
841 run_test 16b "Verify setstripe/getstripe with YAML config file + overstriping"
844 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
845 local file=$DIR/$tdir/$tfile
846 test_mkdir -p $DIR/$tdir
849 $LFS setstripe -E 1M -S 1M -E 2M -c 2 -E -1 -c -1 $file ||
850 error "Create $file failed"
852 local s1=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
853 local s2=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
854 local s3=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
855 echo "1st init: comp size 1:$s1 2:$s2 3:$s3"
858 $TRUNCATE $file $((1024*1024+1))
859 local s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
860 local s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
861 echo "2nd init: comp size 1:$s1n 2:$s2n 3:$s3"
863 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
864 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
867 $TRUNCATE $file $((1024*1024*2+1))
868 s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
869 s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
870 local s3n=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
871 echo "3rd init: comp size 1:$s1n 2:$s2n 3:$s3n"
873 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
874 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
875 [ $s3 -lt $s3n ] || error "3rd comp size $s3 should < $s3n"
877 run_test 17 "Verify LOVEA grows with more component inited"
879 check_distribution() {
883 local obj_min_one=$((OSTCOUNT - 1))
885 objs=$($LFS getstripe $file |
886 awk '/l_ost_idx:/ { print $5 }' | wc -l)
887 let ave=$((objs / OSTCOUNT))
889 # collect objects per OST distribution
890 $LFS getstripe $file | awk '/l_ost_idx:/ { print $5 }' | tr -d "," |
891 (inuse=( $(for i in $(seq 0 $obj_min_one); do echo 0; done) )
893 let inuse[$O]=$((1 + ${inuse[$O]}))
896 # verify object distribution varies no more than +-1
897 for idx in $(seq 0 $obj_min_one); do
898 let dif=$((${inuse[$idx]} - ave))
900 if [ "$dif" -gt 1 ]; then
901 echo "OST${idx}: ${inuse[$idx]} objects"
902 error "bad distribution on OST${idx}"
908 local file1=$DIR/${tfile}-1
909 local file2=$DIR/${tfile}-2
910 local file3=$DIR/${tfile}-3
912 rm -f $file1 $file2 $file3
914 $LFS setstripe -E 1m -S 1m $file1 ||
915 error "Create $file1 failed"
916 $LFS setstripe -E 1m -S 1m $file2 ||
917 error "Create $file2 failed"
918 $LFS setstripe -E 1m -S 1m $file3 ||
919 error "Create $file3 failed"
921 local objs=$((OSTCOUNT+1))
922 for comp in $(seq 1 $OSTCOUNT); do
923 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file1 ||
924 error "Add component to $file1 failed 2"
925 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file2 ||
926 error "Add component to $file2 failed 2"
927 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file3 ||
928 error "Add component to $file3 failed 2"
931 $LFS setstripe --component-add -E -1 -c -1 $file1 ||
932 error "Add component to $file1 failed 3"
933 $LFS setstripe --component-add -E -1 -c -1 $file2 ||
934 error "Add component to $file2 failed 3"
935 $LFS setstripe --component-add -E -1 -c -1 $file3 ||
936 error "Add component to $file3 failed 3"
938 # Instantiate all components
939 dd if=/dev/urandom of=$file1 bs=1M count=$((objs+1)) ||
940 error "dd failed for $file1"
941 dd if=/dev/urandom of=$file2 bs=1M count=$((objs+1)) ||
942 error "dd failed for $file2"
943 dd if=/dev/urandom of=$file3 bs=1M count=$((objs+1)) ||
944 error "dd failed for $file3"
946 check_distribution $file1
947 check_distribution $file2
948 check_distribution $file3
951 run_test 18 "check component distribution"
954 check_and_cleanup_lustre