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
37 SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
38 GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"}
40 MAXFREE=${MAXFREE:-$((2000000 * OSTCOUNT))}
44 POOL2=${POOL2:-${POOL}2}
45 POOL3=${POOL3:-${POOL}3}
46 NON_EXISTANT_POOL=nonexistantpool
47 NON_EXISTANT_FS=nonexistantfs
48 INVALID_POOL=some_invalid_pool_name
50 TGT_FIRST=$(printf %04x 0)
51 TGT_MAX=$(printf %04x $((TGT_COUNT-1)))
53 TGT_LIST=$(seq 0x$TGT_FIRST $TGT_STEP 0x$TGT_MAX)
54 TGT_LIST2=$(seq 0x$TGT_FIRST 2 0x$TGT_MAX)
56 TGT_ALL="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/1]"
57 TGT_HALF="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]"
59 TGT_UUID=$(for i in $TGT_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
60 TGT_UUID2=$(for i in $TGT_LIST2; do printf "$FSNAME-OST%04x_UUID " $i; done)
65 local count=${3:-"-1"}
70 $SETSTRIPE -c $count -p $pool $dir -o $idx
72 $SETSTRIPE -c $count -p $pool $dir
75 error "$SETSTRIPE -p $pool $dir failed."
81 local count=${3:-"-1"}
82 local index=${4:-"-1"}
84 $SETSTRIPE -o $index -c $count -p $pool $file
86 error "$SETSTRIPE -p $pool $file failed."
92 for i in $(do_facet $SINGLEMDS lctl pool_list $FSNAME.$pool |
93 grep -v "^Pool:" | sed -e 's/_UUID$//;s/^.*-OST//'); do
94 res="$res $(printf "%d" 0x$i)"
102 local res=$($GETSTRIPE $dir | grep "^stripe_count:" |
103 cut -d ':' -f 5 | tr -d "[:blank:]")
104 if [[ "$res" != "$pool" ]]; then
105 error found $res instead of $pool
112 check_file_in_pool() {
113 local osts=$(osts_in_pool $2)
114 check_file_in_osts $1 "$osts" $3
117 check_file_in_osts() {
119 local pool_list=${2:-$TGT_LIST}
121 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
124 found=$(echo :$pool_list: | tr " " ":" | grep :$i:)
125 if [[ "$found" == "" ]]; then
126 echo "pool list: $pool_list"
127 echo "striping: $res"
129 error "$file not allocated from OSTs $pool_list."
134 local ost_count=$($GETSTRIPE $file | grep 0x | wc -l)
135 [[ -n "$count" ]] && [[ $ost_count -ne $count ]] &&
136 { error "Stripe count $count expected; got $ost_count" && return 1;}
142 $GETSTRIPE -v $1 | grep "^lmm_pool:" | tr -d "[:blank:]" | cut -f 2 -d ':'
145 check_file_not_in_pool() {
148 local res=$(file_pool $file)
150 if [[ "$res" == "$pool" ]]; then
151 error "File $file is in pool: $res"
158 check_dir_not_in_pool() {
161 local res=$($GETSTRIPE -v $dir | grep "^stripe_count" | head -1 |
163 if [[ "$res" == "$pool" ]]; then
164 error "File $dir is in pool: $res"
172 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool" "" ||
173 error "Failed to remove targets from pool: $pool"
179 local tgt="${3}$(lctl get_param -n lov.$FSNAME-*.pools.$pool |
180 sort -u | tr '\n' ' ')"
182 do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool $osts
184 [[ $RC -ne 0 ]] && return $RC
186 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool |
187 sort -u | tr '\n' ' ' " "$tgt" >/dev/null || RC=1
188 [[ $RC -ne 0 ]] && error "pool_add failed: $1; $2"
192 create_pool_nofail() {
193 create_pool $FSNAME.$1
194 if [[ $? != 0 ]]; then
195 error "Pool creation of $1 failed"
200 create_pool $FSNAME.$1
201 if [[ $? == 0 ]]; then
202 error "Pool creation of $1 succeeded; should have failed"
207 # Destroy pools from previous test runs
208 for p in $(do_facet $SINGLEMDS lctl pool_list $FSNAME | grep $POOL); do
211 rm -rf $DIR/d0.${TESTSUITE}
219 trap "cleanup_tests $FSNAME" EXIT
223 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
224 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
228 # Tests for new commands added
234 run_test 1a "Create a pool with a 1 character pool name"
238 create_pool_nofail ${POOL}12
239 destroy_pool ${POOL}12
241 run_test 1b "Create a pool with a 10 character pool name"
245 create_pool_nofail ${POOL}12345678
246 destroy_pool ${POOL}12345678
248 run_test 1c "Create a pool with a 16 character pool name"
252 create_pool_fail ${POOL}123456789
254 run_test 1d "Create a pool with a 17 char pool name; should fail"
258 local pool_name="$POOL"
259 for ((i = 1; i <= 991; i++)); do pool_name=${pool_name}"o"; done
260 create_pool_fail $pool_name
262 run_test 1e "Create a pool with a 1000 char pool name; should fail"
266 do_facet $SINGLEMDS lctl pool_new .$POOL 2>/dev/null
268 error "pool_new did not fail even though fs-name was missing"
270 run_test 1f "pool_new should fail if fs-name is missing"
274 do_facet $SINGLEMDS lctl pool_new $POOL 2>/dev/null
276 error "pool_new did not fail even though fs-name was missing"
278 run_test 1g "pool_new should fail if fs-name is missing"
282 do_facet $SINGLEMDS lctl pool_new ${FSNAME}. 2>/dev/null
284 error "pool_new did not fail even though pool name was missing"
286 run_test 1h "pool_new should fail if poolname is missing"
290 do_facet $SINGLEMDS lctl pool_new . 2>/dev/null
292 error "pool_new did not fail even if pool and fs-name were missing"
294 run_test 1i "pool_new should fail if poolname and fs-name are missing"
298 do_facet $SINGLEMDS lctl pool_new ${FSNAME},$POOL 2>/dev/null
300 error "pool_new did not fail even though pool name format was wrong"
302 run_test 1j "pool_new should fail if poolname format is wrong"
306 do_facet $SINGLEMDS lctl pool_new ${FSNAME}/$POOL 2>/dev/null
308 error "pool_new did not fail even though pool name format was wrong"
310 run_test 1k "pool_new should fail if poolname format is wrong"
314 create_pool_nofail $POOL2
315 do_facet $SINGLEMDS lctl pool_new ${FSNAME}.$POOL2 2>/dev/null
317 error "pool_new did not fail even though $POOL2 existed"
320 run_test 1m "pool_new did not fail even though $POOL2 existed"
326 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
328 error "pool_add did not fail even though $POOL did not exist"
330 run_test 2a "pool_add: non-existant pool $POOL"
334 do_facet $SINGLEMDS lctl pool_add $FSNAME.${POOL}1234567890 \
335 $FSNAME-OST0000 2>/dev/null
337 error "pool_add did not fail even though pool name was invalid."
339 run_test 2b "pool_add: Invalid pool name"
341 # Testing various combinations of OST name list
347 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
348 [[ $? -ne 0 ]] || destroy_pool $POOL
350 create_pool_nofail $POOL
353 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
354 RC=$?; [[ $RC -eq 0 ]] ||
355 error "pool_add failed. $FSNAME $POOL OST0000: $RC"
356 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
360 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
361 RC=$?; [[ $RC -eq 0 ]] ||
362 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000: $RC"
363 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
366 # 3. $FSNAME-OST0000_UUID
367 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
368 RC=$?; [[ $RC -eq 0 ]] ||
369 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000_UUID: $RC"
370 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
373 # 4. $FSNAME-OST[0,1,2,3,]
375 for i in $TGT_LIST; do TGT=${TGT}$(printf "%04x," $i); done
377 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
378 [[ $? -eq 0 ]] || error "pool_add failed. $FSNAME.$POOL $TGT. $RC"
379 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT
382 # 5. $FSNAME-OST[0-5/1]
383 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
384 RC=$?; [[ $RC -eq 0 ]] ||
385 error "pool_add failed. $FSNAME $POOL" "$TGT_ALL $RC"
386 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL |
387 sort -u | tr '\n' ' ' " "$TGT_UUID" || error "Add to pool failed"
388 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
393 run_test 2c "pool_add: OST index combinations"
400 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
401 [[ $? -ne 0 ]] || destroy_pool $POOL
403 create_pool_nofail $POOL
405 TGT=$(printf "$FSNAME-OST%04x_UUID " $OSTCOUNT)
406 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
407 RC=$?; [[ $RC -ne 0 ]] ||
408 error "pool_add succeeded for an OST ($TGT) that does not exist."
412 run_test 2d "pool_add: OSTs that don't exist should be rejected"
420 $LCTL get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
421 [[ $? -ne 0 ]] || destroy_pool $POOL
423 create_pool_nofail $POOL
425 TGT="$FSNAME-OST0000_UUID "
426 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
427 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL |
428 sort -u | tr '\n' ' ' " "$TGT" || error "Add to pool failed"
429 RESULT=$(do_facet $SINGLEMDS \
430 "LOCALE=C $LCTL pool_add $FSNAME.$POOL $TGT 2>&1")
435 error "pool_add succeeded for an OST that was already in the pool."
437 [[ $(grep "already in pool" <<< $RESULT) ]] ||
438 error "pool_add failed as expected but error message not as expected."
442 run_test 2e "pool_add: OST already in a pool should be rejected"
446 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
447 [[ $? -ne 0 ]] || destroy_pool $POOL
449 do_facet $SINGLEMDS \
450 lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
452 error "pool_remove did not fail even though pool did not exist."
454 run_test 3a "pool_remove: non-existant pool"
458 do_facet $SINGLEMDS \
459 lctl pool_remove ${NON_EXISTANT_FS}.$POOL OST0000 2>/dev/null
461 error "pool_remove did not fail even though fsname did not exist."
463 run_test 3b "pool_remove: non-existant fsname"
467 do_facet $SINGLEMDS lctl pool_remove $FSNAME.p1234567891234567890 \
468 $FSNAME-OST0000 2>/dev/null
470 error "pool_remove did not fail even though pool name was invalid."
472 run_test 3c "pool_remove: Invalid pool name"
474 # Testing various combinations of OST name list
477 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
478 [[ $? -ne 0 ]] || destroy_pool $POOL
480 create_pool_nofail $POOL
481 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
482 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
483 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL OST0000"
486 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
487 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
488 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000"
491 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
492 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
494 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000_UUID"
497 add_pool $POOL $TGT_ALL "$TGT_UUID"
498 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
499 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL" $TGT_ALL
504 run_test 3d "pool_remove: OST index combinations"
508 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
509 [[ $? -ne 0 ]] || destroy_pool $POOL
511 do_facet $SINGLEMDS lctl pool_destroy $FSNAME.$POOL 2>/dev/null
513 error "pool_destroy did not fail even though pool did not exist."
515 run_test 4a "pool_destroy: non-existant pool"
519 do_facet $SINGLEMDS lctl pool_destroy ${NON_EXISTANT_FS}.$POOL 2>/dev/null
521 error "pool_destroy did not fail even though filesystem did not exist."
523 run_test 4b "pool_destroy: non-existant fs-name"
527 create_pool_nofail $POOL
528 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
530 do_facet $SINGLEMDS lctl pool_destroy ${FSNAME}.$POOL
531 [[ $? -ne 0 ]] || error "pool_destroy succeeded with a non-empty pool."
534 run_test 4c "pool_destroy: non-empty pool"
539 $LCMD pool_list 2>/dev/null
540 [[ $? -ne 0 ]] || error "pool_list did not fail even though fsname missing."
542 destroy_pool $POOL 2>/dev/null
543 destroy_pool $POOL2 2>/dev/null
545 create_pool_nofail $POOL
546 create_pool_nofail $POOL2
547 $LCMD pool_list $FSNAME
548 [[ $? -eq 0 ]] || error "pool_list $FSNAME failed."
550 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
552 $LCMD pool_list $FSNAME.$POOL
553 [[ $? -eq 0 ]] || error "pool_list $FSNAME.$POOL failed."
555 $LCMD pool_list ${NON_EXISTANT_FS} 2>/dev/null
556 [[ $? -ne 0 ]] || error "pool_list did not fail for fsname $NON_EXISTANT_FS"
558 $LCMD pool_list ${FSNAME}.$NON_EXISTANT_POOL 2>/dev/null
559 [[ $? -ne 0 ]] || error "pool_list did not fail for pool $NON_EXISTANT_POOL"
561 if [[ ! $(grep $SINGLEMDS <<< $LCMD) ]]; then
562 echo $LCMD pool_list $DIR
564 [[ $? -eq 0 ]] || error "pool_list failed for $DIR"
567 $LCMD pool_list ${DIR}/d1
568 [[ $? -eq 0 ]] || error "pool_list failed for ${DIR}/d1"
571 rm -rf ${DIR}nonexistant
572 $LCMD pool_list ${DIR}nonexistant 2>/dev/null
574 error "pool_list did not fail for invalid mountpoint ${DIR}nonexistant"
582 # Issue commands from client
586 # Issue commands from MDS
587 sub_test_5 "do_facet $SINGLEMDS lctl"
588 sub_test_5 "do_facet $SINGLEMDS lfs"
591 run_test 5 "lfs/lctl pool_list"
595 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
596 local POOL_DIR=$POOL_ROOT/dir_tst
597 local POOL_FILE=$POOL_ROOT/file_tst
599 create_pool_nofail $POOL
601 do_facet $SINGLEMDS lctl pool_list $FSNAME
602 [[ $? -eq 0 ]] || error "pool_list $FSNAME failed."
604 add_pool $POOL $TGT_ALL "$TGT_UUID"
607 $SETSTRIPE -c -1 -p $POOL $POOL_DIR
608 [[ $? -eq 0 ]] || error "$SETSTRIPE -p $POOL failed."
609 check_dir_in_pool $POOL_DIR $POOL
611 # If an invalid pool name is specified, the command should fail
612 $SETSTRIPE -c 2 -p $INVALID_POOL $POOL_DIR 2>/dev/null
613 [[ $? -ne 0 ]] || error "setstripe to invalid pool did not fail."
615 # If the pool name does not exist, the command should fail
616 $SETSTRIPE -c 2 -p $NON_EXISTANT_POOL $POOL_DIR 2>/dev/null
617 [[ $? -ne 0 ]] || error "setstripe to non-existant pool did not fail."
619 # lfs setstripe should work as before if a pool name is not specified.
620 $SETSTRIPE -c -1 $POOL_DIR
621 [[ $? -eq 0 ]] || error "$SETSTRIPE -p $POOL_DIR failed."
622 $SETSTRIPE -c -1 $POOL_FILE
623 [[ $? -eq 0 ]] || error "$SETSTRIPE -p $POOL_FILE failed."
625 # lfs setstripe should fail if a start index that is outside the
627 create_pool_nofail $POOL2
628 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
629 $SETSTRIPE -o 1 -p $POOL2 $ROOT_POOL/$tfile 2>/dev/null
631 error "$SETSTRIPE with start index outside the pool did not fail."
634 run_test 6 "getstripe/setstripe"
638 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
640 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
642 create_pool_nofail $POOL
643 create_pool_nofail $POOL2
645 local start=$(printf %04x $((TGT_FIRST + 1)))
646 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
647 $FSNAME-OST[$start-$TGT_MAX/2]
649 add_pool $POOL $TGT_HALF "$TGT_UUID2"
651 create_dir $POOL_ROOT/dir1 $POOL
652 create_dir $POOL_ROOT/dir2 $POOL2
653 check_dir_in_pool $POOL_ROOT/dir1 $POOL
654 check_dir_in_pool $POOL_ROOT/dir1 $POOL
657 createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
658 error "createmany $POOL_ROOT/dir1/$tfile failed!"
660 for file in $POOL_ROOT/dir1/*; do
661 check_file_in_pool $file $POOL
664 createmany -o $POOL_ROOT/dir2/$tfile $numfiles ||
665 error "createmany $POOL_ROOT/dir2/$tfile failed!"
666 for file in $POOL_ROOT/dir2/*; do
667 check_file_in_pool $file $POOL2
670 rm -rf $POOL_ROOT/dir?
674 run_test 11 "OSTs in overlapping/multiple pools"
678 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
680 [[ $OSTCOUNT -le 2 ]] && skip_env "Need at least 3 OSTs" && return
682 create_pool_nofail $POOL
683 create_pool_nofail $POOL2
685 local start=$(printf %04x $((TGT_FIRST + 1)))
686 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
687 $FSNAME-OST[$start-$TGT_MAX/2]
689 add_pool $POOL $TGT_HALF "$TGT_UUID2"
691 echo creating some files in $POOL and $POOL2
693 create_dir $POOL_ROOT/dir1 $POOL
694 create_dir $POOL_ROOT/dir2 $POOL2
695 create_file $POOL_ROOT/file1 $POOL
696 create_file $POOL_ROOT/file2 $POOL2
698 echo Checking the files created
699 check_dir_in_pool $POOL_ROOT/dir1 $POOL
700 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
701 check_file_in_pool $POOL_ROOT/file1 $POOL
702 check_file_in_pool $POOL_ROOT/file2 $POOL2
704 echo Changing the pool membership
705 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST[$TGT_FIRST]
706 do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL
707 FIRST_UUID=$(echo $TGT_UUID | awk '{print $1}')
708 add_pool $POOL2 $FSNAME-OST[$TGT_FIRST] "$FIRST_UUID "
709 do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL2
711 echo Checking the files again
712 check_dir_in_pool $POOL_ROOT/dir1 $POOL
713 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
714 check_file_in_osts $POOL_ROOT/file1 "$TGT_LIST2"
715 check_file_in_osts $POOL_ROOT/file2 "$(seq 0x$start 2 0x$TGT_MAX)"
717 echo Creating some more files
718 create_dir $POOL_ROOT/dir3 $POOL
719 create_dir $POOL_ROOT/dir4 $POOL2
720 create_file $POOL_ROOT/file3 $POOL
721 create_file $POOL_ROOT/file4 $POOL2
723 echo Checking the new files
724 check_file_in_pool $POOL_ROOT/file3 $POOL
725 check_file_in_pool $POOL_ROOT/file4 $POOL2
729 run_test 12 "OST Pool Membership"
733 [[ $OSTCOUNT -le 2 ]] && skip_env "Need at least 3 OSTs" && return
735 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
739 create_pool_nofail $POOL
740 add_pool $POOL $TGT_ALL "$TGT_UUID"
742 create_dir $POOL_ROOT/dir1 $POOL -1
743 createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
744 error "createmany $POOL_ROOT/dir1/$tfile failed!"
745 for file in $POOL_ROOT/dir1/*; do
746 check_file_in_pool $file $POOL $OSTCOUNT
749 create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
750 create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST + 1))
751 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST + 2))
752 check_file_in_pool $POOL_ROOT/dir1/file1 $POOL 1
753 check_file_in_pool $POOL_ROOT/dir1/file2 $POOL 1
754 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST + 2))
755 check_file_in_osts $POOL_ROOT/dir1/file1 $((16#$TGT_FIRST))
756 check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST + 1))"
757 check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST + 2))"
759 create_dir $POOL_ROOT/dir2 $POOL $count
760 createmany -o $POOL_ROOT/dir2/$tfile- $numfiles ||
761 error "createmany $POOL_ROOT/dir2/$tfile- failed!"
762 for file in $POOL_ROOT/dir2/*; do
763 check_file_in_pool $file $POOL $count
766 create_dir $POOL_ROOT/dir3 $POOL $count $((TGT_FIRST + 1))
767 createmany -o $POOL_ROOT/dir3/$tfile- $numfiles ||
768 error "createmany $POOL_ROOT/dir3/$tfile- failed!"
769 for file in $POOL_ROOT/dir3/*; do
770 check_file_in_pool $file $POOL $count
773 create_dir $POOL_ROOT/dir4 $POOL 1
774 createmany -o $POOL_ROOT/dir4/$tfile- $numfiles ||
775 error "createmany $POOL_ROOT/dir4/$tfile- failed!"
776 for file in $POOL_ROOT/dir4/*; do
777 check_file_in_pool $file $POOL 1
780 create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST + 2))
781 createmany -o $POOL_ROOT/dir5/$tfile- $numfiles ||
782 error "createmany $POOL_ROOT/dir5/$tfile- failed!"
783 for file in $POOL_ROOT/dir5/*; do
784 check_file_in_pool $file $POOL 1
785 check_file_in_osts $file "$((TGT_FIRST + 2))"
788 rm -rf $POOL_ROOT/dir[1-5]/
792 run_test 13 "Striping characteristics in a pool"
796 [[ $OSTCOUNT -le 2 ]] && skip_env "Need at least 3 OSTs" && return
798 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
802 [ $OSTSIZE -gt $((MAXFREE / OSTCOUNT)) ] &&
803 skip_env "OST size $OSTSIZE is larger than $((MAXFREE / OSTCOUNT))" &&
806 create_pool_nofail $POOL
807 create_pool_nofail $POOL2
809 add_pool $POOL $TGT_HALF "$TGT_UUID2"
810 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
812 create_dir $POOL_ROOT/dir1 $POOL 1
813 create_file $POOL_ROOT/dir1/file $POOL 1
814 local OST=$($GETSTRIPE -i $POOL_ROOT/dir1/file)
816 while [[ $i -lt $numfiles ]]; do
818 [[ $OST -gt $((16#$TGT_MAX)) ]] && OST=$TGT_FIRST
820 # echo "Iteration: $i OST: $OST"
821 create_file $POOL_ROOT/dir1/file${i} $POOL 1
822 check_file_in_pool $POOL_ROOT/dir1/file${i} $POOL
826 # Fill up OST0 until it is nearly full.
827 # Create 9 files of size OST0_SIZE/10 each.
828 create_dir $POOL_ROOT/dir2 $POOL2 1
829 $LFS df $POOL_ROOT/dir2
830 OST0_SIZE=$($LFS df $POOL_ROOT/dir2 | awk '/\[OST:0\]/ { print $4 }')
831 FILE_SIZE=$((OST0_SIZE/1024/10))
832 echo "Filling OST0 with 9 files of ${FILE_SIZE}MB in $POOL_ROOT/dir2"
834 while [[ $i -lt 10 ]]; do
835 dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1M count=$FILE_SIZE
838 sleep 1 # get new statfs info
839 $LFS df $POOL_ROOT/dir2
841 # OST $TGT_FIRST is no longer favored; but it may still be used.
842 create_dir $POOL_ROOT/dir3 $POOL 1
843 create_file $POOL_ROOT/dir3/file $POOL 1
844 createmany -o $POOL_ROOT/dir3/$tfile- $numfiles ||
845 error "createmany $POOL_ROOT/dir3/$tfile- failed!"
846 for file in $POOL_ROOT/dir3/*; do
847 check_file_in_pool $file $POOL
854 run_test 14 "Round robin and QOS striping within a pool"
858 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
862 while [[ $i -lt $OSTCOUNT ]]; do
863 create_pool_nofail $POOL${i}
865 local tgt=$(printf "$FSNAME-OST%04x_UUID " $i)
866 add_pool $POOL${i} "$FSNAME-OST[$(printf %04x $i)]" "$tgt"
867 create_dir $POOL_ROOT/dir${i} $POOL${i}
868 createmany -o $POOL_ROOT/dir$i/$tfile $numfiles ||
869 error "createmany $POOL_ROOT/dir$i/$tfile failed!"
871 for file in $POOL_ROOT/dir$i/*; do
872 check_file_in_osts $file $i
880 run_test 15 "One directory per OST/pool"
884 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
888 create_pool_nofail $POOL
890 add_pool $POOL $TGT_HALF "$TGT_UUID2"
892 local dir=$POOL_ROOT/$tdir
893 create_dir $dir $POOL
895 for i in $(seq 1 10); do
900 createmany -o $dir/$tfile $numfiles ||
901 error "createmany $dir/$tfile failed!"
903 for file in $dir/*; do
904 check_file_in_pool $file $POOL
907 rm -rf $POOL_ROOT/$tdir
911 run_test 16 "Inheritance of pool properties"
915 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
919 create_pool_nofail $POOL
921 add_pool $POOL $TGT_ALL "$TGT_UUID"
923 local dir=$POOL_ROOT/dir
924 create_dir $dir $POOL
926 createmany -o $dir/${tfile}1_ $numfiles ||
927 error "createmany $dir/${tfile}1_ failed!"
929 for file in $dir/*; do
930 check_file_in_pool $file $POOL
935 createmany -o $dir/${tfile}2_ $numfiles ||
936 error "createmany $dir/${tfile}2_ failed!"
941 run_test 17 "Referencing an empty pool"
950 wait_delete_completed >/dev/null # give pending IO a chance to go to disk
951 stat=$(createmany -o $cdir/${tfile} -$numsec | tail -1)
952 files=$(echo $stat | cut -f 2 -d ' ')
954 unlinkmany $cdir/${tfile} $files > /dev/null
962 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
965 local plaindir=$POOL_ROOT/plaindir
966 local pooldir=$POOL_ROOT/pooldir
972 for i in $(seq 1 $iter); do
973 echo "Create performance, iteration $i, $numsec seconds x 3"
975 files1=$(create_perf $plaindir $numsec)
976 echo "iter $i: $files1 creates without pool"
977 f1=$(($f1 + $files1))
979 create_pool_nofail $POOL > /dev/null
980 add_pool $POOL $TGT_ALL "$TGT_UUID" > /dev/null
981 create_dir $pooldir $POOL
982 files2=$(create_perf $pooldir $numsec)
983 echo "iter $i: $files2 creates with pool"
984 f2=$(($f2 + $files2))
986 destroy_pool $POOL > /dev/null
987 files3=$(create_perf $pooldir $numsec)
988 echo "iter $i: $files3 creates with missing pool"
989 f3=$(($f3 + $files3))
994 echo Avg files created in $numsec seconds without pool: $((files1 / iter))
995 echo Avg files created in $numsec seconds with pool: $((files2 / iter))
996 echo Avg files created in $numsec seconds missing pool: $((files3 / iter))
998 # Set this high until we establish a baseline for what the degradation
1001 diff=$((($files1 - $files2) * 100 / $files1))
1002 echo "No pool / wide pool: $diff %."
1003 [ $diff -gt $max ] &&
1004 error_ignore 23408 "Degradation with wide pool is $diff% > $max%"
1007 diff=$((($files1 - $files3) * 100 / $files1))
1008 echo "No pool / missing pool: $diff %."
1009 [ $diff -gt $max ] &&
1010 error_ignore 23408 "Degradation with wide pool is $diff% > $max%"
1014 run_test 18 "File create in a directory which references a deleted pool"
1018 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1020 local dir1=$POOL_ROOT/dir1
1021 local dir2=$POOL_ROOT/dir2
1024 create_pool_nofail $POOL
1026 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1028 create_dir $dir1 $POOL
1029 createmany -o $dir1/${tfile} $numfiles ||
1030 error "createmany $dir1/${tfile} failed!"
1031 for file in $dir1/*; do
1032 check_file_in_pool $file $POOL
1036 createmany -o $dir2/${tfile} $numfiles ||
1037 error "createmany $dir2/${tfile} failed!"
1038 for file in $dir2/*; do
1039 check_file_not_in_pool $file $POOL
1046 run_test 19 "Pools should not come into play when not specified"
1050 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1052 local dir1=$POOL_ROOT/dir1
1053 local dir2=$dir1/dir2
1054 local dir3=$dir1/dir3
1058 create_pool_nofail $POOL
1059 create_pool_nofail $POOL2
1061 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1063 local start=$(printf %04x $((TGT_FIRST + 1)))
1064 TGT=$(for i in $(seq 0x$start 2 0x$TGT_MAX); do \
1065 printf "$FSNAME-OST%04x_UUID " $i; done)
1066 add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1068 create_dir $dir1 $POOL
1069 create_file $dir1/file1 $POOL2
1070 create_dir $dir2 $POOL2
1073 $SETSTRIPE -c 1 $dir3 # No pool assignment
1075 $SETSTRIPE -c 1 $dir2/file4 # No pool assignment
1077 check_file_in_pool $dir1/file1 $POOL2
1078 check_file_in_pool $dir2/file2 $POOL2
1080 check_dir_not_in_pool $dir3 $POOL
1081 check_dir_not_in_pool $dir3 $POOL2
1083 check_file_not_in_pool $dir3/file3 $POOL
1084 check_file_not_in_pool $dir3/file3 $POOL2
1086 check_file_not_in_pool $dir2/file4 $POOL
1087 check_file_not_in_pool $dir2/file4 $POOL2
1093 run_test 20 "Different pools in a directory hierarchy."
1097 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1098 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1102 local dir=$POOL_ROOT/dir
1104 create_pool_nofail $POOL
1106 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1108 create_dir $dir $POOL $OSTCOUNT
1109 create_file $dir/file1 $POOL $OSTCOUNT
1110 $GETSTRIPE -v $dir/file1
1111 check_file_in_pool $dir/file1 $POOL
1117 run_test 21 "OST pool with fewer OSTs than stripe count"
1125 for c in $(seq 1 10); do
1126 echo "Pool $pool, iteration $c"
1127 do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool \
1128 OST[$TGT_FIRST-$TGT_MAX/$step] 2>/dev/null
1129 local TGT_SECOND=$(printf %04x $((TGT_FIRST + $step)))
1130 if [ $((16#$TGT_SECOND)) -le $((16#$TGT_MAX)) ]; then
1131 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$pool \
1132 OST[$TGT_SECOND-$TGT_MAX/$step]
1135 echo loop for $pool complete
1140 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1141 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1145 create_pool_nofail $POOL
1146 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
1147 create_pool_nofail $POOL2
1148 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
1153 create_dir $POOL_ROOT $POOL
1154 createmany -o $POOL_ROOT/${tfile} $numfiles ||
1155 error "createmany $POOL_ROOT/${tfile} failed!"
1160 run_test 22 "Simultaneous manipulation of a pool"
1164 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1165 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1168 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS || {
1169 skip_env "User $RUNAS_ID does not exist - skipping"
1175 local BUNIT_SZ=1024 # min block quota unit(kB)
1176 local LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1)))
1177 local dir=$POOL_ROOT/dir
1178 local file="$dir/$tfile-quota"
1180 create_pool_nofail $POOL
1182 local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
1183 printf "$FSNAME-OST%04x_UUID " $i; done)
1184 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1185 create_dir $dir $POOL
1187 $LFS quotaoff -ug $MOUNT
1188 $LFS quotacheck -ug $MOUNT
1189 $LFS setquota -u $RUNAS_ID -b $LIMIT -B $LIMIT $dir
1191 $LFS quota -v -u $RUNAS_ID $dir
1193 $LFS setstripe $file -c 1 -p $POOL
1194 chown $RUNAS_ID.$RUNAS_GID $file
1197 # This does two "dd" runs to ensure that the quota failure is returned
1198 # to userspace when we check. The first "dd" might otherwise complete
1199 # without error if it is only writing into cache.
1200 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
1201 count=$((BUNIT_SZ*2)) 2>&1)
1202 echo $stat | grep "Disk quota exceeded" > /dev/null
1203 if [ $? -eq 0 ]; then
1204 $LFS quota -v -u $RUNAS_ID $dir
1205 cancel_lru_locks osc
1206 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
1207 count=$BUNIT_SZ seek=$((BUNIT_SZ*2)) 2>&1)
1210 [[ $RC -eq 0 ]] && error "second dd did not fail."
1211 echo $stat | grep "Disk quota exceeded" > /dev/null
1212 [[ $? -eq 1 ]] && error "second dd did not fail with EDQUOT."
1214 log "first dd failed with EDQUOT."
1216 $LFS quota -v -u $RUNAS_ID $dir
1218 run_test 23a "OST pools and quota"
1222 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1223 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return 0
1226 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS || {
1227 skip_env "User $RUNAS_ID does not exist - skipping"
1233 local BUNIT_SZ=1024 # min block quota unit(kB)
1234 local LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1)))
1235 local dir=$POOL_ROOT/dir
1236 local file="$dir/$tfile-quota"
1238 create_pool_nofail $POOL
1240 local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
1241 printf "$FSNAME-OST%04x_UUID " $i; done)
1242 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1243 create_dir $dir $POOL
1245 AVAIL=$($LFS df -p $POOL $dir | awk '/summary/ { print $4 }')
1246 [ $AVAIL -gt $MAXFREE ] &&
1247 skip_env "Filesystem space $AVAIL is larger than $MAXFREE limit" &&
1250 $LFS quotaoff -ug $MOUNT
1251 chown $RUNAS_ID.$RUNAS_ID $dir
1254 while [ $RC -eq 0 ]; do
1256 stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file}$i bs=1M \
1257 count=$((LIMIT * 4)) 2>&1)
1260 if [ $RC -eq 1 ]; then
1261 echo $stat | grep "Disk quota exceeded"
1262 [[ $? -eq 0 ]] && error "dd failed with EDQUOT with quota off"
1264 echo $stat | grep "No space left on device"
1266 error "dd did not fail with ENOSPC"
1274 run_test 23b "OST pools and OOS"
1278 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1279 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1287 create_pool_nofail $POOL
1289 add_pool $POOL $TGT_ALL "$TGT_UUID"
1291 create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1293 mkdir $POOL_ROOT/dir2
1294 $SETSTRIPE $POOL_ROOT/dir2 -p $POOL -s 65536 -i 0 -c 1 ||
1295 error "$SETSTRIPE $POOL_ROOT/dir2 failed"
1297 mkdir $POOL_ROOT/dir3
1298 $SETSTRIPE $POOL_ROOT/dir3 -s 65536 -i 0 -c 1 ||
1299 error "$SETSTRIPE $POOL_ROOT/dir3 failed"
1301 mkdir $POOL_ROOT/dir4
1303 for i in 1 2 3 4; do
1304 dir=${POOL_ROOT}/dir${i}
1313 createmany -o $dir/${tfile} $numfiles ||
1314 error "createmany $dir/${tfile} failed!"
1315 res=$($GETSTRIPE -v $dir | grep "^stripe_count:")
1316 if [ $? -ne 0 ]; then
1317 res=$($GETSTRIPE -v $dir | grep "^(Default) ")
1318 pool=$(cut -f 9 -d ' ' <<< $res)
1319 index=$(cut -f 7 -d ' ' <<< $res)
1320 size=$(cut -f 5 -d ' ' <<< $res)
1321 count=$(cut -f 3 -d ' ' <<< $res)
1323 pool=$(cut -f 8 -d ' ' <<< $res)
1324 index=$(cut -f 6 -d ' ' <<< $res)
1325 size=$(cut -f 4 -d ' ' <<< $res)
1326 count=$(cut -f 2 -d ' ' <<< $res)
1329 for file in $dir/*; do
1330 if [ "$pool" != "" ]; then
1331 check_file_in_pool $file $pool
1333 pool1=$(file_pool $file)
1334 count1=$($GETSTRIPE -v $file | grep "^lmm_stripe_count:" |
1335 tr -d '[:blank:]' | cut -f 2 -d ':')
1336 size1=$($GETSTRIPE -v $file | grep "^lmm_stripe_size:" |
1337 tr -d '[:blank:]' | cut -f 2 -d ':')
1338 [[ "$pool" != "$pool1" ]] &&
1339 error "Pool name ($pool) not inherited in $file($pool1)"
1340 [[ "$count" != "$count1" ]] &&
1341 error "Stripe count ($count) not inherited in $file ($count1)"
1342 [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] &&
1343 error "Stripe size ($size) not inherited in $file ($size1)"
1351 run_test 24 "Independence of pool from other setstripe parameters"
1355 local dev=$(mdsdevname ${SINGLEMDS//mds/})
1356 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1360 for i in $(seq 10); do
1361 create_pool_nofail $POOL$i
1362 do_facet $SINGLEMDS "lctl pool_add $FSNAME.$POOL$i OST0000; sync"
1363 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL$i |
1364 sort -u | tr '\n' ' ' " "$FSNAME-OST0000_UUID " >/dev/null ||
1365 error "pool_add failed: $1; $2"
1367 stop $SINGLEMDS || return 1
1368 start $SINGLEMDS ${dev} $MDS_MOUNT_OPTS ||
1369 { error "Failed to start $SINGLEMDS after stopping" && break; }
1370 wait_osc_import_state mds ost FULL
1374 # Veriy that the pool got created and is usable
1375 df $POOL_ROOT > /dev/null
1377 # Make sure OST0 can be striped on
1378 $SETSTRIPE -o 0 -c 1 $POOL_ROOT/$tfile
1379 STR=$($GETSTRIPE $POOL_ROOT/$tfile | grep 0x | cut -f2 | tr -d " ")
1380 rm $POOL_ROOT/$tfile
1381 if [[ "$STR" == "0" ]]; then
1382 echo "Creating a file in pool$i"
1383 create_file $POOL_ROOT/file$i $POOL$i || break
1384 check_file_in_pool $POOL_ROOT/file$i $POOL$i || break
1386 echo "OST 0 seems to be unavailable. Try later."
1392 run_test 25 "Create new pool and restart MDS"
1395 [[ $OSTCOUNT -le 2 ]] && skip_env "Need at least 3 OSTs" && return
1397 local dev=$(mdsdevname ${SINGLEMDS//mds/})
1398 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1402 create_pool_nofail $POOL2
1404 do_facet $SINGLEMDS "lctl pool_add $FSNAME.$POOL2 OST0000; sync"
1405 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL2 |
1406 sort -u | grep $FSNAME-OST0000_UUID " "$FSNAME-OST0000_UUID" ||
1407 error "pool_add failed: $1; $2"
1409 do_facet $SINGLEMDS "lctl pool_add $FSNAME.$POOL2 OST0002; sync"
1410 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL2 |
1411 sort -u | grep $FSNAME-OST0002_UUID" "$FSNAME-OST0002_UUID" ||
1412 error "pool_add failed: $1; $2"
1414 # Veriy that the pool got created and is usable
1416 echo "Creating files in $POOL2"
1418 for ((i = 0; i < 10; i++)); do
1419 #OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
1420 #Fail OST0000 to ensure objects create on the other OST in the pool
1421 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
1422 do_facet $SINGLEMDS lctl set_param fail_val=0
1423 create_file $POOL_ROOT/file$i $POOL2 1 -1 || break
1424 do_facet $SINGLEMDS lctl set_param fail_loc=0
1425 check_file_in_pool $POOL_ROOT/file$i $POOL2 || break
1429 run_test 26 "Choose other OSTs in the pool first in the creation remedy"
1433 complete $(basename $0) $SECONDS
1434 cleanup_pools $FSNAME
1435 check_and_cleanup_lustre