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 0a "Create full components file, no reused OSTs"
69 [[ $($LCTL get_param mdc.*.import |
70 grep "connect_flags:.*overstriping") ]] ||
71 skip "server does not support overstriping"
72 large_xattr_enabled || skip_env "no large xattr support"
74 local comp_file=$DIR/$tdir/$tfile
78 # Create file with 1.1*LOV_MAX_STRIPE_COUNT stripes should succeed
79 $LFS setstripe -E 1m -C $((LOV_MAX_STRIPE_COUNT / 10)) -E -1 \
80 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
81 error "Create $comp_file failed"
83 rm -f $comp_file || error "Delete $comp_file failed"
85 # Create file with 2*LOV_MAX_STRIPE_COUNT stripes should fail
86 $LFS setstripe -E 1m -C $LOV_MAX_STRIPE_COUNT -E -1 -C $LOV_MAX_STRIPE_COUNT \
87 $comp_file && error "Create $comp_file succeeded"
89 rm -f $comp_file || error "Delete $comp_file failed"
91 run_test 0b "Verify comp stripe count limits"
94 local comp_file=$DIR/$tdir/$tfile
95 local rw_len=$((3 * 1024 * 1024)) # 3M
100 $LFS setstripe -E 1m -S 1m -o 0 -E -1 -o 0 $comp_file ||
101 error "Create $comp_file failed"
103 #instantiate all components, so that objs are allocted
104 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
106 local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
107 local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
109 [ $ost_idx1 -ne $ost_idx2 ] && error "$ost_idx1 != $ost_idx2"
111 small_write $comp_file $rw_len || error "Verify RW failed"
113 rm -f $comp_file || error "Delete $comp_file failed"
115 run_test 1a "Create full components file, reused OSTs"
117 # test overstriping (>1 stripe/OST within a component)
119 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
120 [[ $($LCTL get_param mdc.*.import |
121 grep "connect_flags:.*overstriping") ]] ||
122 skip "server does not support overstriping"
124 local comp_file=$DIR/$tdir/$tfile
125 local rw_len=$((3 * 1024 * 1024)) # 3M
127 test_mkdir $DIR/$tdir
129 $LFS setstripe -E 1m -S 1m -o 0,0 -E -1 -o 1,1,0,0 $comp_file ||
130 error "Create $comp_file failed"
132 #instantiate all components, so that objs are allocted
133 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=1M
135 $LFS getstripe $comp_file
136 local OSTS_1=$($LFS getstripe -I1 $comp_file | grep -o 'l_ost_idx.*' |
137 awk -e '{print $2}' | tr "\n" "\0")
138 local OSTS_2=$($LFS getstripe -I2 $comp_file | grep -o 'l_ost_idx.*' |
139 awk -e '{print $2}' | tr "\n" "\0")
143 [ "$OSTS_1" = "0,0," ] || error "incorrect OSTs($OSTS_1) in component 1"
144 [ "$OSTS_2" = "1,1,0,0," ] ||
145 error "incorrect OSTs($OSTS_2) in component 2"
147 small_write $comp_file $rw_len || error "Verify RW failed"
149 rm -f $comp_file || error "Delete $comp_file failed"
151 run_test 1b "Create full components file, overstriping in components"
153 # test overstriping with max stripe count
155 [[ $($LCTL get_param mdc.*.import |
156 grep "connect_flags:.*overstriping") ]] ||
157 skip "server does not support overstriping"
158 large_xattr_enabled || skip_env "no large xattr support"
160 local comp_file=$DIR/$tdir/$tfile
161 local rw_len=$((3 * 1024 * 1024)) # 3M
163 test_mkdir $DIR/$tdir
165 $LFS setstripe -E 1m -C 10 -E 10M -C 100 -E -1 \
166 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
167 error "Create $comp_file failed"
169 # Seek & write in to last component so all objects are allocated
170 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=20000
172 local count=$($LFS getstripe -c -I1 $DIR/$tdir/$tfile)
173 [ $count -eq 10 ] || error "comp1 stripe count $count, should be 10"
174 count=$($LFS getstripe -c -I2 $DIR/$tdir/$tfile)
175 [ $count -eq 100 ] || error "comp2 stripe count $count, should be 100"
176 count=$($LFS getstripe -c -I3 $DIR/$tdir/$tfile)
177 [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
178 error "comp4 stripe count $count != $LOV_MAX_STRIPE_COUNT"
180 small_write $comp_file $rw_len || error "Verify RW failed"
182 rm -f $comp_file || error "Delete $comp_file failed"
184 run_test 1c "Test overstriping w/max stripe count"
187 local comp_file=$DIR/$tdir/$tfile
188 local rw_len=$((5 * 1024 * 1024)) # 5M
190 test_mkdir $DIR/$tdir
193 $LFS setstripe -E 1m -S 1m $comp_file ||
194 error "Create $comp_file failed"
196 local comp_cnt=$($LFS getstripe --component-count $comp_file)
197 [ $comp_cnt -ne 1 ] && error "component count $comp_cnt != 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 comp_cnt=$($LFS getstripe --component-count $comp_file)
213 [ $comp_cnt -ne 2 ] && error "component count $comp_cnt != 2"
215 $LFS setstripe --component-add -E -1 -c 3 $comp_file ||
216 error "Add last component to $comp_file failed"
218 comp_cnt=$($LFS getstripe --component-count $comp_file)
219 [ $comp_cnt -ne 3 ] && error "component count $comp_cnt != 3"
221 small_write $comp_file $rw_len || error "Verify RW failed"
223 rm -f $comp_file || error "Delete $comp_file failed"
225 run_test 2 "Add component to existing file"
227 del_comp_and_verify() {
234 if [ $id == "init" -o $id == "^init" ]; then
235 opt="--component-flags="
238 $LFS setstripe --component-del $opt$id $comp_file ||
239 error "Delete component $id from $comp_file failed"
241 local comp_cnt=$($LFS getstripe --component-count $comp_file)
242 if grep -q "has no stripe info" <<< "$comp_cnt" ; then
245 [ $comp_cnt -ne $left ] && error "$comp_cnt != $left"
247 $CHECKSTAT -s $size $comp_file || error "size != $size"
251 local comp_file=$DIR/$tdir/$tfile
253 test_mkdir $DIR/$tdir
256 $LFS setstripe -E 1M -S 1M -E 64M -c 2 -E -1 -c 3 $comp_file ||
257 error "Create $comp_file failed"
259 local comp_cnt=$($LFS getstripe --component-count $comp_file)
260 [ $comp_cnt -ne 3 ] && error "component count $comp_cnt != 3"
262 dd if=/dev/zero of=$comp_file bs=1M count=2
264 $LFS setstripe --component-del -I 2 $comp_file &&
265 error "Component deletion makes hole"
267 del_comp_and_verify $comp_file 3 2 $((2 * 1024 * 1024))
268 del_comp_and_verify $comp_file 2 1 $((1 * 1024 * 1024))
269 del_comp_and_verify $comp_file 1 0 0
271 rm -f $comp_file || error "Delete $comp_file failed"
273 $LFS setstripe -E 1M -S 1M -E 16M -E -1 $comp_file ||
274 error "Create second $comp_file failed"
276 del_comp_and_verify $comp_file "^init" 1 0
277 del_comp_and_verify $comp_file "init" 0 0
278 rm -f $comp_file || error "Delete second $comp_file failed"
281 run_test 3 "Delete component from existing file"
284 skip "Not supported in PFL"
285 # In PFL project, only LCME_FL_INIT is supported, and it can't
286 # be altered by application.
288 run_test 4 "Modify component flags in existing file"
291 local parent=$DIR/$tdir
292 local comp_file=$DIR/$tdir/$tfile
293 local subdir=$parent/subdir
298 # set default layout to parent directory
299 $LFS setstripe -E 64M -c 2 -i 0 -E -1 -c 4 -i 0 $parent ||
300 error "Set default layout to $parent failed"
302 # create file under parent
303 touch $comp_file || error "Create $comp_file failed"
304 local comp_cnt=$($LFS getstripe --component-count $comp_file)
305 [ $comp_cnt -ne 2 ] && error "file $comp_cnt != 2"
307 #instantiate all components, so that objs are allocted
308 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=65k
310 local ost_idx=$($LFS getstripe -I1 -i $comp_file)
311 [ $ost_idx -ne 0 ] &&
312 error "component 1 ost_idx $ost_idx != 0"
314 ost_idx=$($LFS getstripe -I2 -i $comp_file)
315 [ $ost_idx -ne 0 ] &&
316 error "component 2 ost_idx $ost_idx != 0"
318 # create subdir under parent
319 mkdir -p $subdir || error "Create subdir $subdir failed"
321 comp_cnt=$($LFS getstripe -d --component-count $subdir)
322 [ $comp_cnt -ne 2 ] && error "subdir $comp_cnt != 2"
324 # create file under subdir
325 touch $subdir/$tfile || error "Create $subdir/$tfile failed"
327 comp_cnt=$($LFS getstripe --component-count $subdir/$tfile)
328 [ $comp_cnt -ne 2 ] && error "$subdir/$tfile $comp_cnt != 2"
330 # delete default layout setting from parent
331 $LFS setstripe -d $parent ||
332 error "Delete default layout from $parent failed"
334 comp_cnt=$($LFS getstripe -d --component-count $parent)
335 [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0"
337 rm -f $comp_file || error "Delete $comp_file failed"
338 rm -f $subdir/$tfile || error "Delete $subdir/$tfile failed"
339 rm -r $subdir || error "Delete subdir $subdir failed"
340 rmdir $parent || error "Delete dir $parent failed"
342 run_test 5 "Inherit composite layout from parent directory"
345 local comp_file=$DIR/$tdir/$tfile
347 test_mkdir $DIR/$tdir
350 $LFS setstripe -c 1 -S 128K $comp_file ||
351 error "Create v1 $comp_file failed"
353 local comp_cnt=$($LFS getstripe --component-count $comp_file)
354 [ $comp_cnt -ne 0 ] && error "Wrong component count $comp_cnt"
356 dd if=/dev/urandom of=$comp_file bs=1M count=5 oflag=sync ||
357 error "Write to v1 $comp_file failed"
359 local old_chksum=$(md5sum $comp_file)
361 # Migrate v1 to composite
362 $LFS migrate -E 1M -S 512K -c 1 -E -1 -S 1M -c 2 $comp_file ||
363 error "Migrate(v1 -> composite) $comp_file failed"
365 comp_cnt=$($LFS getstripe --component-count $comp_file)
366 [ "$comp_cnt" -ne 2 ] && error "$comp_cnt != 2"
368 local chksum=$(md5sum $comp_file)
369 [ "$old_chksum" != "$chksum" ] &&
370 error "(v1 -> compsoite) $old_chksum != $chksum"
372 # Migrate composite to composite
373 $LFS migrate -E 1M -S 1M -c 2 -E 4M -S 1M -c 2 \
374 -E -1 -S 3M -c 3 $comp_file ||
375 error "Migrate(compsoite -> composite) $comp_file failed"
377 comp_cnt=$($LFS getstripe --component-count $comp_file)
378 [ "$comp_cnt" -ne 3 ] && error "$comp_cnt != 3"
380 chksum=$(md5sum $comp_file)
381 [ "$old_chksum" != "$chksum" ] &&
382 error "(composite -> compsoite) $old_chksum != $chksum"
384 # Migrate composite to v1
385 $LFS migrate -c 2 -S 2M $comp_file ||
386 error "Migrate(composite -> v1) $comp_file failed"
388 comp_cnt=$($LFS getstripe --component-count $comp_file)
389 [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0"
391 chksum=$(md5sum $comp_file)
392 [ "$old_chksum" != "$chksum" ] &&
393 error "(composite -> v1) $old_chksum != $chksum"
395 rm -f $comp_file || "Delete $comp_file failed"
397 run_test 6 "Migrate composite file"
400 test_mkdir $DIR/$tdir
401 chmod 0777 $DIR/$tdir || error "chmod $tdir failed"
403 local comp_file=$DIR/$tdir/$tfile
404 $RUNAS $LFS setstripe -E 1M -S 1M -c 1 $comp_file ||
405 error "Create composite file $comp_file failed"
407 $RUNAS $LFS setstripe --component-add -E 64M -c 4 $comp_file ||
408 error "Add component to $comp_file failed"
410 $RUNAS $LFS setstripe --component-del -I 2 $comp_file ||
411 error "Delete component from $comp_file failed"
413 $RUNAS $LFS setstripe --component-add -E -1 -c 5 $comp_file ||
414 error "Add last component to $comp_file failed"
416 rm $comp_file || "Delete composite failed"
418 run_test 7 "Add/Delete/Create composite file by non-privileged user"
421 local parent=$DIR/$tdir
426 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c 2 -S 2M \
427 -E -1 -c 4 -S 4M $parent ||
428 error "Set default layout to $parent failed"
430 sh rundbench -C -D $parent 2 || error "dbench failed"
432 rm -fr $parent || error "Delete dir $parent failed"
434 run_test 8 "Run dbench over composite files"
437 local comp_file=$DIR/$tdir/$tfile
439 test_mkdir $DIR/$tdir
442 $LFS setstripe -E 1M -S 1M -E -1 -c 1 $comp_file ||
443 error "Create $comp_file failed"
445 local comp_cnt=$($LFS getstripe --component-count $comp_file)
446 [ $comp_cnt -ne 2 ] && error "component count $comp_cnt != 2"
448 replay_barrier $SINGLEMDS
450 # instantiate the 2nd component
451 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
453 local f1=$($LFS getstripe -I2 $comp_file |
454 awk '/l_fid:/ {print $7}')
455 echo "before MDS recovery, the ost fid of 2nd component is $f1"
458 local f2=$($LFS getstripe -I2 $comp_file |
459 awk '/l_fid:/ {print $7}')
460 echo "after MDS recovery, the ost fid of 2nd component is $f2"
461 [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
463 run_test 9 "Replay layout extend object instantiation"
466 echo $($LFS getstripe $1 |
467 awk '$1 == "lcm_entry_count:" { printf("%d", $2) }
468 $1 == "lcme_extent.e_start:" { printf("[%#lx", $2) }
469 $1 == "lcme_extent.e_end:" { printf(",%s]", $2) }')
473 local parent=$DIR/$tdir
476 save_layout_restore_at_exit $MOUNT
480 # mount root on $MOUNT2 if FILESET is set
481 if [ -n "$FILESET" ]; then
482 FILESET="" mount_client $MOUNT2 ||
483 error "mount $MOUNT2 fail"
487 $LFS setstripe -d $root || error "clear root layout"
489 # set root composite layout
490 $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c2 -S 2M \
491 -E -1 -c 4 -S 4M $root ||
492 error "Set root layout failed"
494 if [ "$root" == "$MOUNT2" ]; then
495 umount_client $MOUNT2 ||
496 error "umount $MOUNT2 fail"
500 # set a different layout for parent
501 $LFS setstripe -E -1 -c 1 -S 1M $parent ||
502 error "set $parent layout failed"
505 local f1_entry=$(component_dump $parent/file1)
507 # delete parent's layout
508 $LFS setstripe -d $parent || error "Clear $parent layout failed"
511 local f2_entry=$(component_dump $parent/file2)
513 # verify layout inheritance
515 local f1_expect="1[0,EOF]"
516 local f2_expect="3[0,2097152][0x200000,16777216][0x1000000,EOF]"
518 echo "f1 expect=$f1_expect"
519 echo "f1 get =$f1_entry"
520 echo "f2 expect=$f2_expect"
521 echo "f2 get =$f2_entry"
523 [ x$f1_expect != x$f1_entry ] &&
524 error "$parent/file1 does not inherite parent layout"
525 [ x$f2_expect != x$f2_entry ] &&
526 error "$parent/file2 does not inherite root layout"
530 run_test 10 "Inherit composite template from root"
533 local comp_file=$DIR/$tdir/$tfile
534 test_mkdir $DIR/$tdir
537 # only 1st component instantiated
538 $LFS setstripe -E 1M -S 1M -E 2M -E 3M -E -1 $comp_file ||
539 error "Create $comp_file failed"
541 local f1=$($LFS getstripe -I1 $comp_file | grep "l_fid")
542 [[ -z $f1 ]] && error "1: 1st component uninstantiated"
543 local f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
544 [[ -n $f2 ]] && error "1: 2nd component instantiated"
545 local f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
546 [[ -n $f3 ]] && error "1: 3rd component instantiated"
547 local f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
548 [[ -n $f4 ]] && error "1: 4th component instantiated"
550 # the first 2 components instantiated
551 $TRUNCATE $comp_file $((1024*1024*1+1))
553 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
554 [[ -z $f2 ]] && error "2: 2nd component uninstantiated"
555 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
556 [[ -n $f3 ]] && error "2: 3rd component instantiated"
557 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
558 [[ -n $f4 ]] && error "2: 4th component instantiated"
560 # the first 3 components instantiated
561 $TRUNCATE $comp_file $((1024*1024*3))
562 $TRUNCATE $comp_file $((1024*1024*1+1))
564 f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
565 [[ -z $f2 ]] && error "3: 2nd component uninstantiated"
566 f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
567 [[ -z $f3 ]] && error "3: 3rd component uninstantiated"
568 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
569 [[ -n $f4 ]] && error "3: 4th component instantiated"
571 # all 4 components instantiated, using append write
572 dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
574 rwv -f $comp_file -w -a -n 2 $((1024*1023)) 1
577 f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
578 [[ -z $f4 ]] && error "4: 4th component uninstantiated"
582 run_test 11 "Verify component instantiation with write/truncate"
585 [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs"
587 local file=$DIR/$tdir/$tfile
588 test_mkdir $DIR/$tdir
591 # specify ost list for component
592 $LFS setstripe -E 1M -S 1M -c 2 -o 0,1 -E 2M -c 2 -o 1,2 \
593 -E 3M -c 2 -o 2,1 -E 4M -c 1 -i 2 -E -1 $file ||
594 error "Create $file failed"
596 # clear lod component cache
597 stop $SINGLEMDS || error "stop MDS"
598 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
599 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "start MDS"
601 # instantiate all components
602 $TRUNCATE $file $((1024*1024*4+1))
604 #verify object alloc order
605 local o1=$($LFS getstripe -I1 $file |
606 awk '/l_ost_idx:/ {printf("%d",$5)}')
607 [[ $o1 != "01" ]] && error "$o1 is not 01"
609 local o2=$($LFS getstripe -I2 $file |
610 awk '/l_ost_idx:/ {printf("%d",$5)}')
611 [[ $o2 != "12" ]] && error "$o2 is not 12"
613 local o3=$($LFS getstripe -I3 $file |
614 awk '/l_ost_idx:/ {printf("%d",$5)}')
615 [[ $o3 != "21" ]] && error "$o3 is not 21"
617 local o4=$($LFS getstripe -I4 $file |
618 awk '/l_ost_idx:/ {printf("%d",$5)}')
619 [[ $o4 != "2" ]] && error "$o4 is not 2"
623 run_test 12 "Verify ost list specification"
625 test_13() { # LU-9311
626 [ $OSTCOUNT -lt 8 ] && skip "needs >= 8 OSTs"
628 local file=$DIR/$tfile
630 local dd_size=$(($dd_count * 1024 * 1024))
634 $LFS setstripe -E 1M -S 1M -c 1 -E 2M -c 2 -E -1 -c -1 -i 1 $file ||
635 error "Create $file failed"
636 dd if=/dev/zero of=$file bs=1M count=$dd_count
637 real_size=$(stat -c %s $file)
638 [ $real_size -eq $dd_size ] ||
639 error "dd actually wrote $real_size != $dd_size bytes"
643 run_test 13 "shouldn't reprocess granted resent request"
646 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
647 local file=$DIR/$tdir/$tfile
648 test_mkdir -p $DIR/$tdir
651 $LFS setstripe -E1m -c1 -S1m --pool="pool1" -E2m \
652 -E4m -c2 -S2m --pool="pool2" -E-1 $file ||
653 error "Create $file failed"
655 # check --pool inheritance
657 pool="$($LFS getstripe -I2 --pool $file)"
658 [ x"$pool" != "xpool1" ] && $LFS getstripe -I2 $file &&
659 error "$file: component 2 doesn't have poolname pool1"
660 pool="$($LFS getstripe -I4 --pool $file)"
661 [ x"$pool" != "xpool2" ] && $LFS getstripe -I4 $file &&
662 error "$file: component 4 doesn't have poolname pool2"
664 #check --stripe-count inheritance
666 count="$($LFS getstripe -I2 -c $file)"
667 [ $count -ne 1 ] && $LFS getstripe -I2 $file &&
668 error "$file: component 2 doesn't have 1 stripe_count"
669 count="$($LFS getstripe -I4 -c $file)"
670 [ $count -ne 2 ] && $LFS getstripe -I4 $file &&
671 error "$file: component 4 doesn't have 2 stripe_count"
673 #check --stripe-size inheritance
675 size="$($LFS getstripe -I2 -S $file)"
676 [ $size -ne $((1024*1024)) ] && $LFS getstripe -I2 $file &&
677 error "$file: component 2 doesn't have 1M stripe_size"
678 size="$($LFS getstripe -I4 -S $file)"
679 [ $size -ne $((1024*1024*2)) ] && $LFS getstripe -I4 $file &&
680 error "$file: component 4 doesn't have 2M stripe_size"
684 run_test 14 "Verify setstripe poolname/stripe_count/stripe_size inheritance"
687 local parent=$DIR/$tdir
692 $LFS setstripe -d $parent || error "delete default layout"
694 $LFS setstripe -E 1M -S 1M -E 10M -E eof $parent/f1 || error "create f1"
695 $LFS setstripe -E 4M -E 20M -E eof $parent/f2 || error "create f2"
696 test_mkdir $parent/subdir
697 $LFS setstripe -E 6M -S 1M -E 30M -E eof $parent/subdir ||
698 error "setstripe to subdir"
699 $LFS setstripe -E 8M -E eof $parent/subdir/f3 || error "create f3"
700 $LFS setstripe -c 1 $parent/subdir/f4 || error "create f4"
703 local found=$($LFS find --component-start +2M -E -15M $parent | wc -l)
704 [ $found -eq 0 ] || error "start+2M, end-15M, $found != 0"
707 found=$($LFS find --component-start +2M -E -35M $parent | wc -l)
708 [ $found -eq 2 ] || error "start+2M, end-35M, $found != 2"
711 found=$($LFS find --component-start +4M -E -eof $parent | wc -l)
712 [ $found -eq 1 ] || error "start+4M, end-eof, $found != 1"
714 local flg_opts="--component-flags init"
716 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
718 error "before write: start=1M, end=10M, flag=init, $found != 0"
720 dd if=/dev/zero of=$parent/f1 bs=1M count=2 ||
721 error "dd $parent/f1 failed"
724 found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
726 error "after write: start=1M, end=10M, flag=init, $found != 1"
728 local ext_opts="--component-start -1M -E +5M"
729 # parent, subdir, f3, f4
730 found=$($LFS find $ext_opts $parent | wc -l)
731 [ $found -eq 4 ] || error "start-1M, end+5M, $found != 4"
733 local cnt_opts="--component-count +2"
735 found=$($LFS find $ext_opts $cnt_opts $parent | wc -l)
736 [ $found -eq 1 ] || error "start-1M, end+5M, count+2, $found != 1"
739 found=$($LFS find $ext_opts $cnt_opts $flg_opts $parent | wc -l)
741 error "start-1M, end+5M, count+2, flag=init, $found != 0"
744 found=$($LFS find $ext_opts ! $cnt_opts $flg_opts $parent | wc -l)
746 error "start-1M, end+5M, !count+2, flag=init, $found != 2"
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"
860 local file=$DIR/$tdir/$tfile
861 test_mkdir -p $DIR/$tdir
864 $LFS setstripe -E 1M -S 1M -E 2M -c 2 -E -1 -c -1 $file ||
865 error "Create $file failed"
867 local s1=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
868 local s2=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
869 local s3=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
870 echo "1st init: comp size 1:$s1 2:$s2 3:$s3"
873 $TRUNCATE $file $((1024*1024+1))
874 local s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
875 local s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
876 echo "2nd init: comp size 1:$s1n 2:$s2n 3:$s3"
878 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
879 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
882 $TRUNCATE $file $((1024*1024*2+1))
883 s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
884 s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
885 local s3n=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
886 echo "3rd init: comp size 1:$s1n 2:$s2n 3:$s3n"
888 [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
889 [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
890 [ $s3 -lt $s3n ] || error "3rd comp size $s3 should < $s3n"
892 run_test 17 "Verify LOVEA grows with more component inited"
894 check_distribution() {
898 local obj_min_one=$((OSTCOUNT - 1))
900 objs=$($LFS getstripe $file |
901 awk '/l_ost_idx:/ { print $5 }' | wc -l)
902 let ave=$((objs / OSTCOUNT))
904 # collect objects per OST distribution
905 $LFS getstripe $file | awk '/l_ost_idx:/ { print $5 }' | tr -d "," |
906 (inuse=( $(for i in $(seq 0 $obj_min_one); do echo 0; done) )
908 let inuse[$O]=$((1 + ${inuse[$O]}))
911 # verify object distribution varies no more than +-1
912 for idx in $(seq 0 $obj_min_one); do
913 let dif=$((${inuse[$idx]} - ave))
915 if [ "$dif" -gt 1 ]; then
916 echo "OST${idx}: ${inuse[$idx]} objects"
917 error "bad distribution on OST${idx}"
923 local file1=$DIR/${tfile}-1
924 local file2=$DIR/${tfile}-2
925 local file3=$DIR/${tfile}-3
927 rm -f $file1 $file2 $file3
929 $LFS setstripe -E 1m -S 1m $file1 ||
930 error "Create $file1 failed"
931 $LFS setstripe -E 1m -S 1m $file2 ||
932 error "Create $file2 failed"
933 $LFS setstripe -E 1m -S 1m $file3 ||
934 error "Create $file3 failed"
936 local objs=$((OSTCOUNT+1))
937 for comp in $(seq 1 $OSTCOUNT); do
938 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file1 ||
939 error "Add component to $file1 failed 2"
940 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file2 ||
941 error "Add component to $file2 failed 2"
942 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file3 ||
943 error "Add component to $file3 failed 2"
946 $LFS setstripe --component-add -E -1 -c -1 $file1 ||
947 error "Add component to $file1 failed 3"
948 $LFS setstripe --component-add -E -1 -c -1 $file2 ||
949 error "Add component to $file2 failed 3"
950 $LFS setstripe --component-add -E -1 -c -1 $file3 ||
951 error "Add component to $file3 failed 3"
953 # Instantiate all components
954 dd if=/dev/urandom of=$file1 bs=1M count=$((objs+1)) ||
955 error "dd failed for $file1"
956 dd if=/dev/urandom of=$file2 bs=1M count=$((objs+1)) ||
957 error "dd failed for $file2"
958 dd if=/dev/urandom of=$file3 bs=1M count=$((objs+1)) ||
959 error "dd failed for $file3"
961 check_distribution $file1
962 check_distribution $file2
963 check_distribution $file3
966 run_test 18 "check component distribution"
969 check_and_cleanup_lustre