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"
192 OSTS=$(do_facet $SINGLEMDS lctl pool_list $1 | \
193 awk '$1 !~ /^Pool:/ {print $1}')
196 do_facet $SINGLEMDS lctl pool_remove $1 $ost
198 do_facet $SINGLEMDS lctl pool_destroy $1
204 do_facet $SINGLEMDS lctl pool_list $FSNAME.$1
206 [[ $RC -ne 0 ]] && return $RC
208 destroy_pool_int $FSNAME.$1
210 [[ $RC -ne 0 ]] && return $RC
212 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$1 \
213 2>/dev/null || echo foo" "foo" && return 0
219 local tgt="${3}$(lctl get_param -n lov.$FSNAME-*.pools.$pool | \
220 sort -u | tr '\n' ' ')"
222 do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool $osts
224 [[ $RC -ne 0 ]] && return $RC
226 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool | \
227 sort -u | tr '\n' ' ' " "$tgt" || RC=1
228 [[ $RC -ne 0 ]] && error "pool_add failed: $1; $2"
232 create_pool_nofail() {
236 error "Pool creation of $1 failed"
244 error "Pool creation of $1 succeeded; should have failed"
249 # Destroy pools from previous test runs
250 for p in $(do_facet $SINGLEMDS lctl pool_list $FSNAME | \
251 grep $FSNAME.pool[0-$OSTCOUNT]); do
254 rm -rf $DIR/d0.${TESTSUITE}
263 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
264 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
267 # Tests for new commands added
270 echo "Creating a pool with a 1 character pool name"
273 echo "Creating a pool with a 10 character pool name"
274 create_pool_nofail p123456789
275 destroy_pool p123456789
277 echo "Creating a pool with a 16 character pool name"
278 create_pool_nofail p123456789123456
279 destroy_pool p123456789123456
281 echo "Creating a pool with a 17 character pool name; should fail"
282 create_pool_fail p1234567891234567
284 echo "Creating a pool with a 1000 character pool name; should fail"
286 for i in `seq 1 999`; do NAME=${NAME}"o"; done
287 create_pool_fail $NAME
289 echo "pool_new should fail if fs-name or poolname are missing."
290 do_facet $SINGLEMDS lctl pool_new .pool1
292 error "pool_new did not fail even though fs-name was missing."
293 do_facet $SINGLEMDS lctl pool_new pool1
295 error "pool_new did not fail even though fs-name was missing."
296 do_facet $SINGLEMDS lctl pool_new ${FSNAME}.
298 error "pool_new did not fail even though pool name was missing."
299 do_facet $SINGLEMDS lctl pool_new .
301 error "pool_new did not fail even though pool name and fs-name " \
303 do_facet $SINGLEMDS lctl pool_new ${FSNAME},pool1
305 error "pool_new did not fail even though pool name format was wrong"
306 do_facet $SINGLEMDS lctl pool_new ${FSNAME}/pool1
308 error "pool_new did not fail even though pool name format was wrong"
310 do_facet $SINGLEMDS lctl pool_new ${FSNAME}.p
312 error "pool_new did not fail even though pool1 existed"
316 run_test 1 "Test lctl pool_new ========================================="
321 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
323 error " pool_add did not fail even though pool did " \
326 run_test 2a "pool_add: non-existant pool"
329 do_facet $SINGLEMDS lctl pool_add $FSNAME.p1234567891234567890 \
332 error "pool_add did not fail even though pool name was invalid."
334 run_test 2b "pool_add: Invalid pool name"
336 # Testing various combinations of OST name list
341 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
345 create_pool_nofail $POOL
348 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
349 RC=$?; [[ $RC -eq 0 ]] || \
350 error "pool_add failed. $FSNAME $POOL OST0000: $RC"
351 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
355 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
356 RC=$?; [[ $RC -eq 0 ]] || \
357 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000: $RC"
358 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
361 # 3. lustre-OST0000_UUID
362 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
363 RC=$?; [[ $RC -eq 0 ]] || \
364 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000_UUID: $RC"
365 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
368 # 4. lustre-OST[0,1,2,3,]
370 for i in $TGT_LIST; do TGT=${TGT}$(printf "$i," $i); done
372 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
374 error "pool_add failed. $FSNAME.$POOL $TGT. $RC"
375 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT
378 # 5. lustre-OST[0-5/1]
379 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
380 RC=$?; [[ $RC -eq 0 ]] || \
381 error "pool_add failed. $FSNAME $POOL" "$TGT_ALL $RC"
382 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
383 sort -u | tr '\n' ' ' " "$TGT_UUID" || error "Add to pool failed"
384 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
389 run_test 2c "pool_add: OST index combinations ==========================="
395 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
399 create_pool_nofail $POOL
401 TGT=$(printf "$FSNAME-OST%04x_UUID " $OSTCOUNT)
402 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
403 RC=$?; [[ $RC -ne 0 ]] || \
404 error "pool_add succeeded for an OST ($TGT) that does not exist."
408 run_test 2d "pool_add: OSTs that don't exist should be rejected ========"
415 $LCTL get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
419 create_pool_nofail $POOL
421 TGT="$FSNAME-OST0000_UUID "
422 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
423 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
424 sort -u | tr '\n' ' ' " "$TGT" || error "Add to pool failed"
425 RESULT=$(do_facet $SINGLEMDS \
426 "LOCALE=C $LCTL pool_add $FSNAME.$POOL $TGT 2>&1")
431 error "pool_add succeeded for an OST that was already in the pool."
433 [[ $(grep "already in pool" <<< $RESULT) ]] || \
434 error "pool_add failed as expected but error message not as expected."
438 run_test 2e "pool_add: OST already in a pool should be rejected ========"
441 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
445 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
447 error "pool_remove did not fail even though" \
448 "pool did not exist."
450 run_test 3a "pool_remove: non-existant pool"
453 do_facet $SINGLEMDS lctl pool_remove ${NON_EXISTANT_FS}.$POOL OST0000
455 error "pool_remove did not fail even though fsname did not exist."
457 run_test 3b "pool_remove: non-existant fsname"
460 do_facet $SINGLEMDS lctl pool_remove $FSNAME.p1234567891234567890 \
463 error "pool_remove did not fail even though pool name was invalid."
465 run_test 3c "pool_remove: Invalid pool name"
468 # Testing various combinations of OST name list
470 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
474 create_pool_nofail $POOL
475 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
476 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
478 error "pool_remove failed. $FSNAME $POOL OST0000"
481 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
482 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
484 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000"
487 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
488 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
490 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000_UUID"
493 add_pool $POOL $TGT_ALL "$TGT_UUID"
494 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
496 error "pool_remove failed. $FSNAME $POOL" $TGT_ALL
501 run_test 3d "pool_remove: OST index combinations ==========================="
504 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
508 do_facet $SINGLEMDS lctl pool_destroy $FSNAME.$POOL
510 error "pool_destroy did not fail even though pool did not exist."
512 run_test 4a "pool_destroy: non-existant pool"
515 do_facet $SINGLEMDS lctl pool_destroy ${NON_EXISTANT_FS}.$POOL
517 error "pool_destroy did not fail even though the filesystem did not exist."
519 run_test 4b "pool_destroy: non-existant fs-name"
522 create_pool_nofail $POOL
523 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
525 do_facet $SINGLEMDS lctl pool_destroy ${FSNAME}.$POOL
527 error "pool_destroy succeeded with a non-empty pool name."
530 run_test 4c "pool_destroy: non-empty pool ==============================="
537 error "pool_list did not fail even though fsname was not mentioned."
542 create_pool_nofail $POOL
543 create_pool_nofail $POOL2
544 $LCMD pool_list $FSNAME
546 error "pool_list $FSNAME failed."
548 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
550 $LCMD pool_list $FSNAME.$POOL
552 error "pool_list $FSNAME.$POOL failed."
554 $LCMD pool_list ${NON_EXISTANT_FS}
556 error "pool_list did not fail for a non-existant fsname $NON_EXISTANT_FS"
558 $LCMD pool_list ${FSNAME}.$NON_EXISTANT_POOL
560 error "pool_list did not fail for a non-existant pool $NON_EXISTANT_POOL"
562 if [[ ! $(grep $SINGLEMDS <<< $LCMD) ]]; then
563 echo $LCMD pool_list $DIR
566 error "pool_list failed for $DIR"
569 $LCMD pool_list ${DIR}/d1
571 error "pool_list failed for ${DIR}/d1"
574 rm -rf ${DIR}nonexistant
575 $LCMD pool_list ${DIR}nonexistant
577 error "pool_list did not fail for invalid mountpoint ${DIR}nonexistant"
584 # Issue commands from client
588 # Issue commands from MDS
589 sub_test_5 "do_facet $SINGLEMDS lctl"
590 sub_test_5 "do_facet $SINGLEMDS lfs"
593 run_test 5 "lfs/lctl pool_list"
596 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
597 local POOL_DIR=$POOL_ROOT/dir_tst
598 local POOL_FILE=$POOL_ROOT/file_tst
600 create_pool_nofail $POOL
602 do_facet $SINGLEMDS lctl pool_list $FSNAME
604 error "pool_list $FSNAME failed."
606 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
609 $SETSTRIPE -c -1 -p $POOL $POOL_DIR
611 error "$SETSTRIPE -p $POOL failed."
612 check_dir_in_pool $POOL_DIR $POOL
614 # If an invalid pool name is specified, the command should fail
615 $SETSTRIPE -c 2 -p $INVALID_POOL $POOL_DIR
617 error_ignore 19919 "setstripe to invalid pool did not fail."
619 # If the pool name does not exist, the command should fail
620 $SETSTRIPE -c 2 -p $NON_EXISTANT_POOL $POOL_DIR
622 error_ignore 19919 "setstripe to non-existant pool did not fail."
624 # lfs setstripe should work as before if a pool name is not specified.
625 $SETSTRIPE -c -1 $POOL_DIR
627 error "$SETSTRIPE -p $POOL_DIR failed."
628 $SETSTRIPE -c -1 $POOL_FILE
630 error "$SETSTRIPE -p $POOL_FILE failed."
632 # lfs setstripe should fail if a start index that is outside the
634 create_pool_nofail $POOL2
635 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
636 $SETSTRIPE -o 1 -p $POOL2 $ROOT_POOL/$tfile
638 error "$SETSTRIPE with start index outside the pool did not fail."
643 run_test 6 "getstripe/setstripe"
646 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
648 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
650 create_pool_nofail $POOL
651 create_pool_nofail $POOL2
653 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL \
654 $FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]
655 local start=$((TGT_FIRST+1))
656 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
657 $FSNAME-OST[$start-$TGT_MAX/2]
659 create_dir $POOL_ROOT/dir1 $POOL
660 create_dir $POOL_ROOT/dir2 $POOL2
661 check_dir_in_pool $POOL_ROOT/dir1 $POOL
662 check_dir_in_pool $POOL_ROOT/dir1 $POOL
665 createmany -o $POOL_ROOT/dir1/$tfile $numfiles || \
666 error "createmany $POOL_ROOT/dir1/$tfile failed!"
668 for file in $POOL_ROOT/dir1/*; do
669 check_file_in_pool $file $POOL
672 createmany -o $POOL_ROOT/dir2/$tfile $numfiles || \
673 error "createmany $POOL_ROOT/dir2/$tfile failed!"
674 for file in $POOL_ROOT/dir2/*; do
675 check_file_in_pool $file $POOL2
678 rm -rf $POOL_ROOT/dir?
685 run_test 11 "OSTs in overlapping/multiple pools"
688 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
690 [[ $OSTCOUNT -le 2 ]] && skip "Need atleast 3 OSTs" && return
692 create_pool_nofail $POOL
693 create_pool_nofail $POOL2
695 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL \
696 $FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]
697 local start=$((TGT_FIRST+1))
698 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
699 $FSNAME-OST[$start-$TGT_MAX/2]
701 echo creating some files in $POOL and $POOL2
703 create_dir $POOL_ROOT/dir1 $POOL
704 create_dir $POOL_ROOT/dir2 $POOL2
705 create_file $POOL_ROOT/file1 $POOL
706 create_file $POOL_ROOT/file2 $POOL2
708 echo Checking the files created
709 check_dir_in_pool $POOL_ROOT/dir1 $POOL
710 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
711 check_file_in_pool $POOL_ROOT/file1 $POOL
712 check_file_in_pool $POOL_ROOT/file2 $POOL2
714 echo Changing the pool membership
715 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST[$TGT_FIRST]
716 do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL
717 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 $FSNAME-OST[$TGT_FIRST]
718 do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL2
720 echo Checking the files again
721 check_dir_in_pool $POOL_ROOT/dir1 $POOL
722 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
723 check_file_in_osts $POOL_ROOT/file1 "$TGT_LIST2"
724 check_file_in_osts $POOL_ROOT/file2 "$(seq $start 2 $TGT_MAX)"
726 echo Creating some more files
727 create_dir $POOL_ROOT/dir3 $POOL
728 create_dir $POOL_ROOT/dir4 POOL2
729 create_file $POOL_ROOT/file3 $POOL
730 create_file $POOL_ROOT/file4 $POOL2
732 echo Checking the new files
733 check_file_in_pool $POOL_ROOT/file3 $POOL
734 check_file_in_pool $POOL_ROOT/file4 $POOL2
741 run_test 12 "OST Pool Membership"
744 [[ $OSTCOUNT -le 2 ]] && skip "Need atleast 3 OSTs" && return
746 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
750 create_pool_nofail $POOL
751 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
753 create_dir $POOL_ROOT/dir1 $POOL -1
754 createmany -o $POOL_ROOT/dir1/$tfile $numfiles || \
755 error "createmany $POOL_ROOT/dir1/$tfile failed!"
756 for file in $POOL_ROOT/dir1/*; do
757 check_file_in_pool $file $POOL $OSTCOUNT
760 create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
761 create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST+1))
762 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST+2))
763 check_file_in_pool $POOL_ROOT/dir1/file1 $POOL 1
764 check_file_in_pool $POOL_ROOT/dir1/file2 $POOL 1
765 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST+2))
766 check_file_in_osts $POOL_ROOT/dir1/file1 "$TGT_FIRST"
767 check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST+1))"
768 check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST+2))"
770 create_dir $POOL_ROOT/dir2 $POOL $count
771 createmany -o $POOL_ROOT/dir2/$tfile $numfiles || \
772 error "createmany $POOL_ROOT/dir2/$tfile failed!"
773 for file in $POOL_ROOT/dir2/*; do
774 check_file_in_pool $file $POOL $count
777 create_dir $POOL_ROOT/dir3 $POOL $count $((TGT_FIRST+1))
778 createmany -o $POOL_ROOT/dir3/$tfile_ $numfiles || \
779 error "createmany $POOL_ROOT/dir3/$tfile_ failed!"
780 for file in $POOL_ROOT/dir3/*; do
781 check_file_in_pool $file $POOL $count
784 create_dir $POOL_ROOT/dir4 $POOL 1
785 createmany -o $POOL_ROOT/dir4/$tfile_ $numfiles || \
786 error "createmany $POOL_ROOT/dir4/$tfile_ failed!"
787 for file in $POOL_ROOT/dir4/*; do
788 check_file_in_pool $file $POOL 1
791 create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST+2))
792 createmany -o $POOL_ROOT/dir5/$tfile_ $numfiles || \
793 error "createmany $POOL_ROOT/dir5/$tfile_ failed!"
794 for file in $POOL_ROOT/dir5/*; do
795 check_file_in_pool $file $POOL 1
796 check_file_in_osts $file "$((TGT_FIRST+2))"
799 rm -rf create_dir $POOL_ROOT/dir?
804 run_test 13 "Striping characteristics in a pool"
807 [[ $OSTCOUNT -le 2 ]] && skip "Need atleast 3 OSTs" && return
809 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
813 # Create a new filesystem that is guaranteed to be balanced.
817 create_pool_nofail $POOL
818 create_pool_nofail $POOL2
820 add_pool $POOL $TGT_HALF "$TGT_UUID2"
821 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
823 create_dir $POOL_ROOT/dir1 $POOL 1
824 create_file $POOL_ROOT/dir1/file $POOL 1
825 local OST=$($GETSTRIPE $POOL_ROOT/dir1/file | grep 0x | cut -f2)
827 while [[ $i -lt $numfiles ]];
830 [[ $OST -gt $TGT_MAX ]] && OST=$TGT_FIRST
832 # echo "Iteration: $i OST: $OST"
833 create_file $POOL_ROOT/dir1/file${i} $POOL 1
834 check_file_in_osts $POOL_ROOT/dir1/file${i} $OST
838 # Fill OST $TGT_FIRST with 10M files
839 create_dir $POOL_ROOT/dir2 $POOL2 1
842 while [[ $RC -eq 0 ]];
844 dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1k count=$((1024*10))
849 # Leave some space on the OST
850 rm -f $POOL_ROOT/dir2/f0
853 # OST $TGT_FIRST is no longer favored; but it may still be used.
854 create_dir $POOL_ROOT/dir3 $POOL 1
855 create_file $POOL_ROOT/dir3/file $POOL 1
856 createmany -o $POOL_ROOT/dir3/$tfile_ $numfiles || \
857 error "createmany $POOL_ROOT/dir3/$tfile_ failed!"
858 for file in $POOL_ROOT/dir3/*; do
859 check_file_in_pool $file $POOL
867 run_test 14 "Round robin and QOS striping within a pool"
870 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
874 while [[ $i -lt $OSTCOUNT ]]
876 create_pool_nofail pool${i}
878 local tgt=$(printf "$FSNAME-OST%04x_UUID " $i)
879 add_pool pool${i} "$FSNAME-OST[$i]" "$tgt"
880 create_dir $POOL_ROOT/dir${i} pool${i}
881 createmany -o $POOL_ROOT/dir$i/$tfile $numfiles || \
882 error "createmany $POOL_ROOT/dir$i/$tfile failed!"
884 for file in $POOL_ROOT/dir$i/*; do
885 check_file_in_osts $file $i
892 while [[ $i -lt $OSTCOUNT ]]
894 destroy_pool pool${i}
900 run_test 15 "One directory per OST/pool"
903 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
907 create_pool_nofail $POOL
909 add_pool $POOL $TGT_HALF "$TGT_UUID2"
911 local dir=$POOL_ROOT/$tdir
912 create_dir $dir $POOL
914 for i in $(seq 1 10); do
919 createmany -o $dir/$tfile $numfiles || \
920 error "createmany $dir/$tfile failed!"
922 for file in $dir/*; do
923 check_file_in_pool $file $POOL
926 rm -rf $POOL_ROOT/$tdir
932 run_test 16 "Inheritance of pool properties"
935 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
939 create_pool_nofail $POOL
941 add_pool $POOL $TGT_ALL "$TGT_UUID"
943 local dir=$POOL_ROOT/dir
944 create_dir $dir $POOL
946 createmany -o $dir/${tfile}1_ $numfiles || \
947 error "createmany $dir/${tfile}1_ failed!"
949 for file in $dir/*; do
950 check_file_in_pool $file $POOL
955 createmany -o $dir/${tfile}2_ $numfiles || \
956 error "createmany $dir/${tfile}2_ failed!"
961 run_test 17 "Referencing an empty pool"
969 sync; sleep 5 # give pending IO a chance to go to disk
970 stat=$(createmany -o $dir/${tfile} $numfiles)
973 time=$(echo $stat | cut -f 5 -d ' ')
974 echo $stat > /dev/stderr
979 local t1=$(create_perf_one $1 $2)
980 local t2=$(create_perf_one $1 $2)
981 local t3=$(create_perf_one $1 $2)
982 local time=$(echo "scale=2; ( $t1 + $t2 + $t3 ) / 3" | bc)
988 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
994 local dir=$POOL_ROOT/dir
998 time1=$(create_perf $dir $numfiles)
1000 create_pool_nofail $POOL
1002 add_pool $POOL $TGT_ALL "$TGT_UUID"
1004 create_dir $dir $POOL
1005 time2=$(create_perf $dir $numfiles)
1009 time3=$(create_perf $dir $numfiles)
1011 echo Time taken for $numfiles creates without pools: $time1
1012 echo Time taken for $numfiles creates with pools: $time2
1013 echo Time taken for $numfiles creates without pools: $time3
1015 deg=$(echo "scale=2; (($time2 - $time3) * 100 / $time3) > 5" | bc)
1016 diff=$(echo "scale=2; ($time2 - $time3) * 100 / $time3" | bc)
1018 if [[ "$deg" == "1" ]]; then
1019 error "Performance degradation with pools is $diff %."
1021 echo "Performance degradation with pools is $diff %."
1025 run_test 18 "File create in a directory which references a deleted pool"
1029 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1031 local dir1=$POOL_ROOT/dir1
1032 local dir2=$POOL_ROOT/dir2
1035 create_pool_nofail $POOL
1037 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1039 create_dir $dir1 $POOL
1040 createmany -o $dir1/${tfile} $numfiles || \
1041 error "createmany $dir1/${tfile} failed!"
1042 for file in $dir1/*; do
1043 check_file_in_pool $file $POOL
1047 createmany -o $dir2/${tfile} $numfiles || \
1048 error "createmany $dir2/${tfile} failed!"
1049 for file in $dir2/*; do
1050 check_file_not_in_pool $file $POOL
1058 run_test 19 "Pools should not come into play when not specified"
1061 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1063 local dir1=$POOL_ROOT/dir1
1064 local dir2=$dir1/dir2
1065 local dir3=$dir1/dir3
1069 create_pool_nofail $POOL
1070 create_pool_nofail $POOL2
1072 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1074 local start=$((TGT_FIRST+1))
1075 TGT=$(for i in `seq $start 2 $TGT_MAX`; \
1076 do printf "$FSNAME-OST%04x_UUID " $i; done)
1077 add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1079 create_dir $dir1 $POOL
1080 create_file $dir1/file1 $POOL2
1081 create_dir $dir2 $POOL2
1084 $SETSTRIPE -c 1 $dir3 # No pool assignment
1086 $SETSTRIPE -c 1 $dir2/file4 # No pool assignment
1088 check_file_in_pool $dir1/file1 $POOL2
1089 check_file_in_pool $dir2/file2 $POOL2
1091 check_dir_not_in_pool $dir3 $POOL
1092 check_dir_not_in_pool $dir3 $POOL2
1094 check_file_not_in_pool $dir3/file3 $POOL
1095 check_file_not_in_pool $dir3/file3 $POOL2
1097 check_file_not_in_pool $dir2/file4 $POOL
1098 check_file_not_in_pool $dir2/file4 $POOL2
1106 run_test 20 "Different pools in a directory hierarchy."
1109 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1110 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1114 local dir=$POOL_ROOT/dir
1116 create_pool_nofail $POOL
1118 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1120 create_dir $dir $POOL $OSTCOUNT
1121 create_file $dir/file1 $POOL $OSTCOUNT
1122 $GETSTRIPE -v $dir/file1
1123 check_file_in_pool $dir/file1 $POOL
1130 run_test 21 "OST pool with fewer OSTs than stripe count"
1138 for c in $(seq 1 10);
1140 echo "Pool $pool, iteration $c"
1141 create_pool_nofail $pool
1142 local TGT=$(for i in `seq $TGT_FIRST $step $TGT_MAX`; \
1143 do printf "$FSNAME-OST%04x_UUID " $i; done)
1144 add_pool $pool "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/$step]" "$TGT"
1146 do_facet $SINGLEMDS lctl pool_list $FSNAME
1148 echo loop for $pool complete
1152 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1153 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1160 create_dir $POOL_ROOT $POOL
1161 createmany -o $POOL_ROOT/${tfile} $numfiles || \
1162 error "createmany $POOL_ROOT/${tfile} failed!"
1167 run_test 22 "Simultaneous manipulation of a pool"
1170 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1171 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1174 check_runas_id $TSTID $TSTID $RUNAS || {
1175 skip "User $RUNAS_ID does not exist - skipping"
1183 local dir=$POOL_ROOT/dir
1184 local file1="$dir/$tfile-quota1"
1185 local file2="$dir/$tfile-quota2"
1187 create_pool_nofail $POOL
1189 local TGT=$(for i in `seq $TGT_FIRST 3 $TGT_MAX`; \
1190 do printf "$FSNAME-OST%04x_UUID " $i; done)
1191 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1192 create_dir $dir $POOL
1194 $LFS quotaoff -ug $MOUNT
1195 $LFS quotacheck -ug $MOUNT
1196 $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir #-i 5 -I 5 $dir
1198 $LFS setstripe $file1 -c 1 -p $POOL
1199 chown $TSTUSR.$TSTUSR $file1
1203 stat=$(LC_ALL=C $RUNAS dd if=/dev/zero of=$file1 bs=1024 count=$((LIMIT*2)) 2>&1)
1206 [[ $RC -eq 0 ]] && error "dd did not fail with EDQUOT."
1207 echo $stat | grep "Disk quota exceeded"
1208 [[ $? -eq 1 ]] && error "dd did not fail with EDQUOT."
1211 $LFS quotaoff -ug $MOUNT
1212 # $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir
1213 chown $TSTUSR.$TSTUSR $dir
1216 while [ $RC -eq 0 ];
1219 stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file2}$i bs=1024 \
1220 count=$((LIMIT*LIMIT)) 2>&1)
1222 if [ $RC -eq 1 ]; then
1224 echo $stat | grep "Disk quota exceeded"
1225 [[ $? -eq 0 ]] && error "dd failed with EDQUOT"
1227 echo $stat | grep "No space left on device"
1228 [[ $? -ne 0 ]] && error "dd did not fail with ENOSPC; " \
1240 run_test 23 "OST pools and quota"
1243 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1244 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1253 create_pool_nofail $POOL
1255 add_pool $POOL $TGT_ALL "$TGT_UUID"
1257 create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1259 mkdir $POOL_ROOT/dir2
1260 $SETSTRIPE $POOL_ROOT/dir2 -p $POOL -s 65536 -i 0 -c 1 || \
1261 error "$SETSTRIPE $POOL_ROOT/dir2 failed"
1263 mkdir $POOL_ROOT/dir3
1264 $SETSTRIPE $POOL_ROOT/dir3 -s 65536 -i 0 -c 1 || \
1265 error "$SETSTRIPE $POOL_ROOT/dir3 failed"
1267 mkdir $POOL_ROOT/dir4
1269 for i in $(seq 1 4);
1271 dir=${POOL_ROOT}/dir${i}
1280 createmany -o $dir/${tfile} $numfiles || \
1281 error "createmany $dir/${tfile} failed!"
1282 res=$($GETSTRIPE -v $dir | grep "^stripe_count:")
1283 if [ $? -ne 0 ]; then
1284 res=$($GETSTRIPE -v $dir | grep "^(Default) ")
1285 pool=$(cut -f 9 -d ' ' <<< $res)
1286 index=$(cut -f 7 -d ' ' <<< $res)
1287 size=$(cut -f 5 -d ' ' <<< $res)
1288 count=$(cut -f 3 -d ' ' <<< $res)
1290 pool=$(cut -f 8 -d ' ' <<< $res)
1291 index=$(cut -f 6 -d ' ' <<< $res)
1292 size=$(cut -f 4 -d ' ' <<< $res)
1293 count=$(cut -f 2 -d ' ' <<< $res)
1296 for file in $dir/*; do
1297 if [ "$pool" != "" ]; then
1298 check_file_in_pool $file $pool
1300 pool1=$($GETSTRIPE -v $file | grep "^pool:" |\
1301 tr -d '[:blank:]' | cut -f 2 -d ':')
1302 count1=$($GETSTRIPE -v $file | grep "^lmm_stripe_count:" |\
1303 tr -d '[:blank:]' | cut -f 2 -d ':')
1304 size1=$($GETSTRIPE -v $file | grep "^lmm_stripe_size:" |\
1305 tr -d '[:blank:]' | cut -f 2 -d ':')
1306 [[ "$pool" != "$pool1" ]] && \
1307 error "Pool name ($pool) not inherited in $file($pool1)"
1308 [[ "$count" != "$count1" ]] && \
1309 error "Stripe count ($count) not inherited in $file ($count1)"
1310 [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] && \
1311 error "Stripe size ($size) not inherited in $file ($size1)"
1320 run_test 24 "Independence of pool from other setstripe parameters"
1323 local dev=$(mdsdevname ${SINGLEMDS//mds/})
1324 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1328 for i in $(seq 10); do
1329 create_pool_nofail pool$i
1330 stop $SINGLEMDS -f || return 1
1332 start $SINGLEMDS ${dev} $MDS_MOUNT_OPTS || \
1333 error "Failed to start $SINGLEMDS after stopping"
1335 # Veriy that the pool got created and is usable
1336 echo "Creating a file in pool$i"
1337 create_file $POOL_ROOT/file$i pool$i
1338 check_file_in_pool $POOL_ROOT/file$i pool$i
1342 for i in $(seq 10); do
1346 run_test 25 "Create new pool and restart MDS ======================="
1348 log "cleanup: ======================================================"
1351 check_and_cleanup_lustre
1352 echo '=========================== finished ==============================='
1353 [ -f "$POOLSLOG" ] && cat $POOLSLOG && grep -q FAIL $POOLSLOG && exit 1 || true
1354 echo "$0: completed"