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