3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
8 export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
11 # Bug number for skipped test:
12 ALWAYS_EXCEPT="$SANITY_PFL_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
16 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
18 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
19 . $LUSTRE/tests/test-framework.sh
21 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
24 check_and_setup_lustre
26 if [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.51) ]]; then
27 skip_env "Need MDS version at least 2.9.51"
30 [ "$ALWAYS_EXCEPT$EXCEPT" ] &&
31 echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
35 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
36 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
37 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
40 rm -rf $DIR/[Rdfs][0-9]*
43 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
45 local comp_file=$DIR/$tdir/$tfile
46 local rw_len=$((3 * 1024 * 1024)) # 3M
51 $LFS setstripe -E 1m -S 1M -c 1 -E -1 -c 1 $comp_file ||
52 error "Create $comp_file failed"
54 #instantiate all components, so that objs are allocted
55 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
57 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
58 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
60 [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
62 small_write $comp_file $rw_len || error "Verify RW failed"
64 rm -f $comp_file || error "Delete $comp_file failed"
66 run_test 0 "Create full components file, no reused OSTs"
69 local comp_file=$DIR/$tdir/$tfile
70 local rw_len=$((3 * 1024 * 1024)) # 3M
75 $LFS setstripe -E 1m -S 1m -o 0 -E -1 -o 0 $comp_file ||
76 error "Create $comp_file failed"
78 #instantiate all components, so that objs are allocted
79 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
81 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
82 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
84 [ $ost_idx1 -ne $ost_idx2 ] && error "$ost_idx1 != $ost_idx2"
86 small_write $comp_file $rw_len || error "Verify RW failed"
88 rm -f $comp_file || error "Delete $comp_file failed"
90 run_test 1 "Create full components file, reused OSTs"
93 local comp_file=$DIR/$tdir/$tfile
94 local rw_len=$((5 * 1024 * 1024)) # 5M
99 $LFS setstripe -E 1m -S 1m $comp_file ||
100 error "Create $comp_file failed"
102 local comp_cnt=$($LFS getstripe --component-count $comp_file)
103 [ $comp_cnt -ne 1 ] && error "component count $comp_cnt != 1"
105 dd if=/dev/zero of=$comp_file bs=1M count=1 > /dev/null 2>&1 ||
106 error "Write first component failed"
107 dd if=$comp_file of=/dev/null bs=1M count=1 > /dev/null 2>&1 ||
108 error "Read first component failed"
110 dd if=/dev/zero of=$comp_file bs=1M count=2 > /dev/null 2>&1 &&
111 error "Write beyond component should fail"
112 dd if=$comp_file of=/dev/null bs=1M count=2 > /dev/null 2>&1 ||
113 error "Read beyond component should short read, not fail"
115 $LFS setstripe --component-add -E 2M -S 1M -c 1 $comp_file ||
116 error "Add component to $comp_file failed"
118 comp_cnt=$($LFS getstripe --component-count $comp_file)
119 [ $comp_cnt -ne 2 ] && error "component count $comp_cnt != 2"
121 $LFS setstripe --component-add -E -1 -c 3 $comp_file ||
122 error "Add last component to $comp_file failed"
124 comp_cnt=$($LFS getstripe --component-count $comp_file)
125 [ $comp_cnt -ne 3 ] && error "component count $comp_cnt != 3"
127 small_write $comp_file $rw_len || error "Verify RW failed"
129 rm -f $comp_file || error "Delete $comp_file failed"
131 run_test 2 "Add component to existing file"
133 del_comp_and_verify() {
140 if [ $id == "init" -o $id == "^init" ]; then
141 opt="--component-flags="
144 $LFS setstripe --component-del $opt$id $comp_file ||
145 error "Delete component $id from $comp_file failed"
147 local comp_cnt=$($LFS getstripe --component-count $comp_file)
148 if grep -q "has no stripe info" <<< "$comp_cnt" ; then
151 [ $comp_cnt -ne $left ] && error "$comp_cnt != $left"
153 $CHECKSTAT -s $size $comp_file || error "size != $size"
157 local comp_file=$DIR/$tdir/$tfile
159 test_mkdir $DIR/$tdir
162 $LFS setstripe -E 1M -S 1M -E 64M -c 2 -E -1 -c 3 $comp_file ||
163 error "Create $comp_file failed"
165 local comp_cnt=$($LFS getstripe --component-count $comp_file)
166 [ $comp_cnt -ne 3 ] && error "component count $comp_cnt != 3"
168 dd if=/dev/zero of=$comp_file bs=1M count=2
170 $LFS setstripe --component-del -I 2 $comp_file &&
171 error "Component deletion makes hole"
173 del_comp_and_verify $comp_file 3 2 $((2 * 1024 * 1024))
174 del_comp_and_verify $comp_file 2 1 $((1 * 1024 * 1024))
175 del_comp_and_verify $comp_file 1 0 0
177 rm -f $comp_file || error "Delete $comp_file failed"
179 $LFS setstripe -E 1M -S 1M -E 16M -E -1 $comp_file ||
180 error "Create second $comp_file failed"
182 del_comp_and_verify $comp_file "^init" 1 0
183 del_comp_and_verify $comp_file "init" 0 0
184 rm -f $comp_file || error "Delete second $comp_file failed"
187 run_test 3 "Delete component from existing file"
190 skip "Not supported in PFL"
191 # In PFL project, only LCME_FL_INIT is supported, and it can't
192 # be altered by application.
194 run_test 4 "Modify component flags in existing file"
197 local parent=$DIR/$tdir
198 local comp_file=$DIR/$tdir/$tfile
199 local subdir=$parent/subdir
204 # set default layout to parent directory
205 $LFS setstripe -E 64M -c 2 -i 0 -E -1 -c 4 -i 0 $parent ||
206 error "Set default layout to $parent failed"
208 # create file under parent
209 touch $comp_file || error "Create $comp_file failed"
210 local comp_cnt=$($LFS getstripe --component-count $comp_file)
211 [ $comp_cnt -ne 2 ] && error "file $comp_cnt != 2"
213 #instantiate all components, so that objs are allocted
214 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=65k
216 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
217 [ $ost_idx -ne 0 ] &&
218 error "component 1 ost_idx $ost_idx != 0"
220 ost_idx=$($LFS getstripe -I2 -i $comp_file)
221 [ $ost_idx -ne 0 ] &&
222 error "component 2 ost_idx $ost_idx != 0"
224 # create subdir under parent
225 mkdir -p $subdir || error "Create subdir $subdir failed"
227 comp_cnt=$($LFS getstripe -d --component-count $subdir)
228 [ $comp_cnt -ne 2 ] && error "subdir $comp_cnt != 2"
230 # create file under subdir
231 touch $subdir/$tfile || error "Create $subdir/$tfile failed"
233 comp_cnt=$($LFS getstripe --component-count $subdir/$tfile)
234 [ $comp_cnt -ne 2 ] && error "$subdir/$tfile $comp_cnt != 2"
236 # delete default layout setting from parent
237 $LFS setstripe -d $parent ||
238 error "Delete default layout from $parent failed"
240 comp_cnt=$($LFS getstripe -d --component-count $parent)
241 [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0"
243 rm -f $comp_file || error "Delete $comp_file failed"
244 rm -f $subdir/$tfile || error "Delete $subdir/$tfile failed"
245 rm -r $subdir || error "Delete subdir $subdir failed"
246 rmdir $parent || error "Delete dir $parent failed"
248 run_test 5 "Inherit composite layout from parent directory"
251 local comp_file=$DIR/$tdir/$tfile
253 test_mkdir $DIR/$tdir
256 $LFS setstripe -c 1 -S 128K $comp_file ||
257 error "Create v1 $comp_file failed"
259 local comp_cnt=$($LFS getstripe --component-count $comp_file)
260 [ $comp_cnt -ne 0 ] && error "Wrong component count $comp_cnt"
262 dd if=/dev/urandom of=$comp_file bs=1M count=5 oflag=sync ||
263 error "Write to v1 $comp_file failed"
265 local old_chksum=$(md5sum $comp_file)
267 # Migrate v1 to composite
268 $LFS migrate -E 1M -S 512K -c 1 -E -1 -S 1M -c 2 $comp_file ||
269 error "Migrate(v1 -> composite) $comp_file failed"
271 comp_cnt=$($LFS getstripe --component-count $comp_file)
272 [ "$comp_cnt" -ne 2 ] && error "$comp_cnt != 2"
274 local chksum=$(md5sum $comp_file)
275 [ "$old_chksum" != "$chksum" ] &&
276 error "(v1 -> compsoite) $old_chksum != $chksum"
278 # Migrate composite to composite
279 $LFS migrate -E 1M -S 1M -c 2 -E 4M -S 1M -c 2 \
280 -E -1 -S 3M -c 3 $comp_file ||
281 error "Migrate(compsoite -> composite) $comp_file failed"
283 comp_cnt=$($LFS getstripe --component-count $comp_file)
284 [ "$comp_cnt" -ne 3 ] && error "$comp_cnt != 3"
286 chksum=$(md5sum $comp_file)
287 [ "$old_chksum" != "$chksum" ] &&
288 error "(composite -> compsoite) $old_chksum != $chksum"
290 # Migrate composite to v1
291 $LFS migrate -c 2 -S 2M $comp_file ||
292 error "Migrate(composite -> v1) $comp_file failed"
294 comp_cnt=$($LFS getstripe --component-count $comp_file)
295 [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0"
297 chksum=$(md5sum $comp_file)
298 [ "$old_chksum" != "$chksum" ] &&
299 error "(composite -> v1) $old_chksum != $chksum"
301 rm -f $comp_file || "Delete $comp_file failed"
303 run_test 6 "Migrate composite file"
306 test_mkdir $DIR/$tdir
307 chmod 0777 $DIR/$tdir || error "chmod $tdir failed"
309 local comp_file=$DIR/$tdir/$tfile
310 $RUNAS $LFS setstripe -E 1M -S 1M -c 1 $comp_file ||
311 error "Create composite file $comp_file failed"
313 $RUNAS $LFS setstripe --component-add -E 64M -c 4 $comp_file ||
314 error "Add component to $comp_file failed"
316 $RUNAS $LFS setstripe --component-del -I 2 $comp_file ||
317 error "Delete component from $comp_file failed"
319 $RUNAS $LFS setstripe --component-add -E -1 -c 5 $comp_file ||
320 error "Add last component to $comp_file failed"
322 rm $comp_file || "Delete composite failed"
324 run_test 7 "Add/Delete/Create composite file by non-privileged user"
327 local parent=$DIR/$tdir
332 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c 2 -S 2M \
333 -E -1 -c 4 -S 4M $parent ||
334 error "Set default layout to $parent failed"
336 sh rundbench -C -D $parent 2 || error "dbench failed"
338 rm -fr $parent || error "Delete dir $parent failed"
340 run_test 8 "Run dbench over composite files"
343 local comp_file=$DIR/$tdir/$tfile
345 test_mkdir $DIR/$tdir
348 $LFS setstripe -E 1M -S 1M -E -1 -c 1 $comp_file ||
349 error "Create $comp_file failed"
351 local comp_cnt=$($LFS getstripe --component-count $comp_file)
352 [ $comp_cnt -ne 2 ] && error "component count $comp_cnt != 2"
354 replay_barrier $SINGLEMDS
356 # instantiate the 2nd component
357 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
359 local f1=$($LFS getstripe -I2 $comp_file |
360 awk '/l_fid:/ {print $7}')
361 echo "before MDS recovery, the ost fid of 2nd component is $f1"
364 local f2=$($LFS getstripe -I2 $comp_file |
365 awk '/l_fid:/ {print $7}')
366 echo "after MDS recovery, the ost fid of 2nd component is $f2"
367 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
369 run_test 9 "Replay layout extend object instantiation"
372 echo $($LFS getstripe $1 |
373 awk '$1 == "lcm_entry_count:" { printf("%d", $2) }
374 $1 == "lcme_extent.e_start:" { printf("[%#lx", $2) }
375 $1 == "lcme_extent.e_end:" { printf(",%s]", $2) }')
379 local parent=$DIR/$tdir
382 save_layout_restore_at_exit $MOUNT
386 # mount root on $MOUNT2 if FILESET is set
387 if [ -n "$FILESET" ]; then
388 FILESET="" mount_client $MOUNT2 ||
389 error "mount $MOUNT2 fail"
393 $LFS setstripe -d $root || error "clear root layout"
395 # set root composite layout
396 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c2 -S 2M \
397 -E -1 -c 4 -S 4M $root ||
398 error "Set root layout failed"
400 if [ "$root" == "$MOUNT2" ]; then
401 umount_client $MOUNT2 ||
402 error "umount $MOUNT2 fail"
406 # set a different layout for parent
407 $LFS setstripe -E -1 -c 1 -S 1M $parent ||
408 error "set $parent layout failed"
411 local f1_entry=$(component_dump $parent/file1)
413 # delete parent's layout
414 $LFS setstripe -d $parent || error "Clear $parent layout failed"
417 local f2_entry=$(component_dump $parent/file2)
419 # verify layout inheritance
421 local f1_expect="1[0,EOF]"
422 local f2_expect="3[0,2097152][0x200000,16777216][0x1000000,EOF]"
424 echo "f1 expect=$f1_expect"
425 echo "f1 get =$f1_entry"
426 echo "f2 expect=$f2_expect"
427 echo "f2 get =$f2_entry"
429 [ x$f1_expect != x$f1_entry ] &&
430 error "$parent/file1 does not inherite parent layout"
431 [ x$f2_expect != x$f2_entry ] &&
432 error "$parent/file2 does not inherite root layout"
436 run_test 10 "Inherit composite template from root"
439 local comp_file=$DIR/$tdir/$tfile
440 test_mkdir $DIR/$tdir
443 # only 1st component instantiated
444 $LFS setstripe -E 1M -S 1M -E 2M -E 3M -E -1 $comp_file ||
445 error "Create $comp_file failed"
447 local f1=$($LFS getstripe -I1 $comp_file | grep "l_fid")
448 [[ -z $f1 ]] && error "1: 1st component uninstantiated"
449 local f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
450 [[ -n $f2 ]] && error "1: 2nd component instantiated"
451 local f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
452 [[ -n $f3 ]] && error "1: 3rd component instantiated"
453 local f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
454 [[ -n $f4 ]] && error "1: 4th component instantiated"
456 # the first 2 components instantiated
457 $TRUNCATE $comp_file $((1024*1024*1+1))
459 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
460 [[ -z $f2 ]] && error "2: 2nd component uninstantiated"
461 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
462 [[ -n $f3 ]] && error "2: 3rd component instantiated"
463 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
464 [[ -n $f4 ]] && error "2: 4th component instantiated"
466 # the first 3 components instantiated
467 $TRUNCATE $comp_file $((1024*1024*3))
468 $TRUNCATE $comp_file $((1024*1024*1+1))
470 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
471 [[ -z $f2 ]] && error "3: 2nd component uninstantiated"
472 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
473 [[ -z $f3 ]] && error "3: 3rd component uninstantiated"
474 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
475 [[ -n $f4 ]] && error "3: 4th component instantiated"
477 # all 4 components instantiated, using append write
478 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
480 rwv -f $comp_file -w -a -n 2 $((1024*1023)) 1
483 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
484 [[ -z $f4 ]] && error "4: 4th component uninstantiated"
488 run_test 11 "Verify component instantiation with write/truncate"
491 [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs"
493 local file=$DIR/$tdir/$tfile
494 test_mkdir $DIR/$tdir
497 # specify ost list for component
498 $LFS setstripe -E 1M -S 1M -c 2 -o 0,1 -E 2M -c 2 -o 1,2 \
499 -E 3M -c 2 -o 2,1 -E 4M -c 1 -i 2 -E -1 $file ||
500 error "Create $file failed"
502 # clear lod component cache
503 stop $SINGLEMDS || error "stop MDS"
504 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
505 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "start MDS"
507 # instantiate all components
508 $TRUNCATE $file $((1024*1024*4+1))
510 #verify object alloc order
511 local o1=$($LFS getstripe -I1 $file |
512 awk '/l_ost_idx:/ {printf("%d",$5)}')
513 [[ $o1 != "01" ]] && error "$o1 is not 01"
515 local o2=$($LFS getstripe -I2 $file |
516 awk '/l_ost_idx:/ {printf("%d",$5)}')
517 [[ $o2 != "12" ]] && error "$o2 is not 12"
519 local o3=$($LFS getstripe -I3 $file |
520 awk '/l_ost_idx:/ {printf("%d",$5)}')
521 [[ $o3 != "21" ]] && error "$o3 is not 21"
523 local o4=$($LFS getstripe -I4 $file |
524 awk '/l_ost_idx:/ {printf("%d",$5)}')
525 [[ $o4 != "2" ]] && error "$o4 is not 2"
529 run_test 12 "Verify ost list specification"
531 test_13() { # LU-9311
532 [ $OSTCOUNT -lt 8 ] && skip "needs >= 8 OSTs"
534 local file=$DIR/$tfile
536 local dd_size=$(($dd_count * 1024 * 1024))
540 $LFS setstripe -E 1M -S 1M -c 1 -E 2M -c 2 -E -1 -c -1 -i 1 $file ||
541 error "Create $file failed"
542 dd if=/dev/zero of=$file bs=1M count=$dd_count
543 real_size=$(stat -c %s $file)
544 [ $real_size -eq $dd_size ] ||
545 error "dd actually wrote $real_size != $dd_size bytes"
549 run_test 13 "shouldn't reprocess granted resent request"
552 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
553 local file=$DIR/$tdir/$tfile
554 test_mkdir -p $DIR/$tdir
557 $LFS setstripe -E1m -c1 -S1m --pool="pool1" -E2m \
558 -E4m -c2 -S2m --pool="pool2" -E-1 $file ||
559 error "Create $file failed"
561 # check --pool inheritance
563 pool="$($LFS getstripe -I2 --pool $file)"
564 [ x"$pool" != "xpool1" ] && $LFS getstripe -I2 $file &&
565 error "$file: component 2 doesn't have poolname pool1"
566 pool="$($LFS getstripe -I4 --pool $file)"
567 [ x"$pool" != "xpool2" ] && $LFS getstripe -I4 $file &&
568 error "$file: component 4 doesn't have poolname pool2"
570 #check --stripe-count inheritance
572 count="$($LFS getstripe -I2 -c $file)"
573 [ $count -ne 1 ] && $LFS getstripe -I2 $file &&
574 error "$file: component 2 doesn't have 1 stripe_count"
575 count="$($LFS getstripe -I4 -c $file)"
576 [ $count -ne 2 ] && $LFS getstripe -I4 $file &&
577 error "$file: component 4 doesn't have 2 stripe_count"
579 #check --stripe-size inheritance
581 size="$($LFS getstripe -I2 -S $file)"
582 [ $size -ne $((1024*1024)) ] && $LFS getstripe -I2 $file &&
583 error "$file: component 2 doesn't have 1M stripe_size"
584 size="$($LFS getstripe -I4 -S $file)"
585 [ $size -ne $((1024*1024*2)) ] && $LFS getstripe -I4 $file &&
586 error "$file: component 4 doesn't have 2M stripe_size"
590 run_test 14 "Verify setstripe poolname/stripe_count/stripe_size inheritance"
593 local parent=$DIR/$tdir
598 $LFS setstripe -d $parent || error "delete default layout"
600 $LFS setstripe -E 1M -S 1M -E 10M -E eof $parent/f1 || error "create f1"
601 $LFS setstripe -E 4M -E 20M -E eof $parent/f2 || error "create f2"
602 test_mkdir $parent/subdir
603 $LFS setstripe -E 6M -S 1M -E 30M -E eof $parent/subdir ||
604 error "setstripe to subdir"
605 $LFS setstripe -E 8M -E eof $parent/subdir/f3 || error "create f3"
606 $LFS setstripe -c 1 $parent/subdir/f4 || error "create f4"
609 local found=$($LFS find --component-start +2M -E -15M $parent | wc -l)
610 [ $found -eq 0 ] || error "start+2M, end-15M, $found != 0"
613 found=$($LFS find --component-start +2M -E -35M $parent | wc -l)
614 [ $found -eq 2 ] || error "start+2M, end-35M, $found != 2"
617 found=$($LFS find --component-start +4M -E -eof $parent | wc -l)
618 [ $found -eq 1 ] || error "start+4M, end-eof, $found != 1"
620 local flg_opts="--component-flags init"
622 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
624 error "before write: start=1M, end=10M, flag=init, $found != 0"
626 dd if=/dev/zero of=$parent/f1 bs=1M count=2 ||
627 error "dd $parent/f1 failed"
630 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
632 error "after write: start=1M, end=10M, flag=init, $found != 1"
634 local ext_opts="--component-start -1M -E +5M"
635 # parent, subdir, f3, f4
636 found=$($LFS find $ext_opts $parent | wc -l)
637 [ $found -eq 4 ] || error "start-1M, end+5M, $found != 4"
639 local cnt_opts="--component-count +2"
641 found=$($LFS find $ext_opts $cnt_opts $parent | wc -l)
642 [ $found -eq 1 ] || error "start-1M, end+5M, count+2, $found != 1"
645 found=$($LFS find $ext_opts $cnt_opts $flg_opts $parent | wc -l)
647 error "start-1M, end+5M, count+2, flag=init, $found != 0"
650 found=$($LFS find $ext_opts ! $cnt_opts $flg_opts $parent | wc -l)
652 error "start-1M, end+5M, !count+2, flag=init, $found != 2"
654 run_test 15 "Verify component options for lfs find"
662 echo "getstripe --yaml $src"
663 $LFS getstripe --yaml $src > $temp || error "getstripe $src failed"
664 echo "setstripe --yaml=$temp $dst"
665 $LFS setstripe --yaml=$temp $dst|| error "setstripe $dst failed"
668 local layout1=$(get_layout_param $src)
669 local layout2=$(get_layout_param $dst)
670 # compare their layout info
671 [ "$layout1" == "$layout2" ] ||
672 error "$msg_prefix $src/$dst layouts are not equal"
676 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
678 local file=$DIR/$tdir/$tfile
679 local dir=$DIR/$tdir/dir
680 local temp=$DIR/$tdir/template
682 test_mkdir $DIR/$tdir
684 #####################################################################
686 # set stripe for source file
687 $LFS setstripe -E1m -S 1M -c2 -o0,1 -E2m -c2 -E3m -o1,0 -E4m -c1 -E-1 \
688 $file || error "Create $file failed"
691 verify_16 $file $file.copy $temp "1. PFL file"
693 #####################################################################
695 # set stripe for source file
697 $LFS setstripe -c2 -o0,1 -i1 $file || error "Create $file failed"
701 verify_16 $file $file.copy $temp "2. plain file"
703 #####################################################################
705 # set stripe for source dir
707 $LFS setstripe -E1m -S 1M -c2 -E2m -c1 -E-1 $dir ||
708 error "setstripe $dir failed"
712 verify_16 $dir $dir.copy $temp.dir "3. PFL dir"
714 #####################################################################
716 # set stripe for source dir
717 $LFS setstripe -c2 -i-1 $dir || error "setstripe $dir failed"
720 verify_16 $dir $dir.copy $temp.dir "4. plain dir"
722 run_test 16 "Verify setstripe/getstripe with YAML config file"
725 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
726 local file=$DIR/$tdir/$tfile
727 test_mkdir -p $DIR/$tdir
730 $LFS setstripe -E 1M -S 1M -E 2M -c 2 -E -1 -c -1 $file ||
731 error "Create $file failed"
733 local s1=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
734 local s2=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
735 local s3=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
736 echo "1st init: comp size 1:$s1 2:$s2 3:$s3"
739 $TRUNCATE $file $((1024*1024+1))
740 local s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
741 local s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
742 echo "2nd init: comp size 1:$s1n 2:$s2n 3:$s3"
744 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
745 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
748 $TRUNCATE $file $((1024*1024*2+1))
749 s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
750 s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
751 local s3n=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
752 echo "3rd init: comp size 1:$s1n 2:$s2n 3:$s3n"
754 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
755 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
756 [ $s3 -lt $s3n ] || error "3rd comp size $s3 should < $s3n"
758 run_test 17 "Verify LOVEA grows with more component inited"
760 check_distribution() {
764 local obj_min_one=$((OSTCOUNT - 1))
766 objs=$($LFS getstripe $file |
767 awk '/l_ost_idx:/ { print $5 }' | wc -l)
768 let ave=$((objs / OSTCOUNT))
770 # collect objects per OST distribution
771 $LFS getstripe $file | awk '/l_ost_idx:/ { print $5 }' | tr -d "," |
772 (inuse=( $(for i in $(seq 0 $obj_min_one); do echo 0; done) )
774 let inuse[$O]=$((1 + ${inuse[$O]}))
777 # verify object distribution varies no more than +-1
778 for idx in $(seq 0 $obj_min_one); do
779 let dif=$((${inuse[$idx]} - ave))
781 if [ "$dif" -gt 1 ]; then
782 echo "OST${idx}: ${inuse[$idx]} objects"
783 error "bad distribution on OST${idx}"
789 local file1=$DIR/${tfile}-1
790 local file2=$DIR/${tfile}-2
791 local file3=$DIR/${tfile}-3
793 rm -f $file1 $file2 $file3
795 $LFS setstripe -E 1m -S 1m $file1 ||
796 error "Create $file1 failed"
797 $LFS setstripe -E 1m -S 1m $file2 ||
798 error "Create $file2 failed"
799 $LFS setstripe -E 1m -S 1m $file3 ||
800 error "Create $file3 failed"
802 local objs=$((OSTCOUNT+1))
803 for comp in $(seq 1 $OSTCOUNT); do
804 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file1 ||
805 error "Add component to $file1 failed 2"
806 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file2 ||
807 error "Add component to $file2 failed 2"
808 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file3 ||
809 error "Add component to $file3 failed 2"
812 $LFS setstripe --component-add -E -1 -c -1 $file1 ||
813 error "Add component to $file1 failed 3"
814 $LFS setstripe --component-add -E -1 -c -1 $file2 ||
815 error "Add component to $file2 failed 3"
816 $LFS setstripe --component-add -E -1 -c -1 $file3 ||
817 error "Add component to $file3 failed 3"
819 # Instantiate all components
820 dd if=/dev/urandom of=$file1 bs=1M count=$((objs+1)) ||
821 error "dd failed for $file1"
822 dd if=/dev/urandom of=$file2 bs=1M count=$((objs+1)) ||
823 error "dd failed for $file2"
824 dd if=/dev/urandom of=$file3 bs=1M count=$((objs+1)) ||
825 error "dd failed for $file3"
827 check_distribution $file1
828 check_distribution $file2
829 check_distribution $file3
832 run_test 18 "check component distribution"
835 check_and_cleanup_lustre