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