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