2 # -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
3 # vim:autoindent:shiftwidth=4:tabstop=4:
5 # Run select tests by setting ONLY, or as arguments to the script.
6 # Skip specific tests by setting EXCEPT.
8 # Run test by setting NOSETUP=true when ltest has setup env for us
11 export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
14 ALWAYS_EXCEPT="$OST_POOLS_EXCEPT"
15 # bug number for skipped test: -
16 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
18 [ "$ALWAYS_EXCEPT$EXCEPT" ] && \
19 echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT`"
24 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
25 . $LUSTRE/tests/test-framework.sh
27 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
29 check_and_setup_lustre
36 FAIL_ON_ERROR=${FAIL_ON_ERROR:-true}
40 SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
41 GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"}
45 TSTUSR=${TSTUSR:-"quota_usr"}
47 RUNAS="runas -u $TSTID -g $TSTID"
53 NON_EXISTANT_POOL=nonexistantpool
54 NON_EXISTANT_FS=nonexistantfs
55 INVALID_POOL=some_invalid_pool_name
58 TGT_MAX=$((TGT_COUNT-1))
60 TGT_LIST=$(seq $TGT_FIRST $TGT_STEP $TGT_MAX)
61 TGT_LIST2=$(seq $TGT_FIRST 2 $TGT_MAX)
63 TGT_ALL="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/1]"
64 TGT_HALF="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]"
66 TGT_UUID=$(for i in $TGT_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
67 TGT_UUID2=$(for i in $TGT_LIST2; do printf "$FSNAME-OST%04x_UUID " $i; done)
72 local count=${3:-"-1"}
77 $SETSTRIPE -c $count -p $pool $dir -o $idx
79 $SETSTRIPE -c $count -p $pool $dir
82 error "$SETSTRIPE -p $pool $dir failed."
88 local count=${3:-"-1"}
89 local index=${4:-"-1"}
91 $SETSTRIPE -o $index -c $count -p $pool $file
93 error "$SETSTRIPE -p $pool $file failed."
99 for i in $(do_facet $SINGLEMDS lctl pool_list $FSNAME.$pool | \
100 grep -v "^Pool:" | sed -e 's/_UUID$//;s/^.*-OST//'); do
101 res="$res $(printf "%d" 0x$i)"
106 check_dir_in_pool() {
109 local res=$($GETSTRIPE $dir | grep "^stripe_count:" \
110 | cut -d ':' -f 5 | tr -d "[:blank:]")
111 if [[ "$res" == "$pool" ]]; then
114 error found $res instead of $pool
119 check_file_in_pool() {
120 local osts=$(osts_in_pool $2)
121 check_file_in_osts $1 "$osts" $3
124 check_file_in_osts() {
126 local pool_list=${2:-$TGT_LIST}
128 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
132 found=$(echo :$pool_list: | tr " " ":" | grep :$i:)
133 if [[ "$found" == "" ]]; then
134 echo "pool list: $pool_list"
135 echo "striping: $res"
137 error "$file not allocated from OSTs $pool_list."
142 local ost_count=$($GETSTRIPE $file | grep 0x | wc -l)
143 [[ -n "$count" ]] && [[ $ost_count -ne $count ]] && \
144 { error "Stripe count $count expected; got $ost_count" && return 1; }
149 check_file_not_in_pool() {
152 local res=$($GETSTRIPE -v $file | grep "^pool:" | tr -d "[:blank:]" | cut -f 2 -d ':')
153 if [[ "$res" == "$pool" ]]; then
154 error "File $file is in pool: $res"
161 check_dir_not_in_pool() {
164 local res=$($GETSTRIPE -v $dir | grep "^stripe_count" | head -1 | \
166 if [[ "$res" == "$pool" ]]; then
167 error "File $dir is in pool: $res"
176 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool" ""\
177 ||error "Failed to remove targets from pool: $pool"
183 local tgt="${3}$(lctl get_param -n lov.$FSNAME-*.pools.$pool | \
184 sort -u | tr '\n' ' ')"
186 do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool $osts
188 [[ $RC -ne 0 ]] && return $RC
190 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool | \
191 sort -u | tr '\n' ' ' " "$tgt" || RC=1
192 [[ $RC -ne 0 ]] && error "pool_add failed: $1; $2"
196 create_pool_nofail() {
197 create_pool $FSNAME.$1
200 error "Pool creation of $1 failed"
205 create_pool $FSNAME.$1
208 error "Pool creation of $1 succeeded; should have failed"
213 # Destroy pools from previous test runs
214 for p in $(do_facet $SINGLEMDS lctl pool_list $FSNAME | \
215 grep $FSNAME.pool[0-$OSTCOUNT]); do
218 rm -rf $DIR/d0.${TESTSUITE}
227 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
228 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
231 trap "cleanup_pools $FSNAME" EXIT
233 # Tests for new commands added
235 echo "Creating a pool with a 1 character pool name"
238 echo "Creating a pool with a 10 character pool name"
239 create_pool_nofail p123456789
240 destroy_pool p123456789
242 echo "Creating a pool with a 16 character pool name"
243 create_pool_nofail p123456789123456
244 destroy_pool p123456789123456
246 echo "Creating a pool with a 17 character pool name; should fail"
247 create_pool_fail p1234567891234567
249 echo "Creating a pool with a 1000 character pool name; should fail"
251 for i in `seq 1 999`; do NAME=${NAME}"o"; done
252 create_pool_fail $NAME
254 echo "pool_new should fail if fs-name or poolname are missing."
255 do_facet $SINGLEMDS lctl pool_new .pool1 2>/dev/null
257 error "pool_new did not fail even though fs-name was missing."
258 do_facet $SINGLEMDS lctl pool_new pool1 2>/dev/null
260 error "pool_new did not fail even though fs-name was missing."
261 do_facet $SINGLEMDS lctl pool_new ${FSNAME}. 2>/dev/null
263 error "pool_new did not fail even though pool name was missing."
264 do_facet $SINGLEMDS lctl pool_new . 2>/dev/null
266 error "pool_new did not fail even though pool name and fs-name " \
268 do_facet $SINGLEMDS lctl pool_new ${FSNAME},pool1 2>/dev/null
270 error "pool_new did not fail even though pool name format was wrong"
271 do_facet $SINGLEMDS lctl pool_new ${FSNAME}/pool1 2>/dev/null
273 error "pool_new did not fail even though pool name format was wrong"
275 do_facet $SINGLEMDS lctl pool_new ${FSNAME}.p 2>/dev/null
277 error "pool_new did not fail even though pool1 existed"
281 run_test 1 "Test lctl pool_new ========================================="
286 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
288 error " pool_add did not fail even though pool did " \
291 run_test 2a "pool_add: non-existant pool"
294 do_facet $SINGLEMDS lctl pool_add $FSNAME.p1234567891234567890 \
295 $FSNAME-OST0000 2>/dev/null
297 error "pool_add did not fail even though pool name was invalid."
299 run_test 2b "pool_add: Invalid pool name"
301 # Testing various combinations of OST name list
306 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
310 create_pool_nofail $POOL
313 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
314 RC=$?; [[ $RC -eq 0 ]] || \
315 error "pool_add failed. $FSNAME $POOL OST0000: $RC"
316 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
320 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
321 RC=$?; [[ $RC -eq 0 ]] || \
322 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000: $RC"
323 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
326 # 3. lustre-OST0000_UUID
327 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
328 RC=$?; [[ $RC -eq 0 ]] || \
329 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000_UUID: $RC"
330 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
333 # 4. lustre-OST[0,1,2,3,]
335 for i in $TGT_LIST; do TGT=${TGT}$(printf "$i," $i); done
337 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
339 error "pool_add failed. $FSNAME.$POOL $TGT. $RC"
340 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT
343 # 5. lustre-OST[0-5/1]
344 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
345 RC=$?; [[ $RC -eq 0 ]] || \
346 error "pool_add failed. $FSNAME $POOL" "$TGT_ALL $RC"
347 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
348 sort -u | tr '\n' ' ' " "$TGT_UUID" || error "Add to pool failed"
349 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
354 run_test 2c "pool_add: OST index combinations ==========================="
360 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
364 create_pool_nofail $POOL
366 TGT=$(printf "$FSNAME-OST%04x_UUID " $OSTCOUNT)
367 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
368 RC=$?; [[ $RC -ne 0 ]] || \
369 error "pool_add succeeded for an OST ($TGT) that does not exist."
373 run_test 2d "pool_add: OSTs that don't exist should be rejected ========"
380 $LCTL get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
384 create_pool_nofail $POOL
386 TGT="$FSNAME-OST0000_UUID "
387 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
388 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
389 sort -u | tr '\n' ' ' " "$TGT" || error "Add to pool failed"
390 RESULT=$(do_facet $SINGLEMDS \
391 "LOCALE=C $LCTL pool_add $FSNAME.$POOL $TGT 2>&1")
396 error "pool_add succeeded for an OST that was already in the pool."
398 [[ $(grep "already in pool" <<< $RESULT) ]] || \
399 error "pool_add failed as expected but error message not as expected."
403 run_test 2e "pool_add: OST already in a pool should be rejected ========"
406 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
410 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
412 error "pool_remove did not fail even though pool did not exist."
414 run_test 3a "pool_remove: non-existant pool"
417 do_facet $SINGLEMDS lctl pool_remove ${NON_EXISTANT_FS}.$POOL OST0000 2>/dev/null
419 error "pool_remove did not fail even though fsname did not exist."
421 run_test 3b "pool_remove: non-existant fsname"
424 do_facet $SINGLEMDS lctl pool_remove $FSNAME.p1234567891234567890 \
425 $FSNAME-OST0000 2>/dev/null
427 error "pool_remove did not fail even though pool name was invalid."
429 run_test 3c "pool_remove: Invalid pool name"
431 # Testing various combinations of OST name list
433 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
437 create_pool_nofail $POOL
438 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
439 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
441 error "pool_remove failed. $FSNAME $POOL OST0000"
444 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
445 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
447 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000"
450 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
451 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
453 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000_UUID"
456 add_pool $POOL $TGT_ALL "$TGT_UUID"
457 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
459 error "pool_remove failed. $FSNAME $POOL" $TGT_ALL
464 run_test 3d "pool_remove: OST index combinations ==========================="
467 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
471 do_facet $SINGLEMDS lctl pool_destroy $FSNAME.$POOL 2>/dev/null
473 error "pool_destroy did not fail even though pool did not exist."
475 run_test 4a "pool_destroy: non-existant pool"
478 do_facet $SINGLEMDS lctl pool_destroy ${NON_EXISTANT_FS}.$POOL 2>/dev/null
480 error "pool_destroy did not fail even though the filesystem did not exist."
482 run_test 4b "pool_destroy: non-existant fs-name"
485 create_pool_nofail $POOL
486 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
488 do_facet $SINGLEMDS lctl pool_destroy ${FSNAME}.$POOL
490 error "pool_destroy succeeded with a non-empty pool."
493 run_test 4c "pool_destroy: non-empty pool ==============================="
498 $LCMD pool_list 2>/dev/null
500 error "pool_list did not fail even though fsname was not mentioned."
502 destroy_pool $POOL 2>/dev/null
503 destroy_pool $POOL2 2>/dev/null
505 create_pool_nofail $POOL
506 create_pool_nofail $POOL2
507 $LCMD pool_list $FSNAME
509 error "pool_list $FSNAME failed."
511 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
513 $LCMD pool_list $FSNAME.$POOL
515 error "pool_list $FSNAME.$POOL failed."
517 $LCMD pool_list ${NON_EXISTANT_FS} 2>/dev/null
519 error "pool_list did not fail for a non-existant fsname $NON_EXISTANT_FS"
521 $LCMD pool_list ${FSNAME}.$NON_EXISTANT_POOL 2>/dev/null
523 error "pool_list did not fail for a non-existant pool $NON_EXISTANT_POOL"
525 if [[ ! $(grep $SINGLEMDS <<< $LCMD) ]]; then
526 echo $LCMD pool_list $DIR
529 error "pool_list failed for $DIR"
532 $LCMD pool_list ${DIR}/d1
534 error "pool_list failed for ${DIR}/d1"
537 rm -rf ${DIR}nonexistant
538 $LCMD pool_list ${DIR}nonexistant 2>/dev/null
540 error "pool_list did not fail for invalid mountpoint ${DIR}nonexistant"
547 # Issue commands from client
551 # Issue commands from MDS
552 sub_test_5 "do_facet $SINGLEMDS lctl"
553 sub_test_5 "do_facet $SINGLEMDS lfs"
556 run_test 5 "lfs/lctl pool_list"
559 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
560 local POOL_DIR=$POOL_ROOT/dir_tst
561 local POOL_FILE=$POOL_ROOT/file_tst
563 create_pool_nofail $POOL
565 do_facet $SINGLEMDS lctl pool_list $FSNAME
567 error "pool_list $FSNAME failed."
569 add_pool $POOL $TGT_ALL "$TGT_UUID"
572 $SETSTRIPE -c -1 -p $POOL $POOL_DIR
574 error "$SETSTRIPE -p $POOL failed."
575 check_dir_in_pool $POOL_DIR $POOL
577 # If an invalid pool name is specified, the command should fail
578 $SETSTRIPE -c 2 -p $INVALID_POOL $POOL_DIR 2>/dev/null
580 error "setstripe to invalid pool did not fail."
582 # If the pool name does not exist, the command should fail
583 $SETSTRIPE -c 2 -p $NON_EXISTANT_POOL $POOL_DIR 2>/dev/null
585 error "setstripe to non-existant pool did not fail."
587 # lfs setstripe should work as before if a pool name is not specified.
588 $SETSTRIPE -c -1 $POOL_DIR
590 error "$SETSTRIPE -p $POOL_DIR failed."
591 $SETSTRIPE -c -1 $POOL_FILE
593 error "$SETSTRIPE -p $POOL_FILE failed."
595 # lfs setstripe should fail if a start index that is outside the
597 create_pool_nofail $POOL2
598 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
599 $SETSTRIPE -o 1 -p $POOL2 $ROOT_POOL/$tfile 2>/dev/null
601 error "$SETSTRIPE with start index outside the pool did not fail."
606 run_test 6 "getstripe/setstripe"
609 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
611 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
613 create_pool_nofail $POOL
614 create_pool_nofail $POOL2
616 local start=$((TGT_FIRST+1))
617 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
618 $FSNAME-OST[$start-$TGT_MAX/2]
620 add_pool $POOL $TGT_HALF "$TGT_UUID2"
622 create_dir $POOL_ROOT/dir1 $POOL
623 create_dir $POOL_ROOT/dir2 $POOL2
624 check_dir_in_pool $POOL_ROOT/dir1 $POOL
625 check_dir_in_pool $POOL_ROOT/dir1 $POOL
628 createmany -o $POOL_ROOT/dir1/$tfile $numfiles || \
629 error "createmany $POOL_ROOT/dir1/$tfile failed!"
631 for file in $POOL_ROOT/dir1/*; do
632 check_file_in_pool $file $POOL
635 createmany -o $POOL_ROOT/dir2/$tfile $numfiles || \
636 error "createmany $POOL_ROOT/dir2/$tfile failed!"
637 for file in $POOL_ROOT/dir2/*; do
638 check_file_in_pool $file $POOL2
641 rm -rf $POOL_ROOT/dir?
648 run_test 11 "OSTs in overlapping/multiple pools"
651 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
653 [[ $OSTCOUNT -le 2 ]] && skip_env "Need atleast 3 OSTs" && return
655 create_pool_nofail $POOL
656 create_pool_nofail $POOL2
658 local start=$((TGT_FIRST+1))
659 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
660 $FSNAME-OST[$start-$TGT_MAX/2]
662 add_pool $POOL $TGT_HALF "$TGT_UUID2"
664 echo creating some files in $POOL and $POOL2
666 create_dir $POOL_ROOT/dir1 $POOL
667 create_dir $POOL_ROOT/dir2 $POOL2
668 create_file $POOL_ROOT/file1 $POOL
669 create_file $POOL_ROOT/file2 $POOL2
671 echo Checking the files created
672 check_dir_in_pool $POOL_ROOT/dir1 $POOL
673 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
674 check_file_in_pool $POOL_ROOT/file1 $POOL
675 check_file_in_pool $POOL_ROOT/file2 $POOL2
677 echo Changing the pool membership
678 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST[$TGT_FIRST]
679 do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL
680 FIRST_UUID=$(echo $TGT_UUID | awk '{print $1}')
681 add_pool $POOL2 $FSNAME-OST[$TGT_FIRST] "$FIRST_UUID "
682 do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL2
684 echo Checking the files again
685 check_dir_in_pool $POOL_ROOT/dir1 $POOL
686 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
687 check_file_in_osts $POOL_ROOT/file1 "$TGT_LIST2"
688 check_file_in_osts $POOL_ROOT/file2 "$(seq $start 2 $TGT_MAX)"
690 echo Creating some more files
691 create_dir $POOL_ROOT/dir3 $POOL
692 create_dir $POOL_ROOT/dir4 $POOL2
693 create_file $POOL_ROOT/file3 $POOL
694 create_file $POOL_ROOT/file4 $POOL2
696 echo Checking the new files
697 check_file_in_pool $POOL_ROOT/file3 $POOL
698 check_file_in_pool $POOL_ROOT/file4 $POOL2
705 run_test 12 "OST Pool Membership"
708 [[ $OSTCOUNT -le 2 ]] && skip_env "Need atleast 3 OSTs" && return
710 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
714 create_pool_nofail $POOL
715 add_pool $POOL $TGT_ALL "$TGT_UUID"
717 create_dir $POOL_ROOT/dir1 $POOL -1
718 createmany -o $POOL_ROOT/dir1/$tfile $numfiles || \
719 error "createmany $POOL_ROOT/dir1/$tfile failed!"
720 for file in $POOL_ROOT/dir1/*; do
721 check_file_in_pool $file $POOL $OSTCOUNT
724 create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
725 create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST+1))
726 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST+2))
727 check_file_in_pool $POOL_ROOT/dir1/file1 $POOL 1
728 check_file_in_pool $POOL_ROOT/dir1/file2 $POOL 1
729 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST+2))
730 check_file_in_osts $POOL_ROOT/dir1/file1 "$TGT_FIRST"
731 check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST+1))"
732 check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST+2))"
734 create_dir $POOL_ROOT/dir2 $POOL $count
735 createmany -o $POOL_ROOT/dir2/$tfile $numfiles || \
736 error "createmany $POOL_ROOT/dir2/$tfile failed!"
737 for file in $POOL_ROOT/dir2/*; do
738 check_file_in_pool $file $POOL $count
741 create_dir $POOL_ROOT/dir3 $POOL $count $((TGT_FIRST+1))
742 createmany -o $POOL_ROOT/dir3/$tfile_ $numfiles || \
743 error "createmany $POOL_ROOT/dir3/$tfile_ failed!"
744 for file in $POOL_ROOT/dir3/*; do
745 check_file_in_pool $file $POOL $count
748 create_dir $POOL_ROOT/dir4 $POOL 1
749 createmany -o $POOL_ROOT/dir4/$tfile_ $numfiles || \
750 error "createmany $POOL_ROOT/dir4/$tfile_ failed!"
751 for file in $POOL_ROOT/dir4/*; do
752 check_file_in_pool $file $POOL 1
755 create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST+2))
756 createmany -o $POOL_ROOT/dir5/$tfile_ $numfiles || \
757 error "createmany $POOL_ROOT/dir5/$tfile_ failed!"
758 for file in $POOL_ROOT/dir5/*; do
759 check_file_in_pool $file $POOL 1
760 check_file_in_osts $file "$((TGT_FIRST+2))"
763 rm -rf create_dir $POOL_ROOT/dir?
768 run_test 13 "Striping characteristics in a pool"
771 [[ $OSTCOUNT -le 2 ]] && skip_env "Need atleast 3 OSTs" && return
773 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
777 # Create a new filesystem that is guaranteed to be balanced.
781 create_pool_nofail $POOL
782 create_pool_nofail $POOL2
784 add_pool $POOL $TGT_HALF "$TGT_UUID2"
785 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
787 create_dir $POOL_ROOT/dir1 $POOL 1
788 create_file $POOL_ROOT/dir1/file $POOL 1
789 local OST=$($GETSTRIPE $POOL_ROOT/dir1/file | grep 0x | cut -f2)
791 while [[ $i -lt $numfiles ]];
794 [[ $OST -gt $TGT_MAX ]] && OST=$TGT_FIRST
796 # echo "Iteration: $i OST: $OST"
797 create_file $POOL_ROOT/dir1/file${i} $POOL 1
798 check_file_in_pool $POOL_ROOT/dir1/file${i} $POOL
802 # Fill up OST0 until it is nearly full.
803 # Create 9 files of size OST0_SIZE/10 each.
804 create_dir $POOL_ROOT/dir2 $POOL2 1
805 $LFS df $POOL_ROOT/dir2
806 echo "Filling up OST0"
807 OST0_SIZE=`$LFS df $POOL_ROOT/dir2 | awk '/\[OST:0\]/ {print $4}'`
808 FILE_SIZE=$((OST0_SIZE/1024/10))
810 while [[ $i -lt 10 ]];
812 dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1M count=$FILE_SIZE
815 $LFS df $POOL_ROOT/dir2
817 # OST $TGT_FIRST is no longer favored; but it may still be used.
818 create_dir $POOL_ROOT/dir3 $POOL 1
819 create_file $POOL_ROOT/dir3/file $POOL 1
820 createmany -o $POOL_ROOT/dir3/$tfile_ $numfiles || \
821 error "createmany $POOL_ROOT/dir3/$tfile_ failed!"
822 for file in $POOL_ROOT/dir3/*; do
823 check_file_in_pool $file $POOL
831 run_test 14 "Round robin and QOS striping within a pool"
834 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
838 while [[ $i -lt $OSTCOUNT ]]
840 create_pool_nofail pool${i}
842 local tgt=$(printf "$FSNAME-OST%04x_UUID " $i)
843 add_pool pool${i} "$FSNAME-OST[$i]" "$tgt"
844 create_dir $POOL_ROOT/dir${i} pool${i}
845 createmany -o $POOL_ROOT/dir$i/$tfile $numfiles || \
846 error "createmany $POOL_ROOT/dir$i/$tfile failed!"
848 for file in $POOL_ROOT/dir$i/*; do
849 check_file_in_osts $file $i
856 while [[ $i -lt $OSTCOUNT ]]
858 destroy_pool pool${i}
864 run_test 15 "One directory per OST/pool"
867 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
871 create_pool_nofail $POOL
873 add_pool $POOL $TGT_HALF "$TGT_UUID2"
875 local dir=$POOL_ROOT/$tdir
876 create_dir $dir $POOL
878 for i in $(seq 1 10); do
883 createmany -o $dir/$tfile $numfiles || \
884 error "createmany $dir/$tfile failed!"
886 for file in $dir/*; do
887 check_file_in_pool $file $POOL
890 rm -rf $POOL_ROOT/$tdir
896 run_test 16 "Inheritance of pool properties"
899 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
903 create_pool_nofail $POOL
905 add_pool $POOL $TGT_ALL "$TGT_UUID"
907 local dir=$POOL_ROOT/dir
908 create_dir $dir $POOL
910 createmany -o $dir/${tfile}1_ $numfiles || \
911 error "createmany $dir/${tfile}1_ failed!"
913 for file in $dir/*; do
914 check_file_in_pool $file $POOL
919 createmany -o $dir/${tfile}2_ $numfiles || \
920 error "createmany $dir/${tfile}2_ failed!"
925 run_test 17 "Referencing an empty pool"
933 sync; sleep 5 # give pending IO a chance to go to disk
934 stat=$(createmany -o $cdir/${tfile} $numfiles | tail -1)
937 time=$(echo $stat | cut -f 5 -d ' ')
938 echo $stat >> /dev/stderr
943 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
945 local plaindir=$POOL_ROOT/plaindir
946 local pooldir=$POOL_ROOT/pooldir
954 echo "Create performance, iteration $i, $numfiles files x 3"
956 time1=$(create_perf $plaindir $numfiles)
957 echo "iter $i: $numfiles creates without pool: $time1"
958 t1=$(echo "scale=2; $t1 + $time1" | bc)
960 create_pool_nofail $POOL > /dev/null
961 add_pool $POOL $TGT_ALL "$TGT_UUID" > /dev/null
962 create_dir $pooldir $POOL
963 time2=$(create_perf $pooldir $numfiles)
964 echo "iter $i: $numfiles creates with pool: $time2"
965 t2=$(echo "scale=2; $t2 + $time2" | bc)
967 destroy_pool $POOL > /dev/null
968 time3=$(create_perf $pooldir $numfiles)
969 echo "iter $i: $numfiles creates with missing pool: $time3"
970 t3=$(echo "scale=2; $t3 + $time3" | bc)
975 time1=$(echo "scale=2; $t1 / $i" | bc)
976 echo Avg time taken for $numfiles creates without pool: $time1
977 time2=$(echo "scale=2; $t2 / $i" | bc)
978 echo Avg time taken for $numfiles creates with pool: $time2
979 time3=$(echo "scale=2; $t3 / $i" | bc)
980 echo Avg time taken for $numfiles creates with missing pool: $time3
982 # Set this high until we establish a baseline for what the degradation
985 diff=$(echo "scale=2; ($time2 - $time1) * 100 / $time1" | bc)
986 echo "No pool to wide pool: $diff %."
987 deg=$(echo "scale=2; $diff > $max" | bc)
988 [ "$deg" == "1" ] && error_ignore 23408 "Degradation with wide pool is $diff % (> $max %)"
991 diff=$(echo "scale=2; ($time3 - $time1) * 100 / $time1" | bc)
992 echo "No pool to missing pool: $diff %."
993 deg=$(echo "scale=2; $diff > $max" | bc)
994 [ "$deg" == "1" ] && error_ignore 23408 "Degradation with missing pool is $diff % (> $max %)"
998 run_test 18 "File create in a directory which references a deleted pool"
1001 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1003 local dir1=$POOL_ROOT/dir1
1004 local dir2=$POOL_ROOT/dir2
1007 create_pool_nofail $POOL
1009 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1011 create_dir $dir1 $POOL
1012 createmany -o $dir1/${tfile} $numfiles || \
1013 error "createmany $dir1/${tfile} failed!"
1014 for file in $dir1/*; do
1015 check_file_in_pool $file $POOL
1019 createmany -o $dir2/${tfile} $numfiles || \
1020 error "createmany $dir2/${tfile} failed!"
1021 for file in $dir2/*; do
1022 check_file_not_in_pool $file $POOL
1030 run_test 19 "Pools should not come into play when not specified"
1033 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1035 local dir1=$POOL_ROOT/dir1
1036 local dir2=$dir1/dir2
1037 local dir3=$dir1/dir3
1041 create_pool_nofail $POOL
1042 create_pool_nofail $POOL2
1044 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1046 local start=$((TGT_FIRST+1))
1047 TGT=$(for i in `seq $start 2 $TGT_MAX`; \
1048 do printf "$FSNAME-OST%04x_UUID " $i; done)
1049 add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1051 create_dir $dir1 $POOL
1052 create_file $dir1/file1 $POOL2
1053 create_dir $dir2 $POOL2
1056 $SETSTRIPE -c 1 $dir3 # No pool assignment
1058 $SETSTRIPE -c 1 $dir2/file4 # No pool assignment
1060 check_file_in_pool $dir1/file1 $POOL2
1061 check_file_in_pool $dir2/file2 $POOL2
1063 check_dir_not_in_pool $dir3 $POOL
1064 check_dir_not_in_pool $dir3 $POOL2
1066 check_file_not_in_pool $dir3/file3 $POOL
1067 check_file_not_in_pool $dir3/file3 $POOL2
1069 check_file_not_in_pool $dir2/file4 $POOL
1070 check_file_not_in_pool $dir2/file4 $POOL2
1078 run_test 20 "Different pools in a directory hierarchy."
1081 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1082 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
1086 local dir=$POOL_ROOT/dir
1088 create_pool_nofail $POOL
1090 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1092 create_dir $dir $POOL $OSTCOUNT
1093 create_file $dir/file1 $POOL $OSTCOUNT
1094 $GETSTRIPE -v $dir/file1
1095 check_file_in_pool $dir/file1 $POOL
1102 run_test 21 "OST pool with fewer OSTs than stripe count"
1110 for c in $(seq 1 10);
1112 echo "Pool $pool, iteration $c"
1113 do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool OST[$TGT_FIRST-$TGT_MAX/$step] 2>/dev/null
1114 local TGT_SECOND=$(($TGT_FIRST+$step))
1115 if [ "$TGT_SECOND" -le "$TGT_MAX" ]; then
1116 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$pool OST[$TGT_SECOND-$TGT_MAX/$step]
1119 echo loop for $pool complete
1123 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1124 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1128 create_pool_nofail $POOL
1129 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
1130 create_pool_nofail $POOL2
1131 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
1136 create_dir $POOL_ROOT $POOL
1137 createmany -o $POOL_ROOT/${tfile} $numfiles || \
1138 error "createmany $POOL_ROOT/${tfile} failed!"
1146 run_test 22 "Simultaneous manipulation of a pool"
1149 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1150 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
1153 check_runas_id $TSTID $TSTID $RUNAS || {
1154 skip_env "User $RUNAS_ID does not exist - skipping"
1161 local BUNIT_SZ=1024 # min block quota unit(kB)
1162 local LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
1163 local OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
1165 local dir=$POOL_ROOT/dir
1166 local file="$dir/$tfile-quota"
1168 create_pool_nofail $POOL
1170 local TGT=$(for i in `seq $TGT_FIRST 3 $TGT_MAX`; \
1171 do printf "$FSNAME-OST%04x_UUID " $i; done)
1172 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1173 create_dir $dir $POOL
1175 $LFS quotaoff -ug $MOUNT
1176 $LFS quotacheck -ug $MOUNT
1177 LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1)))
1178 $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir
1180 $LFS quota -v -u $TSTUSR $dir
1182 $LFS setstripe $file -c 1 -p $POOL
1183 chown $TSTUSR.$TSTUSR $file
1187 LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BLK_SZ count=$((BUNIT_SZ*2)) || true
1188 $LFS quota -v -u $TSTUSR $dir
1189 cancel_lru_locks osc
1190 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ*2)) 2>&1)
1193 [[ $RC -eq 0 ]] && error "dd did not fail with EDQUOT."
1194 echo $stat | grep "Disk quota exceeded" > /dev/null
1195 [[ $? -eq 1 ]] && error "dd did not fail with EDQUOT."
1196 $LFS quota -v -u $TSTUSR $dir
1199 $LFS quotaoff -ug $MOUNT
1200 # $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir
1201 chown $TSTUSR.$TSTUSR $dir
1204 while [ $RC -eq 0 ];
1207 stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file}$i bs=1M \
1208 count=$((LIMIT*LIMIT)) 2>&1)
1210 if [ $RC -eq 1 ]; then
1212 echo $stat | grep "Disk quota exceeded"
1213 [[ $? -eq 0 ]] && error "dd failed with EDQUOT"
1215 echo $stat | grep "No space left on device"
1216 [[ $? -ne 0 ]] && error "dd did not fail with ENOSPC; " \
1228 run_test 23 "OST pools and quota"
1231 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1232 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
1241 create_pool_nofail $POOL
1243 add_pool $POOL $TGT_ALL "$TGT_UUID"
1245 create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1247 mkdir $POOL_ROOT/dir2
1248 $SETSTRIPE $POOL_ROOT/dir2 -p $POOL -s 65536 -i 0 -c 1 || \
1249 error "$SETSTRIPE $POOL_ROOT/dir2 failed"
1251 mkdir $POOL_ROOT/dir3
1252 $SETSTRIPE $POOL_ROOT/dir3 -s 65536 -i 0 -c 1 || \
1253 error "$SETSTRIPE $POOL_ROOT/dir3 failed"
1255 mkdir $POOL_ROOT/dir4
1257 for i in $(seq 1 4);
1259 dir=${POOL_ROOT}/dir${i}
1268 createmany -o $dir/${tfile} $numfiles || \
1269 error "createmany $dir/${tfile} failed!"
1270 res=$($GETSTRIPE -v $dir | grep "^stripe_count:")
1271 if [ $? -ne 0 ]; then
1272 res=$($GETSTRIPE -v $dir | grep "^(Default) ")
1273 pool=$(cut -f 9 -d ' ' <<< $res)
1274 index=$(cut -f 7 -d ' ' <<< $res)
1275 size=$(cut -f 5 -d ' ' <<< $res)
1276 count=$(cut -f 3 -d ' ' <<< $res)
1278 pool=$(cut -f 8 -d ' ' <<< $res)
1279 index=$(cut -f 6 -d ' ' <<< $res)
1280 size=$(cut -f 4 -d ' ' <<< $res)
1281 count=$(cut -f 2 -d ' ' <<< $res)
1284 for file in $dir/*; do
1285 if [ "$pool" != "" ]; then
1286 check_file_in_pool $file $pool
1288 pool1=$($GETSTRIPE -v $file | grep "^pool:" |\
1289 tr -d '[:blank:]' | cut -f 2 -d ':')
1290 count1=$($GETSTRIPE -v $file | grep "^lmm_stripe_count:" |\
1291 tr -d '[:blank:]' | cut -f 2 -d ':')
1292 size1=$($GETSTRIPE -v $file | grep "^lmm_stripe_size:" |\
1293 tr -d '[:blank:]' | cut -f 2 -d ':')
1294 [[ "$pool" != "$pool1" ]] && \
1295 error "Pool name ($pool) not inherited in $file($pool1)"
1296 [[ "$count" != "$count1" ]] && \
1297 error "Stripe count ($count) not inherited in $file ($count1)"
1298 [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] && \
1299 error "Stripe size ($size) not inherited in $file ($size1)"
1308 run_test 24 "Independence of pool from other setstripe parameters"
1311 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1315 for i in $(seq 10); do
1316 create_pool_nofail pool$i
1317 do_facet $SINGLEMDS "lctl pool_add $FSNAME.pool$i OST0000; sync"
1318 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.pool$i | \
1319 sort -u | tr '\n' ' ' " "$FSNAME-OST0000_UUID " || \
1320 error "pool_add failed: $1; $2"
1322 stop $SINGLEMDS || return 1
1323 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS || \
1324 { error "Failed to start $SINGLEMDS after stopping" && break; }
1325 wait_osc_import_state mds ost FULL
1328 # Verify that the pool got created and is usable
1329 df $POOL_ROOT > /dev/null
1331 # Make sure OST0 can be striped on
1332 $SETSTRIPE -o 0 -c 1 $POOL_ROOT/$tfile
1333 STR=$($GETSTRIPE $POOL_ROOT/$tfile | grep 0x | cut -f2 | tr -d " ")
1334 rm $POOL_ROOT/$tfile
1335 if [[ "$STR" == "0" ]]; then
1336 echo "Creating a file in pool$i"
1337 create_file $POOL_ROOT/file$i pool$i || break
1338 check_file_in_pool $POOL_ROOT/file$i pool$i || break
1340 echo "OST 0 seems to be unavailable. Try later."
1345 for i in $(seq 10); do
1349 run_test 25 "Create new pool and restart MDS ======================="
1353 complete $(basename $0) $SECONDS
1354 cleanup_pools $FSNAME
1355 check_and_cleanup_lustre