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
34 POOLSLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
35 [ "$POOLSLOG" ] && rm -f $POOLSLOG || true
38 FAIL_ON_ERROR=${FAIL_ON_ERROR:-true}
42 SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
43 GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"}
46 TSTUSR=${TSTUSR:-"quota_usr"}
48 RUNAS="runas -u $TSTID -g $TSTID"
54 NON_EXISTANT_POOL=nonexistantpool
55 NON_EXISTANT_FS=nonexistantfs
56 INVALID_POOL=some_invalid_pool_name
59 TGT_MAX=$((TGT_COUNT-1))
61 TGT_LIST=$(seq $TGT_FIRST $TGT_STEP $TGT_MAX)
62 TGT_LIST2=$(seq $TGT_FIRST 2 $TGT_MAX)
64 TGT_ALL="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/1]"
65 TGT_HALF="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]"
67 TGT_UUID=$(for i in $TGT_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
68 TGT_UUID2=$(for i in $TGT_LIST2; do printf "$FSNAME-OST%04x_UUID " $i; done)
73 local count=${3:-"-1"}
78 $SETSTRIPE -c $count -p $pool $dir -o $idx
80 $SETSTRIPE -c $count -p $pool $dir
83 error "$SETSTRIPE -p $pool $dir failed."
89 local count=${3:-"-1"}
90 local index=${4:-"-1"}
92 $SETSTRIPE -o $index -c $count -p $pool $file
94 error "$SETSTRIPE -p $pool $file failed."
100 for i in $(do_facet $SINGLEMDS lctl pool_list $FSNAME.$pool | \
101 grep -v "^Pool:" | sed -e 's/_UUID$//;s/^.*-OST//'); do
102 res="$res $(printf "%d" 0x$i)"
107 check_dir_in_pool() {
110 local res=$($GETSTRIPE $dir | grep "^stripe_count:" \
111 | cut -d ':' -f 5 | tr -d "[:blank:]")
112 if [[ "$res" == "$pool" ]]; then
115 error found $res instead of $pool
120 check_file_in_pool() {
121 local osts=$(osts_in_pool $2)
122 check_file_in_osts $1 "$osts" $3
125 check_file_in_osts() {
127 local pool_list=${2:-$TGT_LIST}
129 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
133 found=$(echo :$pool_list: | tr " " ":" | grep :$i:)
134 if [[ "$found" == "" ]]; then
135 echo "pool list: $pool_list"
136 echo "striping: $res"
138 error "$file not allocated from OSTs $pool_list."
143 local ost_count=$($GETSTRIPE $file | grep 0x | wc -l)
144 [[ -n "$count" ]] && [[ $ost_count -ne $count ]] && \
145 { error "Stripe count $count expected; got $ost_count" && return 1; }
150 check_file_not_in_pool() {
153 local res=$($GETSTRIPE -v $file | grep "^pool:" | tr -d "[:blank:]" | cut -f 2 -d ':')
154 if [[ "$res" == "$pool" ]]; then
155 error "File $file is in pool: $res"
162 check_dir_not_in_pool() {
165 local res=$($GETSTRIPE -v $dir | grep "^stripe_count" | head -1 | \
167 if [[ "$res" == "$pool" ]]; then
168 error "File $dir is in pool: $res"
176 do_facet $SINGLEMDS lctl pool_new $FSNAME.$1
178 # get param should return err until pool is created
179 [[ $RC -ne 0 ]] && return $RC
181 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$1 \
182 2>/dev/null || echo foo" "" || RC=1
183 [[ $RC -ne 0 ]] && error "pool_new failed"
189 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool" ""\
190 ||error "Failed to remove targets from pool: $pool"
196 local tgt="${3}$(lctl get_param -n lov.$FSNAME-*.pools.$pool | \
197 sort -u | tr '\n' ' ')"
199 do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool $osts
201 [[ $RC -ne 0 ]] && return $RC
203 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool | \
204 sort -u | tr '\n' ' ' " "$tgt" || RC=1
205 [[ $RC -ne 0 ]] && error "pool_add failed: $1; $2"
209 create_pool_nofail() {
213 error "Pool creation of $1 failed"
221 error "Pool creation of $1 succeeded; should have failed"
226 # Destroy pools from previous test runs
227 for p in $(do_facet $SINGLEMDS lctl pool_list $FSNAME | \
228 grep $FSNAME.pool[0-$OSTCOUNT]); do
231 rm -rf $DIR/d0.${TESTSUITE}
240 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
241 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
244 # Tests for new commands added
247 echo "Creating a pool with a 1 character pool name"
250 echo "Creating a pool with a 10 character pool name"
251 create_pool_nofail p123456789
252 destroy_pool p123456789
254 echo "Creating a pool with a 16 character pool name"
255 create_pool_nofail p123456789123456
256 destroy_pool p123456789123456
258 echo "Creating a pool with a 17 character pool name; should fail"
259 create_pool_fail p1234567891234567
261 echo "Creating a pool with a 1000 character pool name; should fail"
263 for i in `seq 1 999`; do NAME=${NAME}"o"; done
264 create_pool_fail $NAME
266 echo "pool_new should fail if fs-name or poolname are missing."
267 do_facet $SINGLEMDS lctl pool_new .pool1 2>/dev/null
269 error "pool_new did not fail even though fs-name was missing."
270 do_facet $SINGLEMDS lctl pool_new pool1 2>/dev/null
272 error "pool_new did not fail even though fs-name was missing."
273 do_facet $SINGLEMDS lctl pool_new ${FSNAME}. 2>/dev/null
275 error "pool_new did not fail even though pool name was missing."
276 do_facet $SINGLEMDS lctl pool_new . 2>/dev/null
278 error "pool_new did not fail even though pool name and fs-name " \
280 do_facet $SINGLEMDS lctl pool_new ${FSNAME},pool1 2>/dev/null
282 error "pool_new did not fail even though pool name format was wrong"
283 do_facet $SINGLEMDS lctl pool_new ${FSNAME}/pool1 2>/dev/null
285 error "pool_new did not fail even though pool name format was wrong"
287 do_facet $SINGLEMDS lctl pool_new ${FSNAME}.p 2>/dev/null
289 error "pool_new did not fail even though pool1 existed"
293 run_test 1 "Test lctl pool_new ========================================="
298 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
300 error " pool_add did not fail even though pool did " \
303 run_test 2a "pool_add: non-existant pool"
306 do_facet $SINGLEMDS lctl pool_add $FSNAME.p1234567891234567890 \
307 $FSNAME-OST0000 2>/dev/null
309 error "pool_add did not fail even though pool name was invalid."
311 run_test 2b "pool_add: Invalid pool name"
313 # Testing various combinations of OST name list
318 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
322 create_pool_nofail $POOL
325 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
326 RC=$?; [[ $RC -eq 0 ]] || \
327 error "pool_add failed. $FSNAME $POOL OST0000: $RC"
328 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
332 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
333 RC=$?; [[ $RC -eq 0 ]] || \
334 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000: $RC"
335 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
338 # 3. lustre-OST0000_UUID
339 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
340 RC=$?; [[ $RC -eq 0 ]] || \
341 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000_UUID: $RC"
342 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
345 # 4. lustre-OST[0,1,2,3,]
347 for i in $TGT_LIST; do TGT=${TGT}$(printf "$i," $i); done
349 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
351 error "pool_add failed. $FSNAME.$POOL $TGT. $RC"
352 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT
355 # 5. lustre-OST[0-5/1]
356 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
357 RC=$?; [[ $RC -eq 0 ]] || \
358 error "pool_add failed. $FSNAME $POOL" "$TGT_ALL $RC"
359 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
360 sort -u | tr '\n' ' ' " "$TGT_UUID" || error "Add to pool failed"
361 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
366 run_test 2c "pool_add: OST index combinations ==========================="
372 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
376 create_pool_nofail $POOL
378 TGT=$(printf "$FSNAME-OST%04x_UUID " $OSTCOUNT)
379 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
380 RC=$?; [[ $RC -ne 0 ]] || \
381 error "pool_add succeeded for an OST ($TGT) that does not exist."
385 run_test 2d "pool_add: OSTs that don't exist should be rejected ========"
392 $LCTL get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
396 create_pool_nofail $POOL
398 TGT="$FSNAME-OST0000_UUID "
399 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
400 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
401 sort -u | tr '\n' ' ' " "$TGT" || error "Add to pool failed"
402 RESULT=$(do_facet $SINGLEMDS \
403 "LOCALE=C $LCTL pool_add $FSNAME.$POOL $TGT 2>&1")
408 error "pool_add succeeded for an OST that was already in the pool."
410 [[ $(grep "already in pool" <<< $RESULT) ]] || \
411 error "pool_add failed as expected but error message not as expected."
415 run_test 2e "pool_add: OST already in a pool should be rejected ========"
418 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
422 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
424 error "pool_remove did not fail even though pool did not exist."
426 run_test 3a "pool_remove: non-existant pool"
429 do_facet $SINGLEMDS lctl pool_remove ${NON_EXISTANT_FS}.$POOL OST0000 2>/dev/null
431 error "pool_remove did not fail even though fsname did not exist."
433 run_test 3b "pool_remove: non-existant fsname"
436 do_facet $SINGLEMDS lctl pool_remove $FSNAME.p1234567891234567890 \
437 $FSNAME-OST0000 2>/dev/null
439 error "pool_remove did not fail even though pool name was invalid."
441 run_test 3c "pool_remove: Invalid pool name"
443 # Testing various combinations of OST name list
445 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
449 create_pool_nofail $POOL
450 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
451 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
453 error "pool_remove failed. $FSNAME $POOL OST0000"
456 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
457 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
459 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000"
462 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
463 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
465 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000_UUID"
468 add_pool $POOL $TGT_ALL "$TGT_UUID"
469 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
471 error "pool_remove failed. $FSNAME $POOL" $TGT_ALL
476 run_test 3d "pool_remove: OST index combinations ==========================="
479 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
483 do_facet $SINGLEMDS lctl pool_destroy $FSNAME.$POOL 2>/dev/null
485 error "pool_destroy did not fail even though pool did not exist."
487 run_test 4a "pool_destroy: non-existant pool"
490 do_facet $SINGLEMDS lctl pool_destroy ${NON_EXISTANT_FS}.$POOL 2>/dev/null
492 error "pool_destroy did not fail even though the filesystem did not exist."
494 run_test 4b "pool_destroy: non-existant fs-name"
497 create_pool_nofail $POOL
498 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
500 do_facet $SINGLEMDS lctl pool_destroy ${FSNAME}.$POOL
502 error "pool_destroy succeeded with a non-empty pool."
505 run_test 4c "pool_destroy: non-empty pool ==============================="
510 $LCMD pool_list 2>/dev/null
512 error "pool_list did not fail even though fsname was not mentioned."
514 destroy_pool $POOL 2>/dev/null
515 destroy_pool $POOL2 2>/dev/null
517 create_pool_nofail $POOL
518 create_pool_nofail $POOL2
519 $LCMD pool_list $FSNAME
521 error "pool_list $FSNAME failed."
523 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
525 $LCMD pool_list $FSNAME.$POOL
527 error "pool_list $FSNAME.$POOL failed."
529 $LCMD pool_list ${NON_EXISTANT_FS} 2>/dev/null
531 error "pool_list did not fail for a non-existant fsname $NON_EXISTANT_FS"
533 $LCMD pool_list ${FSNAME}.$NON_EXISTANT_POOL 2>/dev/null
535 error "pool_list did not fail for a non-existant pool $NON_EXISTANT_POOL"
537 if [[ ! $(grep $SINGLEMDS <<< $LCMD) ]]; then
538 echo $LCMD pool_list $DIR
541 error "pool_list failed for $DIR"
544 $LCMD pool_list ${DIR}/d1
546 error "pool_list failed for ${DIR}/d1"
549 rm -rf ${DIR}nonexistant
550 $LCMD pool_list ${DIR}nonexistant 2>/dev/null
552 error "pool_list did not fail for invalid mountpoint ${DIR}nonexistant"
559 # Issue commands from client
563 # Issue commands from MDS
564 sub_test_5 "do_facet $SINGLEMDS lctl"
565 sub_test_5 "do_facet $SINGLEMDS lfs"
568 run_test 5 "lfs/lctl pool_list"
571 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
572 local POOL_DIR=$POOL_ROOT/dir_tst
573 local POOL_FILE=$POOL_ROOT/file_tst
575 create_pool_nofail $POOL
577 do_facet $SINGLEMDS lctl pool_list $FSNAME
579 error "pool_list $FSNAME failed."
581 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
584 $SETSTRIPE -c -1 -p $POOL $POOL_DIR
586 error "$SETSTRIPE -p $POOL failed."
587 check_dir_in_pool $POOL_DIR $POOL
589 # If an invalid pool name is specified, the command should fail
590 $SETSTRIPE -c 2 -p $INVALID_POOL $POOL_DIR 2>/dev/null
592 error "setstripe to invalid pool did not fail."
594 # If the pool name does not exist, the command should fail
595 $SETSTRIPE -c 2 -p $NON_EXISTANT_POOL $POOL_DIR 2>/dev/null
597 error "setstripe to non-existant pool did not fail."
599 # lfs setstripe should work as before if a pool name is not specified.
600 $SETSTRIPE -c -1 $POOL_DIR
602 error "$SETSTRIPE -p $POOL_DIR failed."
603 $SETSTRIPE -c -1 $POOL_FILE
605 error "$SETSTRIPE -p $POOL_FILE failed."
607 # lfs setstripe should fail if a start index that is outside the
609 create_pool_nofail $POOL2
610 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
611 $SETSTRIPE -o 1 -p $POOL2 $ROOT_POOL/$tfile 2>/dev/null
613 error "$SETSTRIPE with start index outside the pool did not fail."
618 run_test 6 "getstripe/setstripe"
621 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
623 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
625 create_pool_nofail $POOL
626 create_pool_nofail $POOL2
628 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL \
629 $FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]
630 local start=$((TGT_FIRST+1))
631 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
632 $FSNAME-OST[$start-$TGT_MAX/2]
634 create_dir $POOL_ROOT/dir1 $POOL
635 create_dir $POOL_ROOT/dir2 $POOL2
636 check_dir_in_pool $POOL_ROOT/dir1 $POOL
637 check_dir_in_pool $POOL_ROOT/dir1 $POOL
640 createmany -o $POOL_ROOT/dir1/$tfile $numfiles || \
641 error "createmany $POOL_ROOT/dir1/$tfile failed!"
643 for file in $POOL_ROOT/dir1/*; do
644 check_file_in_pool $file $POOL
647 createmany -o $POOL_ROOT/dir2/$tfile $numfiles || \
648 error "createmany $POOL_ROOT/dir2/$tfile failed!"
649 for file in $POOL_ROOT/dir2/*; do
650 check_file_in_pool $file $POOL2
653 rm -rf $POOL_ROOT/dir?
660 run_test 11 "OSTs in overlapping/multiple pools"
663 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
665 [[ $OSTCOUNT -le 2 ]] && skip "Need atleast 3 OSTs" && return
667 create_pool_nofail $POOL
668 create_pool_nofail $POOL2
670 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL \
671 $FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]
672 local start=$((TGT_FIRST+1))
673 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
674 $FSNAME-OST[$start-$TGT_MAX/2]
676 echo creating some files in $POOL and $POOL2
678 create_dir $POOL_ROOT/dir1 $POOL
679 create_dir $POOL_ROOT/dir2 $POOL2
680 create_file $POOL_ROOT/file1 $POOL
681 create_file $POOL_ROOT/file2 $POOL2
683 echo Checking the files created
684 check_dir_in_pool $POOL_ROOT/dir1 $POOL
685 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
686 check_file_in_pool $POOL_ROOT/file1 $POOL
687 check_file_in_pool $POOL_ROOT/file2 $POOL2
689 echo Changing the pool membership
690 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST[$TGT_FIRST]
691 do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL
692 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 $FSNAME-OST[$TGT_FIRST]
693 do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL2
695 echo Checking the files again
696 check_dir_in_pool $POOL_ROOT/dir1 $POOL
697 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
698 check_file_in_osts $POOL_ROOT/file1 "$TGT_LIST2"
699 check_file_in_osts $POOL_ROOT/file2 "$(seq $start 2 $TGT_MAX)"
701 echo Creating some more files
702 create_dir $POOL_ROOT/dir3 $POOL
703 create_dir $POOL_ROOT/dir4 POOL2
704 create_file $POOL_ROOT/file3 $POOL
705 create_file $POOL_ROOT/file4 $POOL2
707 echo Checking the new files
708 check_file_in_pool $POOL_ROOT/file3 $POOL
709 check_file_in_pool $POOL_ROOT/file4 $POOL2
716 run_test 12 "OST Pool Membership"
719 [[ $OSTCOUNT -le 2 ]] && skip "Need atleast 3 OSTs" && return
721 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
725 create_pool_nofail $POOL
726 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
728 create_dir $POOL_ROOT/dir1 $POOL -1
729 createmany -o $POOL_ROOT/dir1/$tfile $numfiles || \
730 error "createmany $POOL_ROOT/dir1/$tfile failed!"
731 for file in $POOL_ROOT/dir1/*; do
732 check_file_in_pool $file $POOL $OSTCOUNT
735 create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
736 create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST+1))
737 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST+2))
738 check_file_in_pool $POOL_ROOT/dir1/file1 $POOL 1
739 check_file_in_pool $POOL_ROOT/dir1/file2 $POOL 1
740 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST+2))
741 check_file_in_osts $POOL_ROOT/dir1/file1 "$TGT_FIRST"
742 check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST+1))"
743 check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST+2))"
745 create_dir $POOL_ROOT/dir2 $POOL $count
746 createmany -o $POOL_ROOT/dir2/$tfile $numfiles || \
747 error "createmany $POOL_ROOT/dir2/$tfile failed!"
748 for file in $POOL_ROOT/dir2/*; do
749 check_file_in_pool $file $POOL $count
752 create_dir $POOL_ROOT/dir3 $POOL $count $((TGT_FIRST+1))
753 createmany -o $POOL_ROOT/dir3/$tfile_ $numfiles || \
754 error "createmany $POOL_ROOT/dir3/$tfile_ failed!"
755 for file in $POOL_ROOT/dir3/*; do
756 check_file_in_pool $file $POOL $count
759 create_dir $POOL_ROOT/dir4 $POOL 1
760 createmany -o $POOL_ROOT/dir4/$tfile_ $numfiles || \
761 error "createmany $POOL_ROOT/dir4/$tfile_ failed!"
762 for file in $POOL_ROOT/dir4/*; do
763 check_file_in_pool $file $POOL 1
766 create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST+2))
767 createmany -o $POOL_ROOT/dir5/$tfile_ $numfiles || \
768 error "createmany $POOL_ROOT/dir5/$tfile_ failed!"
769 for file in $POOL_ROOT/dir5/*; do
770 check_file_in_pool $file $POOL 1
771 check_file_in_osts $file "$((TGT_FIRST+2))"
774 rm -rf create_dir $POOL_ROOT/dir?
779 run_test 13 "Striping characteristics in a pool"
782 [[ $OSTCOUNT -le 2 ]] && skip "Need atleast 3 OSTs" && return
784 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
788 # Create a new filesystem that is guaranteed to be balanced.
792 create_pool_nofail $POOL
793 create_pool_nofail $POOL2
795 add_pool $POOL $TGT_HALF "$TGT_UUID2"
796 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
798 create_dir $POOL_ROOT/dir1 $POOL 1
799 create_file $POOL_ROOT/dir1/file $POOL 1
800 local OST=$($GETSTRIPE $POOL_ROOT/dir1/file | grep 0x | cut -f2)
802 while [[ $i -lt $numfiles ]];
805 [[ $OST -gt $TGT_MAX ]] && OST=$TGT_FIRST
807 # echo "Iteration: $i OST: $OST"
808 create_file $POOL_ROOT/dir1/file${i} $POOL 1
809 check_file_in_osts $POOL_ROOT/dir1/file${i} $OST
813 # Fill OST $TGT_FIRST with 10M files
814 create_dir $POOL_ROOT/dir2 $POOL2 1
817 while [[ $RC -eq 0 ]];
819 dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1k count=$((1024*10))
824 # Leave some space on the OST
825 rm -f $POOL_ROOT/dir2/f0
828 # OST $TGT_FIRST is no longer favored; but it may still be used.
829 create_dir $POOL_ROOT/dir3 $POOL 1
830 create_file $POOL_ROOT/dir3/file $POOL 1
831 createmany -o $POOL_ROOT/dir3/$tfile_ $numfiles || \
832 error "createmany $POOL_ROOT/dir3/$tfile_ failed!"
833 for file in $POOL_ROOT/dir3/*; do
834 check_file_in_pool $file $POOL
842 run_test 14 "Round robin and QOS striping within a pool"
845 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
849 while [[ $i -lt $OSTCOUNT ]]
851 create_pool_nofail pool${i}
853 local tgt=$(printf "$FSNAME-OST%04x_UUID " $i)
854 add_pool pool${i} "$FSNAME-OST[$i]" "$tgt"
855 create_dir $POOL_ROOT/dir${i} pool${i}
856 createmany -o $POOL_ROOT/dir$i/$tfile $numfiles || \
857 error "createmany $POOL_ROOT/dir$i/$tfile failed!"
859 for file in $POOL_ROOT/dir$i/*; do
860 check_file_in_osts $file $i
867 while [[ $i -lt $OSTCOUNT ]]
869 destroy_pool pool${i}
875 run_test 15 "One directory per OST/pool"
878 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
882 create_pool_nofail $POOL
884 add_pool $POOL $TGT_HALF "$TGT_UUID2"
886 local dir=$POOL_ROOT/$tdir
887 create_dir $dir $POOL
889 for i in $(seq 1 10); do
894 createmany -o $dir/$tfile $numfiles || \
895 error "createmany $dir/$tfile failed!"
897 for file in $dir/*; do
898 check_file_in_pool $file $POOL
901 rm -rf $POOL_ROOT/$tdir
907 run_test 16 "Inheritance of pool properties"
910 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
914 create_pool_nofail $POOL
916 add_pool $POOL $TGT_ALL "$TGT_UUID"
918 local dir=$POOL_ROOT/dir
919 create_dir $dir $POOL
921 createmany -o $dir/${tfile}1_ $numfiles || \
922 error "createmany $dir/${tfile}1_ failed!"
924 for file in $dir/*; do
925 check_file_in_pool $file $POOL
930 createmany -o $dir/${tfile}2_ $numfiles || \
931 error "createmany $dir/${tfile}2_ failed!"
936 run_test 17 "Referencing an empty pool"
944 sync; sleep 5 # give pending IO a chance to go to disk
945 stat=$(createmany -o $dir/${tfile} $numfiles)
948 time=$(echo $stat | cut -f 5 -d ' ')
949 echo $stat > /dev/stderr
954 local t1=$(create_perf_one $1 $2)
955 local t2=$(create_perf_one $1 $2)
956 local t3=$(create_perf_one $1 $2)
957 local time=$(echo "scale=2; ( $t1 + $t2 + $t3 ) / 3" | bc)
963 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
969 local dir=$POOL_ROOT/dir
973 time1=$(create_perf $dir $numfiles)
975 create_pool_nofail $POOL
977 add_pool $POOL $TGT_ALL "$TGT_UUID"
979 create_dir $dir $POOL
980 time2=$(create_perf $dir $numfiles)
984 time3=$(create_perf $dir $numfiles)
986 echo Time taken for $numfiles creates without pools: $time1
987 echo Time taken for $numfiles creates with pools: $time2
988 echo Time taken for $numfiles creates without pools: $time3
990 deg=$(echo "scale=2; (($time2 - $time3) * 100 / $time3) > 5" | bc)
991 diff=$(echo "scale=2; ($time2 - $time3) * 100 / $time3" | bc)
993 if [[ "$deg" == "1" ]]; then
994 error "Performance degradation with pools is $diff %."
996 echo "Performance degradation with pools is $diff %."
1000 run_test 18 "File create in a directory which references a deleted pool"
1004 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1006 local dir1=$POOL_ROOT/dir1
1007 local dir2=$POOL_ROOT/dir2
1010 create_pool_nofail $POOL
1012 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1014 create_dir $dir1 $POOL
1015 createmany -o $dir1/${tfile} $numfiles || \
1016 error "createmany $dir1/${tfile} failed!"
1017 for file in $dir1/*; do
1018 check_file_in_pool $file $POOL
1022 createmany -o $dir2/${tfile} $numfiles || \
1023 error "createmany $dir2/${tfile} failed!"
1024 for file in $dir2/*; do
1025 check_file_not_in_pool $file $POOL
1033 run_test 19 "Pools should not come into play when not specified"
1036 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1038 local dir1=$POOL_ROOT/dir1
1039 local dir2=$dir1/dir2
1040 local dir3=$dir1/dir3
1044 create_pool_nofail $POOL
1045 create_pool_nofail $POOL2
1047 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1049 local start=$((TGT_FIRST+1))
1050 TGT=$(for i in `seq $start 2 $TGT_MAX`; \
1051 do printf "$FSNAME-OST%04x_UUID " $i; done)
1052 add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1054 create_dir $dir1 $POOL
1055 create_file $dir1/file1 $POOL2
1056 create_dir $dir2 $POOL2
1059 $SETSTRIPE -c 1 $dir3 # No pool assignment
1061 $SETSTRIPE -c 1 $dir2/file4 # No pool assignment
1063 check_file_in_pool $dir1/file1 $POOL2
1064 check_file_in_pool $dir2/file2 $POOL2
1066 check_dir_not_in_pool $dir3 $POOL
1067 check_dir_not_in_pool $dir3 $POOL2
1069 check_file_not_in_pool $dir3/file3 $POOL
1070 check_file_not_in_pool $dir3/file3 $POOL2
1072 check_file_not_in_pool $dir2/file4 $POOL
1073 check_file_not_in_pool $dir2/file4 $POOL2
1081 run_test 20 "Different pools in a directory hierarchy."
1084 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1085 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1089 local dir=$POOL_ROOT/dir
1091 create_pool_nofail $POOL
1093 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1095 create_dir $dir $POOL $OSTCOUNT
1096 create_file $dir/file1 $POOL $OSTCOUNT
1097 $GETSTRIPE -v $dir/file1
1098 check_file_in_pool $dir/file1 $POOL
1105 run_test 21 "OST pool with fewer OSTs than stripe count"
1113 for c in $(seq 1 10);
1115 echo "Pool $pool, iteration $c"
1116 do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool OST[$TGT_FIRST-$TGT_MAX/$step] 2>/dev/null
1117 local TGT_SECOND=$(($TGT_FIRST+$step))
1118 if [ "$TGT_SECOND" -le "$TGT_MAX" ]; then
1119 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$pool OST[$TGT_SECOND-$TGT_MAX/$step]
1122 echo loop for $pool complete
1126 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1127 [[ $OSTCOUNT -le 1 ]] && skip "Need at least 2 OSTs" && return
1131 create_pool_nofail $POOL
1132 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
1133 create_pool_nofail $POOL2
1134 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
1139 create_dir $POOL_ROOT $POOL
1140 createmany -o $POOL_ROOT/${tfile} $numfiles || \
1141 error "createmany $POOL_ROOT/${tfile} failed!"
1149 run_test 22 "Simultaneous manipulation of a pool"
1152 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1153 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1156 check_runas_id $TSTID $TSTID $RUNAS || {
1157 skip "User $RUNAS_ID does not exist - skipping"
1165 local dir=$POOL_ROOT/dir
1166 local file1="$dir/$tfile-quota1"
1167 local file2="$dir/$tfile-quota2"
1169 create_pool_nofail $POOL
1171 local TGT=$(for i in `seq $TGT_FIRST 3 $TGT_MAX`; \
1172 do printf "$FSNAME-OST%04x_UUID " $i; done)
1173 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1174 create_dir $dir $POOL
1176 $LFS quotaoff -ug $MOUNT
1177 $LFS quotacheck -ug $MOUNT
1178 $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir #-i 5 -I 5 $dir
1180 $LFS setstripe $file1 -c 1 -p $POOL
1181 chown $TSTUSR.$TSTUSR $file1
1185 stat=$(LC_ALL=C $RUNAS dd if=/dev/zero of=$file1 bs=1024 count=$((LIMIT*2)) 2>&1)
1188 [[ $RC -eq 0 ]] && error "dd did not fail with EDQUOT."
1189 echo $stat | grep "Disk quota exceeded"
1190 [[ $? -eq 1 ]] && error "dd did not fail with EDQUOT."
1193 $LFS quotaoff -ug $MOUNT
1194 # $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir
1195 chown $TSTUSR.$TSTUSR $dir
1198 while [ $RC -eq 0 ];
1201 stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file2}$i bs=1024 \
1202 count=$((LIMIT*LIMIT)) 2>&1)
1204 if [ $RC -eq 1 ]; then
1206 echo $stat | grep "Disk quota exceeded"
1207 [[ $? -eq 0 ]] && error "dd failed with EDQUOT"
1209 echo $stat | grep "No space left on device"
1210 [[ $? -ne 0 ]] && error "dd did not fail with ENOSPC; " \
1222 run_test 23 "OST pools and quota"
1225 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1226 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1235 create_pool_nofail $POOL
1237 add_pool $POOL $TGT_ALL "$TGT_UUID"
1239 create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1241 mkdir $POOL_ROOT/dir2
1242 $SETSTRIPE $POOL_ROOT/dir2 -p $POOL -s 65536 -i 0 -c 1 || \
1243 error "$SETSTRIPE $POOL_ROOT/dir2 failed"
1245 mkdir $POOL_ROOT/dir3
1246 $SETSTRIPE $POOL_ROOT/dir3 -s 65536 -i 0 -c 1 || \
1247 error "$SETSTRIPE $POOL_ROOT/dir3 failed"
1249 mkdir $POOL_ROOT/dir4
1251 for i in $(seq 1 4);
1253 dir=${POOL_ROOT}/dir${i}
1262 createmany -o $dir/${tfile} $numfiles || \
1263 error "createmany $dir/${tfile} failed!"
1264 res=$($GETSTRIPE -v $dir | grep "^stripe_count:")
1265 if [ $? -ne 0 ]; then
1266 res=$($GETSTRIPE -v $dir | grep "^(Default) ")
1267 pool=$(cut -f 9 -d ' ' <<< $res)
1268 index=$(cut -f 7 -d ' ' <<< $res)
1269 size=$(cut -f 5 -d ' ' <<< $res)
1270 count=$(cut -f 3 -d ' ' <<< $res)
1272 pool=$(cut -f 8 -d ' ' <<< $res)
1273 index=$(cut -f 6 -d ' ' <<< $res)
1274 size=$(cut -f 4 -d ' ' <<< $res)
1275 count=$(cut -f 2 -d ' ' <<< $res)
1278 for file in $dir/*; do
1279 if [ "$pool" != "" ]; then
1280 check_file_in_pool $file $pool
1282 pool1=$($GETSTRIPE -v $file | grep "^pool:" |\
1283 tr -d '[:blank:]' | cut -f 2 -d ':')
1284 count1=$($GETSTRIPE -v $file | grep "^lmm_stripe_count:" |\
1285 tr -d '[:blank:]' | cut -f 2 -d ':')
1286 size1=$($GETSTRIPE -v $file | grep "^lmm_stripe_size:" |\
1287 tr -d '[:blank:]' | cut -f 2 -d ':')
1288 [[ "$pool" != "$pool1" ]] && \
1289 error "Pool name ($pool) not inherited in $file($pool1)"
1290 [[ "$count" != "$count1" ]] && \
1291 error "Stripe count ($count) not inherited in $file ($count1)"
1292 [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] && \
1293 error "Stripe size ($size) not inherited in $file ($size1)"
1302 run_test 24 "Independence of pool from other setstripe parameters"
1305 local dev=$(mdsdevname ${SINGLEMDS//mds/})
1306 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1310 for i in $(seq 10); do
1311 create_pool_nofail pool$i
1312 do_facet $SINGLEMDS lctl pool_add $FSNAME.pool$i OST0000
1313 stop $SINGLEMDS || return 1
1314 start $SINGLEMDS ${dev} $MDS_MOUNT_OPTS || \
1315 { error "Failed to start $SINGLEMDS after stopping" && break; }
1318 # Veriy that the pool got created and is usable
1319 echo "Creating a file in pool$i"
1320 create_file $POOL_ROOT/file$i pool$i || break
1321 check_file_in_pool $POOL_ROOT/file$i pool$i || break
1325 for i in $(seq 10); do
1329 run_test 25 "Create new pool and restart MDS ======================="
1331 log "cleanup: ======================================================"
1334 check_and_cleanup_lustre
1335 echo '=========================== finished ==============================='
1336 [ -f "$POOLSLOG" ] && cat $POOLSLOG && grep -q FAIL $POOLSLOG && exit 1 || true
1337 echo "$0: completed"