Whamcloud - gitweb
Branch HEAD
[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 create_pool() {
176     do_facet $SINGLEMDS lctl pool_new $FSNAME.$1
177     local RC=$?
178     # get param should return err until pool is created
179     [[ $RC -ne 0 ]] && return $RC
180
181     wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$1 \
182         2>/dev/null || echo foo" "" || RC=1
183     [[ $RC -ne 0 ]] && error "pool_new failed"
184     return $RC
185 }
186
187 drain_pool() {
188     pool=$1
189     wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool" ""\
190         ||error "Failed to remove targets from pool: $pool"
191 }
192
193 add_pool() {
194     local pool=$1
195     local osts=$2
196     local tgt="${3}$(lctl get_param -n lov.$FSNAME-*.pools.$pool | \
197         sort -u | tr '\n' ' ')"
198
199     do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool $osts
200     local RC=$?
201     [[ $RC -ne 0 ]] && return $RC
202
203     wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool | \
204         sort -u | tr '\n' ' ' " "$tgt" || RC=1
205     [[ $RC -ne 0 ]] && error "pool_add failed: $1; $2"
206     return $RC
207 }
208
209 create_pool_nofail() {
210     create_pool $1
211     if [[ $? != 0 ]]
212     then
213         error "Pool creation of $1 failed"
214     fi
215 }
216
217 create_pool_fail() {
218     create_pool $1
219     if [[ $? == 0 ]]
220     then
221         error "Pool creation of $1 succeeded; should have failed"
222     fi
223 }
224
225 cleanup_tests() {
226     # Destroy pools from previous test runs
227     for p in $(do_facet $SINGLEMDS lctl pool_list $FSNAME | \
228       grep $FSNAME.pool[0-$OSTCOUNT]); do
229         destroy_pool_int $p;
230     done
231     rm -rf $DIR/d0.${TESTSUITE}
232 }
233
234 ost_pools_init() {
235     cleanup_tests
236 }
237
238
239 # Initialization
240 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
241 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
242 ost_pools_init
243
244 # Tests for new commands added
245
246 test_1() {
247     echo "Creating a pool with a 1 character pool name"
248     create_pool_nofail p
249
250     echo "Creating a pool with a 10 character pool name"
251     create_pool_nofail p123456789
252     destroy_pool p123456789
253
254     echo "Creating a pool with a 16 character pool name"
255     create_pool_nofail p123456789123456
256     destroy_pool p123456789123456
257
258     echo "Creating a pool with a 17 character pool name; should fail"
259     create_pool_fail p1234567891234567
260
261     echo "Creating a pool with a 1000 character pool name; should fail"
262     NAME="p"
263     for i in `seq 1 999`; do NAME=${NAME}"o"; done
264     create_pool_fail $NAME
265
266     echo "pool_new should fail if fs-name or poolname are missing."
267     do_facet $SINGLEMDS lctl pool_new .pool1 2>/dev/null
268     [[ $? -ne 0 ]] || \
269         error "pool_new did not fail even though fs-name was missing."
270     do_facet $SINGLEMDS lctl pool_new pool1 2>/dev/null
271     [[ $? -ne 0 ]] || \
272         error "pool_new did not fail even though fs-name was missing."
273     do_facet $SINGLEMDS lctl pool_new ${FSNAME}. 2>/dev/null
274     [[ $? -ne 0 ]] || \
275         error "pool_new did not fail even though pool name was missing."
276     do_facet $SINGLEMDS lctl pool_new . 2>/dev/null
277     [[ $? -ne 0 ]] || \
278         error "pool_new did not fail even though pool name and fs-name " \
279             "were missing."
280     do_facet $SINGLEMDS lctl pool_new ${FSNAME},pool1 2>/dev/null
281     [[ $? -ne 0 ]] || \
282         error "pool_new did not fail even though pool name format was wrong"
283     do_facet $SINGLEMDS lctl pool_new ${FSNAME}/pool1 2>/dev/null
284     [[ $? -ne 0 ]] || \
285         error "pool_new did not fail even though pool name format was wrong"
286
287     do_facet $SINGLEMDS lctl pool_new ${FSNAME}.p 2>/dev/null
288     [[ $? -ne 0 ]] || \
289         error "pool_new did not fail even though pool1 existed"
290     destroy_pool p
291
292 }
293 run_test 1 "Test lctl pool_new  ========================================="
294
295 test_2a() {
296     destroy_pool $POOL
297
298     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
299     [[ $? -ne 0 ]] || \
300         error " pool_add did not fail even though pool did " \
301         " not exist."
302 }
303 run_test 2a "pool_add: non-existant pool"
304
305 test_2b() {
306     do_facet $SINGLEMDS lctl pool_add $FSNAME.p1234567891234567890 \
307         $FSNAME-OST0000 2>/dev/null
308     [[ $? -ne 0 ]] || \
309         error "pool_add did not fail even though pool name was invalid."
310 }
311 run_test 2b "pool_add: Invalid pool name"
312
313 # Testing various combinations of OST name list
314 test_2c() {
315     local TGT
316     local RC
317
318     lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
319     [[ $? -ne 0 ]] || \
320         destroy_pool $POOL
321
322     create_pool_nofail $POOL
323
324     # 1. OST0000
325     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
326     RC=$?; [[ $RC -eq 0 ]] || \
327         error "pool_add failed. $FSNAME $POOL OST0000: $RC"
328     do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
329     drain_pool $POOL
330
331     # 2. lustre-OST0000
332     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
333     RC=$?; [[ $RC -eq 0 ]] || \
334         error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000: $RC"
335     do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
336     drain_pool $POOL
337
338     # 3. lustre-OST0000_UUID
339     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
340     RC=$?; [[ $RC -eq 0 ]] || \
341         error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000_UUID: $RC"
342     do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
343     drain_pool $POOL
344
345     # 4. lustre-OST[0,1,2,3,]
346     TGT="$FSNAME-OST["
347     for i in $TGT_LIST; do TGT=${TGT}$(printf "$i," $i); done
348     TGT="${TGT}]"
349     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
350     [[ $? -eq 0 ]] || \
351         error "pool_add failed. $FSNAME.$POOL $TGT. $RC"
352     do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT
353     drain_pool $POOL
354
355     # 5. lustre-OST[0-5/1]
356     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
357     RC=$?; [[ $RC -eq 0 ]] || \
358         error "pool_add failed. $FSNAME $POOL" "$TGT_ALL $RC"
359     wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
360       sort -u | tr '\n' ' ' " "$TGT_UUID" || error "Add to pool failed"
361     do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
362     drain_pool $POOL
363
364     destroy_pool $POOL
365 }
366 run_test 2c "pool_add: OST index combinations ==========================="
367
368 test_2d() {
369     local TGT
370     local RC
371
372     lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
373     [[ $? -ne 0 ]] || \
374         destroy_pool $POOL
375
376     create_pool_nofail $POOL
377
378     TGT=$(printf "$FSNAME-OST%04x_UUID " $OSTCOUNT)
379     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
380     RC=$?; [[ $RC -ne 0 ]] || \
381         error "pool_add succeeded for an OST ($TGT) that does not exist."
382
383     destroy_pool $POOL
384 }
385 run_test 2d "pool_add: OSTs that don't exist should be rejected ========"
386
387 test_2e() {
388     local TGT
389     local RC
390     local RESULT
391
392     $LCTL get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
393     [[ $? -ne 0 ]] || \
394         destroy_pool $POOL
395
396     create_pool_nofail $POOL
397
398     TGT="$FSNAME-OST0000_UUID "
399     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
400     wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
401       sort -u | tr '\n' ' ' " "$TGT" || error "Add to pool failed"
402     RESULT=$(do_facet $SINGLEMDS \
403         "LOCALE=C $LCTL pool_add $FSNAME.$POOL $TGT 2>&1")
404     RC=$?
405     echo $RESULT
406
407     [[ $RC -ne 0 ]] || \
408         error "pool_add succeeded for an OST that was already in the pool."
409
410     [[ $(grep "already in pool" <<< $RESULT) ]] || \
411         error "pool_add failed as expected but error message not as expected."
412
413     destroy_pool $POOL
414 }
415 run_test 2e "pool_add: OST already in a pool should be rejected ========"
416
417 test_3a() {
418     lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
419     [[ $? -ne 0 ]] || \
420         destroy_pool $POOL
421
422     do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
423     [[ $? -ne 0 ]] || \
424         error "pool_remove did not fail even though pool did not exist."
425 }
426 run_test 3a "pool_remove: non-existant pool"
427
428 test_3b() {
429     do_facet $SINGLEMDS lctl pool_remove ${NON_EXISTANT_FS}.$POOL OST0000 2>/dev/null
430     [[ $? -ne 0 ]] || \
431         error "pool_remove did not fail even though fsname did not exist."
432 }
433 run_test 3b "pool_remove: non-existant fsname"
434
435 test_3c() {
436     do_facet $SINGLEMDS lctl pool_remove $FSNAME.p1234567891234567890 \
437         $FSNAME-OST0000 2>/dev/null
438     [[ $? -ne 0 ]] || \
439         error "pool_remove did not fail even though pool name was invalid."
440 }
441 run_test 3c "pool_remove: Invalid pool name"
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 2>/dev/null
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 2>/dev/null
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."
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 2>/dev/null
511     [[ $? -ne 0 ]] || \
512         error "pool_list did not fail even though fsname was not mentioned."
513
514     destroy_pool $POOL 2>/dev/null
515     destroy_pool $POOL2 2>/dev/null
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} 2>/dev/null
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 2>/dev/null
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 2>/dev/null
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     add_pool $POOL $TGT_ALL "$TGT_UUID"
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 2>/dev/null
591     [[ $? -ne 0 ]] || \
592         error "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 2>/dev/null
596     [[ $? -ne 0 ]] || \
597         error "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 2>/dev/null
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     local start=$((TGT_FIRST+1))
629     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
630         $FSNAME-OST[$start-$TGT_MAX/2]
631
632     add_pool $POOL $TGT_HALF "$TGT_UUID2"
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     local start=$((TGT_FIRST+1))
671     do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
672         $FSNAME-OST[$start-$TGT_MAX/2]
673
674     add_pool $POOL $TGT_HALF "$TGT_UUID2"
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         FIRST_UUID=$(echo $TGT_UUID | awk '{print $1}')
693     add_pool $POOL2 $FSNAME-OST[$TGT_FIRST] "$FIRST_UUID "
694     do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL2
695
696     echo Checking the files again    
697     check_dir_in_pool $POOL_ROOT/dir1 $POOL
698     check_dir_in_pool $POOL_ROOT/dir2 $POOL2
699     check_file_in_osts $POOL_ROOT/file1 "$TGT_LIST2"    
700     check_file_in_osts $POOL_ROOT/file2 "$(seq $start 2 $TGT_MAX)"
701
702     echo Creating some more files
703     create_dir $POOL_ROOT/dir3 $POOL
704     create_dir $POOL_ROOT/dir4 $POOL2
705     create_file $POOL_ROOT/file3 $POOL
706     create_file $POOL_ROOT/file4 $POOL2
707
708     echo Checking the new files 
709     check_file_in_pool $POOL_ROOT/file3 $POOL
710     check_file_in_pool $POOL_ROOT/file4 $POOL2
711
712     destroy_pool $POOL
713     destroy_pool $POOL2
714
715     return 0    
716 }
717 run_test 12 "OST Pool Membership"
718
719 test_13() {
720     [[ $OSTCOUNT -le 2 ]] && skip "Need atleast 3 OSTs" && return
721
722     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
723     local numfiles=10
724     local count=3
725
726     create_pool_nofail $POOL
727     add_pool $POOL $TGT_ALL "$TGT_UUID"
728
729     create_dir $POOL_ROOT/dir1 $POOL -1
730     createmany -o $POOL_ROOT/dir1/$tfile $numfiles || \
731         error "createmany $POOL_ROOT/dir1/$tfile failed!"
732     for file in $POOL_ROOT/dir1/*; do
733         check_file_in_pool $file $POOL $OSTCOUNT
734     done
735
736     create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
737     create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST+1))
738     create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST+2))
739     check_file_in_pool $POOL_ROOT/dir1/file1 $POOL 1
740     check_file_in_pool $POOL_ROOT/dir1/file2 $POOL 1
741     create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST+2))
742     check_file_in_osts $POOL_ROOT/dir1/file1 "$TGT_FIRST"
743     check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST+1))"
744     check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST+2))"
745
746     create_dir $POOL_ROOT/dir2 $POOL $count
747     createmany -o $POOL_ROOT/dir2/$tfile $numfiles || \
748         error "createmany $POOL_ROOT/dir2/$tfile failed!"
749     for file in $POOL_ROOT/dir2/*; do
750         check_file_in_pool $file $POOL $count
751     done
752
753     create_dir $POOL_ROOT/dir3 $POOL $count $((TGT_FIRST+1))
754     createmany -o $POOL_ROOT/dir3/$tfile_ $numfiles || \
755         error "createmany $POOL_ROOT/dir3/$tfile_ failed!"
756     for file in $POOL_ROOT/dir3/*; do
757         check_file_in_pool $file $POOL $count
758     done
759
760     create_dir $POOL_ROOT/dir4 $POOL 1
761     createmany -o $POOL_ROOT/dir4/$tfile_ $numfiles || \
762         error "createmany $POOL_ROOT/dir4/$tfile_ failed!"
763     for file in $POOL_ROOT/dir4/*; do
764         check_file_in_pool $file $POOL 1
765     done
766
767     create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST+2))
768     createmany -o $POOL_ROOT/dir5/$tfile_ $numfiles || \
769         error "createmany $POOL_ROOT/dir5/$tfile_ failed!"
770     for file in $POOL_ROOT/dir5/*; do
771         check_file_in_pool $file $POOL 1
772         check_file_in_osts  $file "$((TGT_FIRST+2))"
773     done
774
775     rm -rf create_dir $POOL_ROOT/dir?
776     destroy_pool $POOL
777
778     return 0
779 }
780 run_test 13 "Striping characteristics in a pool"
781
782 test_14() {
783     [[ $OSTCOUNT -le 2 ]] && skip "Need atleast 3 OSTs" && return
784
785     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
786     local numfiles=100
787     local i
788
789     # Create a new filesystem that is guaranteed to be balanced.
790     formatall
791     setupall
792
793     create_pool_nofail $POOL
794     create_pool_nofail $POOL2
795
796     add_pool $POOL $TGT_HALF "$TGT_UUID2"
797     add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
798
799     create_dir $POOL_ROOT/dir1 $POOL 1
800     create_file $POOL_ROOT/dir1/file $POOL 1
801     local OST=$($GETSTRIPE $POOL_ROOT/dir1/file | grep 0x | cut -f2)    
802     i=0
803     while [[ $i -lt $numfiles ]];
804     do
805         OST=$((OST+2))
806         [[ $OST -gt $TGT_MAX ]] && OST=$TGT_FIRST
807
808         # echo "Iteration: $i OST: $OST"
809         create_file $POOL_ROOT/dir1/file${i} $POOL 1
810         check_file_in_osts $POOL_ROOT/dir1/file${i} $OST
811         i=$((i+1))
812     done
813
814     # Fill OST $TGT_FIRST with 10M files
815     create_dir $POOL_ROOT/dir2 $POOL2 1
816     RC=0
817     i=0
818     while [[ $RC -eq 0 ]];
819     do
820       dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1k count=$((1024*10))
821       RC=$?
822       i=$((i+1))
823     done
824
825     # Leave some space on the OST
826     rm -f $POOL_ROOT/dir2/f0
827     df -h /mnt/ost?
828
829     # OST $TGT_FIRST is no longer favored; but it may still be used.
830     create_dir $POOL_ROOT/dir3 $POOL 1
831     create_file $POOL_ROOT/dir3/file $POOL 1
832     createmany -o $POOL_ROOT/dir3/$tfile_ $numfiles || \
833         error "createmany $POOL_ROOT/dir3/$tfile_ failed!"
834     for file in $POOL_ROOT/dir3/*; do
835         check_file_in_pool $file $POOL
836     done
837
838     rm -rf $POOL_ROOT
839     destroy_pool $POOL
840     destroy_pool $POOL2
841     return 0
842 }
843 run_test 14 "Round robin and QOS striping within a pool"
844
845 test_15() {
846     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
847     local numfiles=100
848     local i=0
849
850     while [[ $i -lt $OSTCOUNT ]]
851     do
852       create_pool_nofail pool${i}
853
854       local tgt=$(printf "$FSNAME-OST%04x_UUID " $i)
855       add_pool pool${i} "$FSNAME-OST[$i]" "$tgt"
856       create_dir $POOL_ROOT/dir${i} pool${i}
857       createmany -o $POOL_ROOT/dir$i/$tfile $numfiles || \
858           error "createmany $POOL_ROOT/dir$i/$tfile failed!"
859
860       for file in $POOL_ROOT/dir$i/*; do
861           check_file_in_osts $file $i
862       done
863
864       i=$((i+1))
865     done
866
867     i=0
868     while [[ $i -lt $OSTCOUNT ]]
869     do
870       destroy_pool pool${i}
871       i=$((i+1))
872     done
873
874     return 0
875 }
876 run_test 15 "One directory per OST/pool"
877
878 test_16() {
879     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
880     local numfiles=10
881     local i=0
882
883     create_pool_nofail $POOL
884
885     add_pool $POOL $TGT_HALF "$TGT_UUID2"
886
887     local dir=$POOL_ROOT/$tdir
888     create_dir $dir $POOL
889
890     for i in $(seq 1 10); do
891         dir=${dir}/dir${i}
892     done
893     mkdir -p $dir
894
895     createmany -o $dir/$tfile $numfiles || \
896           error "createmany $dir/$tfile failed!"
897
898     for file in $dir/*; do
899         check_file_in_pool $file $POOL
900     done
901
902     rm -rf $POOL_ROOT/$tdir
903
904     destroy_pool $POOL
905
906     return 0
907 }
908 run_test 16 "Inheritance of pool properties"
909
910 test_17() {
911     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
912     local numfiles=10
913     local i=0
914
915     create_pool_nofail $POOL
916
917     add_pool $POOL $TGT_ALL "$TGT_UUID"
918
919     local dir=$POOL_ROOT/dir
920     create_dir $dir $POOL
921
922     createmany -o $dir/${tfile}1_ $numfiles || \
923           error "createmany $dir/${tfile}1_ failed!"
924
925     for file in $dir/*; do
926         check_file_in_pool $file $POOL
927     done
928
929     destroy_pool $POOL
930
931     createmany -o $dir/${tfile}2_ $numfiles || \
932           error "createmany $dir/${tfile}2_ failed!"
933
934     rm -rf $dir
935     return 0
936 }
937 run_test 17 "Referencing an empty pool"
938
939 create_perf_one() {
940     local dir=$1/d
941     local numfiles=$2
942     local time
943
944     mkdir -p $dir
945     sync; sleep 5 # give pending IO a chance to go to disk
946     stat=$(createmany -o $dir/${tfile} $numfiles)
947     rm -rf $dir
948     sync
949     time=$(echo $stat | cut -f 5 -d ' ')
950     echo $stat > /dev/stderr
951     echo $time
952 }
953
954 create_perf() {
955     local t1=$(create_perf_one $1 $2)
956     local t2=$(create_perf_one $1 $2)
957     local t3=$(create_perf_one $1 $2)
958     local time=$(echo "scale=2; ( $t1 + $t2 + $t3 ) / 3" | bc)
959
960     echo "$time"
961 }
962
963 test_18() {
964     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
965     local numfiles=10000
966     local i=0
967     local time1
968     local time2
969     local time3
970     local dir=$POOL_ROOT/dir
971     local stat
972     local diff
973
974     time1=$(create_perf $dir $numfiles)
975
976     create_pool_nofail $POOL
977
978     add_pool $POOL $TGT_ALL "$TGT_UUID"
979
980     create_dir $dir $POOL
981     time2=$(create_perf $dir $numfiles)
982
983     destroy_pool $POOL
984
985     time3=$(create_perf $dir $numfiles)
986
987     echo Time taken for $numfiles creates without pools: $time1
988     echo Time taken for $numfiles creates with pools: $time2
989     echo Time taken for $numfiles creates without pools: $time3
990
991     deg=$(echo "scale=2; (($time2 - $time3) * 100 / $time3) > 5" | bc)
992     diff=$(echo "scale=2; ($time2 - $time3) * 100 / $time3" | bc)
993
994     if [[ "$deg" == "1" ]]; then
995         error "Performance degradation with pools is $diff %."
996     else
997         echo  "Performance degradation with pools is $diff %."
998     fi
999     return 0
1000 }
1001 run_test 18 "File create in a directory which references a deleted pool"
1002
1003
1004 test_19() {
1005     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1006     local numfiles=12
1007     local dir1=$POOL_ROOT/dir1
1008     local dir2=$POOL_ROOT/dir2
1009     local i=0
1010
1011     create_pool_nofail $POOL
1012
1013     add_pool $POOL $TGT_HALF "$TGT_UUID2"
1014
1015     create_dir $dir1 $POOL
1016     createmany -o $dir1/${tfile} $numfiles || \
1017           error "createmany $dir1/${tfile} failed!"
1018     for file in $dir1/*; do
1019         check_file_in_pool $file $POOL
1020     done
1021
1022     mkdir -p $dir2
1023     createmany -o $dir2/${tfile} $numfiles || \
1024           error "createmany $dir2/${tfile} failed!"
1025     for file in $dir2/*; do
1026         check_file_not_in_pool $file $POOL
1027     done
1028
1029     rm -rf $dir1 $dir2
1030     destroy_pool $POOL
1031
1032     return 0
1033 }
1034 run_test 19 "Pools should not come into play when not specified"
1035
1036 test_20() {
1037     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1038     local numfiles=12
1039     local dir1=$POOL_ROOT/dir1
1040     local dir2=$dir1/dir2
1041     local dir3=$dir1/dir3
1042     local i=0
1043     local TGT
1044
1045     create_pool_nofail $POOL
1046     create_pool_nofail $POOL2
1047
1048     add_pool $POOL $TGT_HALF "$TGT_UUID2"
1049
1050     local start=$((TGT_FIRST+1))
1051     TGT=$(for i in `seq $start 2 $TGT_MAX`; \
1052         do printf "$FSNAME-OST%04x_UUID " $i; done)
1053     add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1054
1055     create_dir $dir1 $POOL
1056     create_file $dir1/file1 $POOL2
1057     create_dir $dir2 $POOL2
1058     touch $dir2/file2
1059     mkdir $dir3
1060     $SETSTRIPE -c 1 $dir3 # No pool assignment
1061     touch $dir3/file3
1062     $SETSTRIPE -c 1 $dir2/file4 # No pool assignment
1063
1064     check_file_in_pool $dir1/file1 $POOL2
1065     check_file_in_pool $dir2/file2 $POOL2
1066
1067     check_dir_not_in_pool $dir3 $POOL
1068     check_dir_not_in_pool $dir3 $POOL2
1069
1070     check_file_not_in_pool $dir3/file3 $POOL
1071     check_file_not_in_pool $dir3/file3 $POOL2
1072
1073     check_file_not_in_pool $dir2/file4 $POOL
1074     check_file_not_in_pool $dir2/file4 $POOL2
1075
1076     rm -rf $dir1
1077     destroy_pool $POOL
1078     destroy_pool $POOL2
1079
1080     return 0
1081 }
1082 run_test 20 "Different pools in a directory hierarchy."
1083
1084 test_21() {
1085     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1086     [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1087
1088     local numfiles=12
1089     local i=0
1090     local dir=$POOL_ROOT/dir
1091
1092     create_pool_nofail $POOL
1093
1094     add_pool $POOL $TGT_HALF "$TGT_UUID2"
1095
1096     create_dir $dir $POOL $OSTCOUNT
1097     create_file $dir/file1 $POOL $OSTCOUNT
1098     $GETSTRIPE -v $dir/file1
1099     check_file_in_pool $dir/file1 $POOL
1100
1101     rm -rf $dir
1102     destroy_pool $POOL
1103
1104     return 0
1105 }
1106 run_test 21 "OST pool with fewer OSTs than stripe count"
1107
1108 add_loop() {
1109     local pool=$1
1110     local step=$2
1111
1112     echo loop for $pool
1113
1114     for c in $(seq 1 10);
1115     do
1116         echo "Pool $pool, iteration $c"
1117         do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool OST[$TGT_FIRST-$TGT_MAX/$step] 2>/dev/null
1118         local TGT_SECOND=$(($TGT_FIRST+$step))
1119         if [ "$TGT_SECOND" -le "$TGT_MAX" ]; then
1120             do_facet $SINGLEMDS lctl pool_remove $FSNAME.$pool OST[$TGT_SECOND-$TGT_MAX/$step]
1121         fi
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 at least 2 OSTs" && return
1129
1130     local numfiles=100
1131
1132     create_pool_nofail $POOL
1133     add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
1134     create_pool_nofail $POOL2
1135     add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
1136
1137     add_loop $POOL 1 &
1138     add_loop $POOL2 2 &
1139     sleep 5
1140     create_dir $POOL_ROOT $POOL
1141     createmany -o $POOL_ROOT/${tfile} $numfiles || \
1142           error "createmany $POOL_ROOT/${tfile} failed!"
1143     wait
1144
1145     destroy_pool $POOL
1146     destroy_pool $POOL2
1147
1148     return 0
1149 }
1150 run_test 22 "Simultaneous manipulation of a pool"
1151
1152 test_23() {
1153     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1154     [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1155
1156     mkdir -p $POOL_ROOT
1157     check_runas_id $TSTID $TSTID $RUNAS  || {
1158         skip "User $RUNAS_ID does not exist - skipping"
1159         return 0
1160     }
1161
1162     local i=0
1163     local TGT
1164     local BLK_SZ=1024
1165     local BUNIT_SZ=1024         # min block quota unit(kB)
1166     local LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
1167     local OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
1168     local LIMIT
1169     local dir=$POOL_ROOT/dir
1170     local file="$dir/$tfile-quota"
1171
1172     create_pool_nofail $POOL
1173
1174     local TGT=$(for i in `seq $TGT_FIRST 3 $TGT_MAX`; \
1175         do printf "$FSNAME-OST%04x_UUID " $i; done)
1176     add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1177     create_dir $dir $POOL
1178
1179     $LFS quotaoff -ug $MOUNT
1180     $LFS quotacheck -ug $MOUNT
1181     LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1)))
1182     $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir
1183     sleep 3
1184     $LFS quota -v -u $TSTUSR $dir
1185
1186     $LFS setstripe $file -c 1 -p $POOL
1187     chown $TSTUSR.$TSTUSR $file
1188     ls -l $file
1189     type runas
1190
1191     LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BLK_SZ count=$((BUNIT_SZ*2)) || true
1192     $LFS quota -v -u $TSTUSR $dir
1193     cancel_lru_locks osc
1194     stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ*2)) 2>&1)
1195     RC=$?
1196     echo $stat
1197     [[ $RC -eq 0 ]] && error "dd did not fail with EDQUOT."
1198     echo $stat | grep "Disk quota exceeded" > /dev/null
1199     [[ $? -eq 1 ]] && error "dd did not fail with EDQUOT."
1200     $LFS quota -v -u $TSTUSR $dir
1201
1202     echo "second run"
1203     $LFS quotaoff -ug $MOUNT
1204     # $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir
1205     chown $TSTUSR.$TSTUSR $dir
1206     i=0
1207     RC=0
1208     while [ $RC -eq 0 ];
1209     do
1210       i=$((i+1))
1211       stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file}$i bs=1M \
1212           count=$((LIMIT*LIMIT)) 2>&1)
1213       RC=$?
1214       if [ $RC -eq 1 ]; then
1215           echo $stat
1216           echo $stat | grep "Disk quota exceeded"
1217           [[ $? -eq 0 ]] && error "dd failed with EDQUOT"
1218
1219           echo $stat | grep "No space left on device"
1220           [[ $? -ne 0 ]] && error "dd did not fail with ENOSPC; " \
1221               "failed with $stat"
1222       fi
1223     done
1224
1225     df -h
1226
1227     rm -rf $POOL_ROOT
1228     destroy_pool $POOL
1229
1230     return 0
1231 }
1232 run_test 23 "OST pools and quota"
1233
1234 test_24() {
1235     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1236     [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1237
1238     local numfiles=10
1239     local i=0
1240     local TGT
1241     local dir
1242     local res
1243
1244
1245     create_pool_nofail $POOL
1246
1247     add_pool $POOL $TGT_ALL "$TGT_UUID"
1248
1249     create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1250
1251     mkdir $POOL_ROOT/dir2
1252     $SETSTRIPE $POOL_ROOT/dir2 -p $POOL -s 65536 -i 0 -c 1 || \
1253         error "$SETSTRIPE $POOL_ROOT/dir2 failed"
1254
1255     mkdir $POOL_ROOT/dir3
1256     $SETSTRIPE $POOL_ROOT/dir3 -s 65536 -i 0 -c 1 || \
1257         error "$SETSTRIPE $POOL_ROOT/dir3 failed"
1258
1259     mkdir $POOL_ROOT/dir4
1260
1261     for i in $(seq 1 4);
1262     do
1263       dir=${POOL_ROOT}/dir${i}
1264       local pool
1265       local pool1
1266       local count
1267       local count1
1268       local index
1269       local size
1270       local size1
1271
1272       createmany -o $dir/${tfile} $numfiles || \
1273           error "createmany $dir/${tfile} failed!"
1274       res=$($GETSTRIPE -v $dir | grep "^stripe_count:")
1275       if [ $? -ne 0 ]; then
1276           res=$($GETSTRIPE -v $dir | grep "^(Default) ")
1277           pool=$(cut -f 9 -d ' ' <<< $res)
1278           index=$(cut -f 7 -d ' ' <<< $res)
1279           size=$(cut -f 5 -d ' ' <<< $res)
1280           count=$(cut -f 3 -d ' ' <<< $res)
1281       else
1282           pool=$(cut -f 8 -d ' ' <<< $res)
1283           index=$(cut -f 6 -d ' ' <<< $res)
1284           size=$(cut -f 4 -d ' ' <<< $res)
1285           count=$(cut -f 2 -d ' ' <<< $res)
1286       fi
1287
1288       for file in $dir/*; do
1289           if [ "$pool" != "" ]; then
1290               check_file_in_pool $file $pool
1291           fi
1292           pool1=$($GETSTRIPE -v $file | grep "^pool:" |\
1293               tr -d '[:blank:]' | cut -f 2 -d ':')
1294           count1=$($GETSTRIPE -v $file | grep "^lmm_stripe_count:" |\
1295               tr -d '[:blank:]' | cut -f 2 -d ':')
1296           size1=$($GETSTRIPE -v $file | grep "^lmm_stripe_size:" |\
1297               tr -d '[:blank:]' | cut -f 2 -d ':')
1298           [[ "$pool" != "$pool1" ]] && \
1299               error "Pool name ($pool) not inherited in $file($pool1)"
1300           [[ "$count" != "$count1" ]] && \
1301               error "Stripe count ($count) not inherited in $file ($count1)"
1302           [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] && \
1303               error "Stripe size ($size) not inherited in $file ($size1)"
1304       done 
1305     done
1306
1307     rm -rf $POOL_ROOT
1308     destroy_pool $POOL
1309
1310     return 0
1311 }
1312 run_test 24 "Independence of pool from other setstripe parameters"
1313
1314 test_25() {
1315     local dev=$(mdsdevname ${SINGLEMDS//mds/})
1316     local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1317
1318     mkdir -p $POOL_ROOT
1319
1320     for i in $(seq 10); do
1321         create_pool_nofail pool$i
1322         do_facet $SINGLEMDS lctl pool_add $FSNAME.pool$i OST0000
1323         stop $SINGLEMDS || return 1
1324         start $SINGLEMDS ${dev} $MDS_MOUNT_OPTS  || \
1325             { error "Failed to start $SINGLEMDS after stopping" && break; }
1326         client_df
1327
1328         # Veriy that the pool got created and is usable
1329         echo "Creating a file in pool$i"
1330         create_file $POOL_ROOT/file$i pool$i || break
1331         check_file_in_pool $POOL_ROOT/file$i pool$i || break
1332     done
1333
1334     rm -rf $POOL_ROOT
1335     for i in $(seq 10); do
1336         destroy_pool pool$i
1337     done
1338 }
1339 run_test 25 "Create new pool and restart MDS ======================="
1340
1341 log "cleanup: ======================================================"
1342 cd $ORIG_PWD
1343 cleanup_tests
1344 check_and_cleanup_lustre
1345 echo '=========================== finished ==============================='
1346 [ -f "$POOLSLOG" ] && cat $POOLSLOG && grep -q FAIL $POOLSLOG && exit 1 || true
1347 echo "$0: completed"