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