Whamcloud - gitweb
372f9ba506880100c4b61a4af62ad14a58af0fbb
[fs/lustre-release.git] / lustre / tests / sanity-pfl.sh
1 #!/bin/bash
2 #
3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
5 set -e
6
7 SRCDIR=$(dirname $0)
8 export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
9
10 ONLY=${ONLY:-"$*"}
11 # Bug number for skipped test:
12 ALWAYS_EXCEPT="$SANITY_PFL_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
14
15 [ "$ALWAYS_EXCEPT$EXCEPT" ] &&
16         echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
17
18 TMP=${TMP:-/tmp}
19 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
20
21 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
22 . $LUSTRE/tests/test-framework.sh
23 init_test_env $@
24 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
25 init_logging
26
27 check_and_setup_lustre
28
29 if [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.51) ]]; then
30         skip_env "Need MDS version at least 2.9.51" && exit
31 fi
32
33 build_test_filter
34
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
38
39 test_0() {
40         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
41
42         local comp_file=$DIR/$tdir/$tfile
43         local rw_len=$((3 * 1024 * 1024))       # 3M
44
45         test_mkdir $DIR/$tdir
46         rm -f $comp_file
47
48         $LFS setstripe -E 1m -S 1M -c 1 -E -1 -c 1 $comp_file ||
49                 error "Create $comp_file failed"
50
51         #instantiate all components, so that objs are allocted
52         dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
53
54         local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
55         local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
56
57         [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
58
59         small_write $comp_file $rw_len || error "Verify RW failed"
60
61         rm -f $comp_file || error "Delete $comp_file failed"
62 }
63 run_test 0 "Create full components file, no reused OSTs"
64
65 test_1() {
66         local comp_file=$DIR/$tdir/$tfile
67         local rw_len=$((3 * 1024 * 1024))       # 3M
68
69         test_mkdir $DIR/$tdir
70         rm -f $comp_file
71
72         $LFS setstripe -E 1m -S 1m -o 0 -E -1 -o 0 $comp_file ||
73                 error "Create $comp_file failed"
74
75         #instantiate all components, so that objs are allocted
76         dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
77
78         local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
79         local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
80
81         [ $ost_idx1 -ne $ost_idx2 ] && error "$ost_idx1 != $ost_idx2"
82
83         small_write $comp_file $rw_len || error "Verify RW failed"
84
85         rm -f $comp_file || error "Delete $comp_file failed"
86 }
87 run_test 1 "Create full components file, reused OSTs"
88
89 test_2() {
90         local comp_file=$DIR/$tdir/$tfile
91         local rw_len=$((5 * 1024 * 1024))       # 5M
92
93         test_mkdir $DIR/$tdir
94         rm -f $comp_file
95
96         $LFS setstripe -E 1m -S 1m $comp_file ||
97                 error "Create $comp_file failed"
98
99         local comp_cnt=$($LFS getstripe --component-count $comp_file)
100         [ $comp_cnt -ne 1 ] && error "component count $comp_cnt != 1"
101
102         dd if=/dev/zero of=$comp_file bs=1M count=1 > /dev/null 2>&1 ||
103                 error "Write first component failed"
104         dd if=$comp_file of=/dev/null bs=1M count=1 > /dev/null 2>&1 ||
105                 error "Read first component failed"
106
107         dd if=/dev/zero of=$comp_file bs=1M count=2 > /dev/null 2>&1 &&
108                 error "Write beyond component should fail"
109         dd if=$comp_file of=/dev/null bs=1M count=2 > /dev/null 2>&1 ||
110                 error "Read beyond component should short read, not fail"
111
112         $LFS setstripe --component-add -E 2M -c 1 $comp_file ||
113                 error "Add component to $comp_file failed"
114
115         comp_cnt=$($LFS getstripe --component-count $comp_file)
116         [ $comp_cnt -ne 2 ] && error "component count $comp_cnt != 2"
117
118         $LFS setstripe --component-add -E -1 -c 3 $comp_file ||
119                 error "Add last component to $comp_file failed"
120
121         comp_cnt=$($LFS getstripe --component-count $comp_file)
122         [ $comp_cnt -ne 3 ] && error "component count $comp_cnt != 3"
123
124         small_write $comp_file $rw_len || error "Verify RW failed"
125
126         rm -f $comp_file || error "Delete $comp_file failed"
127 }
128 run_test 2 "Add component to existing file"
129
130 del_comp_and_verify() {
131         local comp_file=$1
132         local id=$2
133         local left=$3
134         local size=$4
135
136         local opt="-I "
137         if [ $id == "init" -o $id == "^init" ]; then
138                 opt="--component-flags="
139         fi
140
141         $LFS setstripe --component-del $opt$id $comp_file ||
142                 error "Delete component $id from $comp_file failed"
143
144         local comp_cnt=$($LFS getstripe --component-count $comp_file)
145         if grep -q "has no stripe info" <<< "$comp_cnt" ; then
146                 comp_cnt=0
147         fi
148         [ $comp_cnt -ne $left ] && error "$comp_cnt != $left"
149
150         $CHECKSTAT -s $size $comp_file || error "size != $size"
151 }
152
153 test_3() {
154         local comp_file=$DIR/$tdir/$tfile
155
156         test_mkdir $DIR/$tdir
157         rm -f $comp_file
158
159         $LFS setstripe -E 1M -E 64M -c 2 -E -1 -c 3 $comp_file ||
160                 error "Create $comp_file failed"
161
162         local comp_cnt=$($LFS getstripe --component-count $comp_file)
163         [ $comp_cnt -ne 3 ] && error "component count $comp_cnt != 3"
164
165         dd if=/dev/zero of=$comp_file bs=1M count=2
166
167         $LFS setstripe --component-del -I 2 $comp_file &&
168                 error "Component deletion makes hole"
169
170         del_comp_and_verify $comp_file 3 2 $((2 * 1024 * 1024))
171         del_comp_and_verify $comp_file 2 1 $((1 * 1024 * 1024))
172         del_comp_and_verify $comp_file 1 0 0
173
174         rm -f $comp_file || error "Delete $comp_file failed"
175
176         $LFS setstripe -E 1M -E 16M -E -1 $comp_file ||
177                 error "Create second $comp_file failed"
178
179         del_comp_and_verify $comp_file "^init" 1 0
180         del_comp_and_verify $comp_file "init" 0 0
181         rm -f $comp_file || error "Delete second $comp_file failed"
182
183 }
184 run_test 3 "Delete component from existing file"
185
186 test_4() {
187         skip "Not supported in PFL" && return
188         # In PFL project, only LCME_FL_INIT is supported, and it can't
189         # be altered by application.
190 }
191 run_test 4 "Modify component flags in existing file"
192
193 test_5() {
194         local parent=$DIR/$tdir
195         local comp_file=$DIR/$tdir/$tfile
196         local subdir=$parent/subdir
197
198         rm -fr $parent
199         test_mkdir $parent
200
201         # set default layout to parent directory
202         $LFS setstripe -E 64M -c 2 -i 0 -E -1 -c 4 -i 0 $parent ||
203                 error "Set default layout to $parent failed"
204
205         # create file under parent
206         touch $comp_file || error "Create $comp_file failed"
207         local comp_cnt=$($LFS getstripe --component-count $comp_file)
208         [ $comp_cnt -ne 2 ] && error "file $comp_cnt != 2"
209
210         #instantiate all components, so that objs are allocted
211         dd if=/dev/zero of=$comp_file bs=1k count=1 seek=65k
212
213         local ost_idx=$($LFS getstripe -I1 -i $comp_file)
214         [ $ost_idx -ne 0 ] &&
215                 error "component 1 ost_idx $ost_idx != 0"
216
217         ost_idx=$($LFS getstripe -I2 -i $comp_file)
218         [ $ost_idx -ne 0 ] &&
219                 error "component 2 ost_idx $ost_idx != 0"
220
221         # create subdir under parent
222         mkdir -p $subdir || error "Create subdir $subdir failed"
223
224         comp_cnt=$($LFS getstripe -d --component-count $subdir)
225         [ $comp_cnt -ne 2 ] && error "subdir $comp_cnt != 2"
226
227         # create file under subdir
228         touch $subdir/$tfile || error "Create $subdir/$tfile failed"
229
230         comp_cnt=$($LFS getstripe --component-count $subdir/$tfile)
231         [ $comp_cnt -ne 2 ] && error "$subdir/$tfile $comp_cnt != 2"
232
233         # delete default layout setting from parent
234         $LFS setstripe -d $parent ||
235                 error "Delete default layout from $parent failed"
236
237         comp_cnt=$($LFS getstripe -d --component-count $parent)
238         [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0"
239
240         rm -f $comp_file || error "Delete $comp_file failed"
241         rm -f $subdir/$tfile || error "Delete $subdir/$tfile failed"
242         rm -r $subdir || error "Delete subdir $subdir failed"
243         rmdir $parent || error "Delete dir $parent failed"
244 }
245 run_test 5 "Inherit composite layout from parent directory"
246
247 test_6() {
248         local comp_file=$DIR/$tdir/$tfile
249
250         test_mkdir $DIR/$tdir
251         rm -f $DIR/$tfile
252
253         $LFS setstripe -c 1 -S 128K $comp_file ||
254                 error "Create v1 $comp_file failed"
255
256         local comp_cnt=$($LFS getstripe --component-count $comp_file)
257         [ $comp_cnt -ne 0 ] && error "Wrong component count $comp_cnt"
258
259         dd if=/dev/urandom of=$comp_file bs=1M count=5 oflag=sync ||
260                 error "Write to v1 $comp_file failed"
261
262         local old_chksum=$(md5sum $comp_file)
263
264         # Migrate v1 to composite
265         $LFS migrate -E 1M -S 512K -c 1 -E -1 -S 1M -c 2 $comp_file ||
266                 error "Migrate(v1 -> composite) $comp_file failed"
267
268         comp_cnt=$($LFS getstripe --component-count $comp_file)
269         [ "$comp_cnt" -ne 2 ] && error "$comp_cnt != 2"
270
271         local chksum=$(md5sum $comp_file)
272         [ "$old_chksum" != "$chksum" ] &&
273                 error "(v1 -> compsoite) $old_chksum != $chksum"
274
275         # Migrate composite to composite
276         $LFS migrate -E 1M -S 1M -c 2 -E 4M -S 1M -c 2 \
277                 -E -1 -S 3M -c 3 $comp_file ||
278                 error "Migrate(compsoite -> composite) $comp_file failed"
279
280         comp_cnt=$($LFS getstripe --component-count $comp_file)
281         [ "$comp_cnt" -ne 3 ] && error "$comp_cnt != 3"
282
283         chksum=$(md5sum $comp_file)
284         [ "$old_chksum" != "$chksum" ] &&
285                 error "(composite -> compsoite) $old_chksum != $chksum"
286
287         # Migrate composite to v1
288         $LFS migrate -c 2 -S 2M $comp_file ||
289                 error "Migrate(composite -> v1) $comp_file failed"
290
291         comp_cnt=$($LFS getstripe --component-count $comp_file)
292         [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0"
293
294         chksum=$(md5sum $comp_file)
295         [ "$old_chksum" != "$chksum" ] &&
296                 error "(composite -> v1) $old_chksum != $chksum"
297
298         rm -f $comp_file || "Delete $comp_file failed"
299 }
300 run_test 6 "Migrate composite file"
301
302 test_7() {
303         test_mkdir $DIR/$tdir
304         chmod 0777 $DIR/$tdir || error "chmod $tdir failed"
305
306         local comp_file=$DIR/$tdir/$tfile
307         $RUNAS $LFS setstripe -E 1M -c 1 $comp_file ||
308                 error "Create composite file $comp_file failed"
309
310         $RUNAS $LFS setstripe --component-add -E 64M -c 4 $comp_file ||
311                 error "Add component to $comp_file failed"
312
313         $RUNAS $LFS setstripe --component-del -I 2 $comp_file ||
314                 error "Delete component from $comp_file failed"
315
316         $RUNAS $LFS setstripe --component-add -E -1 -c 5 $comp_file ||
317                 error "Add last component to $comp_file failed"
318
319         rm $comp_file || "Delete composite failed"
320 }
321 run_test 7 "Add/Delete/Create composite file by non-privileged user"
322
323 test_8() {
324         local parent=$DIR/$tdir
325
326         rm -fr $parent
327         test_mkdir $parent
328
329         $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c 2 -S 2M \
330                 -E -1 -c 4 -S 4M $parent ||
331                 error "Set default layout to $parent failed"
332
333         sh rundbench -C -D $parent 2 || error "dbench failed"
334
335         rm -fr $parent || error "Delete dir $parent failed"
336 }
337 run_test 8 "Run dbench over composite files"
338
339 test_9() {
340         local comp_file=$DIR/$tdir/$tfile
341
342         test_mkdir $DIR/$tdir
343         rm -f $comp_file
344
345         $LFS setstripe -E 1m -S 1m -E 2M -c 1 $comp_file ||
346                 error "Create $comp_file failed"
347
348         local comp_cnt=$($LFS getstripe --component-count $comp_file)
349         [ $comp_cnt -ne 2 ] && error "component count $comp_cnt != 2"
350
351         replay_barrier $SINGLEMDS
352
353         # instantiate the 2nd component
354         dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
355
356         local f1=$($LFS getstripe -I2 $comp_file |
357                         awk '/l_fid:/ {print $7}')
358         echo "before MDS recovery, the ost fid of 2nd component is $f1"
359         fail $SINGLEMDS
360
361         local f2=$($LFS getstripe -I2 $comp_file |
362                         awk '/l_fid:/ {print $7}')
363         echo "after MDS recovery, the ost fid of 2nd component is $f2"
364         [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
365 }
366 run_test 9 "Replay layout extend object instantiation"
367
368 component_dump() {
369         echo $($LFS getstripe $1 |
370                 awk '$1 == "lcm_entry_count:" { printf("%d", $2) }
371                      $1 == "lcme_extent.e_start:" { printf("[%#lx", $2) }
372                      $1 == "lcme_extent.e_end:" { printf(",%s]", $2) }')
373 }
374
375 test_10() {
376         local parent=$DIR/$tdir
377         local root_layout=$(get_layout_param $MOUNT)
378
379         rm -rf $parent
380         $LFS setstripe -d $MOUNT || error "clear root layout"
381
382         # set root composite layout
383         $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c2 -S 2M \
384                 -E -1 -c 4 -S 4M $MOUNT ||
385                 error "Set root layout failed"
386
387         test_mkdir $parent
388         # set a different layout for parent
389         $LFS setstripe -E -1 -c 1 -S 1M $parent ||
390                 error "set $parent layout failed"
391         touch $parent/file1
392
393         local f1_entry=$(component_dump $parent/file1)
394
395         # delete parent's layout
396         $LFS setstripe -d $parent || error "Clear $parent layout failed"
397         touch $parent/file2
398
399         local f2_entry=$(component_dump $parent/file2)
400
401         # verify layout inheritance
402         local eof="EOF"
403         local f1_expect="1[0,EOF]"
404         local f2_expect="3[0,2097152][0x200000,16777216][0x1000000,EOF]"
405
406         echo "f1 expect=$f1_expect"
407         echo "f1 get   =$f1_entry"
408         echo "f2 expect=$f2_expect"
409         echo "f2 get   =$f2_entry"
410
411         [  x$f1_expect != x$f1_entry ] &&
412                 error "$parent/file1 does not inherite parent layout"
413         [  x$f2_expect != x$f2_entry ] &&
414                 error "$parent/file2 does not inherite root layout"
415
416         $LFS setstripe $root_layout $MOUNT
417         return 0
418 }
419 run_test 10 "Inherit composite template from root"
420
421 test_11() {
422         local comp_file=$DIR/$tdir/$tfile
423         test_mkdir $DIR/$tdir
424         rm -f $comp_file
425
426         # only 1st component instantiated
427         $LFS setstripe -E 1m -E 2m -E 3m -E -1 $comp_file ||
428                 error "Create $comp_file failed"
429
430         local f1=$($LFS getstripe -I1 $comp_file | grep "l_fid")
431         [[ -z $f1 ]] && error "1: 1st component uninstantiated"
432         local f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
433         [[ -n $f2 ]] && error "1: 2nd component instantiated"
434         local f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
435         [[ -n $f3 ]] && error "1: 3rd component instantiated"
436         local f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
437         [[ -n $f4 ]] && error "1: 4th component instantiated"
438
439         # the first 2 components instantiated
440         $TRUNCATE $comp_file $((1024*1024*1+1))
441
442         f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
443         [[ -z $f2 ]] && error "2: 2nd component uninstantiated"
444         f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
445         [[ -n $f3 ]] && error "2: 3rd component instantiated"
446         f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
447         [[ -n $f4 ]] && error "2: 4th component instantiated"
448
449         # the first 3 components instantiated
450         $TRUNCATE $comp_file $((1024*1024*3))
451         $TRUNCATE $comp_file $((1024*1024*1+1))
452
453         f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
454         [[ -z $f2 ]] && error "2: 2nd component uninstantiated"
455         f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
456         [[ -z $f3 ]] && error "3: 3rd component uninstantiated"
457         f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
458         [[ -n $f4 ]] && error "3: 4th component instantiated"
459
460         # all 4 components instantiated, using append write
461         dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
462         ls -l $comp_file
463         rwv -f $comp_file -w -a -n 2 $((1024*1023)) 1
464         ls -l $comp_file
465
466         f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
467         [[ -z $f4 ]] && error "4: 4th component uninstantiated"
468
469         return 0
470 }
471 run_test 11 "Verify component instantiation with write/truncate"
472
473 test_12() {
474         [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs" && return
475
476         local file=$DIR/$tdir/$tfile
477         test_mkdir $DIR/$tdir
478         rm -f $file
479
480         # specify ost list for component
481         $LFS setstripe -E1m -c2 -o0,1 -E2m -c2 -o1,2 -E3m -c2 -o2,1 \
482                 -E4m -c1 -i2 -E-1 $file ||
483                 error "Create $file failed"
484
485         # clear lod component cache
486         stop $SINGLEMDS || error "stop MDS"
487         local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
488         start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "start MDS"
489
490         # instantiate all components
491         $TRUNCATE $file $((1024*1024*4+1))
492
493         #verify object alloc order
494         local o1=$($LFS getstripe -I1 $file |
495                         awk '/l_ost_idx:/ {printf("%d",$5)}')
496         [[ $o1 != "01" ]] && error "$o1 is not 01"
497
498         local o2=$($LFS getstripe -I2 $file |
499                         awk '/l_ost_idx:/ {printf("%d",$5)}')
500         [[ $o2 != "12" ]] && error "$o2 is not 12"
501
502         local o3=$($LFS getstripe -I3 $file |
503                         awk '/l_ost_idx:/ {printf("%d",$5)}')
504         [[ $o3 != "21" ]] && error "$o3 is not 21"
505
506         local o4=$($LFS getstripe -I4 $file |
507                         awk '/l_ost_idx:/ {printf("%d",$5)}')
508         [[ $o4 != "2" ]] && error "$o4 is not 2"
509
510         return 0
511 }
512 run_test 12 "Verify ost list specification"
513
514 test_13() { # LU-9311
515         [ $OSTCOUNT -lt 8 ] && skip "needs >= 8 OSTs" && return
516
517         local file=$DIR/$tfile
518         local dd_count=4
519         local dd_size=$(($dd_count * 1024 * 1024))
520         local real_size
521
522         rm -f $file
523         $LFS setstripe -E 1M -c 1 -E 2M -c 2 -E -1 -c -1 -i 1 $file ||
524                 error "Create $file failed"
525         dd if=/dev/zero of=$file bs=1M count=$dd_count
526         real_size=$(stat -c %s $file)
527         [ $real_size -eq $dd_size ] ||
528                 error "dd actually wrote $real_size != $dd_size bytes"
529
530         rm -f $file
531 }
532 run_test 13 "shouldn't reprocess granted resent request"
533
534 test_14() {
535         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
536         local file=$DIR/$tdir/$tfile
537         test_mkdir -p $DIR/$tdir
538         rm -f $file
539
540         $LFS setstripe -E1m -c1 -S1m --pool="pool1" -E2m \
541                         -E4m -c2 -S2m --pool="pool2" -E-1 $file ||
542                 error "Create $file failed"
543
544         # check --pool inheritance
545         local pool
546         pool="$($LFS getstripe -I2 --pool $file)"
547         [ x"$pool" != "xpool1" ] && $LFS getstripe -I2 $file &&
548                 error "$file: component 2 doesn't have poolname pool1"
549         pool="$($LFS getstripe -I4 --pool $file)"
550         [ x"$pool" != "xpool2" ] && $LFS getstripe -I4 $file &&
551                 error "$file: component 4 doesn't have poolname pool2"
552
553         #check --stripe-count inheritance
554         local count
555         count="$($LFS getstripe -I2 -c $file)"
556         [ $count -ne 1 ] && $LFS getstripe -I2 $file &&
557                 error "$file: component 2 doesn't have 1 stripe_count"
558         count="$($LFS getstripe -I4 -c $file)"
559         [ $count -ne 2 ] && $LFS getstripe -I4 $file &&
560                 error "$file: component 4 doesn't have 2 stripe_count"
561
562         #check --stripe-size inheritance
563         local size
564         size="$($LFS getstripe -I2 -S $file)"
565         [ $size -ne $((1024*1024)) ] && $LFS getstripe -I2 $file &&
566                 error "$file: component 2 doesn't have 1M stripe_size"
567         size="$($LFS getstripe -I4 -S $file)"
568         [ $size -ne $((1024*1024*2)) ] && $LFS getstripe -I4 $file &&
569                 error "$file: component 4 doesn't have 2M stripe_size"
570
571         return 0
572 }
573 run_test 14 "Verify setstripe poolname/stripe_count/stripe_size inheritance"
574
575 test_15() {
576         local parent=$DIR/$tdir
577
578         rm -fr $parent
579         test_mkdir $parent
580
581         $LFS setstripe -d $parent || error "delete default layout"
582
583         $LFS setstripe -E 1M -E 10M -E eof $parent/f1 || error "create f1"
584         $LFS setstripe -E 4M -E 20M -E eof $parent/f2 || error "create f2"
585         test_mkdir $parent/subdir
586         $LFS setstripe -E 6M -E 30M -E eof $parent/subdir ||
587                 error "setstripe to subdir"
588         $LFS setstripe -E 8M -E eof $parent/subdir/f3 || error "create f3"
589         $LFS setstripe -c 1 $parent/subdir/f4 || error "create f4"
590
591         # none
592         local found=$($LFS find --component-start +2M -E -15M $parent | wc -l)
593         [ $found -eq 0 ] || error "start+2M, end-15M, $found != 0"
594
595         # f2, f3
596         found=$($LFS find --component-start +2M -E -35M $parent | wc -l)
597         [ $found -eq 2 ] || error "start+2M, end-35M, $found != 2"
598
599         # subdir
600         found=$($LFS find --component-start +4M -E -eof $parent | wc -l)
601         [ $found -eq 1 ] || error "start+4M, end-eof, $found != 1"
602
603         local flg_opts="--component-flags init"
604         # none
605         found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
606         [ $found -eq 0 ] ||
607                 error "before write: start=1M, end=10M, flag=init, $found != 0"
608
609         dd if=/dev/zero of=$parent/f1 bs=1M count=2 ||
610                 error "dd $parent/f1 failed"
611
612         # f1
613         found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
614         [ $found -eq 1 ] ||
615                 error "after write: start=1M, end=10M, flag=init, $found != 1"
616
617         local ext_opts="--component-start -1M -E +5M"
618         # parent, subdir, f3, f4
619         found=$($LFS find $ext_opts $parent | wc -l)
620         [ $found -eq 4 ] || error "start-1M, end+5M, $found != 4"
621
622         local cnt_opts="--component-count +2"
623         # subdir
624         found=$($LFS find $ext_opts $cnt_opts $parent | wc -l)
625         [ $found -eq 1 ] || error "start-1M, end+5M, count+2, $found != 1"
626
627         # none
628         found=$($LFS find $ext_opts $cnt_opts $flg_opts $parent | wc -l)
629         [ $found -eq 0 ] ||
630                 error "start-1M, end+5M, count+2, flag=init, $found != 0"
631
632         # f3, f4
633         found=$($LFS find $ext_opts ! $cnt_opts $flg_opts $parent | wc -l)
634         [ $found -eq 2 ] ||
635                 error "start-1M, end+5M, !count+2, flag=init, $found != 2"
636 }
637 run_test 15 "Verify component options for lfs find"
638
639 test_17() {
640         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
641         local file=$DIR/$tdir/$tfile
642         test_mkdir -p $DIR/$tdir
643         rm -f $file
644
645         $LFS setstripe -E1m -E2m -c2 -E-1 -c-1 $file ||
646                 error "Create $file failed"
647
648         local s1=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
649         local s2=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
650         local s3=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
651         echo "1st init: comp size 1:$s1 2:$s2 3:$s3"
652
653         # init 2nd component
654         $TRUNCATE $file $((1024*1024+1))
655         local s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
656         local s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
657         echo "2nd init: comp size 1:$s1n 2:$s2n 3:$s3"
658
659         [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
660         [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
661
662         # init 3rd component
663         $TRUNCATE $file $((1024*1024*2+1))
664         s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
665         s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
666         local s3n=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
667         echo "3rd init: comp size 1:$s1n 2:$s2n 3:$s3n"
668
669         [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
670         [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
671         [ $s3 -lt $s3n ] || error "3rd comp size $s3 should < $s3n"
672 }
673 run_test 17 "Verify LOVEA grows with more component inited"
674
675 complete $SECONDS
676 check_and_cleanup_lustre
677 exit_status