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"}
47 TSTUSR=${TSTUSR:-"quota_usr"}
49 RUNAS="runas -u $TSTID -g $TSTID"
55 NON_EXISTANT_POOL=nonexistantpool
56 NON_EXISTANT_FS=nonexistantfs
57 INVALID_POOL=some_invalid_pool_name
60 TGT_MAX=$((TGT_COUNT-1))
62 TGT_LIST=$(seq $TGT_FIRST $TGT_STEP $TGT_MAX)
63 TGT_LIST2=$(seq $TGT_FIRST 2 $TGT_MAX)
65 TGT_ALL="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/1]"
66 TGT_HALF="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]"
68 TGT_UUID=$(for i in $TGT_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
69 TGT_UUID2=$(for i in $TGT_LIST2; do printf "$FSNAME-OST%04x_UUID " $i; done)
74 local count=${3:-"-1"}
79 $SETSTRIPE -c $count -p $pool $dir -o $idx
81 $SETSTRIPE -c $count -p $pool $dir
84 error "$SETSTRIPE -p $pool $dir failed."
90 local count=${3:-"-1"}
91 local index=${4:-"-1"}
93 $SETSTRIPE -o $index -c $count -p $pool $file
95 error "$SETSTRIPE -p $pool $file failed."
101 for i in $(do_facet $SINGLEMDS lctl pool_list $FSNAME.$pool | \
102 grep -v "^Pool:" | sed -e 's/_UUID$//;s/^.*-OST//'); do
103 res="$res $(printf "%d" 0x$i)"
108 check_dir_in_pool() {
111 local res=$($GETSTRIPE $dir | grep "^stripe_count:" \
112 | cut -d ':' -f 5 | tr -d "[:blank:]")
113 if [[ "$res" == "$pool" ]]; then
116 error found $res instead of $pool
121 check_file_in_pool() {
122 local osts=$(osts_in_pool $2)
123 check_file_in_osts $1 "$osts" $3
126 check_file_in_osts() {
128 local pool_list=${2:-$TGT_LIST}
130 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
134 found=$(echo :$pool_list: | tr " " ":" | grep :$i:)
135 if [[ "$found" == "" ]]; then
136 echo "pool list: $pool_list"
137 echo "striping: $res"
139 error "$file not allocated from OSTs $pool_list."
144 local ost_count=$($GETSTRIPE $file | grep 0x | wc -l)
145 [[ -n "$count" ]] && [[ $ost_count -ne $count ]] && \
146 { error "Stripe count $count expected; got $ost_count" && return 1; }
151 check_file_not_in_pool() {
154 local res=$($GETSTRIPE -v $file | grep "^pool:" | tr -d "[:blank:]" | cut -f 2 -d ':')
155 if [[ "$res" == "$pool" ]]; then
156 error "File $file is in pool: $res"
163 check_dir_not_in_pool() {
166 local res=$($GETSTRIPE -v $dir | grep "^stripe_count" | head -1 | \
168 if [[ "$res" == "$pool" ]]; then
169 error "File $dir is in pool: $res"
178 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool" ""\
179 ||error "Failed to remove targets from pool: $pool"
185 local tgt="${3}$(lctl get_param -n lov.$FSNAME-*.pools.$pool | \
186 sort -u | tr '\n' ' ')"
188 do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool $osts
190 [[ $RC -ne 0 ]] && return $RC
192 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool | \
193 sort -u | tr '\n' ' ' " "$tgt" || RC=1
194 [[ $RC -ne 0 ]] && error "pool_add failed: $1; $2"
198 create_pool_nofail() {
199 create_pool $FSNAME.$1
202 error "Pool creation of $1 failed"
207 create_pool $FSNAME.$1
210 error "Pool creation of $1 succeeded; should have failed"
215 # Destroy pools from previous test runs
216 for p in $(do_facet $SINGLEMDS lctl pool_list $FSNAME | \
217 grep $FSNAME.pool[0-$OSTCOUNT]); do
220 rm -rf $DIR/d0.${TESTSUITE}
229 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
230 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
233 trap "cleanup_pools $FSNAME" EXIT
235 # Tests for new commands added
237 echo "Creating a pool with a 1 character pool name"
240 echo "Creating a pool with a 10 character pool name"
241 create_pool_nofail p123456789
242 destroy_pool p123456789
244 echo "Creating a pool with a 16 character pool name"
245 create_pool_nofail p123456789123456
246 destroy_pool p123456789123456
248 echo "Creating a pool with a 17 character pool name; should fail"
249 create_pool_fail p1234567891234567
251 echo "Creating a pool with a 1000 character pool name; should fail"
253 for i in `seq 1 999`; do NAME=${NAME}"o"; done
254 create_pool_fail $NAME
256 echo "pool_new should fail if fs-name or poolname are missing."
257 do_facet $SINGLEMDS lctl pool_new .pool1 2>/dev/null
259 error "pool_new did not fail even though fs-name was missing."
260 do_facet $SINGLEMDS lctl pool_new pool1 2>/dev/null
262 error "pool_new did not fail even though fs-name was missing."
263 do_facet $SINGLEMDS lctl pool_new ${FSNAME}. 2>/dev/null
265 error "pool_new did not fail even though pool name was missing."
266 do_facet $SINGLEMDS lctl pool_new . 2>/dev/null
268 error "pool_new did not fail even though pool name and fs-name " \
270 do_facet $SINGLEMDS lctl pool_new ${FSNAME},pool1 2>/dev/null
272 error "pool_new did not fail even though pool name format was wrong"
273 do_facet $SINGLEMDS lctl pool_new ${FSNAME}/pool1 2>/dev/null
275 error "pool_new did not fail even though pool name format was wrong"
277 do_facet $SINGLEMDS lctl pool_new ${FSNAME}.p 2>/dev/null
279 error "pool_new did not fail even though pool1 existed"
283 run_test 1 "Test lctl pool_new ========================================="
288 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
290 error " pool_add did not fail even though pool did " \
293 run_test 2a "pool_add: non-existant pool"
296 do_facet $SINGLEMDS lctl pool_add $FSNAME.p1234567891234567890 \
297 $FSNAME-OST0000 2>/dev/null
299 error "pool_add did not fail even though pool name was invalid."
301 run_test 2b "pool_add: Invalid pool name"
303 # Testing various combinations of OST name list
308 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
312 create_pool_nofail $POOL
315 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
316 RC=$?; [[ $RC -eq 0 ]] || \
317 error "pool_add failed. $FSNAME $POOL OST0000: $RC"
318 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
322 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
323 RC=$?; [[ $RC -eq 0 ]] || \
324 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000: $RC"
325 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
328 # 3. lustre-OST0000_UUID
329 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
330 RC=$?; [[ $RC -eq 0 ]] || \
331 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000_UUID: $RC"
332 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
335 # 4. lustre-OST[0,1,2,3,]
337 for i in $TGT_LIST; do TGT=${TGT}$(printf "$i," $i); done
339 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
341 error "pool_add failed. $FSNAME.$POOL $TGT. $RC"
342 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT
345 # 5. lustre-OST[0-5/1]
346 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
347 RC=$?; [[ $RC -eq 0 ]] || \
348 error "pool_add failed. $FSNAME $POOL" "$TGT_ALL $RC"
349 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
350 sort -u | tr '\n' ' ' " "$TGT_UUID" || error "Add to pool failed"
351 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
356 run_test 2c "pool_add: OST index combinations ==========================="
362 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
366 create_pool_nofail $POOL
368 TGT=$(printf "$FSNAME-OST%04x_UUID " $OSTCOUNT)
369 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
370 RC=$?; [[ $RC -ne 0 ]] || \
371 error "pool_add succeeded for an OST ($TGT) that does not exist."
375 run_test 2d "pool_add: OSTs that don't exist should be rejected ========"
382 $LCTL get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
386 create_pool_nofail $POOL
388 TGT="$FSNAME-OST0000_UUID "
389 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
390 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
391 sort -u | tr '\n' ' ' " "$TGT" || error "Add to pool failed"
392 RESULT=$(do_facet $SINGLEMDS \
393 "LOCALE=C $LCTL pool_add $FSNAME.$POOL $TGT 2>&1")
398 error "pool_add succeeded for an OST that was already in the pool."
400 [[ $(grep "already in pool" <<< $RESULT) ]] || \
401 error "pool_add failed as expected but error message not as expected."
405 run_test 2e "pool_add: OST already in a pool should be rejected ========"
408 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
412 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
414 error "pool_remove did not fail even though pool did not exist."
416 run_test 3a "pool_remove: non-existant pool"
419 do_facet $SINGLEMDS lctl pool_remove ${NON_EXISTANT_FS}.$POOL OST0000 2>/dev/null
421 error "pool_remove did not fail even though fsname did not exist."
423 run_test 3b "pool_remove: non-existant fsname"
426 do_facet $SINGLEMDS lctl pool_remove $FSNAME.p1234567891234567890 \
427 $FSNAME-OST0000 2>/dev/null
429 error "pool_remove did not fail even though pool name was invalid."
431 run_test 3c "pool_remove: Invalid pool name"
433 # Testing various combinations of OST name list
435 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
439 create_pool_nofail $POOL
440 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
441 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
443 error "pool_remove failed. $FSNAME $POOL OST0000"
446 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
447 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
449 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000"
452 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
453 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
455 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000_UUID"
458 add_pool $POOL $TGT_ALL "$TGT_UUID"
459 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
461 error "pool_remove failed. $FSNAME $POOL" $TGT_ALL
466 run_test 3d "pool_remove: OST index combinations ==========================="
469 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
473 do_facet $SINGLEMDS lctl pool_destroy $FSNAME.$POOL 2>/dev/null
475 error "pool_destroy did not fail even though pool did not exist."
477 run_test 4a "pool_destroy: non-existant pool"
480 do_facet $SINGLEMDS lctl pool_destroy ${NON_EXISTANT_FS}.$POOL 2>/dev/null
482 error "pool_destroy did not fail even though the filesystem did not exist."
484 run_test 4b "pool_destroy: non-existant fs-name"
487 create_pool_nofail $POOL
488 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
490 do_facet $SINGLEMDS lctl pool_destroy ${FSNAME}.$POOL
492 error "pool_destroy succeeded with a non-empty pool."
495 run_test 4c "pool_destroy: non-empty pool ==============================="
500 $LCMD pool_list 2>/dev/null
502 error "pool_list did not fail even though fsname was not mentioned."
504 destroy_pool $POOL 2>/dev/null
505 destroy_pool $POOL2 2>/dev/null
507 create_pool_nofail $POOL
508 create_pool_nofail $POOL2
509 $LCMD pool_list $FSNAME
511 error "pool_list $FSNAME failed."
513 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
515 $LCMD pool_list $FSNAME.$POOL
517 error "pool_list $FSNAME.$POOL failed."
519 $LCMD pool_list ${NON_EXISTANT_FS} 2>/dev/null
521 error "pool_list did not fail for a non-existant fsname $NON_EXISTANT_FS"
523 $LCMD pool_list ${FSNAME}.$NON_EXISTANT_POOL 2>/dev/null
525 error "pool_list did not fail for a non-existant pool $NON_EXISTANT_POOL"
527 if [[ ! $(grep $SINGLEMDS <<< $LCMD) ]]; then
528 echo $LCMD pool_list $DIR
531 error "pool_list failed for $DIR"
534 $LCMD pool_list ${DIR}/d1
536 error "pool_list failed for ${DIR}/d1"
539 rm -rf ${DIR}nonexistant
540 $LCMD pool_list ${DIR}nonexistant 2>/dev/null
542 error "pool_list did not fail for invalid mountpoint ${DIR}nonexistant"
549 # Issue commands from client
553 # Issue commands from MDS
554 sub_test_5 "do_facet $SINGLEMDS lctl"
555 sub_test_5 "do_facet $SINGLEMDS lfs"
558 run_test 5 "lfs/lctl pool_list"
561 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
562 local POOL_DIR=$POOL_ROOT/dir_tst
563 local POOL_FILE=$POOL_ROOT/file_tst
565 create_pool_nofail $POOL
567 do_facet $SINGLEMDS lctl pool_list $FSNAME
569 error "pool_list $FSNAME failed."
571 add_pool $POOL $TGT_ALL "$TGT_UUID"
574 $SETSTRIPE -c -1 -p $POOL $POOL_DIR
576 error "$SETSTRIPE -p $POOL failed."
577 check_dir_in_pool $POOL_DIR $POOL
579 # If an invalid pool name is specified, the command should fail
580 $SETSTRIPE -c 2 -p $INVALID_POOL $POOL_DIR 2>/dev/null
582 error "setstripe to invalid pool did not fail."
584 # If the pool name does not exist, the command should fail
585 $SETSTRIPE -c 2 -p $NON_EXISTANT_POOL $POOL_DIR 2>/dev/null
587 error "setstripe to non-existant pool did not fail."
589 # lfs setstripe should work as before if a pool name is not specified.
590 $SETSTRIPE -c -1 $POOL_DIR
592 error "$SETSTRIPE -p $POOL_DIR failed."
593 $SETSTRIPE -c -1 $POOL_FILE
595 error "$SETSTRIPE -p $POOL_FILE failed."
597 # lfs setstripe should fail if a start index that is outside the
599 create_pool_nofail $POOL2
600 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
601 $SETSTRIPE -o 1 -p $POOL2 $ROOT_POOL/$tfile 2>/dev/null
603 error "$SETSTRIPE with start index outside the pool did not fail."
608 run_test 6 "getstripe/setstripe"
611 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
613 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
615 create_pool_nofail $POOL
616 create_pool_nofail $POOL2
618 local start=$((TGT_FIRST+1))
619 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
620 $FSNAME-OST[$start-$TGT_MAX/2]
622 add_pool $POOL $TGT_HALF "$TGT_UUID2"
624 create_dir $POOL_ROOT/dir1 $POOL
625 create_dir $POOL_ROOT/dir2 $POOL2
626 check_dir_in_pool $POOL_ROOT/dir1 $POOL
627 check_dir_in_pool $POOL_ROOT/dir1 $POOL
630 createmany -o $POOL_ROOT/dir1/$tfile $numfiles || \
631 error "createmany $POOL_ROOT/dir1/$tfile failed!"
633 for file in $POOL_ROOT/dir1/*; do
634 check_file_in_pool $file $POOL
637 createmany -o $POOL_ROOT/dir2/$tfile $numfiles || \
638 error "createmany $POOL_ROOT/dir2/$tfile failed!"
639 for file in $POOL_ROOT/dir2/*; do
640 check_file_in_pool $file $POOL2
643 rm -rf $POOL_ROOT/dir?
650 run_test 11 "OSTs in overlapping/multiple pools"
653 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
655 [[ $OSTCOUNT -le 2 ]] && skip_env "Need atleast 3 OSTs" && return
657 create_pool_nofail $POOL
658 create_pool_nofail $POOL2
660 local start=$((TGT_FIRST+1))
661 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
662 $FSNAME-OST[$start-$TGT_MAX/2]
664 add_pool $POOL $TGT_HALF "$TGT_UUID2"
666 echo creating some files in $POOL and $POOL2
668 create_dir $POOL_ROOT/dir1 $POOL
669 create_dir $POOL_ROOT/dir2 $POOL2
670 create_file $POOL_ROOT/file1 $POOL
671 create_file $POOL_ROOT/file2 $POOL2
673 echo Checking the files created
674 check_dir_in_pool $POOL_ROOT/dir1 $POOL
675 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
676 check_file_in_pool $POOL_ROOT/file1 $POOL
677 check_file_in_pool $POOL_ROOT/file2 $POOL2
679 echo Changing the pool membership
680 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST[$TGT_FIRST]
681 do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL
682 FIRST_UUID=$(echo $TGT_UUID | awk '{print $1}')
683 add_pool $POOL2 $FSNAME-OST[$TGT_FIRST] "$FIRST_UUID "
684 do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL2
686 echo Checking the files again
687 check_dir_in_pool $POOL_ROOT/dir1 $POOL
688 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
689 check_file_in_osts $POOL_ROOT/file1 "$TGT_LIST2"
690 check_file_in_osts $POOL_ROOT/file2 "$(seq $start 2 $TGT_MAX)"
692 echo Creating some more files
693 create_dir $POOL_ROOT/dir3 $POOL
694 create_dir $POOL_ROOT/dir4 $POOL2
695 create_file $POOL_ROOT/file3 $POOL
696 create_file $POOL_ROOT/file4 $POOL2
698 echo Checking the new files
699 check_file_in_pool $POOL_ROOT/file3 $POOL
700 check_file_in_pool $POOL_ROOT/file4 $POOL2
707 run_test 12 "OST Pool Membership"
710 [[ $OSTCOUNT -le 2 ]] && skip_env "Need atleast 3 OSTs" && return
712 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
716 create_pool_nofail $POOL
717 add_pool $POOL $TGT_ALL "$TGT_UUID"
719 create_dir $POOL_ROOT/dir1 $POOL -1
720 createmany -o $POOL_ROOT/dir1/$tfile $numfiles || \
721 error "createmany $POOL_ROOT/dir1/$tfile failed!"
722 for file in $POOL_ROOT/dir1/*; do
723 check_file_in_pool $file $POOL $OSTCOUNT
726 create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
727 create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST+1))
728 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST+2))
729 check_file_in_pool $POOL_ROOT/dir1/file1 $POOL 1
730 check_file_in_pool $POOL_ROOT/dir1/file2 $POOL 1
731 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST+2))
732 check_file_in_osts $POOL_ROOT/dir1/file1 "$TGT_FIRST"
733 check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST+1))"
734 check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST+2))"
736 create_dir $POOL_ROOT/dir2 $POOL $count
737 createmany -o $POOL_ROOT/dir2/$tfile $numfiles || \
738 error "createmany $POOL_ROOT/dir2/$tfile failed!"
739 for file in $POOL_ROOT/dir2/*; do
740 check_file_in_pool $file $POOL $count
743 create_dir $POOL_ROOT/dir3 $POOL $count $((TGT_FIRST+1))
744 createmany -o $POOL_ROOT/dir3/$tfile_ $numfiles || \
745 error "createmany $POOL_ROOT/dir3/$tfile_ failed!"
746 for file in $POOL_ROOT/dir3/*; do
747 check_file_in_pool $file $POOL $count
750 create_dir $POOL_ROOT/dir4 $POOL 1
751 createmany -o $POOL_ROOT/dir4/$tfile_ $numfiles || \
752 error "createmany $POOL_ROOT/dir4/$tfile_ failed!"
753 for file in $POOL_ROOT/dir4/*; do
754 check_file_in_pool $file $POOL 1
757 create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST+2))
758 createmany -o $POOL_ROOT/dir5/$tfile_ $numfiles || \
759 error "createmany $POOL_ROOT/dir5/$tfile_ failed!"
760 for file in $POOL_ROOT/dir5/*; do
761 check_file_in_pool $file $POOL 1
762 check_file_in_osts $file "$((TGT_FIRST+2))"
765 rm -rf create_dir $POOL_ROOT/dir?
770 run_test 13 "Striping characteristics in a pool"
773 [[ $OSTCOUNT -le 2 ]] && skip_env "Need atleast 3 OSTs" && return
775 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
779 # Create a new filesystem that is guaranteed to be balanced.
783 create_pool_nofail $POOL
784 create_pool_nofail $POOL2
786 add_pool $POOL $TGT_HALF "$TGT_UUID2"
787 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
789 create_dir $POOL_ROOT/dir1 $POOL 1
790 create_file $POOL_ROOT/dir1/file $POOL 1
791 local OST=$($GETSTRIPE $POOL_ROOT/dir1/file | grep 0x | cut -f2)
793 while [[ $i -lt $numfiles ]];
796 [[ $OST -gt $TGT_MAX ]] && OST=$TGT_FIRST
798 # echo "Iteration: $i OST: $OST"
799 create_file $POOL_ROOT/dir1/file${i} $POOL 1
800 check_file_in_pool $POOL_ROOT/dir1/file${i} $POOL
804 # Fill up OST0 until it is nearly full.
805 # Create 9 files of size OST0_SIZE/10 each.
806 create_dir $POOL_ROOT/dir2 $POOL2 1
807 $LFS df $POOL_ROOT/dir2
808 echo "Filling up OST0"
809 OST0_SIZE=`$LFS df $POOL_ROOT/dir2 | awk '/\[OST:0\]/ {print $4}'`
810 FILE_SIZE=$((OST0_SIZE/1024/10))
812 while [[ $i -lt 10 ]];
814 dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1M count=$FILE_SIZE
817 $LFS df $POOL_ROOT/dir2
819 # OST $TGT_FIRST is no longer favored; but it may still be used.
820 create_dir $POOL_ROOT/dir3 $POOL 1
821 create_file $POOL_ROOT/dir3/file $POOL 1
822 createmany -o $POOL_ROOT/dir3/$tfile_ $numfiles || \
823 error "createmany $POOL_ROOT/dir3/$tfile_ failed!"
824 for file in $POOL_ROOT/dir3/*; do
825 check_file_in_pool $file $POOL
833 run_test 14 "Round robin and QOS striping within a pool"
836 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
840 while [[ $i -lt $OSTCOUNT ]]
842 create_pool_nofail pool${i}
844 local tgt=$(printf "$FSNAME-OST%04x_UUID " $i)
845 add_pool pool${i} "$FSNAME-OST[$i]" "$tgt"
846 create_dir $POOL_ROOT/dir${i} pool${i}
847 createmany -o $POOL_ROOT/dir$i/$tfile $numfiles || \
848 error "createmany $POOL_ROOT/dir$i/$tfile failed!"
850 for file in $POOL_ROOT/dir$i/*; do
851 check_file_in_osts $file $i
858 while [[ $i -lt $OSTCOUNT ]]
860 destroy_pool pool${i}
866 run_test 15 "One directory per OST/pool"
869 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
873 create_pool_nofail $POOL
875 add_pool $POOL $TGT_HALF "$TGT_UUID2"
877 local dir=$POOL_ROOT/$tdir
878 create_dir $dir $POOL
880 for i in $(seq 1 10); do
885 createmany -o $dir/$tfile $numfiles || \
886 error "createmany $dir/$tfile failed!"
888 for file in $dir/*; do
889 check_file_in_pool $file $POOL
892 rm -rf $POOL_ROOT/$tdir
898 run_test 16 "Inheritance of pool properties"
901 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
905 create_pool_nofail $POOL
907 add_pool $POOL $TGT_ALL "$TGT_UUID"
909 local dir=$POOL_ROOT/dir
910 create_dir $dir $POOL
912 createmany -o $dir/${tfile}1_ $numfiles || \
913 error "createmany $dir/${tfile}1_ failed!"
915 for file in $dir/*; do
916 check_file_in_pool $file $POOL
921 createmany -o $dir/${tfile}2_ $numfiles || \
922 error "createmany $dir/${tfile}2_ failed!"
927 run_test 17 "Referencing an empty pool"
935 sync; sleep 5 # give pending IO a chance to go to disk
936 stat=$(createmany -o $cdir/${tfile} $numfiles | tail -1)
939 time=$(echo $stat | cut -f 5 -d ' ')
940 echo $stat >> /dev/stderr
945 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
947 local plaindir=$POOL_ROOT/plaindir
948 local pooldir=$POOL_ROOT/pooldir
956 echo "Create performance, iteration $i, $numfiles files x 3"
958 time1=$(create_perf $plaindir $numfiles)
959 echo "iter $i: $numfiles creates without pool: $time1"
960 t1=$(echo "scale=2; $t1 + $time1" | bc)
962 create_pool_nofail $POOL > /dev/null
963 add_pool $POOL $TGT_ALL "$TGT_UUID" > /dev/null
964 create_dir $pooldir $POOL
965 time2=$(create_perf $pooldir $numfiles)
966 echo "iter $i: $numfiles creates with pool: $time2"
967 t2=$(echo "scale=2; $t2 + $time2" | bc)
969 destroy_pool $POOL > /dev/null
970 time3=$(create_perf $pooldir $numfiles)
971 echo "iter $i: $numfiles creates with missing pool: $time3"
972 t3=$(echo "scale=2; $t3 + $time3" | bc)
977 time1=$(echo "scale=2; $t1 / $i" | bc)
978 echo Avg time taken for $numfiles creates without pool: $time1
979 time2=$(echo "scale=2; $t2 / $i" | bc)
980 echo Avg time taken for $numfiles creates with pool: $time2
981 time3=$(echo "scale=2; $t3 / $i" | bc)
982 echo Avg time taken for $numfiles creates with missing pool: $time3
984 # Set this high until we establish a baseline for what the degradation
987 diff=$(echo "scale=2; ($time2 - $time1) * 100 / $time1" | bc)
988 echo "No pool to wide pool: $diff %."
989 deg=$(echo "scale=2; $diff > $max" | bc)
990 [ "$deg" == "1" ] && error_ignore 23408 "Degradation with wide pool is $diff % (> $max %)"
993 diff=$(echo "scale=2; ($time3 - $time1) * 100 / $time1" | bc)
994 echo "No pool to missing pool: $diff %."
995 deg=$(echo "scale=2; $diff > $max" | bc)
996 [ "$deg" == "1" ] && error_ignore 23408 "Degradation with missing pool is $diff % (> $max %)"
1000 run_test 18 "File create in a directory which references a deleted pool"
1003 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1005 local dir1=$POOL_ROOT/dir1
1006 local dir2=$POOL_ROOT/dir2
1009 create_pool_nofail $POOL
1011 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1013 create_dir $dir1 $POOL
1014 createmany -o $dir1/${tfile} $numfiles || \
1015 error "createmany $dir1/${tfile} failed!"
1016 for file in $dir1/*; do
1017 check_file_in_pool $file $POOL
1021 createmany -o $dir2/${tfile} $numfiles || \
1022 error "createmany $dir2/${tfile} failed!"
1023 for file in $dir2/*; do
1024 check_file_not_in_pool $file $POOL
1032 run_test 19 "Pools should not come into play when not specified"
1035 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1037 local dir1=$POOL_ROOT/dir1
1038 local dir2=$dir1/dir2
1039 local dir3=$dir1/dir3
1043 create_pool_nofail $POOL
1044 create_pool_nofail $POOL2
1046 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1048 local start=$((TGT_FIRST+1))
1049 TGT=$(for i in `seq $start 2 $TGT_MAX`; \
1050 do printf "$FSNAME-OST%04x_UUID " $i; done)
1051 add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1053 create_dir $dir1 $POOL
1054 create_file $dir1/file1 $POOL2
1055 create_dir $dir2 $POOL2
1058 $SETSTRIPE -c 1 $dir3 # No pool assignment
1060 $SETSTRIPE -c 1 $dir2/file4 # No pool assignment
1062 check_file_in_pool $dir1/file1 $POOL2
1063 check_file_in_pool $dir2/file2 $POOL2
1065 check_dir_not_in_pool $dir3 $POOL
1066 check_dir_not_in_pool $dir3 $POOL2
1068 check_file_not_in_pool $dir3/file3 $POOL
1069 check_file_not_in_pool $dir3/file3 $POOL2
1071 check_file_not_in_pool $dir2/file4 $POOL
1072 check_file_not_in_pool $dir2/file4 $POOL2
1080 run_test 20 "Different pools in a directory hierarchy."
1083 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1084 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
1088 local dir=$POOL_ROOT/dir
1090 create_pool_nofail $POOL
1092 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1094 create_dir $dir $POOL $OSTCOUNT
1095 create_file $dir/file1 $POOL $OSTCOUNT
1096 $GETSTRIPE -v $dir/file1
1097 check_file_in_pool $dir/file1 $POOL
1104 run_test 21 "OST pool with fewer OSTs than stripe count"
1112 for c in $(seq 1 10);
1114 echo "Pool $pool, iteration $c"
1115 do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool OST[$TGT_FIRST-$TGT_MAX/$step] 2>/dev/null
1116 local TGT_SECOND=$(($TGT_FIRST+$step))
1117 if [ "$TGT_SECOND" -le "$TGT_MAX" ]; then
1118 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$pool OST[$TGT_SECOND-$TGT_MAX/$step]
1121 echo loop for $pool complete
1125 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1126 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1130 create_pool_nofail $POOL
1131 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
1132 create_pool_nofail $POOL2
1133 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
1138 create_dir $POOL_ROOT $POOL
1139 createmany -o $POOL_ROOT/${tfile} $numfiles || \
1140 error "createmany $POOL_ROOT/${tfile} failed!"
1148 run_test 22 "Simultaneous manipulation of a pool"
1151 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1152 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
1155 check_runas_id $TSTID $TSTID $RUNAS || {
1156 skip_env "User $RUNAS_ID does not exist - skipping"
1163 local BUNIT_SZ=1024 # min block quota unit(kB)
1164 local LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
1165 local OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
1167 local dir=$POOL_ROOT/dir
1168 local file="$dir/$tfile-quota"
1170 create_pool_nofail $POOL
1172 local TGT=$(for i in `seq $TGT_FIRST 3 $TGT_MAX`; \
1173 do printf "$FSNAME-OST%04x_UUID " $i; done)
1174 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1175 create_dir $dir $POOL
1177 $LFS quotaoff -ug $MOUNT
1178 $LFS quotacheck -ug $MOUNT
1179 LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1)))
1180 $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir
1182 $LFS quota -v -u $TSTUSR $dir
1184 $LFS setstripe $file -c 1 -p $POOL
1185 chown $TSTUSR.$TSTUSR $file
1189 LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BLK_SZ count=$((BUNIT_SZ*2)) || true
1190 $LFS quota -v -u $TSTUSR $dir
1191 cancel_lru_locks osc
1192 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ*2)) 2>&1)
1195 [[ $RC -eq 0 ]] && error "dd did not fail with EDQUOT."
1196 echo $stat | grep "Disk quota exceeded" > /dev/null
1197 [[ $? -eq 1 ]] && error "dd did not fail with EDQUOT."
1198 $LFS quota -v -u $TSTUSR $dir
1201 $LFS quotaoff -ug $MOUNT
1202 # $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir
1203 chown $TSTUSR.$TSTUSR $dir
1206 while [ $RC -eq 0 ];
1209 stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file}$i bs=1M \
1210 count=$((LIMIT*LIMIT)) 2>&1)
1212 if [ $RC -eq 1 ]; then
1214 echo $stat | grep "Disk quota exceeded"
1215 [[ $? -eq 0 ]] && error "dd failed with EDQUOT"
1217 echo $stat | grep "No space left on device"
1218 [[ $? -ne 0 ]] && error "dd did not fail with ENOSPC; " \
1230 run_test 23 "OST pools and quota"
1233 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1234 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
1243 create_pool_nofail $POOL
1245 add_pool $POOL $TGT_ALL "$TGT_UUID"
1247 create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1249 mkdir $POOL_ROOT/dir2
1250 $SETSTRIPE $POOL_ROOT/dir2 -p $POOL -s 65536 -i 0 -c 1 || \
1251 error "$SETSTRIPE $POOL_ROOT/dir2 failed"
1253 mkdir $POOL_ROOT/dir3
1254 $SETSTRIPE $POOL_ROOT/dir3 -s 65536 -i 0 -c 1 || \
1255 error "$SETSTRIPE $POOL_ROOT/dir3 failed"
1257 mkdir $POOL_ROOT/dir4
1259 for i in $(seq 1 4);
1261 dir=${POOL_ROOT}/dir${i}
1270 createmany -o $dir/${tfile} $numfiles || \
1271 error "createmany $dir/${tfile} failed!"
1272 res=$($GETSTRIPE -v $dir | grep "^stripe_count:")
1273 if [ $? -ne 0 ]; then
1274 res=$($GETSTRIPE -v $dir | grep "^(Default) ")
1275 pool=$(cut -f 9 -d ' ' <<< $res)
1276 index=$(cut -f 7 -d ' ' <<< $res)
1277 size=$(cut -f 5 -d ' ' <<< $res)
1278 count=$(cut -f 3 -d ' ' <<< $res)
1280 pool=$(cut -f 8 -d ' ' <<< $res)
1281 index=$(cut -f 6 -d ' ' <<< $res)
1282 size=$(cut -f 4 -d ' ' <<< $res)
1283 count=$(cut -f 2 -d ' ' <<< $res)
1286 for file in $dir/*; do
1287 if [ "$pool" != "" ]; then
1288 check_file_in_pool $file $pool
1290 pool1=$($GETSTRIPE -v $file | grep "^pool:" |\
1291 tr -d '[:blank:]' | cut -f 2 -d ':')
1292 count1=$($GETSTRIPE -v $file | grep "^lmm_stripe_count:" |\
1293 tr -d '[:blank:]' | cut -f 2 -d ':')
1294 size1=$($GETSTRIPE -v $file | grep "^lmm_stripe_size:" |\
1295 tr -d '[:blank:]' | cut -f 2 -d ':')
1296 [[ "$pool" != "$pool1" ]] && \
1297 error "Pool name ($pool) not inherited in $file($pool1)"
1298 [[ "$count" != "$count1" ]] && \
1299 error "Stripe count ($count) not inherited in $file ($count1)"
1300 [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] && \
1301 error "Stripe size ($size) not inherited in $file ($size1)"
1310 run_test 24 "Independence of pool from other setstripe parameters"
1313 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1317 for i in $(seq 10); do
1318 create_pool_nofail pool$i
1319 do_facet $SINGLEMDS "lctl pool_add $FSNAME.pool$i OST0000; sync"
1320 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.pool$i | \
1321 sort -u | tr '\n' ' ' " "$FSNAME-OST0000_UUID " || \
1322 error "pool_add failed: $1; $2"
1324 stop $SINGLEMDS || return 1
1325 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS || \
1326 { error "Failed to start $SINGLEMDS after stopping" && break; }
1327 wait_osc_import_state mds ost FULL
1330 # Verify that the pool got created and is usable
1331 df $POOL_ROOT > /dev/null
1333 # Make sure OST0 can be striped on
1334 $SETSTRIPE -o 0 -c 1 $POOL_ROOT/$tfile
1335 STR=$($GETSTRIPE $POOL_ROOT/$tfile | grep 0x | cut -f2 | tr -d " ")
1336 rm $POOL_ROOT/$tfile
1337 if [[ "$STR" == "0" ]]; then
1338 echo "Creating a file in pool$i"
1339 create_file $POOL_ROOT/file$i pool$i || break
1340 check_file_in_pool $POOL_ROOT/file$i pool$i || break
1342 echo "OST 0 seems to be unavailable. Try later."
1347 for i in $(seq 10); do
1351 run_test 25 "Create new pool and restart MDS ======================="
1353 log "cleanup: ======================================================"
1355 cleanup_pools $FSNAME
1356 check_and_cleanup_lustre
1357 echo '=========================== finished ==============================='
1358 [ -f "$POOLSLOG" ] && cat $POOLSLOG && grep -q FAIL $POOLSLOG && exit 1 || true
1359 echo "$0: completed"