Whamcloud - gitweb
70a79c2ae17520fe944d294e7e08e34b421a4169
[fs/lustre-release.git] / lustre / tests / ost-pools.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 #
6 # Run test by setting NOSETUP=true when ltest has setup env for us
7
8 SRCDIR=`dirname $0`
9 export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
10
11 ONLY=${ONLY:-"$*"}
12 ALWAYS_EXCEPT="$OST_POOLS_EXCEPT"
13 # bug number for skipped test: -
14 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15
16 [ "$ALWAYS_EXCEPT$EXCEPT" ] && \
17         echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT`"
18
19 TMP=${TMP:-/tmp}
20 ORIG_PWD=${PWD}
21
22 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
23 . $LUSTRE/tests/test-framework.sh
24 init_test_env $@
25 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
26
27 check_and_setup_lustre
28
29 DIR=${DIR:-$MOUNT}
30 assert_DIR
31
32 POOLSLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
33 [ "$POOLSLOG" ] && rm -f $POOLSLOG || true
34 build_test_filter
35
36 FAIL_ON_ERROR=${FAIL_ON_ERROR:-true}
37
38 LFS=${LFS:-lfs}
39 LCTL=${LCTL:-lctl}
40 SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
41 GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"}
42
43
44 TSTUSR=${TSTUSR:-"quota_usr"}
45 TSTID=${TSTID:-60000}
46 RUNAS="runas -u $TSTID -g $TSTID"
47
48 # OST pools tests
49 POOL=${POOL:-pool1}
50 POOL2=${POOL2:-pool2}
51 POOL3=${POOL3:-pool3}
52 NON_EXISTANT_POOL=nonexistantpool
53 NON_EXISTANT_FS=nonexistantfs
54 INVALID_POOL=some_invalid_pool_name
55 TGT_COUNT=$OSTCOUNT
56 TGT_FIRST=0
57 TGT_MAX=$((TGT_COUNT-1))
58 TGT_STEP=1
59 TGT_LIST=$(seq $TGT_FIRST $TGT_STEP $TGT_MAX)
60 TGT_LIST2=$(seq $TGT_FIRST 2 $TGT_MAX)
61
62 TGT_ALL="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/1]"
63 TGT_HALF="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]"
64
65 TGT_UUID=$(for i in $TGT_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
66 TGT_UUID2=$(for i in $TGT_LIST2; do printf "$FSNAME-OST%04x_UUID " $i; done)
67
68 create_dir() {
69     local dir=$1
70     local pool=$2
71     local count=${3:-"-1"}
72     local idx=$4
73
74     mkdir -p $dir
75     if [[ -n $4 ]]; then
76         $SETSTRIPE -c $count -p $pool $dir -o $idx
77     else
78         $SETSTRIPE -c $count -p $pool $dir
79     fi
80     [[ $? -eq 0 ]] || \
81         error "$SETSTRIPE -p $pool $dir failed."
82 }
83
84 create_file() {
85     local file=$1
86     local pool=$2
87     local count=${3:-"-1"}
88     local index=${4:-"-1"}
89     rm -f $file
90     $SETSTRIPE -o $index -c $count -p $pool $file
91     [[ $? -eq 0 ]] || \
92         error "$SETSTRIPE -p $pool $file failed."
93 }
94
95 osts_in_pool() {
96     local pool=$1
97     local res
98     for i in $(do_facet $SINGLEMDS lctl pool_list $FSNAME.$pool | \
99         grep -v "^Pool:" | sed -e 's/_UUID$//;s/^.*-OST//'); do
100       res="$res $(printf "%d" 0x$i)"
101     done
102     echo $res
103 }
104
105 check_dir_in_pool() {
106     local dir=$1
107     local pool=$2
108     local res=$($GETSTRIPE $dir | grep "^stripe_count:" \
109         | cut -d ':' -f 5 | tr -d "[:blank:]")
110     if [[ "$res" == "$pool" ]]; then
111         return 0
112     else
113         error found $res instead of $pool
114         return 1
115     fi
116 }
117
118 check_file_in_pool() {
119     local osts=$(osts_in_pool $2)
120     check_file_in_osts $1 "$osts" $3
121 }
122
123 check_file_in_osts() {
124         local file=$1
125         local pool_list=${2:-$TGT_LIST}
126         local count=$3
127         local res=$($GETSTRIPE $file | grep 0x | cut -f2)
128         local i
129         for i in $res
130         do
131                 found=$(echo :$pool_list: | tr " " ":"  | grep :$i:)
132                 if [[ "$found" == "" ]]; then
133                         echo "pool list: $pool_list"
134                         echo "striping: $res"
135                         $GETSTRIPE $file
136                         error "$file not allocated from OSTs $pool_list."
137                         return 1
138                 fi
139         done
140
141         local ost_count=$($GETSTRIPE $file | grep 0x | wc -l)
142         [[ -n "$count" ]] && [[ $ost_count -ne $count ]] && \
143             error "Stripe count $count expected; got $ost_count"
144                 
145         return 0
146 }
147
148 check_file_not_in_pool() {
149     local file=$1
150     local pool=$2
151     local res=$($GETSTRIPE -v $file | grep "^pool:" | tr -d "[:blank:]" | cut -f 2 -d ':')
152     if [[ "$res" == "$pool" ]]; then
153         error "File $file is in pool: $res"
154         return 1
155     else
156         return 0
157     fi
158 }
159
160 check_dir_not_in_pool() {
161     local dir=$1
162     local pool=$2
163     local res=$($GETSTRIPE -v $dir | grep "^stripe_count" | head -1 | \
164         cut -f 8 -d ' ')
165     if [[ "$res" == "$pool" ]]; then
166         error "File $dir is in pool: $res"
167         return 1
168     else
169         return 0
170     fi
171 }
172
173 create_pool() {
174     do_facet $SINGLEMDS lctl pool_new $FSNAME.$1
175     local RC=$?
176     # get param should return err until pool is created
177     [[ $RC -ne 0 ]] && return $RC
178
179     wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$1 \
180         2>/dev/null || echo foo" "" || RC=1
181     [[ $RC -ne 0 ]] && error "pool_new failed"
182     return $RC
183 }
184
185 drain_pool() {
186     pool=$1
187     wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool" ""\
188         ||error "Failed to remove targets from pool: $pool"
189 }
190
191 add_pool() {
192     local pool=$1
193     local osts=$2
194     local tgt="${3}$(lctl get_param -n lov.$FSNAME-*.pools.$pool | \
195         sort -u | tr '\n' ' ')"
196
197     do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool $osts
198     local RC=$?
199     [[ $RC -ne 0 ]] && return $RC
200
201     wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool | \
202         sort -u | tr '\n' ' ' " "$tgt" || RC=1
203     [[ $RC -ne 0 ]] && error "pool_add failed: $1; $2"
204     return $RC
205 }
206
207 create_pool_nofail() {
208     create_pool $1
209     if [[ $? != 0 ]]
210     then
211         error "Pool creation of $1 failed"
212     fi
213 }
214
215 create_pool_fail() {
216     create_pool $1
217     if [[ $? == 0 ]]
218     then
219         error "Pool creation of $1 succeeded; should have failed"
220     fi
221 }
222
223 cleanup_tests() {
224     # Destroy pools from previous test runs
225     for p in $(do_facet $SINGLEMDS lctl pool_list $FSNAME | \
226       grep $FSNAME.pool[0-$OSTCOUNT]); do
227         destroy_pool_int $p;
228     done
229     rm -rf $DIR/d0.${TESTSUITE}
230 }
231
232 ost_pools_init() {
233     cleanup_tests
234 }
235
236
237 # Initialization
238 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
239 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
240 ost_pools_init
241
242 # Tests for new commands added
243
244 test_1() {
245     echo "Creating a pool with a 1 character pool name"
246     create_pool_nofail p
247
248     echo "Creating a pool with a 10 character pool name"
249     create_pool_nofail p123456789
250     destroy_pool p123456789
251
252     echo "Creating a pool with a 16 character pool name"
253     create_pool_nofail p123456789123456
254     destroy_pool p123456789123456
255
256     echo "Creating a pool with a 17 character pool name; should fail"
257     create_pool_fail p1234567891234567
258
259     echo "Creating a pool with a 1000 character pool name; should fail"
260     NAME="p"
261     for i in `seq 1 999`; do NAME=${NAME}"o"; done
262     create_pool_fail $NAME
263
264     echo "pool_new should fail if fs-name or poolname are missing."
265     do_facet $SINGLEMDS lctl pool_new .pool1
266     [[ $? -ne 0 ]] || \
267         error "pool_new did not fail even though fs-name was missing."
268     do_facet $SINGLEMDS lctl pool_new pool1
269     [[ $? -ne 0 ]] || \
270         error "pool_new did not fail even though fs-name was missing."
271     do_facet $SINGLEMDS lctl pool_new ${FSNAME}.
272     [[ $? -ne 0 ]] || \
273         error "pool_new did not fail even though pool name was missing."
274     do_facet $SINGLEMDS lctl pool_new .
275     [[ $? -ne 0 ]] || \
276         error "pool_new did not fail even though pool name and fs-name " \
277             "were missing."
278     do_facet $SINGLEMDS lctl pool_new ${FSNAME},pool1
279     [[ $? -ne 0 ]] || \
280         error "pool_new did not fail even though pool name format was wrong"
281     do_facet $SINGLEMDS lctl pool_new ${FSNAME}/pool1
282     [[ $? -ne 0 ]] || \
283         error "pool_new did not fail even though pool name format was wrong"
284
285     do_facet $SINGLEMDS lctl pool_new ${FSNAME}.p
286     [[ $? -ne 0 ]] || \
287         error "pool_new did not fail even though pool1 existed"
288     destroy_pool p
289
290 }
291 run_test 1 "Test lctl pool_new  ========================================="
292
293 test_2a() {
294     destroy_pool $POOL
295
296     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
297     [[ $? -ne 0 ]] || \
298         error " pool_add did not fail even though pool did " \
299         " not exist."
300 }
301 run_test 2a "pool_add: non-existant pool"
302
303 test_2b() {
304     do_facet $SINGLEMDS lctl pool_add $FSNAME.p1234567891234567890 \
305         $FSNAME-OST0000
306     [[ $? -ne 0 ]] || \
307         error "pool_add did not fail even though pool name was invalid."
308 }
309 run_test 2b "pool_add: Invalid pool name"
310
311 # Testing various combinations of OST name list
312 test_2c() {
313     local TGT
314     local RC
315
316     lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
317     [[ $? -ne 0 ]] || \
318         destroy_pool $POOL
319
320     create_pool_nofail $POOL
321
322     # 1. OST0000
323     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
324     RC=$?; [[ $RC -eq 0 ]] || \
325         error "pool_add failed. $FSNAME $POOL OST0000: $RC"
326     do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
327     drain_pool $POOL
328
329     # 2. lustre-OST0000
330     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
331     RC=$?; [[ $RC -eq 0 ]] || \
332         error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000: $RC"
333     do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
334     drain_pool $POOL
335
336     # 3. lustre-OST0000_UUID
337     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
338     RC=$?; [[ $RC -eq 0 ]] || \
339         error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000_UUID: $RC"
340     do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
341     drain_pool $POOL
342
343     # 4. lustre-OST[0,1,2,3,]
344     TGT="$FSNAME-OST["
345     for i in $TGT_LIST; do TGT=${TGT}$(printf "$i," $i); done
346     TGT="${TGT}]"
347     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
348     [[ $? -eq 0 ]] || \
349         error "pool_add failed. $FSNAME.$POOL $TGT. $RC"
350     do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT
351     drain_pool $POOL
352
353     # 5. lustre-OST[0-5/1]
354     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
355     RC=$?; [[ $RC -eq 0 ]] || \
356         error "pool_add failed. $FSNAME $POOL" "$TGT_ALL $RC"
357     wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
358       sort -u | tr '\n' ' ' " "$TGT_UUID" || error "Add to pool failed"
359     do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
360     drain_pool $POOL
361
362     destroy_pool $POOL
363 }
364 run_test 2c "pool_add: OST index combinations ==========================="
365
366 test_2d() {
367     local TGT
368     local RC
369
370     lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
371     [[ $? -ne 0 ]] || \
372         destroy_pool $POOL
373
374     create_pool_nofail $POOL
375
376     TGT=$(printf "$FSNAME-OST%04x_UUID " $OSTCOUNT)
377     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
378     RC=$?; [[ $RC -ne 0 ]] || \
379         error "pool_add succeeded for an OST ($TGT) that does not exist."
380
381     destroy_pool $POOL
382 }
383 run_test 2d "pool_add: OSTs that don't exist should be rejected ========"
384
385 test_2e() {
386     local TGT
387     local RC
388     local RESULT
389
390     $LCTL get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
391     [[ $? -ne 0 ]] || \
392         destroy_pool $POOL
393
394     create_pool_nofail $POOL
395
396     TGT="$FSNAME-OST0000_UUID "
397     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
398     wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
399       sort -u | tr '\n' ' ' " "$TGT" || error "Add to pool failed"
400     RESULT=$(do_facet $SINGLEMDS \
401         "LOCALE=C $LCTL pool_add $FSNAME.$POOL $TGT 2>&1")
402     RC=$?
403     echo $RESULT
404
405     [[ $RC -ne 0 ]] || \
406         error "pool_add succeeded for an OST that was already in the pool."
407
408     [[ $(grep "already in pool" <<< $RESULT) ]] || \
409         error "pool_add failed as expected but error message not as expected."
410
411     destroy_pool $POOL
412 }
413 run_test 2e "pool_add: OST already in a pool should be rejected ========"
414
415 test_3a() {
416     lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
417     [[ $? -ne 0 ]] || \
418         destroy_pool $POOL
419
420     do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
421     [[ $? -ne 0 ]] || \
422         error "pool_remove did not fail even though" \
423         "pool did not exist."
424 }
425 run_test 3a "pool_remove: non-existant pool"
426
427 test_3b() {
428     do_facet $SINGLEMDS lctl pool_remove ${NON_EXISTANT_FS}.$POOL OST0000
429     [[ $? -ne 0 ]] || \
430         error "pool_remove did not fail even though fsname did not exist."
431 }
432 run_test 3b "pool_remove: non-existant fsname"
433
434 test_3c() {
435     do_facet $SINGLEMDS lctl pool_remove $FSNAME.p1234567891234567890 \
436         $FSNAME-OST0000
437     [[ $? -ne 0 ]] || \
438         error "pool_remove did not fail even though pool name was invalid."
439 }
440 run_test 3c "pool_remove: Invalid pool name"
441
442
443 # Testing various combinations of OST name list
444 test_3d() {
445     lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
446     [[ $? -ne 0 ]] || \
447         destroy_pool $POOL
448
449     create_pool_nofail $POOL
450     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
451     do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
452     [[ $? -eq 0 ]] || \
453         error "pool_remove failed. $FSNAME $POOL OST0000"
454     drain_pool $POOL
455
456     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
457     do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
458     [[ $? -eq 0 ]] || \
459         error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000"
460     drain_pool $POOL
461
462     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
463     do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
464     [[ $? -eq 0 ]] || \
465         error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000_UUID"
466     drain_pool $POOL
467
468     add_pool $POOL $TGT_ALL "$TGT_UUID"
469     do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
470     [[ $? -eq 0 ]] || \
471         error "pool_remove failed. $FSNAME $POOL" $TGT_ALL
472     drain_pool $POOL
473
474     destroy_pool $POOL
475 }
476 run_test 3d "pool_remove: OST index combinations ==========================="
477
478 test_4a() {
479     lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
480     [[ $? -ne 0 ]] || \
481         destroy_pool $POOL
482
483     do_facet $SINGLEMDS lctl pool_destroy $FSNAME.$POOL
484     [[ $? -ne 0 ]] || \
485         error "pool_destroy did not fail even though pool did not exist."
486 }
487 run_test 4a "pool_destroy: non-existant pool"
488
489 test_4b() {
490     do_facet $SINGLEMDS lctl pool_destroy ${NON_EXISTANT_FS}.$POOL
491     [[ $? -ne 0 ]] || \
492         error "pool_destroy did not fail even though the filesystem did not exist."
493 }
494 run_test 4b "pool_destroy: non-existant fs-name"
495
496 test_4c() {
497     create_pool_nofail $POOL
498     add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
499
500     do_facet $SINGLEMDS lctl pool_destroy ${FSNAME}.$POOL
501     [[ $? -ne 0 ]] || \
502         error "pool_destroy succeeded with a non-empty pool name."
503     destroy_pool $POOL
504 }
505 run_test 4c "pool_destroy: non-empty pool ==============================="
506
507 sub_test_5() {
508     local LCMD=$1
509
510     $LCMD pool_list
511     [[ $? -ne 0 ]] || \
512         error "pool_list did not fail even though fsname was not mentioned."
513
514     destroy_pool $POOL
515     destroy_pool $POOL2
516
517     create_pool_nofail $POOL
518     create_pool_nofail $POOL2
519     $LCMD pool_list $FSNAME
520     [[ $? -eq 0 ]] || \
521         error "pool_list $FSNAME failed."
522
523     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
524
525     $LCMD pool_list $FSNAME.$POOL
526     [[ $? -eq 0 ]] || \
527         error "pool_list $FSNAME.$POOL failed."
528
529     $LCMD pool_list ${NON_EXISTANT_FS}
530     [[ $? -ne 0 ]] || \
531         error "pool_list did not fail for a non-existant fsname $NON_EXISTANT_FS"
532
533     $LCMD pool_list ${FSNAME}.$NON_EXISTANT_POOL
534     [[ $? -ne 0 ]] || \
535         error "pool_list did not fail for a non-existant pool $NON_EXISTANT_POOL"
536
537     if [[ ! $(grep $SINGLEMDS <<< $LCMD) ]]; then
538         echo $LCMD pool_list $DIR
539         $LCMD pool_list $DIR
540         [[ $? -eq 0 ]] || \
541             error "pool_list failed for $DIR"
542
543         mkdir -p ${DIR}/d1
544         $LCMD pool_list ${DIR}/d1
545         [[ $? -eq 0 ]] || \
546             error "pool_list failed for ${DIR}/d1"
547     fi
548
549     rm -rf ${DIR}nonexistant
550     $LCMD pool_list ${DIR}nonexistant
551     [[ $? -ne 0 ]] || \
552         error "pool_list did not fail for invalid mountpoint ${DIR}nonexistant"
553
554     destroy_pool $POOL
555     destroy_pool $POOL2
556 }
557
558 test_5() {
559     # Issue commands from client
560     sub_test_5 $LCTL
561     sub_test_5 $LFS
562
563     # Issue commands from MDS
564     sub_test_5 "do_facet $SINGLEMDS lctl"
565     sub_test_5 "do_facet $SINGLEMDS lfs"
566
567 }
568 run_test 5 "lfs/lctl pool_list"
569
570 test_6() {
571     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
572     local POOL_DIR=$POOL_ROOT/dir_tst
573     local POOL_FILE=$POOL_ROOT/file_tst
574
575     create_pool_nofail $POOL
576
577     do_facet $SINGLEMDS lctl pool_list $FSNAME
578     [[ $? -eq 0 ]] || \
579         error "pool_list $FSNAME failed."
580
581     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
582
583     mkdir -p $POOL_DIR
584     $SETSTRIPE -c -1 -p $POOL $POOL_DIR
585     [[ $? -eq 0 ]] || \
586         error "$SETSTRIPE -p $POOL failed."
587     check_dir_in_pool $POOL_DIR $POOL
588
589     # If an invalid pool name is specified, the command should fail
590     $SETSTRIPE -c 2 -p $INVALID_POOL $POOL_DIR
591     [[ $? -ne 0 ]] || \
592         error_ignore 19919 "setstripe to invalid pool did not fail."
593
594     # If the pool name does not exist, the command should fail
595     $SETSTRIPE -c 2 -p $NON_EXISTANT_POOL $POOL_DIR
596     [[ $? -ne 0 ]] || \
597         error_ignore 19919 "setstripe to non-existant pool did not fail."
598
599     # lfs setstripe should work as before if a pool name is not specified.
600     $SETSTRIPE -c -1 $POOL_DIR
601     [[ $? -eq 0 ]] || \
602         error "$SETSTRIPE -p $POOL_DIR failed."
603     $SETSTRIPE -c -1 $POOL_FILE
604     [[ $? -eq 0 ]] || \
605         error "$SETSTRIPE -p $POOL_FILE failed."
606
607     # lfs setstripe should fail if a start index that is outside the
608     # pool is specified.
609     create_pool_nofail $POOL2
610     add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
611     $SETSTRIPE -o 1 -p $POOL2 $ROOT_POOL/$tfile
612     [[ $? -ne 0 ]] || \
613         error "$SETSTRIPE with start index outside the pool did not fail."
614
615     destroy_pool $POOL
616     destroy_pool $POOL2
617 }
618 run_test 6 "getstripe/setstripe"
619
620 test_11() {
621     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
622
623     [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
624
625     create_pool_nofail $POOL
626     create_pool_nofail $POOL2
627
628     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL \
629         $FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]
630     local start=$((TGT_FIRST+1))
631     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
632         $FSNAME-OST[$start-$TGT_MAX/2]
633
634     create_dir $POOL_ROOT/dir1  $POOL
635     create_dir $POOL_ROOT/dir2  $POOL2
636     check_dir_in_pool $POOL_ROOT/dir1 $POOL
637     check_dir_in_pool $POOL_ROOT/dir1 $POOL
638
639     local numfiles=100
640     createmany -o $POOL_ROOT/dir1/$tfile $numfiles || \
641         error "createmany $POOL_ROOT/dir1/$tfile failed!"
642
643     for file in $POOL_ROOT/dir1/*; do
644         check_file_in_pool $file $POOL
645     done
646
647     createmany -o $POOL_ROOT/dir2/$tfile $numfiles || \
648         error "createmany $POOL_ROOT/dir2/$tfile failed!"
649     for file in $POOL_ROOT/dir2/*; do
650         check_file_in_pool $file $POOL2
651     done
652
653     rm -rf $POOL_ROOT/dir?
654
655     destroy_pool $POOL
656     destroy_pool $POOL2
657
658     return 0
659 }
660 run_test 11 "OSTs in overlapping/multiple pools"
661
662 test_12() {
663     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
664
665     [[ $OSTCOUNT -le 2 ]] && skip "Need atleast 3 OSTs" && return
666
667     create_pool_nofail $POOL
668     create_pool_nofail $POOL2
669
670     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL \
671         $FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]
672     local start=$((TGT_FIRST+1))
673     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
674         $FSNAME-OST[$start-$TGT_MAX/2]
675
676     echo creating some files in $POOL and $POOL2
677
678     create_dir $POOL_ROOT/dir1  $POOL
679     create_dir $POOL_ROOT/dir2  $POOL2
680     create_file $POOL_ROOT/file1 $POOL
681     create_file $POOL_ROOT/file2 $POOL2
682
683     echo Checking the files created
684     check_dir_in_pool $POOL_ROOT/dir1 $POOL
685     check_dir_in_pool $POOL_ROOT/dir2 $POOL2
686     check_file_in_pool $POOL_ROOT/file1 $POOL
687     check_file_in_pool $POOL_ROOT/file2 $POOL2
688
689     echo Changing the pool membership
690     do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST[$TGT_FIRST]
691     do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL
692     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 $FSNAME-OST[$TGT_FIRST]
693     do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL2
694
695     echo Checking the files again    
696     check_dir_in_pool $POOL_ROOT/dir1 $POOL
697     check_dir_in_pool $POOL_ROOT/dir2 $POOL2
698     check_file_in_osts $POOL_ROOT/file1 "$TGT_LIST2"    
699     check_file_in_osts $POOL_ROOT/file2 "$(seq $start 2 $TGT_MAX)"
700
701     echo Creating some more files
702     create_dir $POOL_ROOT/dir3 $POOL
703     create_dir $POOL_ROOT/dir4 POOL2
704     create_file $POOL_ROOT/file3 $POOL
705     create_file $POOL_ROOT/file4 $POOL2
706
707     echo Checking the new files 
708     check_file_in_pool $POOL_ROOT/file3 $POOL
709     check_file_in_pool $POOL_ROOT/file4 $POOL2
710
711     destroy_pool $POOL
712     destroy_pool $POOL2
713
714     return 0    
715 }
716 run_test 12 "OST Pool Membership"
717
718 test_13() {
719     [[ $OSTCOUNT -le 2 ]] && skip "Need atleast 3 OSTs" && return
720
721     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
722     local numfiles=10
723     local count=3
724
725     create_pool_nofail $POOL
726     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
727
728     create_dir $POOL_ROOT/dir1 $POOL -1
729     createmany -o $POOL_ROOT/dir1/$tfile $numfiles || \
730         error "createmany $POOL_ROOT/dir1/$tfile failed!"
731     for file in $POOL_ROOT/dir1/*; do
732         check_file_in_pool $file $POOL $OSTCOUNT
733     done
734
735     create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
736     create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST+1))
737     create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST+2))
738     check_file_in_pool $POOL_ROOT/dir1/file1 $POOL 1
739     check_file_in_pool $POOL_ROOT/dir1/file2 $POOL 1
740     create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST+2))
741     check_file_in_osts $POOL_ROOT/dir1/file1 "$TGT_FIRST"
742     check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST+1))"
743     check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST+2))"
744
745     create_dir $POOL_ROOT/dir2 $POOL $count
746     createmany -o $POOL_ROOT/dir2/$tfile $numfiles || \
747         error "createmany $POOL_ROOT/dir2/$tfile failed!"
748     for file in $POOL_ROOT/dir2/*; do
749         check_file_in_pool $file $POOL $count
750     done
751
752     create_dir $POOL_ROOT/dir3 $POOL $count $((TGT_FIRST+1))
753     createmany -o $POOL_ROOT/dir3/$tfile_ $numfiles || \
754         error "createmany $POOL_ROOT/dir3/$tfile_ failed!"
755     for file in $POOL_ROOT/dir3/*; do
756         check_file_in_pool $file $POOL $count
757     done
758
759     create_dir $POOL_ROOT/dir4 $POOL 1
760     createmany -o $POOL_ROOT/dir4/$tfile_ $numfiles || \
761         error "createmany $POOL_ROOT/dir4/$tfile_ failed!"
762     for file in $POOL_ROOT/dir4/*; do
763         check_file_in_pool $file $POOL 1
764     done
765
766     create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST+2))
767     createmany -o $POOL_ROOT/dir5/$tfile_ $numfiles || \
768         error "createmany $POOL_ROOT/dir5/$tfile_ failed!"
769     for file in $POOL_ROOT/dir5/*; do
770         check_file_in_pool $file $POOL 1
771         check_file_in_osts  $file "$((TGT_FIRST+2))"
772     done
773
774     rm -rf create_dir $POOL_ROOT/dir?
775     destroy_pool $POOL
776
777     return 0
778 }
779 run_test 13 "Striping characteristics in a pool"
780
781 test_14() {
782     [[ $OSTCOUNT -le 2 ]] && skip "Need atleast 3 OSTs" && return
783
784     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
785     local numfiles=100
786     local i
787
788     # Create a new filesystem that is guaranteed to be balanced.
789     formatall
790     setupall
791
792     create_pool_nofail $POOL
793     create_pool_nofail $POOL2
794
795     add_pool $POOL $TGT_HALF "$TGT_UUID2"
796     add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
797
798     create_dir $POOL_ROOT/dir1 $POOL 1
799     create_file $POOL_ROOT/dir1/file $POOL 1
800     local OST=$($GETSTRIPE $POOL_ROOT/dir1/file | grep 0x | cut -f2)    
801     i=0
802     while [[ $i -lt $numfiles ]];
803     do
804         OST=$((OST+2))
805         [[ $OST -gt $TGT_MAX ]] && OST=$TGT_FIRST
806
807         # echo "Iteration: $i OST: $OST"
808         create_file $POOL_ROOT/dir1/file${i} $POOL 1
809         check_file_in_osts $POOL_ROOT/dir1/file${i} $OST
810         i=$((i+1))
811     done
812
813     # Fill OST $TGT_FIRST with 10M files
814     create_dir $POOL_ROOT/dir2 $POOL2 1
815     RC=0
816     i=0
817     while [[ $RC -eq 0 ]];
818     do
819       dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1k count=$((1024*10))
820       RC=$?
821       i=$((i+1))
822     done
823
824     # Leave some space on the OST
825     rm -f $POOL_ROOT/dir2/f0
826     df -h /mnt/ost?
827
828     # OST $TGT_FIRST is no longer favored; but it may still be used.
829     create_dir $POOL_ROOT/dir3 $POOL 1
830     create_file $POOL_ROOT/dir3/file $POOL 1
831     createmany -o $POOL_ROOT/dir3/$tfile_ $numfiles || \
832         error "createmany $POOL_ROOT/dir3/$tfile_ failed!"
833     for file in $POOL_ROOT/dir3/*; do
834         check_file_in_pool $file $POOL
835     done
836
837     rm -rf $POOL_ROOT
838     destroy_pool $POOL
839     destroy_pool $POOL2
840     return 0
841 }
842 run_test 14 "Round robin and QOS striping within a pool"
843
844 test_15() {
845     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
846     local numfiles=100
847     local i=0
848
849     while [[ $i -lt $OSTCOUNT ]]
850     do
851       create_pool_nofail pool${i}
852
853       local tgt=$(printf "$FSNAME-OST%04x_UUID " $i)
854       add_pool pool${i} "$FSNAME-OST[$i]" "$tgt"
855       create_dir $POOL_ROOT/dir${i} pool${i}
856       createmany -o $POOL_ROOT/dir$i/$tfile $numfiles || \
857           error "createmany $POOL_ROOT/dir$i/$tfile failed!"
858
859       for file in $POOL_ROOT/dir$i/*; do
860           check_file_in_osts $file $i
861       done
862
863       i=$((i+1))
864     done
865
866     i=0
867     while [[ $i -lt $OSTCOUNT ]]
868     do
869       destroy_pool pool${i}
870       i=$((i+1))
871     done
872
873     return 0
874 }
875 run_test 15 "One directory per OST/pool"
876
877 test_16() {
878     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
879     local numfiles=10
880     local i=0
881
882     create_pool_nofail $POOL
883
884     add_pool $POOL $TGT_HALF "$TGT_UUID2"
885
886     local dir=$POOL_ROOT/$tdir
887     create_dir $dir $POOL
888
889     for i in $(seq 1 10); do
890         dir=${dir}/dir${i}
891     done
892     mkdir -p $dir
893
894     createmany -o $dir/$tfile $numfiles || \
895           error "createmany $dir/$tfile failed!"
896
897     for file in $dir/*; do
898         check_file_in_pool $file $POOL
899     done
900
901     rm -rf $POOL_ROOT/$tdir
902
903     destroy_pool $POOL
904
905     return 0
906 }
907 run_test 16 "Inheritance of pool properties"
908
909 test_17() {
910     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
911     local numfiles=10
912     local i=0
913
914     create_pool_nofail $POOL
915
916     add_pool $POOL $TGT_ALL "$TGT_UUID"
917
918     local dir=$POOL_ROOT/dir
919     create_dir $dir $POOL
920
921     createmany -o $dir/${tfile}1_ $numfiles || \
922           error "createmany $dir/${tfile}1_ failed!"
923
924     for file in $dir/*; do
925         check_file_in_pool $file $POOL
926     done
927
928     destroy_pool $POOL
929
930     createmany -o $dir/${tfile}2_ $numfiles || \
931           error "createmany $dir/${tfile}2_ failed!"
932
933     rm -rf $dir
934     return 0
935 }
936 run_test 17 "Referencing an empty pool"
937
938 create_perf_one() {
939     local dir=$1/d
940     local numfiles=$2
941     local time
942
943     mkdir -p $dir
944     sync; sleep 5 # give pending IO a chance to go to disk
945     stat=$(createmany -o $dir/${tfile} $numfiles)
946     rm -rf $dir
947     sync
948     time=$(echo $stat | cut -f 5 -d ' ')
949     echo $stat > /dev/stderr
950     echo $time
951 }
952
953 create_perf() {
954     local t1=$(create_perf_one $1 $2)
955     local t2=$(create_perf_one $1 $2)
956     local t3=$(create_perf_one $1 $2)
957     local time=$(echo "scale=2; ( $t1 + $t2 + $t3 ) / 3" | bc)
958
959     echo "$time"
960 }
961
962 test_18() {
963     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
964     local numfiles=10000
965     local i=0
966     local time1
967     local time2
968     local time3
969     local dir=$POOL_ROOT/dir
970     local stat
971     local diff
972
973     time1=$(create_perf $dir $numfiles)
974
975     create_pool_nofail $POOL
976
977     add_pool $POOL $TGT_ALL "$TGT_UUID"
978
979     create_dir $dir $POOL
980     time2=$(create_perf $dir $numfiles)
981
982     destroy_pool $POOL
983
984     time3=$(create_perf $dir $numfiles)
985
986     echo Time taken for $numfiles creates without pools: $time1
987     echo Time taken for $numfiles creates with pools: $time2
988     echo Time taken for $numfiles creates without pools: $time3
989
990     deg=$(echo "scale=2; (($time2 - $time3) * 100 / $time3) > 5" | bc)
991     diff=$(echo "scale=2; ($time2 - $time3) * 100 / $time3" | bc)
992
993     if [[ "$deg" == "1" ]]; then
994         error "Performance degradation with pools is $diff %."
995     else
996         echo  "Performance degradation with pools is $diff %."
997     fi
998     return 0
999 }
1000 run_test 18 "File create in a directory which references a deleted pool"
1001
1002
1003 test_19() {
1004     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1005     local numfiles=12
1006     local dir1=$POOL_ROOT/dir1
1007     local dir2=$POOL_ROOT/dir2
1008     local i=0
1009
1010     create_pool_nofail $POOL
1011
1012     add_pool $POOL $TGT_HALF "$TGT_UUID2"
1013
1014     create_dir $dir1 $POOL
1015     createmany -o $dir1/${tfile} $numfiles || \
1016           error "createmany $dir1/${tfile} failed!"
1017     for file in $dir1/*; do
1018         check_file_in_pool $file $POOL
1019     done
1020
1021     mkdir -p $dir2
1022     createmany -o $dir2/${tfile} $numfiles || \
1023           error "createmany $dir2/${tfile} failed!"
1024     for file in $dir2/*; do
1025         check_file_not_in_pool $file $POOL
1026     done
1027
1028     rm -rf $dir1 $dir2
1029     destroy_pool $POOL
1030
1031     return 0
1032 }
1033 run_test 19 "Pools should not come into play when not specified"
1034
1035 test_20() {
1036     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1037     local numfiles=12
1038     local dir1=$POOL_ROOT/dir1
1039     local dir2=$dir1/dir2
1040     local dir3=$dir1/dir3
1041     local i=0
1042     local TGT
1043
1044     create_pool_nofail $POOL
1045     create_pool_nofail $POOL2
1046
1047     add_pool $POOL $TGT_HALF "$TGT_UUID2"
1048
1049     local start=$((TGT_FIRST+1))
1050     TGT=$(for i in `seq $start 2 $TGT_MAX`; \
1051         do printf "$FSNAME-OST%04x_UUID " $i; done)
1052     add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1053
1054     create_dir $dir1 $POOL
1055     create_file $dir1/file1 $POOL2
1056     create_dir $dir2 $POOL2
1057     touch $dir2/file2
1058     mkdir $dir3
1059     $SETSTRIPE -c 1 $dir3 # No pool assignment
1060     touch $dir3/file3
1061     $SETSTRIPE -c 1 $dir2/file4 # No pool assignment
1062
1063     check_file_in_pool $dir1/file1 $POOL2
1064     check_file_in_pool $dir2/file2 $POOL2
1065
1066     check_dir_not_in_pool $dir3 $POOL
1067     check_dir_not_in_pool $dir3 $POOL2
1068
1069     check_file_not_in_pool $dir3/file3 $POOL
1070     check_file_not_in_pool $dir3/file3 $POOL2
1071
1072     check_file_not_in_pool $dir2/file4 $POOL
1073     check_file_not_in_pool $dir2/file4 $POOL2
1074
1075     rm -rf $dir1
1076     destroy_pool $POOL
1077     destroy_pool $POOL2
1078
1079     return 0
1080 }
1081 run_test 20 "Different pools in a directory hierarchy."
1082
1083 test_21() {
1084     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1085     [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1086
1087     local numfiles=12
1088     local i=0
1089     local dir=$POOL_ROOT/dir
1090
1091     create_pool_nofail $POOL
1092
1093     add_pool $POOL $TGT_HALF "$TGT_UUID2"
1094
1095     create_dir $dir $POOL $OSTCOUNT
1096     create_file $dir/file1 $POOL $OSTCOUNT
1097     $GETSTRIPE -v $dir/file1
1098     check_file_in_pool $dir/file1 $POOL
1099
1100     rm -rf $dir
1101     destroy_pool $POOL
1102
1103     return 0
1104 }
1105 run_test 21 "OST pool with fewer OSTs than stripe count"
1106
1107 add_loop() {
1108     local pool=$1
1109     local step=$2
1110
1111     echo loop for $pool
1112
1113     for c in $(seq 1 10);
1114     do
1115         echo "Pool $pool, iteration $c"
1116         create_pool_nofail $pool
1117         local TGT=$(for i in `seq $TGT_FIRST $step $TGT_MAX`; \
1118             do printf "$FSNAME-OST%04x_UUID " $i; done)
1119         add_pool $pool "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/$step]" "$TGT"
1120         destroy_pool $pool
1121         do_facet $SINGLEMDS lctl pool_list $FSNAME
1122     done
1123     echo loop for $pool complete
1124 }
1125
1126 test_22() {
1127     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1128     [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1129
1130     local numfiles=100
1131
1132     add_loop $POOL 1 &
1133     add_loop $POOL2 2 &
1134     sleep 5
1135     create_dir $POOL_ROOT $POOL
1136     createmany -o $POOL_ROOT/${tfile} $numfiles || \
1137           error "createmany $POOL_ROOT/${tfile} failed!"
1138     wait
1139
1140     return 0
1141 }
1142 run_test 22 "Simultaneous manipulation of a pool"
1143
1144 test_23() {
1145     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1146     [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1147
1148     mkdir -p $POOL_ROOT
1149     check_runas_id $TSTID $TSTID $RUNAS  || {
1150         skip "User $RUNAS_ID does not exist - skipping"
1151         return 0
1152     }
1153
1154     local numfiles=12
1155     local i=0
1156     local TGT
1157     local LIMIT=1024
1158     local dir=$POOL_ROOT/dir
1159     local file1="$dir/$tfile-quota1"
1160     local file2="$dir/$tfile-quota2"
1161
1162     create_pool_nofail $POOL
1163
1164     local TGT=$(for i in `seq $TGT_FIRST 3 $TGT_MAX`; \
1165         do printf "$FSNAME-OST%04x_UUID " $i; done)
1166     add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1167     create_dir $dir $POOL
1168
1169     $LFS quotaoff -ug $MOUNT
1170     $LFS quotacheck -ug $MOUNT
1171     $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir #-i 5 -I 5 $dir
1172
1173     $LFS setstripe $file1 -c 1 -p $POOL
1174     chown $TSTUSR.$TSTUSR $file1
1175     ls -l $file1
1176     type runas
1177
1178     stat=$(LC_ALL=C $RUNAS dd if=/dev/zero of=$file1 bs=1024 count=$((LIMIT*2)) 2>&1)
1179     RC=$?
1180     echo $stat
1181     [[ $RC -eq 0 ]] && error "dd did not fail with EDQUOT."
1182     echo $stat | grep "Disk quota exceeded"
1183     [[ $? -eq 1 ]] && error "dd did not fail with EDQUOT."
1184
1185     echo "second run"
1186     $LFS quotaoff -ug $MOUNT
1187     # $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir
1188     chown $TSTUSR.$TSTUSR $dir
1189     i=0
1190     RC=0
1191     while [ $RC -eq 0 ];
1192     do
1193       i=$((i+1))
1194       stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file2}$i bs=1024 \
1195           count=$((LIMIT*LIMIT)) 2>&1)
1196       RC=$?
1197       if [ $RC -eq 1 ]; then
1198           echo $stat
1199           echo $stat | grep "Disk quota exceeded"
1200           [[ $? -eq 0 ]] && error "dd failed with EDQUOT"
1201
1202           echo $stat | grep "No space left on device"
1203           [[ $? -ne 0 ]] && error "dd did not fail with ENOSPC; " \
1204               "failed with $stat"
1205       fi
1206     done
1207
1208     df -h
1209
1210     rm -rf $POOL_ROOT
1211     destroy_pool $POOL
1212
1213     return 0
1214 }
1215 run_test 23 "OST pools and quota"
1216
1217 test_24() {
1218     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1219     [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1220
1221     local numfiles=10
1222     local i=0
1223     local TGT
1224     local dir
1225     local res
1226
1227
1228     create_pool_nofail $POOL
1229
1230     add_pool $POOL $TGT_ALL "$TGT_UUID"
1231
1232     create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1233
1234     mkdir $POOL_ROOT/dir2
1235     $SETSTRIPE $POOL_ROOT/dir2 -p $POOL -s 65536 -i 0 -c 1 || \
1236         error "$SETSTRIPE $POOL_ROOT/dir2 failed"
1237
1238     mkdir $POOL_ROOT/dir3
1239     $SETSTRIPE $POOL_ROOT/dir3 -s 65536 -i 0 -c 1 || \
1240         error "$SETSTRIPE $POOL_ROOT/dir3 failed"
1241
1242     mkdir $POOL_ROOT/dir4
1243
1244     for i in $(seq 1 4);
1245     do
1246       dir=${POOL_ROOT}/dir${i}
1247       local pool
1248       local pool1
1249       local count
1250       local count1
1251       local index
1252       local size
1253       local size1
1254
1255       createmany -o $dir/${tfile} $numfiles || \
1256           error "createmany $dir/${tfile} failed!"
1257       res=$($GETSTRIPE -v $dir | grep "^stripe_count:")
1258       if [ $? -ne 0 ]; then
1259           res=$($GETSTRIPE -v $dir | grep "^(Default) ")
1260           pool=$(cut -f 9 -d ' ' <<< $res)
1261           index=$(cut -f 7 -d ' ' <<< $res)
1262           size=$(cut -f 5 -d ' ' <<< $res)
1263           count=$(cut -f 3 -d ' ' <<< $res)
1264       else
1265           pool=$(cut -f 8 -d ' ' <<< $res)
1266           index=$(cut -f 6 -d ' ' <<< $res)
1267           size=$(cut -f 4 -d ' ' <<< $res)
1268           count=$(cut -f 2 -d ' ' <<< $res)
1269       fi
1270
1271       for file in $dir/*; do
1272           if [ "$pool" != "" ]; then
1273               check_file_in_pool $file $pool
1274           fi
1275           pool1=$($GETSTRIPE -v $file | grep "^pool:" |\
1276               tr -d '[:blank:]' | cut -f 2 -d ':')
1277           count1=$($GETSTRIPE -v $file | grep "^lmm_stripe_count:" |\
1278               tr -d '[:blank:]' | cut -f 2 -d ':')
1279           size1=$($GETSTRIPE -v $file | grep "^lmm_stripe_size:" |\
1280               tr -d '[:blank:]' | cut -f 2 -d ':')
1281           [[ "$pool" != "$pool1" ]] && \
1282               error "Pool name ($pool) not inherited in $file($pool1)"
1283           [[ "$count" != "$count1" ]] && \
1284               error "Stripe count ($count) not inherited in $file ($count1)"
1285           [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] && \
1286               error "Stripe size ($size) not inherited in $file ($size1)"
1287       done 
1288     done
1289
1290     rm -rf $POOL_ROOT
1291     destroy_pool $POOL
1292
1293     return 0
1294 }
1295 run_test 24 "Independence of pool from other setstripe parameters"
1296
1297 test_25() {
1298     local dev=$(mdsdevname ${SINGLEMDS//mds/})
1299     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1300
1301     mkdir -p $POOL_ROOT
1302
1303     for i in $(seq 10); do
1304         create_pool_nofail pool$i
1305         stop $SINGLEMDS || return 1
1306         sleep 10
1307         start $SINGLEMDS ${dev} $MDS_MOUNT_OPTS  || \
1308             error "Failed to start $SINGLEMDS after stopping" 
1309
1310         # Veriy that the pool got created and is usable
1311         echo "Creating a file in pool$i"
1312         create_file $POOL_ROOT/file$i pool$i
1313         check_file_in_pool $POOL_ROOT/file$i pool$i
1314     done
1315
1316     rm -rf $POOL_ROOT
1317     for i in $(seq 10); do
1318         destroy_pool pool$i
1319     done
1320 }
1321 run_test 25 "Create new pool and restart MDS ======================="
1322
1323 log "cleanup: ======================================================"
1324 cd $ORIG_PWD
1325 cleanup_tests
1326 check_and_cleanup_lustre
1327 echo '=========================== finished ==============================='
1328 [ -f "$POOLSLOG" ] && cat $POOLSLOG && grep -q FAIL $POOLSLOG && exit 1 || true
1329 echo "$0: completed"