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
32 [ "$SLOW" = "no" ] && EXCEPT_SLOW="23b"
39 SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
40 GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"}
42 MAXFREE=${MAXFREE:-$((2000000 * OSTCOUNT))}
46 POOL2=${POOL2:-${POOL}2}
47 POOL3=${POOL3:-${POOL}3}
48 NON_EXISTANT_POOL=nonexistantpool
49 NON_EXISTANT_FS=nonexistantfs
50 INVALID_POOL=some_invalid_pool_name
52 TGT_FIRST=$(printf %04x 0)
53 TGT_MAX=$(printf %04x $((TGT_COUNT-1)))
55 TGT_LIST=$(seq 0x$TGT_FIRST $TGT_STEP 0x$TGT_MAX)
56 TGT_LIST2=$(seq 0x$TGT_FIRST 2 0x$TGT_MAX)
58 TGT_ALL="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/1]"
59 TGT_HALF="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]"
61 TGT_UUID=$(for i in $TGT_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
62 TGT_UUID2=$(for i in $TGT_LIST2; do printf "$FSNAME-OST%04x_UUID " $i; done)
67 local count=${3:-"-1"}
72 $SETSTRIPE -c $count -p $pool $dir -o $idx
74 $SETSTRIPE -c $count -p $pool $dir
77 error "$SETSTRIPE -p $pool $dir failed."
83 local count=${3:-"-1"}
84 local index=${4:-"-1"}
86 $SETSTRIPE -o $index -c $count -p $pool $file
88 error "$SETSTRIPE -p $pool $file failed."
94 for i in $(do_facet $SINGLEMDS lctl pool_list $FSNAME.$pool |
95 grep -v "^Pool:" | sed -e 's/_UUID$//;s/^.*-OST//'); do
96 res="$res $(printf "%d" 0x$i)"
101 check_dir_in_pool() {
104 local res=$($GETSTRIPE $dir | grep "^stripe_count:" |
105 cut -d ':' -f 5 | tr -d "[:blank:]")
106 if [[ "$res" != "$pool" ]]; then
107 error found $res instead of $pool
114 check_file_in_pool() {
115 local osts=$(osts_in_pool $2)
116 check_file_in_osts $1 "$osts" $3
119 check_file_in_osts() {
121 local pool_list=${2:-$TGT_LIST}
123 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
126 found=$(echo :$pool_list: | tr " " ":" | grep :$i:)
127 if [[ "$found" == "" ]]; then
128 echo "pool list: $pool_list"
129 echo "striping: $res"
131 error "$file not allocated from OSTs $pool_list."
136 local ost_count=$($GETSTRIPE $file | grep 0x | wc -l)
137 [[ -n "$count" ]] && [[ $ost_count -ne $count ]] &&
138 { error "Stripe count $count expected; got $ost_count" && return 1;}
144 $GETSTRIPE -v $1 | grep "^lmm_pool:" | tr -d "[:blank:]" | cut -f 2 -d ':'
147 check_file_not_in_pool() {
150 local res=$(file_pool $file)
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 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool" "" ||
175 error "Failed to remove targets from pool: $pool"
181 local tgt="${3}$(lctl get_param -n lov.$FSNAME-*.pools.$pool |
182 sort -u | tr '\n' ' ')"
184 do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool $osts
186 [[ $RC -ne 0 ]] && return $RC
188 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool |
189 sort -u | tr '\n' ' ' " "$tgt" >/dev/null || RC=1
190 [[ $RC -ne 0 ]] && error "pool_add failed: $1; $2"
194 create_pool_nofail() {
195 create_pool $FSNAME.$1
196 if [[ $? != 0 ]]; then
197 error "Pool creation of $1 failed"
202 create_pool $FSNAME.$1
203 if [[ $? == 0 ]]; then
204 error "Pool creation of $1 succeeded; should have failed"
209 # Destroy pools from previous test runs
210 for p in $(do_facet $SINGLEMDS lctl pool_list $FSNAME | grep $POOL); do
213 rm -rf $DIR/d0.${TESTSUITE}
221 trap "cleanup_tests $FSNAME" EXIT
225 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
226 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
230 # Tests for new commands added
236 run_test 1a "Create a pool with a 1 character pool name"
240 create_pool_nofail ${POOL}12
241 destroy_pool ${POOL}12
243 run_test 1b "Create a pool with a 10 character pool name"
247 create_pool_nofail ${POOL}12345678
248 destroy_pool ${POOL}12345678
250 run_test 1c "Create a pool with a 16 character pool name"
254 create_pool_fail ${POOL}123456789
256 run_test 1d "Create a pool with a 17 char pool name; should fail"
260 local pool_name="$POOL"
261 for ((i = 1; i <= 991; i++)); do pool_name=${pool_name}"o"; done
262 create_pool_fail $pool_name
264 run_test 1e "Create a pool with a 1000 char pool name; should fail"
268 do_facet $SINGLEMDS lctl pool_new .$POOL 2>/dev/null
270 error "pool_new did not fail even though fs-name was missing"
272 run_test 1f "pool_new should fail if fs-name is missing"
276 do_facet $SINGLEMDS lctl pool_new $POOL 2>/dev/null
278 error "pool_new did not fail even though fs-name was missing"
280 run_test 1g "pool_new should fail if fs-name is missing"
284 do_facet $SINGLEMDS lctl pool_new ${FSNAME}. 2>/dev/null
286 error "pool_new did not fail even though pool name was missing"
288 run_test 1h "pool_new should fail if poolname is missing"
292 do_facet $SINGLEMDS lctl pool_new . 2>/dev/null
294 error "pool_new did not fail even if pool and fs-name were missing"
296 run_test 1i "pool_new should fail if poolname and fs-name are missing"
300 do_facet $SINGLEMDS lctl pool_new ${FSNAME},$POOL 2>/dev/null
302 error "pool_new did not fail even though pool name format was wrong"
304 run_test 1j "pool_new should fail if poolname format is wrong"
308 do_facet $SINGLEMDS lctl pool_new ${FSNAME}/$POOL 2>/dev/null
310 error "pool_new did not fail even though pool name format was wrong"
312 run_test 1k "pool_new should fail if poolname format is wrong"
316 create_pool_nofail $POOL2
317 do_facet $SINGLEMDS lctl pool_new ${FSNAME}.$POOL2 2>/dev/null
319 error "pool_new did not fail even though $POOL2 existed"
322 run_test 1m "pool_new did not fail even though $POOL2 existed"
328 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
330 error "pool_add did not fail even though $POOL did not exist"
332 run_test 2a "pool_add: non-existant pool $POOL"
336 do_facet $SINGLEMDS lctl pool_add $FSNAME.${POOL}1234567890 \
337 $FSNAME-OST0000 2>/dev/null
339 error "pool_add did not fail even though pool name was invalid."
341 run_test 2b "pool_add: Invalid pool name"
343 # Testing various combinations of OST name list
349 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
350 [[ $? -ne 0 ]] || destroy_pool $POOL
352 create_pool_nofail $POOL
355 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
356 RC=$?; [[ $RC -eq 0 ]] ||
357 error "pool_add failed. $FSNAME $POOL OST0000: $RC"
358 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
362 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
363 RC=$?; [[ $RC -eq 0 ]] ||
364 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000: $RC"
365 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
368 # 3. $FSNAME-OST0000_UUID
369 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
370 RC=$?; [[ $RC -eq 0 ]] ||
371 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000_UUID: $RC"
372 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
375 # 4. $FSNAME-OST[0,1,2,3,]
377 for i in $TGT_LIST; do TGT=${TGT}$(printf "%04x," $i); done
379 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
380 [[ $? -eq 0 ]] || error "pool_add failed. $FSNAME.$POOL $TGT. $RC"
381 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT
384 # 5. $FSNAME-OST[0-5/1]
385 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
386 RC=$?; [[ $RC -eq 0 ]] ||
387 error "pool_add failed. $FSNAME $POOL" "$TGT_ALL $RC"
388 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL |
389 sort -u | tr '\n' ' ' " "$TGT_UUID" || error "Add to pool failed"
390 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
395 run_test 2c "pool_add: OST index combinations"
402 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
403 [[ $? -ne 0 ]] || destroy_pool $POOL
405 create_pool_nofail $POOL
407 TGT=$(printf "$FSNAME-OST%04x_UUID " $OSTCOUNT)
408 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
409 RC=$?; [[ $RC -ne 0 ]] ||
410 error "pool_add succeeded for an OST ($TGT) that does not exist."
414 run_test 2d "pool_add: OSTs that don't exist should be rejected"
422 $LCTL get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
423 [[ $? -ne 0 ]] || destroy_pool $POOL
425 create_pool_nofail $POOL
427 TGT="$FSNAME-OST0000_UUID "
428 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
429 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL |
430 sort -u | tr '\n' ' ' " "$TGT" || error "Add to pool failed"
431 RESULT=$(do_facet $SINGLEMDS \
432 "LOCALE=C $LCTL pool_add $FSNAME.$POOL $TGT 2>&1")
437 error "pool_add succeeded for an OST that was already in the pool."
439 [[ $(grep "already in pool" <<< $RESULT) ]] ||
440 error "pool_add failed as expected but error message not as expected."
444 run_test 2e "pool_add: OST already in a pool should be rejected"
448 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
449 [[ $? -ne 0 ]] || destroy_pool $POOL
451 do_facet $SINGLEMDS \
452 lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
454 error "pool_remove did not fail even though pool did not exist."
456 run_test 3a "pool_remove: non-existant pool"
460 do_facet $SINGLEMDS \
461 lctl pool_remove ${NON_EXISTANT_FS}.$POOL OST0000 2>/dev/null
463 error "pool_remove did not fail even though fsname did not exist."
465 run_test 3b "pool_remove: non-existant fsname"
469 do_facet $SINGLEMDS lctl pool_remove $FSNAME.p1234567891234567890 \
470 $FSNAME-OST0000 2>/dev/null
472 error "pool_remove did not fail even though pool name was invalid."
474 run_test 3c "pool_remove: Invalid pool name"
476 # Testing various combinations of OST name list
479 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
480 [[ $? -ne 0 ]] || destroy_pool $POOL
482 create_pool_nofail $POOL
483 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
484 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
485 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL OST0000"
488 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
489 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
490 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000"
493 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
494 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
496 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000_UUID"
499 add_pool $POOL $TGT_ALL "$TGT_UUID"
500 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
501 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL" $TGT_ALL
506 run_test 3d "pool_remove: OST index combinations"
510 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
511 [[ $? -ne 0 ]] || destroy_pool $POOL
513 do_facet $SINGLEMDS lctl pool_destroy $FSNAME.$POOL 2>/dev/null
515 error "pool_destroy did not fail even though pool did not exist."
517 run_test 4a "pool_destroy: non-existant pool"
521 do_facet $SINGLEMDS lctl pool_destroy ${NON_EXISTANT_FS}.$POOL 2>/dev/null
523 error "pool_destroy did not fail even though filesystem did not exist."
525 run_test 4b "pool_destroy: non-existant fs-name"
529 create_pool_nofail $POOL
530 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
532 do_facet $SINGLEMDS lctl pool_destroy ${FSNAME}.$POOL
533 [[ $? -ne 0 ]] || error "pool_destroy succeeded with a non-empty pool."
536 run_test 4c "pool_destroy: non-empty pool"
541 $LCMD pool_list 2>/dev/null
542 [[ $? -ne 0 ]] || error "pool_list did not fail even though fsname missing."
544 destroy_pool $POOL 2>/dev/null
545 destroy_pool $POOL2 2>/dev/null
547 create_pool_nofail $POOL
548 create_pool_nofail $POOL2
549 $LCMD pool_list $FSNAME
550 [[ $? -eq 0 ]] || error "pool_list $FSNAME failed."
552 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
554 $LCMD pool_list $FSNAME.$POOL
555 [[ $? -eq 0 ]] || error "pool_list $FSNAME.$POOL failed."
557 $LCMD pool_list ${NON_EXISTANT_FS} 2>/dev/null
558 [[ $? -ne 0 ]] || error "pool_list did not fail for fsname $NON_EXISTANT_FS"
560 $LCMD pool_list ${FSNAME}.$NON_EXISTANT_POOL 2>/dev/null
561 [[ $? -ne 0 ]] || error "pool_list did not fail for pool $NON_EXISTANT_POOL"
563 if [[ ! $(grep $SINGLEMDS <<< $LCMD) ]]; then
564 echo $LCMD pool_list $DIR
566 [[ $? -eq 0 ]] || error "pool_list failed for $DIR"
569 $LCMD pool_list ${DIR}/d1
570 [[ $? -eq 0 ]] || error "pool_list failed for ${DIR}/d1"
573 rm -rf ${DIR}nonexistant
574 $LCMD pool_list ${DIR}nonexistant 2>/dev/null
576 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"
597 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
598 local POOL_DIR=$POOL_ROOT/dir_tst
599 local POOL_FILE=$POOL_ROOT/file_tst
601 create_pool_nofail $POOL
603 do_facet $SINGLEMDS lctl pool_list $FSNAME
604 [[ $? -eq 0 ]] || error "pool_list $FSNAME failed."
606 add_pool $POOL $TGT_ALL "$TGT_UUID"
609 $SETSTRIPE -c -1 -p $POOL $POOL_DIR
610 [[ $? -eq 0 ]] || error "$SETSTRIPE -p $POOL failed."
611 check_dir_in_pool $POOL_DIR $POOL
613 # If an invalid pool name is specified, the command should fail
614 $SETSTRIPE -c 2 -p $INVALID_POOL $POOL_DIR 2>/dev/null
615 [[ $? -ne 0 ]] || error "setstripe to invalid pool did not fail."
617 # If the pool name does not exist, the command should fail
618 $SETSTRIPE -c 2 -p $NON_EXISTANT_POOL $POOL_DIR 2>/dev/null
619 [[ $? -ne 0 ]] || error "setstripe to non-existant pool did not fail."
621 # lfs setstripe should work as before if a pool name is not specified.
622 $SETSTRIPE -c -1 $POOL_DIR
623 [[ $? -eq 0 ]] || error "$SETSTRIPE -p $POOL_DIR failed."
624 $SETSTRIPE -c -1 $POOL_FILE
625 [[ $? -eq 0 ]] || error "$SETSTRIPE -p $POOL_FILE failed."
627 # lfs setstripe should fail if a start index that is outside the
629 create_pool_nofail $POOL2
630 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
631 $SETSTRIPE -o 1 -p $POOL2 $ROOT_POOL/$tfile 2>/dev/null
633 error "$SETSTRIPE with start index outside the pool did not fail."
636 run_test 6 "getstripe/setstripe"
640 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
642 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
644 create_pool_nofail $POOL
645 create_pool_nofail $POOL2
647 local start=$(printf %04x $((TGT_FIRST + 1)))
648 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
649 $FSNAME-OST[$start-$TGT_MAX/2]
651 add_pool $POOL $TGT_HALF "$TGT_UUID2"
653 create_dir $POOL_ROOT/dir1 $POOL
654 create_dir $POOL_ROOT/dir2 $POOL2
655 check_dir_in_pool $POOL_ROOT/dir1 $POOL
656 check_dir_in_pool $POOL_ROOT/dir1 $POOL
659 createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
660 error "createmany $POOL_ROOT/dir1/$tfile failed!"
662 for file in $POOL_ROOT/dir1/*; do
663 check_file_in_pool $file $POOL
666 createmany -o $POOL_ROOT/dir2/$tfile $numfiles ||
667 error "createmany $POOL_ROOT/dir2/$tfile failed!"
668 for file in $POOL_ROOT/dir2/*; do
669 check_file_in_pool $file $POOL2
672 rm -rf $POOL_ROOT/dir?
676 run_test 11 "OSTs in overlapping/multiple pools"
680 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
682 [[ $OSTCOUNT -le 2 ]] && skip_env "Need at least 3 OSTs" && return
684 create_pool_nofail $POOL
685 create_pool_nofail $POOL2
687 local start=$(printf %04x $((TGT_FIRST + 1)))
688 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
689 $FSNAME-OST[$start-$TGT_MAX/2]
691 add_pool $POOL $TGT_HALF "$TGT_UUID2"
693 echo creating some files in $POOL and $POOL2
695 create_dir $POOL_ROOT/dir1 $POOL
696 create_dir $POOL_ROOT/dir2 $POOL2
697 create_file $POOL_ROOT/file1 $POOL
698 create_file $POOL_ROOT/file2 $POOL2
700 echo Checking the files created
701 check_dir_in_pool $POOL_ROOT/dir1 $POOL
702 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
703 check_file_in_pool $POOL_ROOT/file1 $POOL
704 check_file_in_pool $POOL_ROOT/file2 $POOL2
706 echo Changing the pool membership
707 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST[$TGT_FIRST]
708 do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL
709 FIRST_UUID=$(echo $TGT_UUID | awk '{print $1}')
710 add_pool $POOL2 $FSNAME-OST[$TGT_FIRST] "$FIRST_UUID "
711 do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL2
713 echo Checking the files again
714 check_dir_in_pool $POOL_ROOT/dir1 $POOL
715 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
716 check_file_in_osts $POOL_ROOT/file1 "$TGT_LIST2"
717 check_file_in_osts $POOL_ROOT/file2 "$(seq 0x$start 2 0x$TGT_MAX)"
719 echo Creating some more files
720 create_dir $POOL_ROOT/dir3 $POOL
721 create_dir $POOL_ROOT/dir4 $POOL2
722 create_file $POOL_ROOT/file3 $POOL
723 create_file $POOL_ROOT/file4 $POOL2
725 echo Checking the new files
726 check_file_in_pool $POOL_ROOT/file3 $POOL
727 check_file_in_pool $POOL_ROOT/file4 $POOL2
731 run_test 12 "OST Pool Membership"
735 [[ $OSTCOUNT -le 2 ]] && skip_env "Need at least 3 OSTs" && return
737 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
741 create_pool_nofail $POOL
742 add_pool $POOL $TGT_ALL "$TGT_UUID"
744 create_dir $POOL_ROOT/dir1 $POOL -1
745 createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
746 error "createmany $POOL_ROOT/dir1/$tfile failed!"
747 for file in $POOL_ROOT/dir1/*; do
748 check_file_in_pool $file $POOL $OSTCOUNT
751 create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
752 create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST + 1))
753 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST + 2))
754 check_file_in_pool $POOL_ROOT/dir1/file1 $POOL 1
755 check_file_in_pool $POOL_ROOT/dir1/file2 $POOL 1
756 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST + 2))
757 check_file_in_osts $POOL_ROOT/dir1/file1 $((16#$TGT_FIRST))
758 check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST + 1))"
759 check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST + 2))"
761 create_dir $POOL_ROOT/dir2 $POOL $count
762 createmany -o $POOL_ROOT/dir2/$tfile- $numfiles ||
763 error "createmany $POOL_ROOT/dir2/$tfile- failed!"
764 for file in $POOL_ROOT/dir2/*; do
765 check_file_in_pool $file $POOL $count
768 create_dir $POOL_ROOT/dir3 $POOL $count $((TGT_FIRST + 1))
769 createmany -o $POOL_ROOT/dir3/$tfile- $numfiles ||
770 error "createmany $POOL_ROOT/dir3/$tfile- failed!"
771 for file in $POOL_ROOT/dir3/*; do
772 check_file_in_pool $file $POOL $count
775 create_dir $POOL_ROOT/dir4 $POOL 1
776 createmany -o $POOL_ROOT/dir4/$tfile- $numfiles ||
777 error "createmany $POOL_ROOT/dir4/$tfile- failed!"
778 for file in $POOL_ROOT/dir4/*; do
779 check_file_in_pool $file $POOL 1
782 create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST + 2))
783 createmany -o $POOL_ROOT/dir5/$tfile- $numfiles ||
784 error "createmany $POOL_ROOT/dir5/$tfile- failed!"
785 for file in $POOL_ROOT/dir5/*; do
786 check_file_in_pool $file $POOL 1
787 check_file_in_osts $file "$((TGT_FIRST + 2))"
790 rm -rf $POOL_ROOT/dir[1-5]/
794 run_test 13 "Striping characteristics in a pool"
798 [[ $OSTCOUNT -le 2 ]] && skip_env "Need at least 3 OSTs" && return
800 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
804 [ $OSTSIZE -gt $((MAXFREE / OSTCOUNT)) ] &&
805 skip_env "OST size $OSTSIZE is larger than $((MAXFREE / OSTCOUNT))" &&
808 create_pool_nofail $POOL
809 create_pool_nofail $POOL2
811 add_pool $POOL $TGT_HALF "$TGT_UUID2"
812 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
814 create_dir $POOL_ROOT/dir1 $POOL 1
815 create_file $POOL_ROOT/dir1/file $POOL 1
816 local OST=$($GETSTRIPE -i $POOL_ROOT/dir1/file)
818 while [[ $i -lt $numfiles ]]; do
820 [[ $OST -gt $((16#$TGT_MAX)) ]] && OST=$TGT_FIRST
822 # echo "Iteration: $i OST: $OST"
823 create_file $POOL_ROOT/dir1/file${i} $POOL 1
824 check_file_in_pool $POOL_ROOT/dir1/file${i} $POOL
828 # Fill up OST0 until it is nearly full.
829 # Create 9 files of size OST0_SIZE/10 each.
830 create_dir $POOL_ROOT/dir2 $POOL2 1
831 $LFS df $POOL_ROOT/dir2
832 OST0_SIZE=$($LFS df $POOL_ROOT/dir2 | awk '/\[OST:0\]/ { print $4 }')
833 FILE_SIZE=$((OST0_SIZE/1024/10))
834 echo "Filling OST0 with 9 files of ${FILE_SIZE}MB in $POOL_ROOT/dir2"
836 while [[ $i -lt 10 ]]; do
837 dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1M count=$FILE_SIZE
840 sleep 1 # get new statfs info
841 $LFS df $POOL_ROOT/dir2
843 # OST $TGT_FIRST is no longer favored; but it may still be used.
844 create_dir $POOL_ROOT/dir3 $POOL 1
845 create_file $POOL_ROOT/dir3/file $POOL 1
846 createmany -o $POOL_ROOT/dir3/$tfile- $numfiles ||
847 error "createmany $POOL_ROOT/dir3/$tfile- failed!"
848 for file in $POOL_ROOT/dir3/*; do
849 check_file_in_pool $file $POOL
856 run_test 14 "Round robin and QOS striping within a pool"
860 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
864 while [[ $i -lt $OSTCOUNT ]]; do
865 create_pool_nofail $POOL${i}
867 local tgt=$(printf "$FSNAME-OST%04x_UUID " $i)
868 add_pool $POOL${i} "$FSNAME-OST[$(printf %04x $i)]" "$tgt"
869 create_dir $POOL_ROOT/dir${i} $POOL${i}
870 createmany -o $POOL_ROOT/dir$i/$tfile $numfiles ||
871 error "createmany $POOL_ROOT/dir$i/$tfile failed!"
873 for file in $POOL_ROOT/dir$i/*; do
874 check_file_in_osts $file $i
882 run_test 15 "One directory per OST/pool"
886 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
890 create_pool_nofail $POOL
892 add_pool $POOL $TGT_HALF "$TGT_UUID2"
894 local dir=$POOL_ROOT/$tdir
895 create_dir $dir $POOL
897 for i in $(seq 1 10); do
902 createmany -o $dir/$tfile $numfiles ||
903 error "createmany $dir/$tfile failed!"
905 for file in $dir/*; do
906 check_file_in_pool $file $POOL
909 rm -rf $POOL_ROOT/$tdir
913 run_test 16 "Inheritance of pool properties"
917 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
921 create_pool_nofail $POOL
923 add_pool $POOL $TGT_ALL "$TGT_UUID"
925 local dir=$POOL_ROOT/dir
926 create_dir $dir $POOL
928 createmany -o $dir/${tfile}1_ $numfiles ||
929 error "createmany $dir/${tfile}1_ failed!"
931 for file in $dir/*; do
932 check_file_in_pool $file $POOL
937 createmany -o $dir/${tfile}2_ $numfiles ||
938 error "createmany $dir/${tfile}2_ failed!"
943 run_test 17 "Referencing an empty pool"
952 wait_delete_completed >/dev/null # give pending IO a chance to go to disk
953 stat=$(createmany -o $cdir/${tfile} -$numsec | tail -1)
954 files=$(echo $stat | cut -f 2 -d ' ')
956 unlinkmany $cdir/${tfile} $files > /dev/null
964 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
967 local plaindir=$POOL_ROOT/plaindir
968 local pooldir=$POOL_ROOT/pooldir
974 for i in $(seq 1 $iter); do
975 echo "Create performance, iteration $i, $numsec seconds x 3"
977 files1=$(create_perf $plaindir $numsec)
978 echo "iter $i: $files1 creates without pool"
979 f1=$(($f1 + $files1))
981 create_pool_nofail $POOL > /dev/null
982 add_pool $POOL $TGT_ALL "$TGT_UUID" > /dev/null
983 create_dir $pooldir $POOL
984 files2=$(create_perf $pooldir $numsec)
985 echo "iter $i: $files2 creates with pool"
986 f2=$(($f2 + $files2))
988 destroy_pool $POOL > /dev/null
989 files3=$(create_perf $pooldir $numsec)
990 echo "iter $i: $files3 creates with missing pool"
991 f3=$(($f3 + $files3))
996 echo Avg files created in $numsec seconds without pool: $((files1 / iter))
997 echo Avg files created in $numsec seconds with pool: $((files2 / iter))
998 echo Avg files created in $numsec seconds missing pool: $((files3 / iter))
1000 # Set this high until we establish a baseline for what the degradation
1003 diff=$((($files1 - $files2) * 100 / $files1))
1004 echo "No pool / wide pool: $diff %."
1005 [ $diff -gt $max ] &&
1006 error_ignore 23408 "Degradation with wide pool is $diff% > $max%"
1009 diff=$((($files1 - $files3) * 100 / $files1))
1010 echo "No pool / missing pool: $diff %."
1011 [ $diff -gt $max ] &&
1012 error_ignore 23408 "Degradation with wide pool is $diff% > $max%"
1016 run_test 18 "File create in a directory which references a deleted pool"
1020 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1022 local dir1=$POOL_ROOT/dir1
1023 local dir2=$POOL_ROOT/dir2
1026 create_pool_nofail $POOL
1028 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1030 create_dir $dir1 $POOL
1031 createmany -o $dir1/${tfile} $numfiles ||
1032 error "createmany $dir1/${tfile} failed!"
1033 for file in $dir1/*; do
1034 check_file_in_pool $file $POOL
1038 createmany -o $dir2/${tfile} $numfiles ||
1039 error "createmany $dir2/${tfile} failed!"
1040 for file in $dir2/*; do
1041 check_file_not_in_pool $file $POOL
1048 run_test 19 "Pools should not come into play when not specified"
1052 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1054 local dir1=$POOL_ROOT/dir1
1055 local dir2=$dir1/dir2
1056 local dir3=$dir1/dir3
1060 create_pool_nofail $POOL
1061 create_pool_nofail $POOL2
1063 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1065 local start=$(printf %04x $((TGT_FIRST + 1)))
1066 TGT=$(for i in $(seq 0x$start 2 0x$TGT_MAX); do \
1067 printf "$FSNAME-OST%04x_UUID " $i; done)
1068 add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1070 create_dir $dir1 $POOL
1071 create_file $dir1/file1 $POOL2
1072 create_dir $dir2 $POOL2
1075 $SETSTRIPE -c 1 $dir3 # No pool assignment
1077 $SETSTRIPE -c 1 $dir2/file4 # No pool assignment
1079 check_file_in_pool $dir1/file1 $POOL2
1080 check_file_in_pool $dir2/file2 $POOL2
1082 check_dir_not_in_pool $dir3 $POOL
1083 check_dir_not_in_pool $dir3 $POOL2
1085 check_file_not_in_pool $dir3/file3 $POOL
1086 check_file_not_in_pool $dir3/file3 $POOL2
1088 check_file_not_in_pool $dir2/file4 $POOL
1089 check_file_not_in_pool $dir2/file4 $POOL2
1095 run_test 20 "Different pools in a directory hierarchy."
1099 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1100 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1104 local dir=$POOL_ROOT/dir
1106 create_pool_nofail $POOL
1108 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1110 create_dir $dir $POOL $OSTCOUNT
1111 create_file $dir/file1 $POOL $OSTCOUNT
1112 $GETSTRIPE -v $dir/file1
1113 check_file_in_pool $dir/file1 $POOL
1119 run_test 21 "OST pool with fewer OSTs than stripe count"
1127 for c in $(seq 1 10); do
1128 echo "Pool $pool, iteration $c"
1129 do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool \
1130 OST[$TGT_FIRST-$TGT_MAX/$step] 2>/dev/null
1131 local TGT_SECOND=$(printf %04x $((TGT_FIRST + $step)))
1132 if [ $((16#$TGT_SECOND)) -le $((16#$TGT_MAX)) ]; then
1133 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$pool \
1134 OST[$TGT_SECOND-$TGT_MAX/$step]
1137 echo loop for $pool complete
1142 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1143 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1147 create_pool_nofail $POOL
1148 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
1149 create_pool_nofail $POOL2
1150 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
1155 create_dir $POOL_ROOT $POOL
1156 createmany -o $POOL_ROOT/${tfile} $numfiles ||
1157 error "createmany $POOL_ROOT/${tfile} failed!"
1162 run_test 22 "Simultaneous manipulation of a pool"
1166 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1167 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1170 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS || {
1171 skip_env "User $RUNAS_ID does not exist - skipping"
1177 local BUNIT_SZ=1024 # min block quota unit(kB)
1178 local LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1)))
1179 local dir=$POOL_ROOT/dir
1180 local file="$dir/$tfile-quota"
1182 create_pool_nofail $POOL
1184 local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
1185 printf "$FSNAME-OST%04x_UUID " $i; done)
1186 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1187 create_dir $dir $POOL
1189 $LFS quotaoff -ug $MOUNT
1190 $LFS quotacheck -ug $MOUNT
1191 $LFS setquota -u $RUNAS_ID -b $LIMIT -B $LIMIT $dir
1193 $LFS quota -v -u $RUNAS_ID $dir
1195 $LFS setstripe $file -c 1 -p $POOL
1196 chown $RUNAS_ID.$RUNAS_GID $file
1199 # This does two "dd" runs to ensure that the quota failure is returned
1200 # to userspace when we check. The first "dd" might otherwise complete
1201 # without error if it is only writing into cache.
1202 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
1203 count=$((BUNIT_SZ*2)) 2>&1)
1204 echo $stat | grep "Disk quota exceeded" > /dev/null
1205 if [ $? -eq 0 ]; then
1206 $LFS quota -v -u $RUNAS_ID $dir
1207 cancel_lru_locks osc
1208 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
1209 count=$BUNIT_SZ seek=$((BUNIT_SZ*2)) 2>&1)
1212 [[ $RC -eq 0 ]] && error "second dd did not fail."
1213 echo $stat | grep "Disk quota exceeded" > /dev/null
1214 [[ $? -eq 1 ]] && error "second dd did not fail with EDQUOT."
1216 log "first dd failed with EDQUOT."
1218 $LFS quota -v -u $RUNAS_ID $dir
1220 run_test 23a "OST pools and quota"
1224 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1225 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return 0
1228 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS || {
1229 skip_env "User $RUNAS_ID does not exist - skipping"
1235 local BUNIT_SZ=1024 # min block quota unit(kB)
1236 local LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1)))
1237 local dir=$POOL_ROOT/dir
1238 local file="$dir/$tfile-quota"
1240 create_pool_nofail $POOL
1242 local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
1243 printf "$FSNAME-OST%04x_UUID " $i; done)
1244 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1245 create_dir $dir $POOL
1247 AVAIL=$($LFS df -p $POOL $dir | awk '/summary/ { print $4 }')
1248 [ $AVAIL -gt $MAXFREE ] &&
1249 skip_env "Filesystem space $AVAIL is larger than $MAXFREE limit" &&
1251 log "OSTCOUNT=$OSTCOUNT, OSTSIZE=$OSTSIZE"
1252 log "MAXFREE=$MAXFREE, AVAIL=$AVAIL, SLOW=$SLOW"
1254 $LFS quotaoff -ug $MOUNT
1255 chown $RUNAS_ID.$RUNAS_ID $dir
1258 while [ $RC -eq 0 ]; do
1260 stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file}$i bs=1M \
1261 count=$((LIMIT * 4)) 2>&1)
1264 if [ $RC -eq 1 ]; then
1265 echo $stat | grep -q "Disk quota exceeded"
1266 [[ $? -eq 0 ]] && error "dd failed with EDQUOT with quota off"
1268 echo $stat | grep -q "No space left on device"
1270 error "dd did not fail with ENOSPC"
1278 run_test 23b "OST pools and OOS"
1282 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1283 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1291 create_pool_nofail $POOL
1293 add_pool $POOL $TGT_ALL "$TGT_UUID"
1295 create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1297 mkdir $POOL_ROOT/dir2
1298 $SETSTRIPE $POOL_ROOT/dir2 -p $POOL -s 65536 -i 0 -c 1 ||
1299 error "$SETSTRIPE $POOL_ROOT/dir2 failed"
1301 mkdir $POOL_ROOT/dir3
1302 $SETSTRIPE $POOL_ROOT/dir3 -s 65536 -i 0 -c 1 ||
1303 error "$SETSTRIPE $POOL_ROOT/dir3 failed"
1305 mkdir $POOL_ROOT/dir4
1307 for i in 1 2 3 4; do
1308 dir=${POOL_ROOT}/dir${i}
1317 createmany -o $dir/${tfile} $numfiles ||
1318 error "createmany $dir/${tfile} failed!"
1319 res=$($GETSTRIPE -v $dir | grep "^stripe_count:")
1320 if [ $? -ne 0 ]; then
1321 res=$($GETSTRIPE -v $dir | grep "^(Default) ")
1322 pool=$(cut -f 9 -d ' ' <<< $res)
1323 index=$(cut -f 7 -d ' ' <<< $res)
1324 size=$(cut -f 5 -d ' ' <<< $res)
1325 count=$(cut -f 3 -d ' ' <<< $res)
1327 pool=$(cut -f 8 -d ' ' <<< $res)
1328 index=$(cut -f 6 -d ' ' <<< $res)
1329 size=$(cut -f 4 -d ' ' <<< $res)
1330 count=$(cut -f 2 -d ' ' <<< $res)
1333 for file in $dir/*; do
1334 if [ "$pool" != "" ]; then
1335 check_file_in_pool $file $pool
1337 pool1=$(file_pool $file)
1338 count1=$($GETSTRIPE -v $file | grep "^lmm_stripe_count:" |
1339 tr -d '[:blank:]' | cut -f 2 -d ':')
1340 size1=$($GETSTRIPE -v $file | grep "^lmm_stripe_size:" |
1341 tr -d '[:blank:]' | cut -f 2 -d ':')
1342 [[ "$pool" != "$pool1" ]] &&
1343 error "Pool name ($pool) not inherited in $file($pool1)"
1344 [[ "$count" != "$count1" ]] &&
1345 error "Stripe count ($count) not inherited in $file ($count1)"
1346 [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] &&
1347 error "Stripe size ($size) not inherited in $file ($size1)"
1355 run_test 24 "Independence of pool from other setstripe parameters"
1359 local dev=$(mdsdevname ${SINGLEMDS//mds/})
1360 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1364 for i in $(seq 10); do
1365 create_pool_nofail $POOL$i
1366 do_facet $SINGLEMDS "lctl pool_add $FSNAME.$POOL$i OST0000; sync"
1367 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL$i |
1368 sort -u | tr '\n' ' ' " "$FSNAME-OST0000_UUID " >/dev/null ||
1369 error "pool_add failed: $1; $2"
1371 stop $SINGLEMDS || return 1
1372 start $SINGLEMDS ${dev} $MDS_MOUNT_OPTS ||
1373 { error "Failed to start $SINGLEMDS after stopping" && break; }
1374 wait_osc_import_state mds ost FULL
1378 # Veriy that the pool got created and is usable
1379 df $POOL_ROOT > /dev/null
1381 # Make sure OST0 can be striped on
1382 $SETSTRIPE -o 0 -c 1 $POOL_ROOT/$tfile
1383 STR=$($GETSTRIPE $POOL_ROOT/$tfile | grep 0x | cut -f2 | tr -d " ")
1384 rm $POOL_ROOT/$tfile
1385 if [[ "$STR" == "0" ]]; then
1386 echo "Creating a file in pool$i"
1387 create_file $POOL_ROOT/file$i $POOL$i || break
1388 check_file_in_pool $POOL_ROOT/file$i $POOL$i || break
1390 echo "OST 0 seems to be unavailable. Try later."
1396 run_test 25 "Create new pool and restart MDS"
1399 [[ $OSTCOUNT -le 2 ]] && skip_env "Need at least 3 OSTs" && return
1401 local dev=$(mdsdevname ${SINGLEMDS//mds/})
1402 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1406 create_pool_nofail $POOL2
1408 do_facet $SINGLEMDS "lctl pool_add $FSNAME.$POOL2 OST0000; sync"
1409 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL2 |
1410 sort -u | grep $FSNAME-OST0000_UUID " "$FSNAME-OST0000_UUID" ||
1411 error "pool_add failed: $1; $2"
1413 do_facet $SINGLEMDS "lctl pool_add $FSNAME.$POOL2 OST0002; sync"
1414 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL2 |
1415 sort -u | grep $FSNAME-OST0002_UUID" "$FSNAME-OST0002_UUID" ||
1416 error "pool_add failed: $1; $2"
1418 # Veriy that the pool got created and is usable
1420 echo "Creating files in $POOL2"
1422 for ((i = 0; i < 10; i++)); do
1423 #OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
1424 #Fail OST0000 to ensure objects create on the other OST in the pool
1425 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
1426 do_facet $SINGLEMDS lctl set_param fail_val=0
1427 create_file $POOL_ROOT/file$i $POOL2 1 -1 || break
1428 do_facet $SINGLEMDS lctl set_param fail_loc=0
1429 check_file_in_pool $POOL_ROOT/file$i $POOL2 || break
1433 run_test 26 "Choose other OSTs in the pool first in the creation remedy"
1437 complete $(basename $0) $SECONDS
1438 cleanup_pools $FSNAME
1439 check_and_cleanup_lustre