3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # Run test by setting NOSETUP=true when ltest has setup env for us
9 export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
12 ALWAYS_EXCEPT="$OST_POOLS_EXCEPT"
13 # bug number for skipped test: -
14 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
16 [ "$ALWAYS_EXCEPT$EXCEPT" ] && \
17 echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT`"
22 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
23 . $LUSTRE/tests/test-framework.sh
25 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
27 check_and_setup_lustre
32 POOLSLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
33 [ "$POOLSLOG" ] && rm -f $POOLSLOG || true
36 FAIL_ON_ERROR=${FAIL_ON_ERROR:-true}
40 SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
41 GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"}
44 TSTUSR=${TSTUSR:-"quota_usr"}
46 RUNAS="runas -u $TSTID -g $TSTID"
52 NON_EXISTANT_POOL=nonexistantpool
53 NON_EXISTANT_FS=nonexistantfs
54 INVALID_POOL=some_invalid_pool_name
57 TGT_MAX=$((TGT_COUNT-1))
59 TGT_LIST=$(seq $TGT_FIRST $TGT_STEP $TGT_MAX)
60 TGT_LIST2=$(seq $TGT_FIRST 2 $TGT_MAX)
62 TGT_ALL="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/1]"
63 TGT_HALF="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]"
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)
71 local count=${3:-"-1"}
76 $SETSTRIPE -c $count -p $pool $dir -o $idx
78 $SETSTRIPE -c $count -p $pool $dir
81 error "$SETSTRIPE -p $pool $dir failed."
87 local count=${3:-"-1"}
88 local index=${4:-"-1"}
90 $SETSTRIPE -o $index -c $count -p $pool $file
92 error "$SETSTRIPE -p $pool $file failed."
98 for i in $(do_facet $SINGLEMDS lctl pool_list $FSNAME.$pool | \
99 grep -v "^Pool:" | sed -e 's/_UUID$//;s/^.*-OST//'); do
100 res="$res $(printf "%d" 0x$i)"
105 check_dir_in_pool() {
108 local res=$($GETSTRIPE $dir | grep "^stripe_count:" \
109 | cut -d ':' -f 5 | tr -d "[:blank:]")
110 if [[ "$res" == "$pool" ]]; then
113 error found $res instead of $pool
118 check_file_in_pool() {
119 local osts=$(osts_in_pool $2)
120 check_file_in_osts $1 "$osts" $3
123 check_file_in_osts() {
125 local pool_list=${2:-$TGT_LIST}
127 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
131 found=$(echo :$pool_list: | tr " " ":" | grep :$i:)
132 if [[ "$found" == "" ]]; then
133 echo "pool list: $pool_list"
134 echo "striping: $res"
136 error "$file not allocated from OSTs $pool_list."
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"
148 check_file_not_in_pool() {
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"
160 check_dir_not_in_pool() {
163 local res=$($GETSTRIPE -v $dir | grep "^stripe_count" | head -1 | \
165 if [[ "$res" == "$pool" ]]; then
166 error "File $dir is in pool: $res"
174 do_facet $SINGLEMDS lctl pool_new $FSNAME.$1
176 # get param should return err until pool is created
177 [[ $RC -ne 0 ]] && return $RC
179 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$1 \
180 2>/dev/null || echo foo" "" || RC=1
181 [[ $RC -ne 0 ]] && error "pool_new failed"
187 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool" ""\
188 ||error "Failed to remove targets from pool: $pool"
194 local tgt="${3}$(lctl get_param -n lov.$FSNAME-*.pools.$pool | \
195 sort -u | tr '\n' ' ')"
197 do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool $osts
199 [[ $RC -ne 0 ]] && return $RC
201 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool | \
202 sort -u | tr '\n' ' ' " "$tgt" || RC=1
203 [[ $RC -ne 0 ]] && error "pool_add failed: $1; $2"
207 create_pool_nofail() {
211 error "Pool creation of $1 failed"
219 error "Pool creation of $1 succeeded; should have failed"
224 # Destroy pools from previous test runs
225 for p in $(do_facet $SINGLEMDS lctl pool_list $FSNAME | \
226 grep $FSNAME.pool[0-$OSTCOUNT]); do
229 rm -rf $DIR/d0.${TESTSUITE}
238 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
239 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
242 # Tests for new commands added
245 echo "Creating a pool with a 1 character pool name"
248 echo "Creating a pool with a 10 character pool name"
249 create_pool_nofail p123456789
250 destroy_pool p123456789
252 echo "Creating a pool with a 16 character pool name"
253 create_pool_nofail p123456789123456
254 destroy_pool p123456789123456
256 echo "Creating a pool with a 17 character pool name; should fail"
257 create_pool_fail p1234567891234567
259 echo "Creating a pool with a 1000 character pool name; should fail"
261 for i in `seq 1 999`; do NAME=${NAME}"o"; done
262 create_pool_fail $NAME
264 echo "pool_new should fail if fs-name or poolname are missing."
265 do_facet $SINGLEMDS lctl pool_new .pool1
267 error "pool_new did not fail even though fs-name was missing."
268 do_facet $SINGLEMDS lctl pool_new pool1
270 error "pool_new did not fail even though fs-name was missing."
271 do_facet $SINGLEMDS lctl pool_new ${FSNAME}.
273 error "pool_new did not fail even though pool name was missing."
274 do_facet $SINGLEMDS lctl pool_new .
276 error "pool_new did not fail even though pool name and fs-name " \
278 do_facet $SINGLEMDS lctl pool_new ${FSNAME},pool1
280 error "pool_new did not fail even though pool name format was wrong"
281 do_facet $SINGLEMDS lctl pool_new ${FSNAME}/pool1
283 error "pool_new did not fail even though pool name format was wrong"
285 do_facet $SINGLEMDS lctl pool_new ${FSNAME}.p
287 error "pool_new did not fail even though pool1 existed"
291 run_test 1 "Test lctl pool_new ========================================="
296 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
298 error " pool_add did not fail even though pool did " \
301 run_test 2a "pool_add: non-existant pool"
304 do_facet $SINGLEMDS lctl pool_add $FSNAME.p1234567891234567890 \
307 error "pool_add did not fail even though pool name was invalid."
309 run_test 2b "pool_add: Invalid pool name"
311 # Testing various combinations of OST name list
316 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
320 create_pool_nofail $POOL
323 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
324 RC=$?; [[ $RC -eq 0 ]] || \
325 error "pool_add failed. $FSNAME $POOL OST0000: $RC"
326 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
330 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
331 RC=$?; [[ $RC -eq 0 ]] || \
332 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000: $RC"
333 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
336 # 3. lustre-OST0000_UUID
337 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
338 RC=$?; [[ $RC -eq 0 ]] || \
339 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000_UUID: $RC"
340 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
343 # 4. lustre-OST[0,1,2,3,]
345 for i in $TGT_LIST; do TGT=${TGT}$(printf "$i," $i); done
347 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
349 error "pool_add failed. $FSNAME.$POOL $TGT. $RC"
350 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT
353 # 5. lustre-OST[0-5/1]
354 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
355 RC=$?; [[ $RC -eq 0 ]] || \
356 error "pool_add failed. $FSNAME $POOL" "$TGT_ALL $RC"
357 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
358 sort -u | tr '\n' ' ' " "$TGT_UUID" || error "Add to pool failed"
359 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
364 run_test 2c "pool_add: OST index combinations ==========================="
370 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
374 create_pool_nofail $POOL
376 TGT=$(printf "$FSNAME-OST%04x_UUID " $OSTCOUNT)
377 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
378 RC=$?; [[ $RC -ne 0 ]] || \
379 error "pool_add succeeded for an OST ($TGT) that does not exist."
383 run_test 2d "pool_add: OSTs that don't exist should be rejected ========"
390 $LCTL get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
394 create_pool_nofail $POOL
396 TGT="$FSNAME-OST0000_UUID "
397 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
398 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
399 sort -u | tr '\n' ' ' " "$TGT" || error "Add to pool failed"
400 RESULT=$(do_facet $SINGLEMDS \
401 "LOCALE=C $LCTL pool_add $FSNAME.$POOL $TGT 2>&1")
406 error "pool_add succeeded for an OST that was already in the pool."
408 [[ $(grep "already in pool" <<< $RESULT) ]] || \
409 error "pool_add failed as expected but error message not as expected."
413 run_test 2e "pool_add: OST already in a pool should be rejected ========"
416 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
420 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
422 error "pool_remove did not fail even though" \
423 "pool did not exist."
425 run_test 3a "pool_remove: non-existant pool"
428 do_facet $SINGLEMDS lctl pool_remove ${NON_EXISTANT_FS}.$POOL OST0000
430 error "pool_remove did not fail even though fsname did not exist."
432 run_test 3b "pool_remove: non-existant fsname"
435 do_facet $SINGLEMDS lctl pool_remove $FSNAME.p1234567891234567890 \
438 error "pool_remove did not fail even though pool name was invalid."
440 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
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
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 name."
505 run_test 4c "pool_destroy: non-empty pool ==============================="
512 error "pool_list did not fail even though fsname was not mentioned."
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}
531 error "pool_list did not fail for a non-existant fsname $NON_EXISTANT_FS"
533 $LCMD pool_list ${FSNAME}.$NON_EXISTANT_POOL
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
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
592 error_ignore 19919 "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
597 error_ignore 19919 "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
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 create_pool_nofail $pool
1117 local TGT=$(for i in `seq $TGT_FIRST $step $TGT_MAX`; \
1118 do printf "$FSNAME-OST%04x_UUID " $i; done)
1119 add_pool $pool "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/$step]" "$TGT"
1121 do_facet $SINGLEMDS lctl pool_list $FSNAME
1123 echo loop for $pool complete
1127 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1128 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1135 create_dir $POOL_ROOT $POOL
1136 createmany -o $POOL_ROOT/${tfile} $numfiles || \
1137 error "createmany $POOL_ROOT/${tfile} failed!"
1142 run_test 22 "Simultaneous manipulation of a pool"
1145 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1146 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1149 check_runas_id $TSTID $TSTID $RUNAS || {
1150 skip "User $RUNAS_ID does not exist - skipping"
1158 local dir=$POOL_ROOT/dir
1159 local file1="$dir/$tfile-quota1"
1160 local file2="$dir/$tfile-quota2"
1162 create_pool_nofail $POOL
1164 local TGT=$(for i in `seq $TGT_FIRST 3 $TGT_MAX`; \
1165 do printf "$FSNAME-OST%04x_UUID " $i; done)
1166 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1167 create_dir $dir $POOL
1169 $LFS quotaoff -ug $MOUNT
1170 $LFS quotacheck -ug $MOUNT
1171 $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir #-i 5 -I 5 $dir
1173 $LFS setstripe $file1 -c 1 -p $POOL
1174 chown $TSTUSR.$TSTUSR $file1
1178 stat=$(LC_ALL=C $RUNAS dd if=/dev/zero of=$file1 bs=1024 count=$((LIMIT*2)) 2>&1)
1181 [[ $RC -eq 0 ]] && error "dd did not fail with EDQUOT."
1182 echo $stat | grep "Disk quota exceeded"
1183 [[ $? -eq 1 ]] && error "dd did not fail with EDQUOT."
1186 $LFS quotaoff -ug $MOUNT
1187 # $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir
1188 chown $TSTUSR.$TSTUSR $dir
1191 while [ $RC -eq 0 ];
1194 stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file2}$i bs=1024 \
1195 count=$((LIMIT*LIMIT)) 2>&1)
1197 if [ $RC -eq 1 ]; then
1199 echo $stat | grep "Disk quota exceeded"
1200 [[ $? -eq 0 ]] && error "dd failed with EDQUOT"
1202 echo $stat | grep "No space left on device"
1203 [[ $? -ne 0 ]] && error "dd did not fail with ENOSPC; " \
1215 run_test 23 "OST pools and quota"
1218 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1219 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1228 create_pool_nofail $POOL
1230 add_pool $POOL $TGT_ALL "$TGT_UUID"
1232 create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1234 mkdir $POOL_ROOT/dir2
1235 $SETSTRIPE $POOL_ROOT/dir2 -p $POOL -s 65536 -i 0 -c 1 || \
1236 error "$SETSTRIPE $POOL_ROOT/dir2 failed"
1238 mkdir $POOL_ROOT/dir3
1239 $SETSTRIPE $POOL_ROOT/dir3 -s 65536 -i 0 -c 1 || \
1240 error "$SETSTRIPE $POOL_ROOT/dir3 failed"
1242 mkdir $POOL_ROOT/dir4
1244 for i in $(seq 1 4);
1246 dir=${POOL_ROOT}/dir${i}
1255 createmany -o $dir/${tfile} $numfiles || \
1256 error "createmany $dir/${tfile} failed!"
1257 res=$($GETSTRIPE -v $dir | grep "^stripe_count:")
1258 if [ $? -ne 0 ]; then
1259 res=$($GETSTRIPE -v $dir | grep "^(Default) ")
1260 pool=$(cut -f 9 -d ' ' <<< $res)
1261 index=$(cut -f 7 -d ' ' <<< $res)
1262 size=$(cut -f 5 -d ' ' <<< $res)
1263 count=$(cut -f 3 -d ' ' <<< $res)
1265 pool=$(cut -f 8 -d ' ' <<< $res)
1266 index=$(cut -f 6 -d ' ' <<< $res)
1267 size=$(cut -f 4 -d ' ' <<< $res)
1268 count=$(cut -f 2 -d ' ' <<< $res)
1271 for file in $dir/*; do
1272 if [ "$pool" != "" ]; then
1273 check_file_in_pool $file $pool
1275 pool1=$($GETSTRIPE -v $file | grep "^pool:" |\
1276 tr -d '[:blank:]' | cut -f 2 -d ':')
1277 count1=$($GETSTRIPE -v $file | grep "^lmm_stripe_count:" |\
1278 tr -d '[:blank:]' | cut -f 2 -d ':')
1279 size1=$($GETSTRIPE -v $file | grep "^lmm_stripe_size:" |\
1280 tr -d '[:blank:]' | cut -f 2 -d ':')
1281 [[ "$pool" != "$pool1" ]] && \
1282 error "Pool name ($pool) not inherited in $file($pool1)"
1283 [[ "$count" != "$count1" ]] && \
1284 error "Stripe count ($count) not inherited in $file ($count1)"
1285 [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] && \
1286 error "Stripe size ($size) not inherited in $file ($size1)"
1295 run_test 24 "Independence of pool from other setstripe parameters"
1298 local dev=$(mdsdevname ${SINGLEMDS//mds/})
1299 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1303 for i in $(seq 10); do
1304 create_pool_nofail pool$i
1305 stop $SINGLEMDS || return 1
1307 start $SINGLEMDS ${dev} $MDS_MOUNT_OPTS || \
1308 error "Failed to start $SINGLEMDS after stopping"
1310 # Veriy that the pool got created and is usable
1311 echo "Creating a file in pool$i"
1312 create_file $POOL_ROOT/file$i pool$i
1313 check_file_in_pool $POOL_ROOT/file$i pool$i
1317 for i in $(seq 10); do
1321 run_test 25 "Create new pool and restart MDS ======================="
1323 log "cleanup: ======================================================"
1326 check_and_cleanup_lustre
1327 echo '=========================== finished ==============================='
1328 [ -f "$POOLSLOG" ] && cat $POOLSLOG && grep -q FAIL $POOLSLOG && exit 1 || true
1329 echo "$0: completed"