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"
178 local comp_file=$DIR/$tdir/$tfile
179 local rw_len=$((5 * 1024 * 1024)) # 5M
181 test_mkdir $DIR/$tdir
184 $LFS setstripe -E 1m -S 1m $comp_file ||
185 error "Create $comp_file failed"
187 local comp_cnt=$($LFS getstripe --component-count $comp_file)
188 [ $comp_cnt -ne 1 ] && error "component count $comp_cnt != 1"
190 dd if=/dev/zero of=$comp_file bs=1M count=1 > /dev/null 2>&1 ||
191 error "Write first component failed"
192 dd if=$comp_file of=/dev/null bs=1M count=1 > /dev/null 2>&1 ||
193 error "Read first component failed"
195 dd if=/dev/zero of=$comp_file bs=1M count=2 > /dev/null 2>&1 &&
196 error "Write beyond component should fail"
197 dd if=$comp_file of=/dev/null bs=1M count=2 > /dev/null 2>&1 ||
198 error "Read beyond component should short read, not fail"
200 $LFS setstripe --component-add -E 2M -S 1M -c 1 $comp_file ||
201 error "Add component to $comp_file failed"
203 comp_cnt=$($LFS getstripe --component-count $comp_file)
204 [ $comp_cnt -ne 2 ] && error "component count $comp_cnt != 2"
206 $LFS setstripe --component-add -E -1 -c 3 $comp_file ||
207 error "Add last component to $comp_file failed"
209 comp_cnt=$($LFS getstripe --component-count $comp_file)
210 [ $comp_cnt -ne 3 ] && error "component count $comp_cnt != 3"
212 small_write $comp_file $rw_len || error "Verify RW failed"
214 rm -f $comp_file || error "Delete $comp_file failed"
216 run_test 2 "Add component to existing file"
218 del_comp_and_verify() {
225 if [ $id == "init" -o $id == "^init" ]; then
226 opt="--component-flags="
229 $LFS setstripe --component-del $opt$id $comp_file ||
230 error "Delete component $id from $comp_file failed"
232 local comp_cnt=$($LFS getstripe --component-count $comp_file)
233 if grep -q "has no stripe info" <<< "$comp_cnt" ; then
236 [ $comp_cnt -ne $left ] && error "$comp_cnt != $left"
238 $CHECKSTAT -s $size $comp_file || error "size != $size"
242 local comp_file=$DIR/$tdir/$tfile
244 test_mkdir $DIR/$tdir
247 $LFS setstripe -E 1M -S 1M -E 64M -c 2 -E -1 -c 3 $comp_file ||
248 error "Create $comp_file failed"
250 local comp_cnt=$($LFS getstripe --component-count $comp_file)
251 [ $comp_cnt -ne 3 ] && error "component count $comp_cnt != 3"
253 dd if=/dev/zero of=$comp_file bs=1M count=2
255 $LFS setstripe --component-del -I 2 $comp_file &&
256 error "Component deletion makes hole"
258 del_comp_and_verify $comp_file 3 2 $((2 * 1024 * 1024))
259 del_comp_and_verify $comp_file 2 1 $((1 * 1024 * 1024))
260 del_comp_and_verify $comp_file 1 0 0
262 rm -f $comp_file || error "Delete $comp_file failed"
264 $LFS setstripe -E 1M -S 1M -E 16M -E -1 $comp_file ||
265 error "Create second $comp_file failed"
267 del_comp_and_verify $comp_file "^init" 1 0
268 del_comp_and_verify $comp_file "init" 0 0
269 rm -f $comp_file || error "Delete second $comp_file failed"
272 run_test 3 "Delete component from existing file"
275 skip "Not supported in PFL"
276 # In PFL project, only LCME_FL_INIT is supported, and it can't
277 # be altered by application.
279 run_test 4 "Modify component flags in existing file"
282 local parent=$DIR/$tdir
283 local comp_file=$DIR/$tdir/$tfile
284 local subdir=$parent/subdir
289 # set default layout to parent directory
290 $LFS setstripe -E 64M -c 2 -i 0 -E -1 -c 4 -i 0 $parent ||
291 error "Set default layout to $parent failed"
293 # create file under parent
294 touch $comp_file || error "Create $comp_file failed"
295 local comp_cnt=$($LFS getstripe --component-count $comp_file)
296 [ $comp_cnt -ne 2 ] && error "file $comp_cnt != 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 comp_cnt=$($LFS getstripe --component-count $subdir/$tfile)
319 [ $comp_cnt -ne 2 ] && error "$subdir/$tfile $comp_cnt != 2"
321 # delete default layout setting from parent
322 $LFS setstripe -d $parent ||
323 error "Delete default layout from $parent failed"
325 comp_cnt=$($LFS getstripe -d --component-count $parent)
326 [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0"
328 rm -f $comp_file || error "Delete $comp_file failed"
329 rm -f $subdir/$tfile || error "Delete $subdir/$tfile failed"
330 rm -r $subdir || error "Delete subdir $subdir failed"
331 rmdir $parent || error "Delete dir $parent failed"
333 run_test 5 "Inherit composite layout from parent directory"
336 local comp_file=$DIR/$tdir/$tfile
338 test_mkdir $DIR/$tdir
341 $LFS setstripe -c 1 -S 128K $comp_file ||
342 error "Create v1 $comp_file failed"
344 local comp_cnt=$($LFS getstripe --component-count $comp_file)
345 [ $comp_cnt -ne 0 ] && error "Wrong component count $comp_cnt"
347 dd if=/dev/urandom of=$comp_file bs=1M count=5 oflag=sync ||
348 error "Write to v1 $comp_file failed"
350 local old_chksum=$(md5sum $comp_file)
352 # Migrate v1 to composite
353 $LFS migrate -E 1M -S 512K -c 1 -E -1 -S 1M -c 2 $comp_file ||
354 error "Migrate(v1 -> composite) $comp_file failed"
356 comp_cnt=$($LFS getstripe --component-count $comp_file)
357 [ "$comp_cnt" -ne 2 ] && error "$comp_cnt != 2"
359 local chksum=$(md5sum $comp_file)
360 [ "$old_chksum" != "$chksum" ] &&
361 error "(v1 -> compsoite) $old_chksum != $chksum"
363 # Migrate composite to composite
364 $LFS migrate -E 1M -S 1M -c 2 -E 4M -S 1M -c 2 \
365 -E -1 -S 3M -c 3 $comp_file ||
366 error "Migrate(compsoite -> composite) $comp_file failed"
368 comp_cnt=$($LFS getstripe --component-count $comp_file)
369 [ "$comp_cnt" -ne 3 ] && error "$comp_cnt != 3"
371 chksum=$(md5sum $comp_file)
372 [ "$old_chksum" != "$chksum" ] &&
373 error "(composite -> compsoite) $old_chksum != $chksum"
375 # Migrate composite to v1
376 $LFS migrate -c 2 -S 2M $comp_file ||
377 error "Migrate(composite -> v1) $comp_file failed"
379 comp_cnt=$($LFS getstripe --component-count $comp_file)
380 [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 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 local comp_cnt=$($LFS getstripe --component-count $comp_file)
437 [ $comp_cnt -ne 2 ] && error "component count $comp_cnt != 2"
439 replay_barrier $SINGLEMDS
441 # instantiate the 2nd component
442 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
444 local f1=$($LFS getstripe -I2 $comp_file |
445 awk '/l_fid:/ {print $7}')
446 echo "before MDS recovery, the ost fid of 2nd component is $f1"
449 local f2=$($LFS getstripe -I2 $comp_file |
450 awk '/l_fid:/ {print $7}')
451 echo "after MDS recovery, the ost fid of 2nd component is $f2"
452 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
454 run_test 9 "Replay layout extend object instantiation"
457 echo $($LFS getstripe $1 |
458 awk '$1 == "lcm_entry_count:" { printf("%d", $2) }
459 $1 == "lcme_extent.e_start:" { printf("[%#lx", $2) }
460 $1 == "lcme_extent.e_end:" { printf(",%s]", $2) }')
464 local parent=$DIR/$tdir
467 save_layout_restore_at_exit $MOUNT
471 # mount root on $MOUNT2 if FILESET is set
472 if [ -n "$FILESET" ]; then
473 FILESET="" mount_client $MOUNT2 ||
474 error "mount $MOUNT2 fail"
478 $LFS setstripe -d $root || error "clear root layout"
480 # set root composite layout
481 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c2 -S 2M \
482 -E -1 -c 4 -S 4M $root ||
483 error "Set root layout failed"
485 if [ "$root" == "$MOUNT2" ]; then
486 umount_client $MOUNT2 ||
487 error "umount $MOUNT2 fail"
491 # set a different layout for parent
492 $LFS setstripe -E -1 -c 1 -S 1M $parent ||
493 error "set $parent layout failed"
496 local f1_entry=$(component_dump $parent/file1)
498 # delete parent's layout
499 $LFS setstripe -d $parent || error "Clear $parent layout failed"
502 local f2_entry=$(component_dump $parent/file2)
504 # verify layout inheritance
506 local f1_expect="1[0,EOF]"
507 local f2_expect="3[0,2097152][0x200000,16777216][0x1000000,EOF]"
509 echo "f1 expect=$f1_expect"
510 echo "f1 get =$f1_entry"
511 echo "f2 expect=$f2_expect"
512 echo "f2 get =$f2_entry"
514 [ x$f1_expect != x$f1_entry ] &&
515 error "$parent/file1 does not inherite parent layout"
516 [ x$f2_expect != x$f2_entry ] &&
517 error "$parent/file2 does not inherite root layout"
521 run_test 10 "Inherit composite template from root"
524 local comp_file=$DIR/$tdir/$tfile
525 test_mkdir $DIR/$tdir
528 # only 1st component instantiated
529 $LFS setstripe -E 1M -S 1M -E 2M -E 3M -E -1 $comp_file ||
530 error "Create $comp_file failed"
532 local f1=$($LFS getstripe -I1 $comp_file | grep "l_fid")
533 [[ -z $f1 ]] && error "1: 1st component uninstantiated"
534 local f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
535 [[ -n $f2 ]] && error "1: 2nd component instantiated"
536 local f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
537 [[ -n $f3 ]] && error "1: 3rd component instantiated"
538 local f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
539 [[ -n $f4 ]] && error "1: 4th component instantiated"
541 # the first 2 components instantiated
542 $TRUNCATE $comp_file $((1024*1024*1+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))
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 -E 30M -E eof $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 run_test 15 "Verify component options for lfs find"
742 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
743 large_xattr_enabled || skip_env "ea_inode feature disabled"
745 local file=$DIR/$tdir/$tfile
746 local dir=$DIR/$tdir/dir
747 local temp=$DIR/$tdir/template
749 test_mkdir $DIR/$tdir
751 #####################################################################
753 # set stripe for source file
754 $LFS setstripe -E1m -S 1M -c2 -o0,1 -E2m -c2 -E3m -o1,0 -E4m -c1 -E-1 \
755 $file || error "Create $file failed"
758 verify_yaml_layout $file $file.copy $temp "1. PFL file"
760 #####################################################################
762 # set stripe for source file
764 $LFS setstripe -c2 -o0,1 -i1 $file || error "Create $file failed"
768 verify_yaml_layout $file $file.copy $temp "2. plain file"
770 #####################################################################
772 # set stripe for source dir
774 $LFS setstripe -E1m -S 1M -c2 -E2m -c1 -E-1 $dir ||
775 error "setstripe $dir failed"
779 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
781 #####################################################################
783 # set stripe for source dir
784 $LFS setstripe -c2 -i-1 $dir || error "setstripe $dir failed"
787 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
789 run_test 16a "Verify setstripe/getstripe with YAML config file"
792 [[ $($LCTL get_param mdc.*.import |
793 grep "connect_flags:.*overstriping") ]] ||
794 skip "server does not support overstriping"
795 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
796 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
797 skip_env "too many osts, skipping"
798 large_xattr_enabled || skip_env "ea_inode feature disabled"
800 local file=$DIR/$tdir/$tfile
801 local dir=$DIR/$tdir/dir
802 local temp=$DIR/$tdir/template
803 # We know OSTCOUNT < (LOV_MAX_STRIPE_COUNT / 2), so this is overstriping
804 local large_count=$((LOV_MAX_STRIPE_COUNT / 2 + 10))
807 test_mkdir $DIR/$tdir
809 #####################################################################
810 # 1. PFL file, overstriping in first comps
811 # set stripe for source file
812 $LFS setstripe -E1m -S 1M -o0,0 -E2m -o1,1 -E3m -C $large_count -E-1 \
813 $file || error "Create $file failed"
816 verify_yaml_layout $file $file.copy $temp "1. PFL file"
818 #####################################################################
819 # 2. plain file + overstriping
820 # set stripe for source file
822 $LFS setstripe -C $large_count -i1 $file || error "Create $file failed"
826 verify_yaml_layout $file $file.copy $temp "2. plain file"
828 #####################################################################
829 # 3. PFL dir + overstriping
830 # set stripe for source dir
832 $LFS setstripe -E1m -S 1M -o 0,0 -E2m -C $large_count -E-1 $dir ||
833 error "setstripe $dir failed"
837 verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
839 #####################################################################
840 # 4. plain dir + overstriping
841 # set stripe for source dir
842 $LFS setstripe -C $large_count $dir || error "setstripe $dir failed"
845 verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
847 run_test 16b "Verify setstripe/getstripe with YAML config file + overstriping"
850 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
851 local file=$DIR/$tdir/$tfile
852 test_mkdir -p $DIR/$tdir
855 $LFS setstripe -E 1M -S 1M -E 2M -c 2 -E -1 -c -1 $file ||
856 error "Create $file failed"
858 local s1=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
859 local s2=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
860 local s3=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
861 echo "1st init: comp size 1:$s1 2:$s2 3:$s3"
864 $TRUNCATE $file $((1024*1024+1))
865 local s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
866 local s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
867 echo "2nd init: comp size 1:$s1n 2:$s2n 3:$s3"
869 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
870 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
873 $TRUNCATE $file $((1024*1024*2+1))
874 s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
875 s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
876 local s3n=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
877 echo "3rd init: comp size 1:$s1n 2:$s2n 3:$s3n"
879 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
880 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
881 [ $s3 -lt $s3n ] || error "3rd comp size $s3 should < $s3n"
883 run_test 17 "Verify LOVEA grows with more component inited"
885 check_distribution() {
889 local obj_min_one=$((OSTCOUNT - 1))
891 objs=$($LFS getstripe $file |
892 awk '/l_ost_idx:/ { print $5 }' | wc -l)
893 let ave=$((objs / OSTCOUNT))
895 # collect objects per OST distribution
896 $LFS getstripe $file | awk '/l_ost_idx:/ { print $5 }' | tr -d "," |
897 (inuse=( $(for i in $(seq 0 $obj_min_one); do echo 0; done) )
899 let inuse[$O]=$((1 + ${inuse[$O]}))
902 # verify object distribution varies no more than +-1
903 for idx in $(seq 0 $obj_min_one); do
904 let dif=$((${inuse[$idx]} - ave))
906 if [ "$dif" -gt 1 ]; then
907 echo "OST${idx}: ${inuse[$idx]} objects"
908 error "bad distribution on OST${idx}"
914 local file1=$DIR/${tfile}-1
915 local file2=$DIR/${tfile}-2
916 local file3=$DIR/${tfile}-3
918 rm -f $file1 $file2 $file3
920 $LFS setstripe -E 1m -S 1m $file1 ||
921 error "Create $file1 failed"
922 $LFS setstripe -E 1m -S 1m $file2 ||
923 error "Create $file2 failed"
924 $LFS setstripe -E 1m -S 1m $file3 ||
925 error "Create $file3 failed"
927 local objs=$((OSTCOUNT+1))
928 for comp in $(seq 1 $OSTCOUNT); do
929 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file1 ||
930 error "Add component to $file1 failed 2"
931 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file2 ||
932 error "Add component to $file2 failed 2"
933 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file3 ||
934 error "Add component to $file3 failed 2"
937 $LFS setstripe --component-add -E -1 -c -1 $file1 ||
938 error "Add component to $file1 failed 3"
939 $LFS setstripe --component-add -E -1 -c -1 $file2 ||
940 error "Add component to $file2 failed 3"
941 $LFS setstripe --component-add -E -1 -c -1 $file3 ||
942 error "Add component to $file3 failed 3"
944 # Instantiate all components
945 dd if=/dev/urandom of=$file1 bs=1M count=$((objs+1)) ||
946 error "dd failed for $file1"
947 dd if=/dev/urandom of=$file2 bs=1M count=$((objs+1)) ||
948 error "dd failed for $file2"
949 dd if=/dev/urandom of=$file3 bs=1M count=$((objs+1)) ||
950 error "dd failed for $file3"
952 check_distribution $file1
953 check_distribution $file2
954 check_distribution $file3
957 run_test 18 "check component distribution"
960 check_and_cleanup_lustre