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