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}
30 check_and_setup_lustre
35 POOLSLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
36 [ "$POOLSLOG" ] && rm -f $POOLSLOG || true
39 FAIL_ON_ERROR=${FAIL_ON_ERROR:-true}
43 SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
44 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_osts $POOL_ROOT/dir1/file${i} $OST
804 # Fill OST $TGT_FIRST with 10M files
805 create_dir $POOL_ROOT/dir2 $POOL2 1
808 while [[ $RC -eq 0 ]];
810 dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1k count=$((1024*10))
815 # Leave some space on the OST
816 rm -f $POOL_ROOT/dir2/f0
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 $dir/${tfile} $numfiles)
939 time=$(echo $stat | cut -f 5 -d ' ')
940 echo $stat > /dev/stderr
945 local t1=$(create_perf_one $1 $2)
946 local t2=$(create_perf_one $1 $2)
947 local t3=$(create_perf_one $1 $2)
948 local time=$(echo "scale=2; ( $t1 + $t2 + $t3 ) / 3" | bc)
954 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
960 local dir=$POOL_ROOT/dir
964 time1=$(create_perf $dir $numfiles)
966 create_pool_nofail $POOL
968 add_pool $POOL $TGT_ALL "$TGT_UUID"
970 create_dir $dir $POOL
971 time2=$(create_perf $dir $numfiles)
975 time3=$(create_perf $dir $numfiles)
977 echo Time taken for $numfiles creates without pools: $time1
978 echo Time taken for $numfiles creates with pools: $time2
979 echo Time taken for $numfiles creates without pools: $time3
981 deg=$(echo "scale=2; (($time2 - $time3) * 100 / $time3) > 5" | bc)
982 diff=$(echo "scale=2; ($time2 - $time3) * 100 / $time3" | bc)
984 if [[ "$deg" == "1" ]]; then
985 error "Performance degradation with pools is $diff %."
987 echo "Performance degradation with pools is $diff %."
991 run_test 18 "File create in a directory which references a deleted pool"
995 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
997 local dir1=$POOL_ROOT/dir1
998 local dir2=$POOL_ROOT/dir2
1001 create_pool_nofail $POOL
1003 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1005 create_dir $dir1 $POOL
1006 createmany -o $dir1/${tfile} $numfiles || \
1007 error "createmany $dir1/${tfile} failed!"
1008 for file in $dir1/*; do
1009 check_file_in_pool $file $POOL
1013 createmany -o $dir2/${tfile} $numfiles || \
1014 error "createmany $dir2/${tfile} failed!"
1015 for file in $dir2/*; do
1016 check_file_not_in_pool $file $POOL
1024 run_test 19 "Pools should not come into play when not specified"
1027 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1029 local dir1=$POOL_ROOT/dir1
1030 local dir2=$dir1/dir2
1031 local dir3=$dir1/dir3
1035 create_pool_nofail $POOL
1036 create_pool_nofail $POOL2
1038 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1040 local start=$((TGT_FIRST+1))
1041 TGT=$(for i in `seq $start 2 $TGT_MAX`; \
1042 do printf "$FSNAME-OST%04x_UUID " $i; done)
1043 add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1045 create_dir $dir1 $POOL
1046 create_file $dir1/file1 $POOL2
1047 create_dir $dir2 $POOL2
1050 $SETSTRIPE -c 1 $dir3 # No pool assignment
1052 $SETSTRIPE -c 1 $dir2/file4 # No pool assignment
1054 check_file_in_pool $dir1/file1 $POOL2
1055 check_file_in_pool $dir2/file2 $POOL2
1057 check_dir_not_in_pool $dir3 $POOL
1058 check_dir_not_in_pool $dir3 $POOL2
1060 check_file_not_in_pool $dir3/file3 $POOL
1061 check_file_not_in_pool $dir3/file3 $POOL2
1063 check_file_not_in_pool $dir2/file4 $POOL
1064 check_file_not_in_pool $dir2/file4 $POOL2
1072 run_test 20 "Different pools in a directory hierarchy."
1075 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1076 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
1080 local dir=$POOL_ROOT/dir
1082 create_pool_nofail $POOL
1084 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1086 create_dir $dir $POOL $OSTCOUNT
1087 create_file $dir/file1 $POOL $OSTCOUNT
1088 $GETSTRIPE -v $dir/file1
1089 check_file_in_pool $dir/file1 $POOL
1096 run_test 21 "OST pool with fewer OSTs than stripe count"
1104 for c in $(seq 1 10);
1106 echo "Pool $pool, iteration $c"
1107 do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool OST[$TGT_FIRST-$TGT_MAX/$step] 2>/dev/null
1108 local TGT_SECOND=$(($TGT_FIRST+$step))
1109 if [ "$TGT_SECOND" -le "$TGT_MAX" ]; then
1110 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$pool OST[$TGT_SECOND-$TGT_MAX/$step]
1113 echo loop for $pool complete
1117 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1118 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1122 create_pool_nofail $POOL
1123 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
1124 create_pool_nofail $POOL2
1125 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
1130 create_dir $POOL_ROOT $POOL
1131 createmany -o $POOL_ROOT/${tfile} $numfiles || \
1132 error "createmany $POOL_ROOT/${tfile} failed!"
1140 run_test 22 "Simultaneous manipulation of a pool"
1143 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1144 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
1147 check_runas_id $TSTID $TSTID $RUNAS || {
1148 skip_env "User $RUNAS_ID does not exist - skipping"
1155 local BUNIT_SZ=1024 # min block quota unit(kB)
1156 local LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
1157 local OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
1159 local dir=$POOL_ROOT/dir
1160 local file="$dir/$tfile-quota"
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 LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1)))
1172 $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir
1174 $LFS quota -v -u $TSTUSR $dir
1176 $LFS setstripe $file -c 1 -p $POOL
1177 chown $TSTUSR.$TSTUSR $file
1181 LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BLK_SZ count=$((BUNIT_SZ*2)) || true
1182 $LFS quota -v -u $TSTUSR $dir
1183 cancel_lru_locks osc
1184 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ*2)) 2>&1)
1187 [[ $RC -eq 0 ]] && error "dd did not fail with EDQUOT."
1188 echo $stat | grep "Disk quota exceeded" > /dev/null
1189 [[ $? -eq 1 ]] && error "dd did not fail with EDQUOT."
1190 $LFS quota -v -u $TSTUSR $dir
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=${file}$i bs=1M \
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_env "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: ======================================================"
1333 cleanup_pools $FSNAME
1334 check_and_cleanup_lustre
1335 echo '=========================== finished ==============================='
1336 [ -f "$POOLSLOG" ] && cat $POOLSLOG && grep -q FAIL $POOLSLOG && exit 1 || true
1337 echo "$0: completed"