Whamcloud - gitweb
e83a9fe04ec6cc8dec737ce28fe0e95e5bc378de
[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 ONLY=${ONLY:-"$*"}
8
9 LUSTRE=${LUSTRE:-$(dirname $0)/..}
10 . $LUSTRE/tests/test-framework.sh
11 init_test_env $@
12 init_logging
13
14 # bug number for skipped test:
15 ALWAYS_EXCEPT="$SANITY_PFL_EXCEPT "
16 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
17
18 # Skip tests for PPC that fail frequently
19 if [[ $(uname -m) = ppc64 ]]; then
20         # bug number:    LU-13186 LU-13205 LU-13207 LU-13186
21         ALWAYS_EXCEPT+=" 14       16a      16b      17"
22 fi
23
24 build_test_filter
25
26 check_and_setup_lustre
27
28 if [[ "$MDS1_VERSION" -lt $(version_code 2.9.51) ]]; then
29         skip_env "Need MDS version at least 2.9.51"
30 fi
31
32 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
33         error "\$RUNAS_ID set to 0, but \$UID is also 0!"
34 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
35
36 assert_DIR
37 rm -rf $DIR/[Rdfs][0-9]*
38
39 test_0a() {
40         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
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 0a "Create full components file, no reused OSTs"
64
65 test_0b() {
66         [[ $($LCTL get_param mdc.*.import |
67                 grep "connect_flags:.*overstriping") ]] ||
68                 skip "server does not support overstriping"
69         large_xattr_enabled || skip_env "no large xattr support"
70
71         local comp_file=$DIR/$tdir/$tfile
72
73         test_mkdir $DIR/$tdir
74
75         # Create file with 1.1*LOV_MAX_STRIPE_COUNT stripes should succeed
76         $LFS setstripe -E 1m -C $((LOV_MAX_STRIPE_COUNT / 10)) -E -1 \
77                 -C $LOV_MAX_STRIPE_COUNT $comp_file ||
78         error "Create $comp_file failed"
79
80         rm -f $comp_file || error "Delete $comp_file failed"
81
82         # Create file with 2*LOV_MAX_STRIPE_COUNT stripes should fail
83         $LFS setstripe -E 1m -C $LOV_MAX_STRIPE_COUNT -E -1 -C $LOV_MAX_STRIPE_COUNT \
84                 $comp_file && error "Create $comp_file succeeded"
85
86         rm -f $comp_file || error "Delete $comp_file failed"
87 }
88 run_test 0b "Verify comp stripe count limits"
89
90 test_1a() {
91         local comp_file=$DIR/$tdir/$tfile
92         local rw_len=$((3 * 1024 * 1024))       # 3M
93
94         test_mkdir $DIR/$tdir
95         rm -f $comp_file
96
97         $LFS setstripe -E 1m -S 1m -o 0 -E -1 -o 0 $comp_file ||
98                 error "Create $comp_file failed"
99
100         #instantiate all components, so that objs are allocted
101         dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
102
103         local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
104         local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
105
106         [ $ost_idx1 -ne $ost_idx2 ] && error "$ost_idx1 != $ost_idx2"
107
108         small_write $comp_file $rw_len || error "Verify RW failed"
109
110         rm -f $comp_file || error "Delete $comp_file failed"
111 }
112 run_test 1a "Create full components file, reused OSTs"
113
114 # test overstriping (>1 stripe/OST within a component)
115 test_1b() {
116         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
117         [[ $($LCTL get_param mdc.*.import |
118                 grep "connect_flags:.*overstriping") ]] ||
119                 skip "server does not support overstriping"
120
121         local comp_file=$DIR/$tdir/$tfile
122         local rw_len=$((3 * 1024 * 1024))       # 3M
123
124         test_mkdir $DIR/$tdir
125
126         $LFS setstripe -E 1m -S 1m -o 0,0 -E -1 -o 1,1,0,0 $comp_file ||
127                 error "Create $comp_file failed"
128
129         #instantiate all components, so that objs are allocted
130         dd if=/dev/zero of=$comp_file bs=1k count=1 seek=1M
131
132         $LFS getstripe $comp_file
133         local OSTS_1=$($LFS getstripe -I1 $comp_file | grep -o 'l_ost_idx.*' |
134                       awk -e '{print $2}' | tr "\n" "\0")
135         local OSTS_2=$($LFS getstripe -I2 $comp_file | grep -o 'l_ost_idx.*' |
136                       awk -e '{print $2}' | tr "\n" "\0")
137
138         echo ":"$OSTS_1":"
139         echo ":"$OSTS_2":"
140         [ "$OSTS_1" = "0,0," ] || error "incorrect OSTs($OSTS_1) in component 1"
141         [ "$OSTS_2" = "1,1,0,0," ] ||
142                 error "incorrect OSTs($OSTS_2) in component 2"
143
144         small_write $comp_file $rw_len || error "Verify RW failed"
145
146         rm -f $comp_file || error "Delete $comp_file failed"
147 }
148 run_test 1b "Create full components file, overstriping in components"
149
150 # test overstriping with max stripe count
151 test_1c() {
152         [[ $($LCTL get_param mdc.*.import |
153                 grep "connect_flags:.*overstriping") ]] ||
154                 skip "server does not support overstriping"
155         large_xattr_enabled || skip_env "no large xattr support"
156
157         local comp_file=$DIR/$tdir/$tfile
158         local rw_len=$((3 * 1024 * 1024))       # 3M
159
160         test_mkdir $DIR/$tdir
161
162         $LFS setstripe -E 1m -C 10 -E 10M -C 100 -E -1 \
163             -C $LOV_MAX_STRIPE_COUNT $comp_file ||
164                 error "Create $comp_file failed"
165
166         # Seek & write in to last component so all objects are allocated
167         dd if=/dev/zero of=$comp_file bs=1k count=1 seek=20000
168
169         local count=$($LFS getstripe -c -I1 $DIR/$tdir/$tfile)
170         [ $count -eq 10 ] || error "comp1 stripe count $count, should be 10"
171         count=$($LFS getstripe -c -I2 $DIR/$tdir/$tfile)
172         [ $count -eq 100 ] || error "comp2 stripe count $count, should be 100"
173         count=$($LFS getstripe -c -I3 $DIR/$tdir/$tfile)
174         [ $count -eq $LOV_MAX_STRIPE_COUNT ] ||
175                 error "comp4 stripe count $count != $LOV_MAX_STRIPE_COUNT"
176
177         small_write $comp_file $rw_len || error "Verify RW failed"
178
179         rm -f $comp_file || error "Delete $comp_file failed"
180 }
181 run_test 1c "Test overstriping w/max stripe count"
182
183 test_2() {
184         local comp_file=$DIR/$tdir/$tfile
185         local rw_len=$((5 * 1024 * 1024))       # 5M
186
187         test_mkdir $DIR/$tdir
188         rm -f $comp_file
189
190         $LFS setstripe -E 1m -S 1m $comp_file ||
191                 error "Create $comp_file failed"
192
193         check_component_count $comp_file 1
194
195         dd if=/dev/zero of=$comp_file bs=1M count=1 > /dev/null 2>&1 ||
196                 error "Write first component failed"
197         dd if=$comp_file of=/dev/null bs=1M count=1 > /dev/null 2>&1 ||
198                 error "Read first component failed"
199
200         dd if=/dev/zero of=$comp_file bs=1M count=2 > /dev/null 2>&1 &&
201                 error "Write beyond component should fail"
202         dd if=$comp_file of=/dev/null bs=1M count=2 > /dev/null 2>&1 ||
203                 error "Read beyond component should short read, not fail"
204
205         $LFS setstripe --component-add -E 2M -S 1M -c 1 $comp_file ||
206                 error "Add component to $comp_file failed"
207
208         check_component_count $comp_file 2
209
210         $LFS setstripe --component-add -E -1 -c 3 $comp_file ||
211                 error "Add last component to $comp_file failed"
212
213         check_component_count $comp_file 3
214
215         small_write $comp_file $rw_len || error "Verify RW failed"
216
217         rm -f $comp_file || error "Delete $comp_file failed"
218 }
219 run_test 2 "Add component to existing file"
220
221 del_comp_and_verify() {
222         local comp_file=$1
223         local id=$2
224         local left=$3
225         local size=$4
226
227         local opt="-I "
228         if [ $id == "init" -o $id == "^init" ]; then
229                 opt="--component-flags="
230         fi
231
232         $LFS setstripe --component-del $opt$id $comp_file ||
233                 error "Delete component $id from $comp_file failed"
234
235         local comp_cnt=$($LFS getstripe --component-count $comp_file)
236         if grep -q "has no stripe info" <<< "$comp_cnt" ; then
237                 comp_cnt=0
238         fi
239         [ $comp_cnt -ne $left ] && error "$comp_cnt != $left"
240
241         $CHECKSTAT -s $size $comp_file || error "size != $size"
242 }
243
244 test_3() {
245         local comp_file=$DIR/$tdir/$tfile
246
247         test_mkdir $DIR/$tdir
248         rm -f $comp_file
249
250         $LFS setstripe -E 1M -S 1M -E 64M -c 2 -E -1 -c 3 $comp_file ||
251                 error "Create $comp_file failed"
252
253         check_component_count $comp_file 3
254
255         dd if=/dev/zero of=$comp_file bs=1M count=2
256
257         $LFS setstripe --component-del -I 2 $comp_file &&
258                 error "Component deletion makes hole"
259
260         del_comp_and_verify $comp_file 3 2 $((2 * 1024 * 1024))
261         del_comp_and_verify $comp_file 2 1 $((1 * 1024 * 1024))
262         del_comp_and_verify $comp_file 1 0 0
263
264         rm -f $comp_file || error "Delete $comp_file failed"
265
266         $LFS setstripe -E 1M -S 1M -E 16M -E -1 $comp_file ||
267                 error "Create second $comp_file failed"
268
269         del_comp_and_verify $comp_file "^init" 1 0
270         del_comp_and_verify $comp_file "init" 0 0
271         rm -f $comp_file || error "Delete second $comp_file failed"
272
273 }
274 run_test 3 "Delete component from existing file"
275
276 test_4() {
277         skip "Not supported in PFL"
278         # In PFL project, only LCME_FL_INIT is supported, and it can't
279         # be altered by application.
280 }
281 run_test 4 "Modify component flags in existing file"
282
283 test_5() {
284         local parent=$DIR/$tdir
285         local comp_file=$DIR/$tdir/$tfile
286         local subdir=$parent/subdir
287
288         rm -fr $parent
289         test_mkdir $parent
290
291         # set default layout to parent directory
292         $LFS setstripe -E 64M -c 2 -i 0 -E -1 -c 4 -i 0 $parent ||
293                 error "Set default layout to $parent failed"
294
295         # create file under parent
296         touch $comp_file || error "Create $comp_file failed"
297         check_component_count $comp_file 2
298
299         #instantiate all components, so that objs are allocted
300         dd if=/dev/zero of=$comp_file bs=1k count=1 seek=65k
301
302         local ost_idx=$($LFS getstripe -I1 -i $comp_file)
303         [ $ost_idx -ne 0 ] &&
304                 error "component 1 ost_idx $ost_idx != 0"
305
306         ost_idx=$($LFS getstripe -I2 -i $comp_file)
307         [ $ost_idx -ne 0 ] &&
308                 error "component 2 ost_idx $ost_idx != 0"
309
310         # create subdir under parent
311         mkdir -p $subdir || error "Create subdir $subdir failed"
312
313         comp_cnt=$($LFS getstripe -d --component-count $subdir)
314         [ $comp_cnt -ne 2 ] && error "subdir $comp_cnt != 2"
315
316         # create file under subdir
317         touch $subdir/$tfile || error "Create $subdir/$tfile failed"
318
319         check_component_count $subdir/$tfile 2
320
321         # delete default layout setting from parent
322         $LFS setstripe -d $parent ||
323                 error "Delete default layout from $parent failed"
324
325         comp_cnt=$($LFS getstripe -d --component-count $parent)
326         [ $comp_cnt -ne 0 ] && error "$comp_cnt isn't 0"
327
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"
332 }
333 run_test 5 "Inherit composite layout from parent directory"
334
335 test_6() {
336         local comp_file=$DIR/$tdir/$tfile
337
338         test_mkdir $DIR/$tdir
339         rm -f $DIR/$tfile
340
341         $LFS setstripe -c 1 -S 128K $comp_file ||
342                 error "Create v1 $comp_file failed"
343
344         check_component_count $comp_file 0
345
346         dd if=/dev/urandom of=$comp_file bs=1M count=5 oflag=sync ||
347                 error "Write to v1 $comp_file failed"
348
349         local old_chksum=$(md5sum $comp_file)
350
351         # Migrate v1 to composite
352         $LFS migrate -E 1M -S 512K -c 1 -E -1 -S 1M -c 2 $comp_file ||
353                 error "Migrate(v1 -> composite) $comp_file failed"
354
355         check_component_count $comp_file 2
356
357         local chksum=$(md5sum $comp_file)
358         [ "$old_chksum" != "$chksum" ] &&
359                 error "(v1 -> compsoite) $old_chksum != $chksum"
360
361         # Migrate composite to composite
362         $LFS migrate -E 1M -S 1M -c 2 -E 4M -S 1M -c 2 \
363                 -E -1 -S 3M -c 3 $comp_file ||
364                 error "Migrate(compsoite -> composite) $comp_file failed"
365
366         check_component_count $comp_file 3
367
368         chksum=$(md5sum $comp_file)
369         [ "$old_chksum" != "$chksum" ] &&
370                 error "(composite -> compsoite) $old_chksum != $chksum"
371
372         # Migrate composite to v1
373         $LFS migrate -c 2 -S 2M $comp_file ||
374                 error "Migrate(composite -> v1) $comp_file failed"
375
376         check_component_count $comp_file 0
377
378         chksum=$(md5sum $comp_file)
379         [ "$old_chksum" != "$chksum" ] &&
380                 error "(composite -> v1) $old_chksum != $chksum"
381
382         rm -f $comp_file || "Delete $comp_file failed"
383 }
384 run_test 6 "Migrate composite file"
385
386 test_7() {
387         test_mkdir $DIR/$tdir
388         chmod 0777 $DIR/$tdir || error "chmod $tdir failed"
389
390         local comp_file=$DIR/$tdir/$tfile
391         $RUNAS $LFS setstripe -E 1M -S 1M -c 1 $comp_file ||
392                 error "Create composite file $comp_file failed"
393
394         $RUNAS $LFS setstripe --component-add -E 64M -c 4 $comp_file ||
395                 error "Add component to $comp_file failed"
396
397         $RUNAS $LFS setstripe --component-del -I 2 $comp_file ||
398                 error "Delete component from $comp_file failed"
399
400         $RUNAS $LFS setstripe --component-add -E -1 -c 5 $comp_file ||
401                 error "Add last component to $comp_file failed"
402
403         rm $comp_file || "Delete composite failed"
404 }
405 run_test 7 "Add/Delete/Create composite file by non-privileged user"
406
407 test_8() {
408         local parent=$DIR/$tdir
409
410         rm -fr $parent
411         test_mkdir $parent
412
413         $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c 2 -S 2M \
414                 -E -1 -c 4 -S 4M $parent ||
415                 error "Set default layout to $parent failed"
416
417         sh rundbench -C -D $parent 2 || error "dbench failed"
418
419         rm -fr $parent || error "Delete dir $parent failed"
420 }
421 run_test 8 "Run dbench over composite files"
422
423 test_9() {
424         local comp_file=$DIR/$tdir/$tfile
425
426         test_mkdir $DIR/$tdir
427         rm -f $comp_file
428
429         $LFS setstripe -E 1M -S 1M -E -1 -c 1 $comp_file ||
430                 error "Create $comp_file failed"
431
432         check_component_count $comp_file 2
433
434         replay_barrier $SINGLEMDS
435
436         # instantiate the 2nd component
437         dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
438
439         local f1=$($LFS getstripe -I2 $comp_file |
440                         awk '/l_fid:/ {print $7}')
441         echo "before MDS recovery, the ost fid of 2nd component is $f1"
442         fail $SINGLEMDS
443
444         local f2=$($LFS getstripe -I2 $comp_file |
445                         awk '/l_fid:/ {print $7}')
446         echo "after MDS recovery, the ost fid of 2nd component is $f2"
447         [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
448 }
449 run_test 9 "Replay layout extend object instantiation"
450
451 component_dump() {
452         echo $($LFS getstripe $1 |
453                 awk '$1 == "lcm_entry_count:" { printf("%d", $2) }
454                      $1 == "lcme_extent.e_start:" { printf("[%#lx", $2) }
455                      $1 == "lcme_extent.e_end:" { printf(",%s]", $2) }')
456 }
457
458 test_10() {
459         local parent=$DIR/$tdir
460         local root=$MOUNT
461
462         save_layout_restore_at_exit $MOUNT
463
464         rm -rf $parent
465
466         # mount root on $MOUNT2 if FILESET is set
467         if [ -n "$FILESET" ]; then
468                 FILESET="" mount_client $MOUNT2 ||
469                         error "mount $MOUNT2 fail"
470                 root=$MOUNT2
471         fi
472
473         $LFS setstripe -d $root || error "clear root layout"
474
475         # set root composite layout
476         $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c2 -S 2M \
477                 -E -1 -c 4 -S 4M $root ||
478                 error "Set root layout failed"
479
480         if [ "$root" == "$MOUNT2" ]; then
481                 umount_client $MOUNT2 ||
482                         error "umount $MOUNT2 fail"
483         fi
484
485         test_mkdir $parent
486         # set a different layout for parent
487         $LFS setstripe -E -1 -c 1 -S 1M $parent ||
488                 error "set $parent layout failed"
489         touch $parent/file1
490
491         local f1_entry=$(component_dump $parent/file1)
492
493         # delete parent's layout
494         $LFS setstripe -d $parent || error "Clear $parent layout failed"
495         touch $parent/file2
496
497         local f2_entry=$(component_dump $parent/file2)
498
499         # verify layout inheritance
500         local eof="EOF"
501         local f1_expect="1[0,EOF]"
502         local f2_expect="3[0,2097152][0x200000,16777216][0x1000000,EOF]"
503
504         echo "f1 expect=$f1_expect"
505         echo "f1 get   =$f1_entry"
506         echo "f2 expect=$f2_expect"
507         echo "f2 get   =$f2_entry"
508
509         [  x$f1_expect != x$f1_entry ] &&
510                 error "$parent/file1 does not inherite parent layout"
511         [  x$f2_expect != x$f2_entry ] &&
512                 error "$parent/file2 does not inherite root layout"
513
514         return 0
515 }
516 run_test 10 "Inherit composite template from root"
517
518 test_11() {
519         local comp_file=$DIR/$tdir/$tfile
520         test_mkdir $DIR/$tdir
521         rm -f $comp_file
522
523         # only 1st component instantiated
524         $LFS setstripe -E 1M -S 1M -E 2M -E 3M -E -1 $comp_file ||
525                 error "Create $comp_file failed"
526
527         local f1=$($LFS getstripe -I1 $comp_file | grep "l_fid")
528         [[ -z $f1 ]] && error "1: 1st component uninstantiated"
529         local f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
530         [[ -n $f2 ]] && error "1: 2nd component instantiated"
531         local f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
532         [[ -n $f3 ]] && error "1: 3rd component instantiated"
533         local f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
534         [[ -n $f4 ]] && error "1: 4th component instantiated"
535
536         # the first 2 components instantiated
537         # Truncate to exact start of new component - LU-12586
538         $TRUNCATE $comp_file $((1024*1024*1))
539
540         f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
541         [[ -z $f2 ]] && error "2: 2nd component uninstantiated"
542         f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
543         [[ -n $f3 ]] && error "2: 3rd component instantiated"
544         f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
545         [[ -n $f4 ]] && error "2: 4th component instantiated"
546
547         # the first 3 components instantiated
548         $TRUNCATE $comp_file $((1024*1024*3 - 1))
549         $TRUNCATE $comp_file $((1024*1024*1+1))
550
551         f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
552         [[ -z $f2 ]] && error "3: 2nd component uninstantiated"
553         f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
554         [[ -z $f3 ]] && error "3: 3rd component uninstantiated"
555         f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
556         [[ -n $f4 ]] && error "3: 4th component instantiated"
557
558         # all 4 components instantiated, using append write
559         dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
560         ls -l $comp_file
561         rwv -f $comp_file -w -a -n 2 $((1024*1023)) 1
562         ls -l $comp_file
563
564         f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
565         [[ -z $f4 ]] && error "4: 4th component uninstantiated"
566
567         return 0
568 }
569 run_test 11 "Verify component instantiation with write/truncate"
570
571 test_12() {
572         [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs"
573
574         local file=$DIR/$tdir/$tfile
575         test_mkdir $DIR/$tdir
576         rm -f $file
577
578         # specify ost list for component
579         $LFS setstripe -E 1M -S 1M -c 2 -o 0,1 -E 2M -c 2 -o 1,2 \
580                 -E 3M -c 2 -o 2,1 -E 4M -c 1 -i 2 -E -1 $file ||
581                 error "Create $file failed"
582
583         # clear lod component cache
584         stop $SINGLEMDS || error "stop MDS"
585         local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
586         start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "start MDS"
587
588         # instantiate all components
589         $TRUNCATE $file $((1024*1024*4+1))
590
591         #verify object alloc order
592         local o1=$($LFS getstripe -I1 $file |
593                         awk '/l_ost_idx:/ {printf("%d",$5)}')
594         [[ $o1 != "01" ]] && error "$o1 is not 01"
595
596         local o2=$($LFS getstripe -I2 $file |
597                         awk '/l_ost_idx:/ {printf("%d",$5)}')
598         [[ $o2 != "12" ]] && error "$o2 is not 12"
599
600         local o3=$($LFS getstripe -I3 $file |
601                         awk '/l_ost_idx:/ {printf("%d",$5)}')
602         [[ $o3 != "21" ]] && error "$o3 is not 21"
603
604         local o4=$($LFS getstripe -I4 $file |
605                         awk '/l_ost_idx:/ {printf("%d",$5)}')
606         [[ $o4 != "2" ]] && error "$o4 is not 2"
607
608         return 0
609 }
610 run_test 12 "Verify ost list specification"
611
612 test_13() { # LU-9311
613         [ $OSTCOUNT -lt 8 ] && skip "needs >= 8 OSTs"
614
615         local file=$DIR/$tfile
616         local dd_count=4
617         local dd_size=$(($dd_count * 1024 * 1024))
618         local real_size
619
620         rm -f $file
621         $LFS setstripe -E 1M -S 1M -c 1 -E 2M -c 2 -E -1 -c -1 -i 1 $file ||
622                 error "Create $file failed"
623         dd if=/dev/zero of=$file bs=1M count=$dd_count
624         real_size=$(stat -c %s $file)
625         [ $real_size -eq $dd_size ] ||
626                 error "dd actually wrote $real_size != $dd_size bytes"
627
628         rm -f $file
629 }
630 run_test 13 "shouldn't reprocess granted resent request"
631
632 test_14() {
633         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
634         local file=$DIR/$tdir/$tfile
635         test_mkdir -p $DIR/$tdir
636         rm -f $file
637
638         $LFS setstripe -E1m -c1 -S1m --pool="pool1" -E2m \
639                         -E4m -c2 -S2m --pool="pool2" -E-1 $file ||
640                 error "Create $file failed"
641
642         # check --pool inheritance
643         local pool
644         pool="$($LFS getstripe -I2 --pool $file)"
645         [ x"$pool" != "xpool1" ] && $LFS getstripe -I2 $file &&
646                 error "$file: component 2 doesn't have poolname pool1"
647         pool="$($LFS getstripe -I4 --pool $file)"
648         [ x"$pool" != "xpool2" ] && $LFS getstripe -I4 $file &&
649                 error "$file: component 4 doesn't have poolname pool2"
650
651         #check --stripe-count inheritance
652         local count
653         count="$($LFS getstripe -I2 -c $file)"
654         [ $count -ne 1 ] && $LFS getstripe -I2 $file &&
655                 error "$file: component 2 doesn't have 1 stripe_count"
656         count="$($LFS getstripe -I4 -c $file)"
657         [ $count -ne 2 ] && $LFS getstripe -I4 $file &&
658                 error "$file: component 4 doesn't have 2 stripe_count"
659
660         #check --stripe-size inheritance
661         local size
662         size="$($LFS getstripe -I2 -S $file)"
663         [ $size -ne $((1024*1024)) ] && $LFS getstripe -I2 $file &&
664                 error "$file: component 2 doesn't have 1M stripe_size"
665         size="$($LFS getstripe -I4 -S $file)"
666         [ $size -ne $((1024*1024*2)) ] && $LFS getstripe -I4 $file &&
667                 error "$file: component 4 doesn't have 2M stripe_size"
668
669         return 0
670 }
671 run_test 14 "Verify setstripe poolname/stripe_count/stripe_size inheritance"
672
673 test_15() {
674         local parent=$DIR/$tdir
675
676         rm -fr $parent
677         test_mkdir $parent
678
679         $LFS setstripe -d $parent || error "delete default layout"
680
681         $LFS setstripe -E 1M -S 1M -E 10M -E eof $parent/f1 || error "create f1"
682         $LFS setstripe -E 4M -E 20M -E eof $parent/f2 || error "create f2"
683         test_mkdir $parent/subdir
684         $LFS setstripe -E 6M -S 1M -c1 -E 30M -c4 -E eof -c -1 $parent/subdir ||
685                 error "setstripe to subdir"
686         $LFS setstripe -E 8M -E eof $parent/subdir/f3 || error "create f3"
687         $LFS setstripe -c 1 $parent/subdir/f4 || error "create f4"
688
689         # none
690         local found=$($LFS find --component-start +2M -E -15M $parent | wc -l)
691         [ $found -eq 0 ] || error "start+2M, end-15M, $found != 0"
692
693         # f2, f3
694         found=$($LFS find --component-start +2M -E -35M $parent | wc -l)
695         [ $found -eq 2 ] || error "start+2M, end-35M, $found != 2"
696
697         # subdir
698         found=$($LFS find --component-start +4M -E -eof $parent | wc -l)
699         [ $found -eq 1 ] || error "start+4M, end-eof, $found != 1"
700
701         local flg_opts="--component-flags init"
702         # none
703         found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
704         [ $found -eq 0 ] ||
705                 error "before write: start=1M, end=10M, flag=init, $found != 0"
706
707         dd if=/dev/zero of=$parent/f1 bs=1M count=2 ||
708                 error "dd $parent/f1 failed"
709
710         # f1
711         found=$($LFS find --component-start 1M -E 10M $flg_opts $parent | wc -l)
712         [ $found -eq 1 ] ||
713                 error "after write: start=1M, end=10M, flag=init, $found != 1"
714
715         local ext_opts="--component-start -1M -E +5M"
716         # parent, subdir, f3, f4
717         found=$($LFS find $ext_opts $parent | wc -l)
718         [ $found -eq 4 ] || error "start-1M, end+5M, $found != 4"
719
720         local cnt_opts="--component-count +2"
721         # subdir
722         found=$($LFS find $ext_opts $cnt_opts $parent | wc -l)
723         [ $found -eq 1 ] || error "start-1M, end+5M, count+2, $found != 1"
724
725         # none
726         found=$($LFS find $ext_opts $cnt_opts $flg_opts $parent | wc -l)
727         [ $found -eq 0 ] ||
728                 error "start-1M, end+5M, count+2, flag=init, $found != 0"
729
730         # f3, f4
731         found=$($LFS find $ext_opts ! $cnt_opts $flg_opts $parent | wc -l)
732         [ $found -eq 2 ] ||
733                 error "start-1M, end+5M, !count+2, flag=init, $found != 2"
734
735         # check last component stripe count
736         if [ $OSTCOUNT -gt 1 ]; then
737                 touch $parent/subdir/f5
738                 $TRUNCATE $parent/subdir/f5 $((32*1024*1024))
739                 found=$($LFS find $parent/subdir -c $OSTCOUNT)
740                 [[ "$found" == "$parent/subdir/f5" ]] ||
741                         error "got '$found' with stripe_count=$OSTCOUNT, not f5"
742         fi
743 }
744 run_test 15 "Verify component options for lfs find"
745
746 test_16a() {
747         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
748         large_xattr_enabled || skip_env "ea_inode feature disabled"
749
750         local file=$DIR/$tdir/$tfile
751         local dir=$DIR/$tdir/dir
752         local temp=$DIR/$tdir/template
753         rm -rf $DIR/$tdir
754         test_mkdir $DIR/$tdir
755
756         #####################################################################
757         #                           1. PFL file
758         # set stripe for source file
759         $LFS setstripe -E1m -S 1M -c2 -o0,1 -E2m -c2 -E3m -o1,0 -E4m -c1 -E-1 \
760                 $file || error "Create $file failed"
761
762         echo "1. PFL file"
763         verify_yaml_layout $file $file.copy $temp "1. PFL file"
764
765         #####################################################################
766         #                           2. plain file
767         # set stripe for source file
768         rm -f $file
769         $LFS setstripe -c2 -o0,1 -i1 $file || error "Create $file failed"
770
771         rm -f $file.copy
772         echo "2. plain file"
773         verify_yaml_layout $file $file.copy $temp "2. plain file"
774
775         #####################################################################
776         #                           3. PFL dir
777         # set stripe for source dir
778         test_mkdir $dir
779         $LFS setstripe -E1m -S 1M -c2 -E2m -c1 -E-1 $dir ||
780                 error "setstripe $dir failed"
781
782         test_mkdir $dir.copy
783         echo "3. PFL dir"
784         verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
785
786         #####################################################################
787         #                           4. plain dir
788         # set stripe for source dir
789         $LFS setstripe -c2 -i-1 $dir || error "setstripe $dir failed"
790
791         echo "4. plain dir"
792         verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
793 }
794 run_test 16a "Verify setstripe/getstripe with YAML config file"
795
796 test_16b() {
797         [[ $($LCTL get_param mdc.*.import |
798                 grep "connect_flags:.*overstriping") ]] ||
799                 skip "server does not support overstriping"
800         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
801         [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
802                 skip_env "too many osts, skipping"
803         large_xattr_enabled || skip_env "ea_inode feature disabled"
804
805         local file=$DIR/$tdir/$tfile
806         local dir=$DIR/$tdir/dir
807         local temp=$DIR/$tdir/template
808         # We know OSTCOUNT < (LOV_MAX_STRIPE_COUNT / 2), so this is overstriping
809         local large_count=$((LOV_MAX_STRIPE_COUNT / 2 + 10))
810
811         rm -rf $DIR/$tdir
812         test_mkdir $DIR/$tdir
813
814         #####################################################################
815         #                           1. PFL file, overstriping in first comps
816         # set stripe for source file
817         $LFS setstripe -E1m -S 1M -o0,0 -E2m -o1,1 -E3m -C $large_count -E-1 \
818                 $file || error "Create $file failed"
819
820         echo "1. PFL file"
821         verify_yaml_layout $file $file.copy $temp "1. PFL file"
822
823         #####################################################################
824         #                           2. plain file + overstriping
825         # set stripe for source file
826         rm -f $file
827         $LFS setstripe -C $large_count -i1 $file || error "Create $file failed"
828
829         rm -f $file.copy
830         echo "2. plain file"
831         verify_yaml_layout $file $file.copy $temp "2. plain file"
832
833         #####################################################################
834         #                           3. PFL dir + overstriping
835         # set stripe for source dir
836         test_mkdir $dir
837         $LFS setstripe -E1m -S 1M -o 0,0 -E2m -C $large_count -E-1 $dir ||
838                 error "setstripe $dir failed"
839
840         test_mkdir $dir.copy
841         echo "3. PFL dir"
842         verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
843
844         #####################################################################
845         #                           4. plain dir + overstriping
846         # set stripe for source dir
847         $LFS setstripe -C $large_count $dir || error "setstripe $dir failed"
848
849         echo "4. plain dir"
850         verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
851 }
852 run_test 16b "Verify setstripe/getstripe with YAML config file + overstriping"
853
854 test_16c() {
855         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
856
857         local file=$DIR/$tdir/$tfile
858         local dir=$DIR/$tdir/dir
859         local temp=$DIR/$tdir/template
860         rm -rf $DIR/$tdir
861         test_mkdir $DIR/$tdir
862
863         #####################################################################
864         #                           1. SEL file
865         # set stripe for source file
866         $LFS setstripe -E256M -S 1M -c2 -o0,1 -z 64M -E-1 -o1,0 -z 128M \
867                 $file || error "Create $file failed"
868
869         echo "1. SEL file"
870         verify_yaml_layout $file $file.copy $temp "1. PFL file"
871
872         #####################################################################
873         #                           2. SEL dir
874         # set stripe for source dir
875         test_mkdir $dir
876         $LFS setstripe -E256M -S 1M -c2 -z 64M -E-1 -z 128M \
877                 $dir || error "setstripe $dir failed"
878
879         test_mkdir $dir.copy
880         echo "2. SEL template on dir"
881         verify_yaml_layout $dir $dir.copy $temp.dir "2. PFL dir"
882 }
883 run_test 16c "Verify setstripe/getstripe for SEL layout with YAML config file"
884
885 test_17() {
886         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
887         local file=$DIR/$tdir/$tfile
888         test_mkdir -p $DIR/$tdir
889         rm -f $file
890
891         $LFS setstripe -E 1M -S 1M -E 2M -c 2 -E -1 -c -1 $file ||
892                 error "Create $file failed"
893
894         local s1=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
895         local s2=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
896         local s3=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
897         echo "1st init: comp size 1:$s1 2:$s2 3:$s3"
898
899         # init 2nd component
900         $TRUNCATE $file $((1024*1024+1))
901         local s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
902         local s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
903         echo "2nd init: comp size 1:$s1n 2:$s2n 3:$s3"
904
905         [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
906         [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
907
908         # init 3rd component
909         $TRUNCATE $file $((1024*1024*2+1))
910         s1n=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}')
911         s2n=$($LFS getstripe -I2 -v $file | awk '/lcme_size:/{print $2}')
912         local s3n=$($LFS getstripe -I3 -v $file | awk '/lcme_size:/{print $2}')
913         echo "3rd init: comp size 1:$s1n 2:$s2n 3:$s3n"
914
915         [ $s1 -eq $s1n ] || error "1st comp size $s1 should == $s1n"
916         [ $s2 -lt $s2n ] || error "2nd comp size $s2 should < $s2n"
917         [ $s3 -lt $s3n ] || error "3rd comp size $s3 should < $s3n"
918 }
919 run_test 17 "Verify LOVEA grows with more component inited"
920
921 check_distribution() {
922         local file=$1
923         local objs
924         local ave
925         local obj_min_one=$((OSTCOUNT - 1))
926
927         objs=$($LFS getstripe $file |
928                 awk '/l_ost_idx:/ { print $5 }' | wc -l)
929         let ave=$((objs / OSTCOUNT))
930
931         # collect objects per OST distribution
932         $LFS getstripe $file | awk '/l_ost_idx:/ { print $5 }' | tr -d "," |
933                 (inuse=( $(for i in $(seq 0 $obj_min_one); do echo 0; done) )
934                 while read O; do
935                         let inuse[$O]=$((1 + ${inuse[$O]}))
936                 done;
937
938                 # verify object distribution varies no more than +-1
939                 for idx in $(seq 0 $obj_min_one); do
940                         let dif=$((${inuse[$idx]} - ave))
941                         let dif=${dif#-}
942                         if [ "$dif" -gt 1 ]; then
943                                 echo "OST${idx}: ${inuse[$idx]} objects"
944                                 error "bad distribution on OST${idx}"
945                         fi
946                 done)
947 }
948
949 test_18() {
950         local file1=$DIR/${tfile}-1
951         local file2=$DIR/${tfile}-2
952         local file3=$DIR/${tfile}-3
953
954         rm -f $file1 $file2 $file3
955
956         $LFS setstripe -E 1m -S 1m $file1 ||
957                 error "Create $file1 failed"
958         $LFS setstripe -E 1m -S 1m $file2 ||
959                 error "Create $file2 failed"
960         $LFS setstripe -E 1m -S 1m $file3 ||
961                 error "Create $file3 failed"
962
963         local objs=$((OSTCOUNT+1))
964         for comp in $(seq 1 $OSTCOUNT); do
965                 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file1 ||
966                         error "Add component to $file1 failed 2"
967                 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file2 ||
968                         error "Add component to $file2 failed 2"
969                 $LFS setstripe --component-add -E $((comp+1))M -c 1 $file3 ||
970                         error "Add component to $file3 failed 2"
971         done
972
973         $LFS setstripe --component-add -E -1 -c -1 $file1 ||
974                 error "Add component to $file1 failed 3"
975         $LFS setstripe --component-add -E -1 -c -1 $file2 ||
976                 error "Add component to $file2 failed 3"
977         $LFS setstripe --component-add -E -1 -c -1 $file3 ||
978                 error "Add component to $file3 failed 3"
979
980         # Instantiate all components
981         dd if=/dev/urandom of=$file1 bs=1M count=$((objs+1)) ||
982                 error "dd failed for $file1"
983         dd if=/dev/urandom of=$file2 bs=1M count=$((objs+1)) ||
984                 error "dd failed for $file2"
985         dd if=/dev/urandom of=$file3 bs=1M count=$((objs+1)) ||
986                 error "dd failed for $file3"
987
988         check_distribution $file1
989         check_distribution $file2
990         check_distribution $file3
991
992 }
993 run_test 18 "check component distribution"
994
995 test19_io_base() {
996         local comp_file=$1
997         local already_created=${2:-0}
998         local rw_len=$((3 * 1024 * 1024))       # 3M
999         local flg_opts=""
1000         local found=""
1001
1002         if [ $already_created != 1 ]; then
1003                 test_mkdir -p $DIR/$tdir
1004                 $LFS setstripe --extension-size 64M -c 1 -E -1 $comp_file ||
1005                         error "Create $comp_file failed"
1006         fi
1007
1008         # write past end of first component, so it is extended
1009         dd if=/dev/zero of=$comp_file bs=1M count=1 seek=127 conv=notrunc ||
1010                 error "dd to extend failed"
1011
1012         local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1013         local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1014
1015         [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1016         [ $ost_idx2 -ne "-1" ] && error "second component init $ost_idx2"
1017
1018         flg_opts="--comp-flags init"
1019         found=$($LFS find --comp-start 0 -E 128M $flg_opts $comp_file | wc -l)
1020         [ $found -eq 1 ] || error "Write: Extended first component not found"
1021
1022         flg_opts="--comp-flags extension"
1023         found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1024         [ $found -eq 1 ] || error "Write: second component not found"
1025
1026         found=$($LFS find -z 64M $comp_file | wc -l)
1027         [ $found -eq 1 ] || error "component not found by ext size"
1028
1029         found=$($LFS find --extension-size +63M $comp_file | wc -l)
1030         [ $found -eq 1 ] || error "component not found by +ext size"
1031
1032         found=$($LFS find --ext-size -65M $comp_file | wc -l)
1033         [ $found -eq 1 ] || error "component not found by -ext size"
1034
1035         found=$($LFS find -z 65M $comp_file | wc -l)
1036         [ $found -eq 0 ] || error "component found by wrong ext size"
1037
1038         found=$($LFS find -z +65M $comp_file | wc -l)
1039         [ $found -eq 0 ] || error "component found by wrong +ext size"
1040
1041         found=$($LFS find -z -63M $comp_file | wc -l)
1042         [ $found -eq 0 ] || error "component found by wrong -ext size"
1043
1044         found=$($LFS find ! -z 64M $comp_file | wc -l)
1045         [ $found -eq 0 ] || error "component found by negation of ext size"
1046
1047         found=$($LFS find ! -z +63M $comp_file | wc -l)
1048         [ $found -eq 0 ] || error "component found by negation of +ext size"
1049
1050         found=$($LFS find ! -z -65M $comp_file | wc -l)
1051         [ $found -eq 0 ] || error "component found by negation of -ext size"
1052
1053         found=$($LFS find ! -z 65M $comp_file | wc -l)
1054         [ $found -eq 1 ] ||
1055                 error "component not found by negation of wrong ext size"
1056
1057         found=$($LFS find ! -z +65M $comp_file | wc -l)
1058         [ $found -eq 1 ] ||
1059                 error "component not found by negation of wrong +ext size"
1060
1061         found=$($LFS find ! -z -63M $comp_file | wc -l)
1062         [ $found -eq 1 ] ||
1063                 error "component not found by negation of wrong -ext size"
1064
1065         found=$($LFS find -S +1M $comp_file | wc -l)
1066         [ $found -eq 0 ] || error "component found by wrong +stripe size"
1067
1068         found=$($LFS find -c 1 $comp_file | wc -l)
1069         [ $found -eq 1 ] || error "component not found by stripe count"
1070
1071         small_write $comp_file $rw_len || error "Verify RW failed"
1072
1073         sel_layout_sanity $comp_file 2
1074 }
1075
1076 # Self-extending PFL tests
1077 test_19a() {
1078         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1079         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1080                 skip "skipped for lustre < $SEL_VER"
1081
1082         test19_io_base $DIR/$tdir/$tfile
1083 }
1084 run_test 19a "Simple test of extension behavior"
1085
1086 # Same as 19a, but with default layout set on directory rather than on file
1087 test_19b() {
1088         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1089         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1090                 skip "skipped for lustre < $SEL_VER"
1091
1092         local comp_file=$DIR/$tdir/$tfile
1093         local comp_dir=$DIR/$tdir/$tdir
1094         local flg_opts=""
1095         local found=""
1096
1097         test_mkdir -p $DIR/$tdir
1098         $LFS setstripe --ext-size 64M -c 1 -E -1 $DIR/$tdir ||
1099                 error "Setstripe on $DIR/$tdir failed"
1100
1101         # check inheritance for a sub-dir and a file
1102         test_mkdir $comp_dir
1103         found=$($LFS find --comp-start 0 -E 64M $comp_dir | wc -l)
1104         [ $found -eq 1 ] || error "Dir Inheritance: wrong first component size"
1105
1106         flg_opts="--comp-flags extension"
1107         found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_dir | wc -l)
1108         [ $found -eq 1 ] || error "Dir Inheritance: Second component not found"
1109
1110         touch $comp_file
1111
1112         flg_opts="--comp-flags init"
1113         found=$($LFS find --comp-start 0 -E 64M $flg_opts $comp_file | wc -l)
1114         [ $found -eq 1 ] || error "File Inheritance: wrong first component size"
1115
1116         flg_opts="--comp-flags extension"
1117         found=$($LFS find --comp-start 64M -E EOF $flg_opts $comp_file | wc -l)
1118         [ $found -eq 1 ] || error "File Inheritance: Second component not found"
1119
1120         test19_io_base $comp_file 1
1121 }
1122 run_test 19b "Simple test of SEL as default layout"
1123
1124 # Test behavior when seeking deep in a file
1125 test_19c() {
1126         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1127         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1128                 skip "skipped for lustre < $SEL_VER"
1129
1130         local comp_file=$DIR/$tdir/$tfile
1131         local flg_opts=""
1132         local found=""
1133
1134         test_mkdir -p $DIR/$tdir
1135
1136         $LFS setstripe -z 128M -E 1G -E -1 $comp_file ||
1137                 error "Create $comp_file failed"
1138
1139         # write past end of first component, so it is extended
1140         dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 conv=notrunc ||
1141                 error "dd to extend failed"
1142
1143         flg_opts="--comp-flags init"
1144         found=$($LFS find --comp-start 0M -E 256M $flg_opts $comp_file | wc -l)
1145         [ $found -eq 1 ] || error "Write: first extension component not found"
1146
1147         flg_opts="--comp-flags extension,^init"
1148         found=$($LFS find --comp-start 256M -E 1024M $flg_opts $comp_file |\
1149                 wc -l)
1150         [ $found -eq 1 ] || error "Write: second extension component not found"
1151
1152         local end_1=$($LFS getstripe -I1 -E $comp_file)
1153
1154         # 256 MiB
1155         [ $end_1 -eq 268435456 ] ||
1156                 error "end of first component $end_1 != 268435456"
1157
1158         # Write past end of extension space component, in to normal component
1159         # should exhaust & remove extension component
1160         dd if=/dev/zero bs=1M count=1 seek=1100 of=$comp_file conv=notrunc ||
1161                 error "dd distant seek failed"
1162
1163         local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1164         # the last component index is 3
1165         local ost_idx2=$($LFS getstripe -I3 -i $comp_file)
1166
1167         [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1168
1169         local start1=$($LFS getstripe -I1 --comp-start $comp_file)
1170         local end1=$($LFS getstripe -I1 -E $comp_file)
1171         local start2=$($LFS getstripe -I3 --comp-start $comp_file)
1172         local end2=$($LFS getstripe -I3 -E $comp_file)
1173
1174         [ $start1 -eq 0 ] || error "start of first component incorrect"
1175         [ $end1 -eq 1073741824 ] || error "end of first component incorrect"
1176         [ $start2 -eq 1073741824  ] ||
1177                 error "start of second component incorrect"
1178         [ "$end2" = "EOF" ] || error "end of second component incorrect"
1179
1180         flg_opts="--comp-flags extension"
1181         found=$($LFS find $flg_opts $comp_file | wc -l)
1182         [ $found -eq 0 ] || error "Seek Write: extension component exists"
1183
1184         sel_layout_sanity $comp_file 2
1185 }
1186 run_test 19c "Test self-extending layout seeking behavior"
1187
1188 test_19d() {
1189         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1190         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1191                 skip "skipped for lustre < $SEL_VER"
1192
1193         local comp_file=$DIR/$tdir/$tfile
1194         local flg_opts=""
1195         local found=""
1196
1197         test_mkdir -p $DIR/$tdir
1198
1199         $LFS setstripe -E 128M -c 1 -z 64M -E -1 $comp_file ||
1200                 error "Create $comp_file failed"
1201
1202         # This will cause component 1 to be extended to 128M, then the
1203         # extension space component will be removed
1204         dd if=/dev/zero of=$comp_file bs=130M count=1 ||
1205                 error "dd to extend failed"
1206
1207         flg_opts="--comp-flags init"
1208         found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file | wc -l)
1209         [ $found -eq 1 ] || error "Write: first component not found"
1210
1211         flg_opts="--comp-flags init"
1212         found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1213         [ $found -eq 1 ] || error "Write: second component not found"
1214
1215         sel_layout_sanity $comp_file 2
1216
1217         # always remove large files in case of DO_CLEANUP=false
1218         rm -f $comp_file || error "Delete $comp_file failed"
1219 }
1220 run_test 19d "Test write which completely spans extension space component"
1221
1222 test_19e_check() {
1223         comp_file=$1
1224
1225         local comp2_flags=$($LFS getstripe -I2 --comp-flags $comp_file)
1226         local comp3_flags=$($LFS getstripe -I3 --comp-flags $comp_file)
1227
1228         [ "$comp2_flags" != "init" ] && error "$comp2_flags != init"
1229         [ "$comp3_flags" != "extension" ] && error "$comp3_flags != extension"
1230
1231         local flg_opts=" --comp-start 2M -E 66M --comp-flags init"
1232         local found=$($LFS find $flg_opts $comp_file | wc -l)
1233         [ $found -eq 1 ] || error "Write: extended second component not found"
1234
1235         flg_opts="--comp-start 66M -E EOF --comp-flags extension"
1236         found=$($LFS find $flg_opts $comp_file | wc -l)
1237         [ $found -eq 1 ] || error "Write: third component not found"
1238
1239         sel_layout_sanity $comp_file 3
1240 }
1241
1242 test_19e() {
1243         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1244         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1245                 skip "skipped for lustre < $SEL_VER"
1246
1247         local comp_file=$DIR/$tdir/$tfile
1248         local rw_len=$((3 * 1024 * 1024))       # 3M
1249         local flg_opts=""
1250         local found=""
1251
1252         test_mkdir -p $DIR/$tdir
1253
1254         $LFS setstripe -E 2m -E -1 -z 64M $comp_file ||
1255                 error "Create $comp_file failed"
1256
1257         replay_barrier $SINGLEMDS
1258
1259         #instantiate & extend second component
1260         dd if=/dev/zero of=$comp_file bs=4M count=1 ||
1261                 error "dd to extend failed"
1262
1263         local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1264         local ost_idx3=$($LFS getstripe -I3 -i $comp_file)
1265
1266         [ $ost_idx2 -eq $ost_idx3 ] && error "$ost_idx2 == $ost_idx3"
1267         [ $ost_idx3 -ne "-1" ] && error "third component init $ost_idx3"
1268
1269         test_19e_check $comp_file
1270
1271         local f1=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1272         echo "before MDS recovery, the ost fid of 2nd component is $f1"
1273
1274         fail $SINGLEMDS
1275
1276         local f2=$($LFS getstripe -I2 $comp_file | awk '/l_fid:/ {print $7}')
1277         echo "after MDS recovery, the ost fid of 2nd component is $f2"
1278         [ "x$f1" == "x$f2" ] || error "$f1 != $f2"
1279
1280         # simply repeat all previous checks, but also verify components are on
1281         # the same OST as before
1282
1283         local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1284         local ost_idx3_2=$($LFS getstripe -I3 -i $comp_file)
1285
1286         [ $ost_idx2_2 -eq $ost_idx3_2 ] && error "$ost_idx2_2 == $ost_idx3_2"
1287         [ $ost_idx3_2 -ne "-1" ] && error "second component init $ost_idx3_2"
1288
1289         # verify OST id is the same after failover
1290         [ $ost_idx2 -ne $ost_idx2_2 ] &&
1291                 error "$ost_idx2 != $ost_idx2_2, changed after failover"
1292
1293         test_19e_check $comp_file
1294 }
1295 run_test 19e "Replay of layout instantiation & extension"
1296
1297 test_19f() {
1298         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1299         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1300                 skip "skipped for lustre < $SEL_VER"
1301
1302         local comp_file=$DIR/$tdir/$tfile
1303         local flg_opts=""
1304         local found=""
1305
1306         test_mkdir -p $DIR/$tdir
1307
1308         $LFS setstripe -E 256M --comp-flags extension -E -1 $comp_file
1309
1310         [ $? != 0 ] || error "should not be able to manually set extension flag"
1311
1312 }
1313 run_test 19f "Rejection of invalid layouts"
1314
1315 test_19g() {
1316         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1317         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1318                 skip "skipped for lustre < $SEL_VER"
1319
1320         local file1=$DIR/${tfile}-1
1321         local file2=$DIR/${tfile}-2
1322
1323         test_mkdir -p $DIR/$tdir
1324         multiop $file1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1325                 error "create failed $file1"
1326         multiop $file2 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
1327                 error "create failed $file2"
1328
1329         $LFS setstripe --component-add -E 1G -c 1 $file1 ||
1330                 error "comp-add [0,1G] failed $file1"
1331         $LFS setstripe --component-add -E 512M -z 128M $file1 &&
1332                 error "comp-add [1G,1G],SEL[1G,512M] succeded $file1"
1333         $LFS setstripe --component-add -E 10G -z 128M $file1 ||
1334                 error "comp-add [1G,1G],SEL[1G,10G] failed $file1"
1335         $LFS setstripe --component-add -E -1 $file1 ||
1336                 error "comp-add [10G,-1] failed $file1"
1337
1338         $LFS setstripe --component-add -E 1G -z 32M -c 1 $file2 &&
1339                 error "comp-add with smal ext size succeeded $file1"
1340         $LFS setstripe --component-add -E 1G -z 100M -c 1 $file2 &&
1341                 error "comp-add with not aligned ext size succeeded $file1"
1342         $LFS setstripe --component-add -E 1G -z 128M -c 1 $file2 ||
1343                 error "comp-add [0,128M],SEL[128M,1G] failed $file1"
1344         $LFS setstripe --component-add -E 10G $file2 ||
1345                 error "comp-add [1G,10G] failed $file1"
1346         $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 ||
1347                 error "comp-add [10G,10G],SEL[10G,-1] failed $file1"
1348         $LFS setstripe --component-add -E -1 -z 128M -c 1 $file2 &&
1349                 error "repeated comp-add [10G,10G],SEL[10G,-1] succeeded $file1"
1350
1351         $LFS getstripe $file1
1352         flg_opts="--comp-flags init"
1353         found=$($LFS find --comp-start 0 -E 1G $flg_opts $file1 | wc -l)
1354         [ $found -eq 1 ] || error "First component not found $file1"
1355
1356         flg_opts="--comp-flags ^init"
1357         found=$($LFS find --comp-start 1G -E 1G $flg_opts $file1 | wc -l)
1358         [ $found -eq 1 ] || error "Second component not found $file1"
1359
1360         flg_opts="--comp-flags ^init,extension"
1361         found=$($LFS find --comp-start 1G -E 10G $flg_opts $file1 | wc -l)
1362         [ $found -eq 1 ] || error "Third component not found $file1"
1363
1364         flg_opts="--comp-flags ^init"
1365         found=$($LFS find --comp-start 10G -E EOF $flg_opts $file1 | wc -l)
1366         [ $found -eq 1 ] || error "Fourth component not found $file1"
1367
1368         $LFS getstripe $file2
1369         flg_opts="--comp-flags init"
1370         found=$($LFS find --comp-start 0 -E 128M $flg_opts $file2 | wc -l)
1371         [ $found -eq 1 ] || error "First component not found $file2"
1372
1373         flg_opts="--comp-flags extension"
1374         found=$($LFS find --comp-start 128M -E 1G $flg_opts $file2 | wc -l)
1375         [ $found -eq 1 ] || error "Second component not found $file2"
1376
1377         flg_opts="--comp-flags ^init"
1378         found=$($LFS find --comp-start 1G -E 10G $flg_opts $file2 | wc -l)
1379         [ $found -eq 1 ] || error "Third component not found $file2"
1380
1381         flg_opts="--comp-flags ^init"
1382         found=$($LFS find --comp-start 10G -E 10G $flg_opts $file2 | wc -l)
1383         [ $found -eq 1 ] || error "Fourth component not found $file2"
1384
1385         flg_opts="--comp-flags ^init,extension"
1386         found=$($LFS find --comp-start 10G -E EOF $flg_opts $file2 | wc -l)
1387         [ $found -eq 1 ] || error "Fifth component not found $file2"
1388 }
1389 run_test 19g "component-add behaviour"
1390
1391 # Test out of space behavior
1392 test_20a() {
1393         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1394         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1395                 skip "skipped for lustre < $SEL_VER"
1396
1397         local comp_file=$DIR/$tdir/$tfile
1398         local flg_opts=""
1399         local found=""
1400
1401         test_mkdir -p $DIR/$tdir
1402
1403         # without this, a previous delete can finish after we check free space
1404         wait_delete_completed
1405         wait_mds_ost_sync
1406
1407         # First component is on OST0
1408         $LFS setstripe -E 256M -i 0 -z 64M -E -1 -z 128M $comp_file ||
1409                 error "Create $comp_file failed"
1410
1411         # write past end of first component, so it is extended
1412         dd if=/dev/zero of=$comp_file bs=1M count=1 seek=66 ||
1413                 error "dd to extend failed"
1414
1415         flg_opts="--comp-flags extension"
1416         found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file |wc -l)
1417         [ $found -eq 1 ] || error "Write: Second component not found"
1418
1419         local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1420         local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1421                     grep "watermarks")
1422         stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1423
1424         flg_opts="--comp-flags extension"
1425         # Write past current init comp, but we won't extend (because no space)
1426         dd if=/dev/zero of=$comp_file bs=1M count=10 seek=200 ||
1427                 error "dd write past current comp failed"
1428
1429         $LFS getstripe $comp_file
1430
1431         flg_opts="--comp-flags init"
1432         found=$($LFS find --comp-start 128M -E 256M $flg_opts $comp_file | \
1433                 wc -l)
1434         [ $found -eq 1 ] || error "Write: third component not found"
1435
1436         flg_opts="--comp-flags extension"
1437         found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file |wc -l)
1438         [ $found -eq 1 ] || error "Write: fourth extension component not found"
1439
1440         sel_layout_sanity $comp_file 3
1441 }
1442 run_test 20a "Test out of space, spillover to defined component"
1443
1444 test_20b() {
1445         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1446         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1447                 skip "skipped for lustre < $SEL_VER"
1448
1449         local comp_file=$DIR/$tdir/$tfile
1450         local flg_opts=""
1451         local found=""
1452
1453         test_mkdir -p $DIR/$tdir
1454
1455         # Pool allows us to force use of only certain OSTs
1456         pool_add $TESTNAME || error "Pool creation failed"
1457         pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1458
1459         # normal component to 10M, extendable component to 1G
1460         # further extendable to EOF
1461         $LFS setstripe -E 10M -E 1G -p $TESTNAME -z 64M -E -1 -p "" -z 128M \
1462                 $comp_file || error "Create $comp_file failed"
1463
1464         replay_barrier $SINGLEMDS
1465
1466         found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1467         [ $found -eq 1 ] || error "Zero length component not found"
1468
1469         local ost_idx1=0
1470         local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1471                     grep "watermarks")
1472         stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1473
1474         # write past end of first component
1475         # This should remove the next component, since OST0 is out of space
1476         # and it is striped there (pool contains only OST0)
1477         dd if=/dev/zero of=$comp_file bs=1M count=1 seek=14 ||
1478                 error "dd to extend/remove failed"
1479
1480         $LFS getstripe $comp_file
1481
1482         found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1483         [ $found -eq 0 ] || error "Write: zero length component still present"
1484
1485         flg_opts="--comp-flags init"
1486         found=$($LFS find --comp-start 10M -E 138M $flg_opts $comp_file | wc -l)
1487         [ $found -eq 1 ] || error "Write: second component not found"
1488
1489         flg_opts="--comp-flags extension"
1490         found=$($LFS find --comp-start 138M -E EOF $flg_opts $comp_file | wc -l)
1491         [ $found -eq 1 ] || error "Write: third component not found"
1492
1493         fail $SINGLEMDS
1494
1495         found=$($LFS find --comp-start 10M -E 10M $flg_opts $comp_file | wc -l)
1496         [ $found -eq 0 ] || error "Failover: 0-length component still present"
1497
1498         flg_opts="--comp-flags init"
1499         found=$($LFS find --comp-start 10M -E 138M $flg_opts $comp_file | wc -l)
1500         [ $found -eq 1 ] || error "Failover: second component not found"
1501
1502         flg_opts="--comp-flags extension"
1503         found=$($LFS find --comp-start 138M -E EOF $flg_opts $comp_file | wc -l)
1504         [ $found -eq 1 ] || error "Failover: third component not found"
1505
1506         sel_layout_sanity $comp_file 3
1507 }
1508 run_test 20b "Remove component without instantiation when there is no space"
1509
1510 test_20c() {
1511         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1512         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1513                 skip "skipped for lustre < $SEL_VER"
1514
1515         local comp_file=$DIR/$tdir/$tfile
1516         local flg_opts=""
1517         local found=""
1518
1519         test_mkdir -p $DIR/$tdir
1520
1521         # pool is used to limit available OSTs to 0 and 1, so we can set all
1522         # available OSTs out of space
1523         pool_add $TESTNAME || error "Pool creation failed"
1524         pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
1525
1526         # without this, a previous delete can finish after we check free space
1527         wait_delete_completed
1528         wait_mds_ost_sync
1529
1530         $LFS setstripe -E 100M -E -1 -p $TESTNAME -z 64M $comp_file ||
1531                 error "Create $comp_file failed"
1532
1533         local ost_idx1=0
1534         local ost_idx2=1
1535         local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1536                     grep "watermarks")
1537         local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
1538                      grep "watermarks")
1539         stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1540         stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
1541
1542         dd if=/dev/zero of=$comp_file bs=1M count=1 seek=120 &&
1543                 error "dd should fail with ENOSPC"
1544
1545         flg_opts="--comp-flags init"
1546         found=$($LFS find --comp-start 0M -E 100M $flg_opts $comp_file | wc -l)
1547         [ $found -eq 1 ] || error "Write: First component not found"
1548
1549         flg_opts="--comp-flags ^init"
1550         found=$($LFS find --comp-start 100M -E 100M $flg_opts $comp_file |wc -l)
1551         [ $found -eq 1 ] || error "Write: 0-length component not found"
1552
1553         flg_opts="--comp-flags extension"
1554         found=$($LFS find --comp-start 100M -E EOF $flg_opts $comp_file | wc -l)
1555         [ $found -eq 1 ] || error "Write: third extension component not found"
1556
1557         sel_layout_sanity $comp_file 3
1558 }
1559 run_test 20c "Test inability to stripe new extension component"
1560
1561 test_20d() {
1562         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1563         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1564                 skip "skipped for lustre < $SEL_VER"
1565
1566         local comp_file=$DIR/$tdir/$tfile
1567         test_mkdir -p $DIR/$tdir
1568
1569         wait_delete_completed
1570         wait_mds_ost_sync
1571
1572         pool_add $TESTNAME || error "Pool creation failed"
1573         pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1574         $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
1575                 error "Create $comp_file failed"
1576
1577         replay_barrier $SINGLEMDS
1578
1579         local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1580         dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1581         RC=$?
1582
1583         ost_watermarks_clear_enospc $tfile 0 $wms
1584         [ $RC -eq 0 ] || error "dd failed: $RC"
1585
1586         $LFS getstripe $comp_file
1587         local flg_opts="--comp-start 64M -E 128M --comp-flags init"
1588         local found=$($LFS find $flg_opts $comp_file | wc -l)
1589         [ $found -eq 1 ] || error "Write: component (64M-128M) not found"
1590
1591         local ost_idx=$($LFS getstripe -I3 -i $comp_file)
1592         [ "$ost_idx" != "-1" ] && error "Write: EXT component disappeared"
1593
1594         fail $SINGLEMDS
1595
1596         found=$($LFS find $flg_opts $comp_file | wc -l)
1597         [ $found -eq 1 ] || error "Failover: component (64M-128M) not found"
1598
1599         ost_idx=$($LFS getstripe -I3 -i $comp_file)
1600         [ "$ost_idx" != "-1" ] && error "Failover: EXT component disappeared"
1601
1602         sel_layout_sanity $comp_file 3
1603 }
1604 run_test 20d "Low on space + 0-length comp: force extension"
1605
1606 test_20e() {
1607         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1608         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1609                 skip "skipped for lustre < $SEL_VER"
1610
1611         local comp_file=$DIR/$tdir/$tfile
1612         test_mkdir -p $DIR/$tdir
1613
1614         wait_delete_completed
1615         wait_mds_ost_sync
1616
1617         pool_add $TESTNAME || error "Pool creation failed"
1618         pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1619
1620         $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
1621                 error "Create $comp_file failed"
1622
1623         local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
1624
1625         dd if=/dev/zero bs=1M count=1 seek=100 of=$comp_file
1626         RC=$?
1627
1628         ost_watermarks_clear_enospc $tfile 0 $wms
1629         [ $RC -eq 0 ] || error "dd failed $RC"
1630
1631         $LFS getstripe $comp_file
1632         local flg_opts="--comp-start 64M -E EOF --comp-flags init"
1633         local found=$($LFS find $flg_opts $comp_file | wc -l)
1634         [ $found -eq 1 ] || error "Write: component (64M-EOF) not found"
1635
1636         local ost_idx=$($LFS getstripe -I2 -i $comp_file)
1637         [ "$ost_idx" != "" ] && error "Write: 0-length component still exists"
1638         ost_idx=$($LFS getstripe -I3 -i $comp_file)
1639         [ "$ost_idx" != "" ] && error "Write: extension component still exists"
1640
1641         sel_layout_sanity $comp_file 2
1642 }
1643 run_test 20e "ENOSPC with next real comp: spillover and backward extension"
1644
1645 # Simple DoM interaction test
1646 test_21a() {
1647         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1648                 skip "skipped for lustre < $SEL_VER"
1649
1650         local comp_file=$DIR/$tdir/$tfile
1651         local flg_opts=""
1652         local found=""
1653
1654         test_mkdir -p $DIR/$tdir
1655
1656         # simple, correct self-extending layout after DoM component
1657         $LFS setstripe -E 1M -L mdt -E -1 -z 64m $comp_file || \
1658                 error "Create $comp_file failed"
1659
1660         # Write to DoM component & to self-extending comp after it
1661         dd if=/dev/zero bs=1M count=12 of=$comp_file ||
1662                 error "dd to extend failed"
1663
1664         flg_opts="--comp-flags init"
1665         found=$($LFS find --comp-start 1M -E 65M $flg_opts $comp_file | wc -l)
1666         [ $found -eq 1 ] || error "Write: extended component not found"
1667
1668         flg_opts="--comp-flags extension"
1669         found=$($LFS find --comp-start 65M $flg_opts $comp_file | wc -l)
1670         [ $found -eq 1 ] || error "Write: extension component not found"
1671
1672         sel_layout_sanity $comp_file 3
1673 }
1674 run_test 21a "Simple DoM interaction tests"
1675
1676 # DoM + extension + removal
1677 test_21b() {
1678         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1679         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1680                 skip "skipped for lustre < $SEL_VER"
1681
1682         local comp_file=$DIR/$tdir/$tfile
1683         local ost_name=$(ostname_from_index 0)
1684         local flg_opts=""
1685         local found=""
1686
1687         test_mkdir -p $DIR/$tdir
1688
1689         # DoM, extendable component, further extendable component
1690         $LFS setstripe -E 1M -L mdt -E 256M -i 0 -z 64M -E -1 -z 128M \
1691                 $comp_file || error "Create $comp_file failed"
1692
1693         found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1694         [ $found -eq 1 ] || error "Write: Zero length component not found"
1695
1696         # This also demonstrates that we will avoid degraded OSTs
1697         do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
1698         # sleep to guarantee we see the degradation
1699         sleep_maxage
1700
1701         # un-degrade on exit
1702         stack_trap "do_facet ost1 $LCTL set_param -n \
1703                 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1704
1705         # This should remove the first component after DoM and spill over to
1706         # the next one
1707         dd if=/dev/zero bs=1M count=2 of=$comp_file ||
1708                 error "dd to remove+spill over failed"
1709
1710         found=$($LFS find --comp-start 1M -E 1M $flg_opts $comp_file | wc -l)
1711         [ $found -eq 0 ] || error "Write: Zero length component still present"
1712
1713         flg_opts="--comp-flags init"
1714         found=$($LFS find --comp-start 1M -E 129M $flg_opts $comp_file | wc -l)
1715         [ $found -eq 1 ] || error "Write: extended component not found"
1716
1717         flg_opts="--comp-flags extension"
1718         found=$($LFS find --comp-start 129M -E EOF $flg_opts $comp_file |wc -l)
1719         [ $found -eq 1 ] || error "Write: extension component not found"
1720
1721         sel_layout_sanity $comp_file 3
1722 }
1723 run_test 21b "DoM followed by extendable component with removal"
1724
1725 # Test of repeat component behavior with OOS/degraded OST
1726 test_22a() {
1727         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1728         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1729                 skip "skipped for lustre < $SEL_VER"
1730
1731         local comp_file=$DIR/$tdir/$tfile
1732         local flg_opts=""
1733         local found=""
1734
1735         test_mkdir -p $DIR/$tdir
1736
1737         $LFS setstripe -E -1 -c 1 -z 128M $comp_file ||
1738                 error "Create $comp_file failed"
1739
1740         local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1741         local ost_name=$(ostname_from_index $ost_idx1)
1742
1743         # write past end of first component, so it is extended
1744         dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
1745                 error "dd to extend failed"
1746
1747         flg_opts="--comp-flags extension"
1748         found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
1749         [ $found -eq 1 ] || error "Write: second component not found"
1750
1751         # degrade OST for component 1
1752         do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
1753                 obdfilter.$ost_name.degraded=1
1754         # sleep to guarantee we see the degradation
1755         sleep_maxage
1756
1757         # un-degrade on exit
1758         stack_trap "do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
1759                 obdfilter.$ost_name.degraded=0; sleep_maxage" EXIT
1760
1761         replay_barrier $SINGLEMDS
1762
1763         # seek past the end of current comp & write, should cause a new comp
1764         # to be created (ie repeat previous comp)
1765         dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
1766                 error "dd to repeat failed"
1767
1768         local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1769
1770         [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1771
1772         flg_opts="--comp-flags init"
1773         found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1774         [ $found -eq 1 ] || error "Write: second component not found"
1775
1776         flg_opts="--comp-flags extension"
1777         found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1778         [ $found -eq 1 ] || error "Write: extension component not found"
1779
1780         fail $SINGLEMDS
1781
1782         local ost_idx2_2=$($LFS getstripe -I2 -i $comp_file)
1783         [ $ost_idx2_2 -ne $ost_idx2 ] && error "$ost_idx2_2 != $ost_idx2"
1784
1785         flg_opts="--comp-flags init"
1786         found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1787         [ $found -eq 1 ] || error "Failover: second component not found"
1788
1789         flg_opts="--comp-flags extension"
1790         found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1791         [ $found -eq 1 ] || error "Failover: extension component not found"
1792
1793         sel_layout_sanity $comp_file 3
1794 }
1795 run_test 22a "Test repeat component behavior with degraded OST"
1796
1797 # Test repeat behavior with low space
1798 test_22b() {
1799         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1800         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1801                 skip "skipped for lustre < $SEL_VER"
1802
1803         local comp_file=$DIR/$tdir/$tfile
1804         local flg_opts=""
1805         local found=""
1806
1807         test_mkdir -p $DIR/$tdir
1808
1809         # without this, a previous delete can finish after we check free space
1810         wait_delete_completed
1811         wait_mds_ost_sync
1812
1813         $LFS setstripe -E -1 -c 1 -z 128M \
1814                 $comp_file || error "Create $comp_file failed"
1815
1816         # write past end of first component, so it is extended
1817         dd if=/dev/zero of=$comp_file bs=1M count=1 seek=130 ||
1818                 error "dd to extend failed"
1819
1820         flg_opts="--comp-flags extension"
1821         found=$($LFS find --comp-start 256M -E EOF $flg_opts $comp_file | wc -l)
1822         [ $found -eq 1 ] || error "Write: Second component not found"
1823
1824         # set our OST low on space
1825         local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1826         local wms=$(ost_watermarks_set_low_space $ost_idx1 | grep "watermarks")
1827
1828         stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1829
1830         # Write past end of current space, fail to extend, causing repeat
1831         dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 ||
1832                 error "dd to repeat failed"
1833
1834         $LFS getstripe $comp_file
1835
1836         local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
1837
1838         [ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
1839
1840         flg_opts="--comp-flags init"
1841         found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1842         [ $found -eq 1 ] || error "Write: Second component not found"
1843
1844         flg_opts="--comp-flags extension"
1845         found=$($LFS find --comp-start 384M -E EOF $flg_opts $comp_file | wc -l)
1846         [ $found -eq 1 ] || error "Write: Extension component not found"
1847
1848         sel_layout_sanity $comp_file 3
1849 }
1850 run_test 22b "Test simple 'out of space' condition with repeat"
1851
1852 # This tests both "repeat" and "extend in place when repeat fails" aspects
1853 # of repeating components
1854 test_22c() {
1855         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1856         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1857                 skip "skipped for lustre < $SEL_VER"
1858
1859         local comp_file=$DIR/$tdir/$tfile
1860         local flg_opts=""
1861         local found=""
1862
1863         test_mkdir -p $DIR/$tdir
1864
1865         # pool is used to limit available OSTs to 0 and 1, so we can set all
1866         # available OSTs out of space
1867         pool_add $TESTNAME || error "Pool creation failed"
1868         pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
1869
1870         # without this, a previous delete can finish after we check free space
1871         wait_delete_completed
1872         wait_mds_ost_sync
1873
1874         $LFS setstripe -E -1 -z 64M -c 1 -p "$TESTNAME" $comp_file || \
1875                 error "Create $comp_file failed"
1876
1877         # write past end of first component, so it is extended
1878         dd if=/dev/zero of=$comp_file bs=1M count=1 seek=80 conv=notrunc ||
1879                 error "dd to extend failed"
1880
1881         $LFS getstripe $comp_file
1882
1883         flg_opts="--comp-flags extension"
1884         found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1885         [ $found -eq 1 ] || error "Write: second component not found"
1886
1887         # set our OST out of space
1888         local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
1889         local wms=$(ost_watermarks_set_enospc $tfile $ost_idx1 |
1890                     grep "watermarks")
1891         stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx1 $wms" EXIT
1892
1893         # This should create a repeat component on a new OST
1894         dd if=/dev/zero of=$comp_file bs=1M count=1 seek=180 conv=notrunc ||
1895                 error "dd to repeat failed"
1896
1897         $LFS getstripe $comp_file
1898
1899         local comp_cnt=$($LFS getstripe --component-count $comp_file)
1900         [ $comp_cnt -ne 3 ] && error "component count: $comp_cnt, should be 3"
1901
1902         # New second component should be on a different OST
1903         local ost_idx2=$($LFS getstripe --comp-start=128m \
1904                          --comp-end=192m --comp-flags=init -i $comp_file)
1905
1906         [ $ost_idx1 -eq $ost_idx2 ] && error "2nd comp: same OST $ost_idx1"
1907
1908         local wms2=$(ost_watermarks_set_enospc $tfile $ost_idx2 |
1909                      grep "watermarks")
1910         stack_trap "ost_watermarks_clear_enospc $tfile $ost_idx2 $wms2" EXIT
1911
1912         # now that the second OST is out of space (as is the first OST), we
1913         # attempt to extend.  This should result in an extension of the
1914         # existing component, rather than a new component.
1915         dd if=/dev/zero of=$comp_file bs=1M count=1 seek=240 conv=notrunc ||
1916                 error "dd for forced extension failed"
1917
1918         $LFS getstripe $comp_file
1919
1920         # clear out of space on first OST
1921         ost_watermarks_clear_enospc $tfile $ost_idx1 $wms
1922
1923         # finally, now that the first OST has space again, we attempt to
1924         # extend one last time.  This should create a new component on the
1925         # first OST
1926         dd if=/dev/zero of=$comp_file bs=1M count=1 seek=300 conv=notrunc ||
1927                 error "dd for repeat on first OST failed"
1928
1929         $LFS getstripe $comp_file
1930
1931         flg_opts="--comp-flags init"
1932         found=$($LFS find --comp-start 128M $flg_opts $comp_file | wc -l)
1933         [ $found -eq 1 ] || error "Write: second component not found"
1934
1935         flg_opts="--comp-flags init"
1936         found=$($LFS find --comp-start 256M $flg_opts $comp_file | wc -l)
1937         [ $found -eq 1 ] || error "Write: third component not found"
1938
1939         flg_opts="--comp-flags extension"
1940         found=$($LFS find --comp-start 320M -E EOF $flg_opts $comp_file | wc -l)
1941         [ $found -eq 1 ] || error "Write: extension component not found"
1942
1943         sel_layout_sanity $comp_file 4
1944 }
1945 run_test 22c "Test repeat with out of space on > 1 OST"
1946
1947 test_22d_post_check() {
1948         local comp_file=$1
1949         local name=$2
1950         local flg_opts="--comp-flags init"
1951         local found=$($LFS find --comp-start 0M -E 128M $flg_opts $comp_file |
1952                       wc -l)
1953         [ $found -eq 1 ] || {
1954                 $LFS getstripe $comp_file
1955                 error "$name: second component not found"
1956         }
1957
1958         flg_opts="--comp-flags extension"
1959         found=$($LFS find --comp-start 128M -E EOF $flg_opts $comp_file | wc -l)
1960         [ $found -eq 1 ] || error "$name: third extension component not found"
1961
1962         sel_layout_sanity $comp_file 2
1963 }
1964
1965 test_22d_pre() {
1966         local comp_file=$1
1967         local wms="$2"
1968         local RC
1969
1970         # write past end of first component
1971         dd if=/dev/zero of=$comp_file bs=1M count=1 seek=70
1972         RC=$?
1973
1974         ost_watermarks_clear_enospc $tfile 0 $wms
1975         [ $RC -eq 0 ] || error "dd to force extend failed"
1976
1977         test_22d_post_check $comp_file "Write"
1978 }
1979
1980 test_22d() {
1981         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1982         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
1983                 skip "skipped for lustre < $SEL_VER"
1984
1985         local comp_file=$DIR/$tdir/$tfile
1986         local flg_opts=""
1987         local found=""
1988
1989         test_mkdir -p $DIR/$tdir
1990
1991         # without this, a previous delete can finish after we check free space
1992         wait_delete_completed
1993         wait_mds_ost_sync
1994
1995         # Pool allows us to force use of only certain OSTs
1996         pool_add $TESTNAME || error "Pool creation failed"
1997         pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
1998
1999         # 1. Fail to extend due to OOS, try to repeat within the same pool,
2000         # fail to stripe (again OOS) the 0-length component, remove the
2001         # repeated one, force the extension on the original one.
2002         $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2003                 error "Create $comp_file failed"
2004
2005         replay_barrier $SINGLEMDS
2006
2007         # set our OST out of space
2008         local wms=$(ost_watermarks_set_enospc $tfile 0 | grep "watermarks")
2009
2010         test_22d_pre $comp_file "$wms"
2011         fail $SINGLEMDS
2012         test_22d_post_check $comp_file "Failover"
2013
2014         # 2. repeat with low on space: 0-length repeated component will be
2015         # striped, but still fails to be extended; otherwise the same as (1).
2016         rm -f $comp_file
2017         $LFS setstripe -E -1 -p $TESTNAME -z 64M $comp_file ||
2018                 error "Create $comp_file failed"
2019
2020         replay_barrier $SINGLEMDS
2021
2022         # set our OST low on space
2023         local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2024
2025         test_22d_pre $comp_file "$wms"
2026         fail $SINGLEMDS
2027         test_22d_post_check $comp_file "Failover"
2028 }
2029 run_test 22d "out of/low on space + failed to repeat + forced extension"
2030
2031 test_23a() {
2032         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2033         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2034                 skip "skipped for lustre < $SEL_VER"
2035
2036         local comp_file=$DIR/$tdir/$tfile
2037         test_mkdir -p $DIR/$tdir
2038
2039         $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2040                 error "Create $comp_file failed"
2041
2042         dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2043                 error "dd append failed"
2044
2045         local flg_opts="--comp-start 0 -E EOF --comp-flags init"
2046         local found=$($LFS find $flg_opts $comp_file | wc -l)
2047         [ $found -eq 1 ] || error "Append: first component (0-EOF) not found"
2048
2049         local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2050         [ "$ost_idx" != "" ] && error "Append: second component still exists"
2051
2052         sel_layout_sanity $comp_file 1
2053 }
2054 run_test 23a "Append: remove EXT comp"
2055
2056 test_23b() {
2057         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2058         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2059                 skip "skipped for lustre < $SEL_VER"
2060
2061         local comp_file=$DIR/$tdir/$tfile
2062         test_mkdir -p $DIR/$tdir
2063
2064         $LFS setstripe -E 64m -E -1 -z 64M $comp_file ||
2065                 error "Create $comp_file failed"
2066
2067         dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2068                 error "dd append failed"
2069
2070         local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2071         local found=$($LFS find $flg_opts $comp_file | wc -l)
2072         [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2073
2074         local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2075         [ "$ost_idx" != "" ] && error "Append: third component still exists"
2076
2077         sel_layout_sanity $comp_file 2
2078 }
2079 run_test 23b "Append with 0-length comp: remove EXT comp"
2080
2081 test_23c() {
2082         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2083         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2084                 skip "skipped for lustre < $SEL_VER"
2085
2086         local comp_file=$DIR/$tdir/$tfile
2087         test_mkdir -p $DIR/$tdir
2088
2089         wait_delete_completed
2090         wait_mds_ost_sync
2091
2092         pool_add $TESTNAME || error "Pool creation failed"
2093         pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2094         $LFS setstripe -E 64m -E -1 -p $TESTNAME -z 64M $comp_file ||
2095                 error "Create $comp_file failed"
2096
2097         local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2098         dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2099         RC=$?
2100
2101         ost_watermarks_clear_enospc $tfile 0 $wms
2102         [ $RC -eq 0 ] || error "dd append failed: $RC"
2103
2104         local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2105         local found=$($LFS find $flg_opts $comp_file | wc -l)
2106         [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2107
2108         local ost_idx=$($LFS getstripe -I3 -i $comp_file)
2109         [ "$ost_idx" != "" ] && error "Append: EXT component still exists"
2110
2111         sel_layout_sanity $comp_file 2
2112 }
2113 run_test 23c "Append with low on space + 0-length comp: force extension"
2114
2115 test_23d() {
2116         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2117         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2118                 skip "skipped for lustre < $SEL_VER"
2119
2120         local comp_file=$DIR/$tdir/$tfile
2121         test_mkdir -p $DIR/$tdir
2122
2123         $LFS setstripe -E 64m -E 640M -z 64M -E -1 $comp_file ||
2124                 error "Create $comp_file failed"
2125
2126         dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file ||
2127                 error "dd append failed"
2128
2129         flg_opts="--comp-start 64M -E 640M --comp-flags init"
2130         found=$($LFS find $flg_opts $comp_file | wc -l)
2131         [ $found -eq 1 ] || error "Append: component (64M-640M) not found"
2132
2133         ost_idx=$($LFS getstripe -I3 -i $comp_file)
2134         [ "$ost_idx" != "" ] && error "Append: third component still exists"
2135
2136         sel_layout_sanity $comp_file 3
2137 }
2138 run_test 23d "Append with 0-length comp + next real comp: remove EXT comp"
2139
2140 test_23e() {
2141         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2142         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2143                 skip "skipped for lustre < $SEL_VER"
2144
2145         local comp_file=$DIR/$tdir/$tfile
2146         test_mkdir -p $DIR/$tdir
2147
2148         wait_delete_completed
2149         wait_mds_ost_sync
2150
2151         pool_add $TESTNAME || error "Pool creation failed"
2152         pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
2153
2154         $LFS setstripe -E 64m -E 640M -z 64M -p $TESTNAME -E -1 $comp_file ||
2155                 error "Create $comp_file failed"
2156
2157         local wms=$(ost_watermarks_set_low_space 0 | grep "watermarks")
2158
2159         dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2160         RC=$?
2161
2162         ost_watermarks_clear_enospc $tfile 0 $wms
2163         [ $RC -eq 0 ] || error "dd append failed $RC"
2164
2165         local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2166         local found=$($LFS find $flg_opts $comp_file | wc -l)
2167         [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2168
2169         local ost_idx=$($LFS getstripe -I2 -i $comp_file)
2170         [ "$ost_idx" != "" ] && error "Append: 0-length component still exists"
2171         ost_idx=$($LFS getstripe -I3 -i $comp_file)
2172         [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2173
2174         sel_layout_sanity $comp_file 2
2175 }
2176 run_test 23e "Append with next real comp: spillover and backward extension"
2177
2178 test_23f() {
2179         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2180         [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2181                 skip "skipped for lustre < $SEL_VER"
2182
2183         local comp_file=$DIR/$tdir/$tfile
2184         test_mkdir -p $DIR/$tdir
2185
2186         $LFS setstripe -z 64M -c 1 -E -1 $comp_file ||
2187                 error "Create $comp_file failed"
2188
2189         local ost_idx=$($LFS getstripe -I1 -i $comp_file)
2190         local wms=$(ost_watermarks_set_low_space $ost_idx | grep "watermarks")
2191
2192         dd if=/dev/zero bs=1M oflag=append count=1 of=$comp_file
2193         RC=$?
2194
2195         ost_watermarks_clear_enospc $tfile $ost_idx $wms
2196         [ $RC -eq 0 ] || error "dd append failed"
2197
2198         local flg_opts="--comp-start 64M -E EOF --comp-flags init"
2199         local found=$($LFS find $flg_opts $comp_file | wc -l)
2200         [ $found -eq 1 ] || error "Append: component (64M-EOF) not found"
2201
2202         ost_idx=$($LFS getstripe -I2 -i $comp_file)
2203         [ "$ost_idx" != "" ] && error "Append: extension component still exists"
2204
2205         sel_layout_sanity $comp_file 2
2206 }
2207 run_test 23f "Append with low on space: repeat and remove EXT comp"
2208
2209 complete $SECONDS
2210 check_and_cleanup_lustre
2211 exit_status