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