2 # -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
3 # vim:autoindent:shiftwidth=4:tabstop=4:
5 # Run select tests by setting ONLY, or as arguments to the script.
6 # Skip specific tests by setting EXCEPT.
8 # Run test by setting NOSETUP=true when ltest has setup env for us
11 export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
14 ALWAYS_EXCEPT="$OST_POOLS_EXCEPT"
15 # bug number for skipped test: -
16 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
18 [ "$ALWAYS_EXCEPT$EXCEPT" ] && \
19 echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT`"
24 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
25 . $LUSTRE/tests/test-framework.sh
27 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
30 check_and_setup_lustre
35 POOLSLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
36 [ "$POOLSLOG" ] && rm -f $POOLSLOG || true
39 FAIL_ON_ERROR=${FAIL_ON_ERROR:-true}
43 SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
44 GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"}
47 TSTUSR=${TSTUSR:-"quota_usr"}
49 RUNAS="runas -u $TSTID -g $TSTID"
55 NON_EXISTANT_POOL=nonexistantpool
56 NON_EXISTANT_FS=nonexistantfs
57 INVALID_POOL=some_invalid_pool_name
60 TGT_MAX=$((TGT_COUNT-1))
62 TGT_LIST=$(seq $TGT_FIRST $TGT_STEP $TGT_MAX)
63 TGT_LIST2=$(seq $TGT_FIRST 2 $TGT_MAX)
65 TGT_ALL="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/1]"
66 TGT_HALF="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]"
68 TGT_UUID=$(for i in $TGT_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
69 TGT_UUID2=$(for i in $TGT_LIST2; do printf "$FSNAME-OST%04x_UUID " $i; done)
74 local count=${3:-"-1"}
79 $SETSTRIPE -c $count -p $pool $dir -o $idx
81 $SETSTRIPE -c $count -p $pool $dir
84 error "$SETSTRIPE -p $pool $dir failed."
90 local count=${3:-"-1"}
91 local index=${4:-"-1"}
93 $SETSTRIPE -o $index -c $count -p $pool $file
95 error "$SETSTRIPE -p $pool $file failed."
101 for i in $(do_facet $SINGLEMDS lctl pool_list $FSNAME.$pool | \
102 grep -v "^Pool:" | sed -e 's/_UUID$//;s/^.*-OST//'); do
103 res="$res $(printf "%d" 0x$i)"
108 check_dir_in_pool() {
111 local res=$($GETSTRIPE $dir | grep "^stripe_count:" \
112 | cut -d ':' -f 5 | tr -d "[:blank:]")
113 if [[ "$res" == "$pool" ]]; then
116 error found $res instead of $pool
121 check_file_in_pool() {
122 local osts=$(osts_in_pool $2)
123 check_file_in_osts $1 "$osts" $3
126 check_file_in_osts() {
128 local pool_list=${2:-$TGT_LIST}
130 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
134 found=$(echo :$pool_list: | tr " " ":" | grep :$i:)
135 if [[ "$found" == "" ]]; then
136 echo "pool list: $pool_list"
137 echo "striping: $res"
139 error "$file not allocated from OSTs $pool_list."
144 local ost_count=$($GETSTRIPE $file | grep 0x | wc -l)
145 [[ -n "$count" ]] && [[ $ost_count -ne $count ]] && \
146 { error "Stripe count $count expected; got $ost_count" && return 1; }
151 check_file_not_in_pool() {
154 local res=$($GETSTRIPE -v $file | grep "^pool:" | tr -d "[:blank:]" | cut -f 2 -d ':')
155 if [[ "$res" == "$pool" ]]; then
156 error "File $file is in pool: $res"
163 check_dir_not_in_pool() {
166 local res=$($GETSTRIPE -v $dir | grep "^stripe_count" | head -1 | \
168 if [[ "$res" == "$pool" ]]; then
169 error "File $dir is in pool: $res"
178 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool" ""\
179 ||error "Failed to remove targets from pool: $pool"
185 local tgt="${3}$(lctl get_param -n lov.$FSNAME-*.pools.$pool | \
186 sort -u | tr '\n' ' ')"
188 do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool $osts
190 [[ $RC -ne 0 ]] && return $RC
192 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool | \
193 sort -u | tr '\n' ' ' " "$tgt" || RC=1
194 [[ $RC -ne 0 ]] && error "pool_add failed: $1; $2"
198 create_pool_nofail() {
199 create_pool $FSNAME.$1
202 error "Pool creation of $1 failed"
207 create_pool $FSNAME.$1
210 error "Pool creation of $1 succeeded; should have failed"
215 # Destroy pools from previous test runs
216 for p in $(do_facet $SINGLEMDS lctl pool_list $FSNAME | \
217 grep $FSNAME.pool[0-$OSTCOUNT]); do
220 rm -rf $DIR/d0.${TESTSUITE}
228 trap "cleanup_pools $FSNAME" EXIT
232 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
233 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
237 # Tests for new commands added
240 echo "Creating a pool with a 1 character pool name"
243 echo "Creating a pool with a 10 character pool name"
244 create_pool_nofail p123456789
245 destroy_pool p123456789
247 echo "Creating a pool with a 16 character pool name"
248 create_pool_nofail p123456789123456
249 destroy_pool p123456789123456
251 echo "Creating a pool with a 17 character pool name; should fail"
252 create_pool_fail p1234567891234567
254 echo "Creating a pool with a 1000 character pool name; should fail"
256 for i in `seq 1 999`; do NAME=${NAME}"o"; done
257 create_pool_fail $NAME
259 echo "pool_new should fail if fs-name or poolname are missing."
260 do_facet $SINGLEMDS lctl pool_new .pool1 2>/dev/null
262 error "pool_new did not fail even though fs-name was missing."
263 do_facet $SINGLEMDS lctl pool_new pool1 2>/dev/null
265 error "pool_new did not fail even though fs-name was missing."
266 do_facet $SINGLEMDS lctl pool_new ${FSNAME}. 2>/dev/null
268 error "pool_new did not fail even though pool name was missing."
269 do_facet $SINGLEMDS lctl pool_new . 2>/dev/null
271 error "pool_new did not fail even though pool name and fs-name " \
273 do_facet $SINGLEMDS lctl pool_new ${FSNAME},pool1 2>/dev/null
275 error "pool_new did not fail even though pool name format was wrong"
276 do_facet $SINGLEMDS lctl pool_new ${FSNAME}/pool1 2>/dev/null
278 error "pool_new did not fail even though pool name format was wrong"
280 do_facet $SINGLEMDS lctl pool_new ${FSNAME}.p 2>/dev/null
282 error "pool_new did not fail even though pool1 existed"
286 run_test 1 "Test lctl pool_new ========================================="
292 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
294 error " pool_add did not fail even though pool did " \
297 run_test 2a "pool_add: non-existant pool"
301 do_facet $SINGLEMDS lctl pool_add $FSNAME.p1234567891234567890 \
302 $FSNAME-OST0000 2>/dev/null
304 error "pool_add did not fail even though pool name was invalid."
306 run_test 2b "pool_add: Invalid pool name"
308 # Testing various combinations of OST name list
314 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
318 create_pool_nofail $POOL
321 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
322 RC=$?; [[ $RC -eq 0 ]] || \
323 error "pool_add failed. $FSNAME $POOL OST0000: $RC"
324 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
328 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
329 RC=$?; [[ $RC -eq 0 ]] || \
330 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000: $RC"
331 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
334 # 3. lustre-OST0000_UUID
335 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
336 RC=$?; [[ $RC -eq 0 ]] || \
337 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000_UUID: $RC"
338 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
341 # 4. lustre-OST[0,1,2,3,]
343 for i in $TGT_LIST; do TGT=${TGT}$(printf "$i," $i); done
345 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
347 error "pool_add failed. $FSNAME.$POOL $TGT. $RC"
348 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT
351 # 5. lustre-OST[0-5/1]
352 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
353 RC=$?; [[ $RC -eq 0 ]] || \
354 error "pool_add failed. $FSNAME $POOL" "$TGT_ALL $RC"
355 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
356 sort -u | tr '\n' ' ' " "$TGT_UUID" || error "Add to pool failed"
357 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
362 run_test 2c "pool_add: OST index combinations ==========================="
369 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
373 create_pool_nofail $POOL
375 TGT=$(printf "$FSNAME-OST%04x_UUID " $OSTCOUNT)
376 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
377 RC=$?; [[ $RC -ne 0 ]] || \
378 error "pool_add succeeded for an OST ($TGT) that does not exist."
382 run_test 2d "pool_add: OSTs that don't exist should be rejected ========"
390 $LCTL get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
394 create_pool_nofail $POOL
396 TGT="$FSNAME-OST0000_UUID "
397 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
398 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
399 sort -u | tr '\n' ' ' " "$TGT" || error "Add to pool failed"
400 RESULT=$(do_facet $SINGLEMDS \
401 "LOCALE=C $LCTL pool_add $FSNAME.$POOL $TGT 2>&1")
406 error "pool_add succeeded for an OST that was already in the pool."
408 [[ $(grep "already in pool" <<< $RESULT) ]] || \
409 error "pool_add failed as expected but error message not as expected."
413 run_test 2e "pool_add: OST already in a pool should be rejected ========"
417 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
421 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
423 error "pool_remove did not fail even though pool did not exist."
425 run_test 3a "pool_remove: non-existant pool"
429 do_facet $SINGLEMDS lctl pool_remove ${NON_EXISTANT_FS}.$POOL OST0000 2>/dev/null
431 error "pool_remove did not fail even though fsname did not exist."
433 run_test 3b "pool_remove: non-existant fsname"
437 do_facet $SINGLEMDS lctl pool_remove $FSNAME.p1234567891234567890 \
438 $FSNAME-OST0000 2>/dev/null
440 error "pool_remove did not fail even though pool name was invalid."
442 run_test 3c "pool_remove: Invalid pool name"
444 # Testing various combinations of OST name list
447 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
451 create_pool_nofail $POOL
452 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
453 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
455 error "pool_remove failed. $FSNAME $POOL OST0000"
458 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
459 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
461 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000"
464 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
465 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
467 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000_UUID"
470 add_pool $POOL $TGT_ALL "$TGT_UUID"
471 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
473 error "pool_remove failed. $FSNAME $POOL" $TGT_ALL
478 run_test 3d "pool_remove: OST index combinations ==========================="
482 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
486 do_facet $SINGLEMDS lctl pool_destroy $FSNAME.$POOL 2>/dev/null
488 error "pool_destroy did not fail even though pool did not exist."
490 run_test 4a "pool_destroy: non-existant pool"
494 do_facet $SINGLEMDS lctl pool_destroy ${NON_EXISTANT_FS}.$POOL 2>/dev/null
496 error "pool_destroy did not fail even though the filesystem did not exist."
498 run_test 4b "pool_destroy: non-existant fs-name"
502 create_pool_nofail $POOL
503 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
505 do_facet $SINGLEMDS lctl pool_destroy ${FSNAME}.$POOL
507 error "pool_destroy succeeded with a non-empty pool."
510 run_test 4c "pool_destroy: non-empty pool ==============================="
515 $LCMD pool_list 2>/dev/null
517 error "pool_list did not fail even though fsname was not mentioned."
519 destroy_pool $POOL 2>/dev/null
520 destroy_pool $POOL2 2>/dev/null
522 create_pool_nofail $POOL
523 create_pool_nofail $POOL2
524 $LCMD pool_list $FSNAME
526 error "pool_list $FSNAME failed."
528 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
530 $LCMD pool_list $FSNAME.$POOL
532 error "pool_list $FSNAME.$POOL failed."
534 $LCMD pool_list ${NON_EXISTANT_FS} 2>/dev/null
536 error "pool_list did not fail for a non-existant fsname $NON_EXISTANT_FS"
538 $LCMD pool_list ${FSNAME}.$NON_EXISTANT_POOL 2>/dev/null
540 error "pool_list did not fail for a non-existant pool $NON_EXISTANT_POOL"
542 if [[ ! $(grep $SINGLEMDS <<< $LCMD) ]]; then
543 echo $LCMD pool_list $DIR
546 error "pool_list failed for $DIR"
549 $LCMD pool_list ${DIR}/d1
551 error "pool_list failed for ${DIR}/d1"
554 rm -rf ${DIR}nonexistant
555 $LCMD pool_list ${DIR}nonexistant 2>/dev/null
557 error "pool_list did not fail for invalid mountpoint ${DIR}nonexistant"
565 # Issue commands from client
569 # Issue commands from MDS
570 sub_test_5 "do_facet $SINGLEMDS lctl"
571 sub_test_5 "do_facet $SINGLEMDS lfs"
574 run_test 5 "lfs/lctl pool_list"
578 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
579 local POOL_DIR=$POOL_ROOT/dir_tst
580 local POOL_FILE=$POOL_ROOT/file_tst
582 create_pool_nofail $POOL
584 do_facet $SINGLEMDS lctl pool_list $FSNAME
586 error "pool_list $FSNAME failed."
588 add_pool $POOL $TGT_ALL "$TGT_UUID"
591 $SETSTRIPE -c -1 -p $POOL $POOL_DIR
593 error "$SETSTRIPE -p $POOL failed."
594 check_dir_in_pool $POOL_DIR $POOL
596 # If an invalid pool name is specified, the command should fail
597 $SETSTRIPE -c 2 -p $INVALID_POOL $POOL_DIR 2>/dev/null
599 error "setstripe to invalid pool did not fail."
601 # If the pool name does not exist, the command should fail
602 $SETSTRIPE -c 2 -p $NON_EXISTANT_POOL $POOL_DIR 2>/dev/null
604 error "setstripe to non-existant pool did not fail."
606 # lfs setstripe should work as before if a pool name is not specified.
607 $SETSTRIPE -c -1 $POOL_DIR
609 error "$SETSTRIPE -p $POOL_DIR failed."
610 $SETSTRIPE -c -1 $POOL_FILE
612 error "$SETSTRIPE -p $POOL_FILE failed."
614 # lfs setstripe should fail if a start index that is outside the
616 create_pool_nofail $POOL2
617 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
618 $SETSTRIPE -o 1 -p $POOL2 $ROOT_POOL/$tfile 2>/dev/null
620 error "$SETSTRIPE with start index outside the pool did not fail."
623 run_test 6 "getstripe/setstripe"
627 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
629 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
631 create_pool_nofail $POOL
632 create_pool_nofail $POOL2
634 local start=$((TGT_FIRST+1))
635 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
636 $FSNAME-OST[$start-$TGT_MAX/2]
638 add_pool $POOL $TGT_HALF "$TGT_UUID2"
640 create_dir $POOL_ROOT/dir1 $POOL
641 create_dir $POOL_ROOT/dir2 $POOL2
642 check_dir_in_pool $POOL_ROOT/dir1 $POOL
643 check_dir_in_pool $POOL_ROOT/dir1 $POOL
646 createmany -o $POOL_ROOT/dir1/$tfile $numfiles || \
647 error "createmany $POOL_ROOT/dir1/$tfile failed!"
649 for file in $POOL_ROOT/dir1/*; do
650 check_file_in_pool $file $POOL
653 createmany -o $POOL_ROOT/dir2/$tfile $numfiles || \
654 error "createmany $POOL_ROOT/dir2/$tfile failed!"
655 for file in $POOL_ROOT/dir2/*; do
656 check_file_in_pool $file $POOL2
659 rm -rf $POOL_ROOT/dir?
663 run_test 11 "OSTs in overlapping/multiple pools"
667 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
669 [[ $OSTCOUNT -le 2 ]] && skip_env "Need atleast 3 OSTs" && return
671 create_pool_nofail $POOL
672 create_pool_nofail $POOL2
674 local start=$((TGT_FIRST+1))
675 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
676 $FSNAME-OST[$start-$TGT_MAX/2]
678 add_pool $POOL $TGT_HALF "$TGT_UUID2"
680 echo creating some files in $POOL and $POOL2
682 create_dir $POOL_ROOT/dir1 $POOL
683 create_dir $POOL_ROOT/dir2 $POOL2
684 create_file $POOL_ROOT/file1 $POOL
685 create_file $POOL_ROOT/file2 $POOL2
687 echo Checking the files created
688 check_dir_in_pool $POOL_ROOT/dir1 $POOL
689 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
690 check_file_in_pool $POOL_ROOT/file1 $POOL
691 check_file_in_pool $POOL_ROOT/file2 $POOL2
693 echo Changing the pool membership
694 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST[$TGT_FIRST]
695 do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL
696 FIRST_UUID=$(echo $TGT_UUID | awk '{print $1}')
697 add_pool $POOL2 $FSNAME-OST[$TGT_FIRST] "$FIRST_UUID "
698 do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL2
700 echo Checking the files again
701 check_dir_in_pool $POOL_ROOT/dir1 $POOL
702 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
703 check_file_in_osts $POOL_ROOT/file1 "$TGT_LIST2"
704 check_file_in_osts $POOL_ROOT/file2 "$(seq $start 2 $TGT_MAX)"
706 echo Creating some more files
707 create_dir $POOL_ROOT/dir3 $POOL
708 create_dir $POOL_ROOT/dir4 $POOL2
709 create_file $POOL_ROOT/file3 $POOL
710 create_file $POOL_ROOT/file4 $POOL2
712 echo Checking the new files
713 check_file_in_pool $POOL_ROOT/file3 $POOL
714 check_file_in_pool $POOL_ROOT/file4 $POOL2
718 run_test 12 "OST Pool Membership"
722 [[ $OSTCOUNT -le 2 ]] && skip_env "Need atleast 3 OSTs" && return
724 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
728 create_pool_nofail $POOL
729 add_pool $POOL $TGT_ALL "$TGT_UUID"
731 create_dir $POOL_ROOT/dir1 $POOL -1
732 createmany -o $POOL_ROOT/dir1/$tfile $numfiles || \
733 error "createmany $POOL_ROOT/dir1/$tfile failed!"
734 for file in $POOL_ROOT/dir1/*; do
735 check_file_in_pool $file $POOL $OSTCOUNT
738 create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
739 create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST+1))
740 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST+2))
741 check_file_in_pool $POOL_ROOT/dir1/file1 $POOL 1
742 check_file_in_pool $POOL_ROOT/dir1/file2 $POOL 1
743 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST+2))
744 check_file_in_osts $POOL_ROOT/dir1/file1 "$TGT_FIRST"
745 check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST+1))"
746 check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST+2))"
748 create_dir $POOL_ROOT/dir2 $POOL $count
749 createmany -o $POOL_ROOT/dir2/$tfile $numfiles || \
750 error "createmany $POOL_ROOT/dir2/$tfile failed!"
751 for file in $POOL_ROOT/dir2/*; do
752 check_file_in_pool $file $POOL $count
755 create_dir $POOL_ROOT/dir3 $POOL $count $((TGT_FIRST+1))
756 createmany -o $POOL_ROOT/dir3/$tfile_ $numfiles || \
757 error "createmany $POOL_ROOT/dir3/$tfile_ failed!"
758 for file in $POOL_ROOT/dir3/*; do
759 check_file_in_pool $file $POOL $count
762 create_dir $POOL_ROOT/dir4 $POOL 1
763 createmany -o $POOL_ROOT/dir4/$tfile_ $numfiles || \
764 error "createmany $POOL_ROOT/dir4/$tfile_ failed!"
765 for file in $POOL_ROOT/dir4/*; do
766 check_file_in_pool $file $POOL 1
769 create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST+2))
770 createmany -o $POOL_ROOT/dir5/$tfile_ $numfiles || \
771 error "createmany $POOL_ROOT/dir5/$tfile_ failed!"
772 for file in $POOL_ROOT/dir5/*; do
773 check_file_in_pool $file $POOL 1
774 check_file_in_osts $file "$((TGT_FIRST+2))"
777 rm -rf create_dir $POOL_ROOT/dir?
781 run_test 13 "Striping characteristics in a pool"
785 [[ $OSTCOUNT -le 2 ]] && skip_env "Need atleast 3 OSTs" && return
787 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
791 # Create a new filesystem that is guaranteed to be balanced.
795 create_pool_nofail $POOL
796 create_pool_nofail $POOL2
798 add_pool $POOL $TGT_HALF "$TGT_UUID2"
799 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
801 create_dir $POOL_ROOT/dir1 $POOL 1
802 create_file $POOL_ROOT/dir1/file $POOL 1
803 local OST=$($GETSTRIPE $POOL_ROOT/dir1/file | grep 0x | cut -f2)
805 while [[ $i -lt $numfiles ]];
808 [[ $OST -gt $TGT_MAX ]] && OST=$TGT_FIRST
810 # echo "Iteration: $i OST: $OST"
811 create_file $POOL_ROOT/dir1/file${i} $POOL 1
812 check_file_in_pool $POOL_ROOT/dir1/file${i} $POOL
816 # Fill up OST0 until it is nearly full.
817 # Create 9 files of size OST0_SIZE/10 each.
818 create_dir $POOL_ROOT/dir2 $POOL2 1
819 $LFS df $POOL_ROOT/dir2
820 echo "Filling up OST0"
821 OST0_SIZE=`$LFS df $POOL_ROOT/dir2 | awk '/\[OST:0\]/ {print $4}'`
822 FILE_SIZE=$((OST0_SIZE/1024/10))
824 while [[ $i -lt 10 ]];
826 dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1M count=$FILE_SIZE
829 $LFS df $POOL_ROOT/dir2
831 # OST $TGT_FIRST is no longer favored; but it may still be used.
832 create_dir $POOL_ROOT/dir3 $POOL 1
833 create_file $POOL_ROOT/dir3/file $POOL 1
834 createmany -o $POOL_ROOT/dir3/$tfile_ $numfiles || \
835 error "createmany $POOL_ROOT/dir3/$tfile_ failed!"
836 for file in $POOL_ROOT/dir3/*; do
837 check_file_in_pool $file $POOL
843 run_test 14 "Round robin and QOS striping within a pool"
847 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
851 while [[ $i -lt $OSTCOUNT ]]
853 create_pool_nofail pool${i}
855 local tgt=$(printf "$FSNAME-OST%04x_UUID " $i)
856 add_pool pool${i} "$FSNAME-OST[$i]" "$tgt"
857 create_dir $POOL_ROOT/dir${i} pool${i}
858 createmany -o $POOL_ROOT/dir$i/$tfile $numfiles || \
859 error "createmany $POOL_ROOT/dir$i/$tfile failed!"
861 for file in $POOL_ROOT/dir$i/*; do
862 check_file_in_osts $file $i
870 run_test 15 "One directory per OST/pool"
874 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
878 create_pool_nofail $POOL
880 add_pool $POOL $TGT_HALF "$TGT_UUID2"
882 local dir=$POOL_ROOT/$tdir
883 create_dir $dir $POOL
885 for i in $(seq 1 10); do
890 createmany -o $dir/$tfile $numfiles || \
891 error "createmany $dir/$tfile failed!"
893 for file in $dir/*; do
894 check_file_in_pool $file $POOL
897 rm -rf $POOL_ROOT/$tdir
901 run_test 16 "Inheritance of pool properties"
905 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
909 create_pool_nofail $POOL
911 add_pool $POOL $TGT_ALL "$TGT_UUID"
913 local dir=$POOL_ROOT/dir
914 create_dir $dir $POOL
916 createmany -o $dir/${tfile}1_ $numfiles || \
917 error "createmany $dir/${tfile}1_ failed!"
919 for file in $dir/*; do
920 check_file_in_pool $file $POOL
925 createmany -o $dir/${tfile}2_ $numfiles || \
926 error "createmany $dir/${tfile}2_ failed!"
931 run_test 17 "Referencing an empty pool"
939 sync; sleep 5 # give pending IO a chance to go to disk
940 stat=$(createmany -o $cdir/${tfile} $numfiles)
943 time=$(echo $stat | cut -f 5 -d ' ')
944 echo $stat >> /dev/stderr
950 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
952 local plaindir=$POOL_ROOT/plaindir
953 local pooldir=$POOL_ROOT/pooldir
961 echo "Create performance, iteration $i, $numfiles files x 3"
963 time1=$(create_perf $plaindir $numfiles)
964 echo "iter $i: $numfiles creates without pool: $time1"
965 t1=$(echo "scale=2; $t1 + $time1" | bc)
967 create_pool_nofail $POOL > /dev/null
968 add_pool $POOL $TGT_ALL "$TGT_UUID" > /dev/null
969 create_dir $pooldir $POOL
970 time2=$(create_perf $pooldir $numfiles)
971 echo "iter $i: $numfiles creates with pool: $time2"
972 t2=$(echo "scale=2; $t2 + $time2" | bc)
974 destroy_pool $POOL > /dev/null
975 time3=$(create_perf $pooldir $numfiles)
976 echo "iter $i: $numfiles creates with missing pool: $time3"
977 t3=$(echo "scale=2; $t3 + $time3" | bc)
982 time1=$(echo "scale=2; $t1 / $i" | bc)
983 echo Avg time taken for $numfiles creates without pool: $time1
984 time2=$(echo "scale=2; $t2 / $i" | bc)
985 echo Avg time taken for $numfiles creates with pool: $time2
986 time3=$(echo "scale=2; $t3 / $i" | bc)
987 echo Avg time taken for $numfiles creates with missing pool: $time3
989 # Set this high until we establish a baseline for what the degradation
992 diff=$(echo "scale=2; ($time2 - $time1) * 100 / $time1" | bc)
993 echo "No pool to wide pool: $diff %."
994 deg=$(echo "scale=2; $diff > $max" | bc)
995 [ "$deg" == "1" ] && error_ignore 23408 "Degradation with wide pool is $diff % (> $max %)"
998 diff=$(echo "scale=2; ($time3 - $time1) * 100 / $time1" | bc)
999 echo "No pool to missing pool: $diff %."
1000 deg=$(echo "scale=2; $diff > $max" | bc)
1001 [ "$deg" == "1" ] && error_ignore 23408 "Degradation with missing pool is $diff % (> $max %)"
1005 run_test 18 "File create in a directory which references a deleted pool"
1010 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1012 local dir1=$POOL_ROOT/dir1
1013 local dir2=$POOL_ROOT/dir2
1016 create_pool_nofail $POOL
1018 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1020 create_dir $dir1 $POOL
1021 createmany -o $dir1/${tfile} $numfiles || \
1022 error "createmany $dir1/${tfile} failed!"
1023 for file in $dir1/*; do
1024 check_file_in_pool $file $POOL
1028 createmany -o $dir2/${tfile} $numfiles || \
1029 error "createmany $dir2/${tfile} failed!"
1030 for file in $dir2/*; do
1031 check_file_not_in_pool $file $POOL
1038 run_test 19 "Pools should not come into play when not specified"
1042 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1044 local dir1=$POOL_ROOT/dir1
1045 local dir2=$dir1/dir2
1046 local dir3=$dir1/dir3
1050 create_pool_nofail $POOL
1051 create_pool_nofail $POOL2
1053 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1055 local start=$((TGT_FIRST+1))
1056 TGT=$(for i in `seq $start 2 $TGT_MAX`; \
1057 do printf "$FSNAME-OST%04x_UUID " $i; done)
1058 add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1060 create_dir $dir1 $POOL
1061 create_file $dir1/file1 $POOL2
1062 create_dir $dir2 $POOL2
1065 $SETSTRIPE -c 1 $dir3 # No pool assignment
1067 $SETSTRIPE -c 1 $dir2/file4 # No pool assignment
1069 check_file_in_pool $dir1/file1 $POOL2
1070 check_file_in_pool $dir2/file2 $POOL2
1072 check_dir_not_in_pool $dir3 $POOL
1073 check_dir_not_in_pool $dir3 $POOL2
1075 check_file_not_in_pool $dir3/file3 $POOL
1076 check_file_not_in_pool $dir3/file3 $POOL2
1078 check_file_not_in_pool $dir2/file4 $POOL
1079 check_file_not_in_pool $dir2/file4 $POOL2
1085 run_test 20 "Different pools in a directory hierarchy."
1089 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1090 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
1094 local dir=$POOL_ROOT/dir
1096 create_pool_nofail $POOL
1098 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1100 create_dir $dir $POOL $OSTCOUNT
1101 create_file $dir/file1 $POOL $OSTCOUNT
1102 $GETSTRIPE -v $dir/file1
1103 check_file_in_pool $dir/file1 $POOL
1109 run_test 21 "OST pool with fewer OSTs than stripe count"
1117 for c in $(seq 1 10);
1119 echo "Pool $pool, iteration $c"
1120 do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool OST[$TGT_FIRST-$TGT_MAX/$step] 2>/dev/null
1121 local TGT_SECOND=$(($TGT_FIRST+$step))
1122 if [ "$TGT_SECOND" -le "$TGT_MAX" ]; then
1123 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$pool OST[$TGT_SECOND-$TGT_MAX/$step]
1126 echo loop for $pool complete
1131 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1132 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1136 create_pool_nofail $POOL
1137 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
1138 create_pool_nofail $POOL2
1139 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
1144 create_dir $POOL_ROOT $POOL
1145 createmany -o $POOL_ROOT/${tfile} $numfiles || \
1146 error "createmany $POOL_ROOT/${tfile} failed!"
1151 run_test 22 "Simultaneous manipulation of a pool"
1155 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1156 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
1159 check_runas_id $TSTID $TSTID $RUNAS || {
1160 skip_env "User $RUNAS_ID does not exist - skipping"
1167 local BUNIT_SZ=1024 # min block quota unit(kB)
1168 local LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
1169 local OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
1171 local dir=$POOL_ROOT/dir
1172 local file="$dir/$tfile-quota"
1174 create_pool_nofail $POOL
1176 local TGT=$(for i in `seq $TGT_FIRST 3 $TGT_MAX`; \
1177 do printf "$FSNAME-OST%04x_UUID " $i; done)
1178 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1179 create_dir $dir $POOL
1181 $LFS quotaoff -ug $MOUNT
1182 $LFS quotacheck -ug $MOUNT
1183 LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1)))
1184 $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir
1186 $LFS quota -v -u $TSTUSR $dir
1188 $LFS setstripe $file -c 1 -p $POOL
1189 chown $TSTUSR.$TSTUSR $file
1193 LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BLK_SZ count=$((BUNIT_SZ*2)) || true
1194 $LFS quota -v -u $TSTUSR $dir
1195 cancel_lru_locks osc
1196 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ*2)) 2>&1)
1199 [[ $RC -eq 0 ]] && error "dd did not fail with EDQUOT."
1200 echo $stat | grep "Disk quota exceeded" > /dev/null
1201 [[ $? -eq 1 ]] && error "dd did not fail with EDQUOT."
1202 $LFS quota -v -u $TSTUSR $dir
1205 $LFS quotaoff -ug $MOUNT
1206 # $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir
1207 chown $TSTUSR.$TSTUSR $dir
1210 while [ $RC -eq 0 ];
1213 stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file}$i bs=1M \
1214 count=$((LIMIT*LIMIT)) 2>&1)
1216 if [ $RC -eq 1 ]; then
1218 echo $stat | grep "Disk quota exceeded"
1219 [[ $? -eq 0 ]] && error "dd failed with EDQUOT"
1221 echo $stat | grep "No space left on device"
1222 [[ $? -ne 0 ]] && error "dd did not fail with ENOSPC; " \
1233 run_test 23 "OST pools and quota"
1237 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1238 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
1247 create_pool_nofail $POOL
1249 add_pool $POOL $TGT_ALL "$TGT_UUID"
1251 create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1253 mkdir $POOL_ROOT/dir2
1254 $SETSTRIPE $POOL_ROOT/dir2 -p $POOL -s 65536 -i 0 -c 1 || \
1255 error "$SETSTRIPE $POOL_ROOT/dir2 failed"
1257 mkdir $POOL_ROOT/dir3
1258 $SETSTRIPE $POOL_ROOT/dir3 -s 65536 -i 0 -c 1 || \
1259 error "$SETSTRIPE $POOL_ROOT/dir3 failed"
1261 mkdir $POOL_ROOT/dir4
1263 for i in $(seq 1 4);
1265 dir=${POOL_ROOT}/dir${i}
1274 createmany -o $dir/${tfile} $numfiles || \
1275 error "createmany $dir/${tfile} failed!"
1276 res=$($GETSTRIPE -v $dir | grep "^stripe_count:")
1277 if [ $? -ne 0 ]; then
1278 res=$($GETSTRIPE -v $dir | grep "^(Default) ")
1279 pool=$(cut -f 9 -d ' ' <<< $res)
1280 index=$(cut -f 7 -d ' ' <<< $res)
1281 size=$(cut -f 5 -d ' ' <<< $res)
1282 count=$(cut -f 3 -d ' ' <<< $res)
1284 pool=$(cut -f 8 -d ' ' <<< $res)
1285 index=$(cut -f 6 -d ' ' <<< $res)
1286 size=$(cut -f 4 -d ' ' <<< $res)
1287 count=$(cut -f 2 -d ' ' <<< $res)
1290 for file in $dir/*; do
1291 if [ "$pool" != "" ]; then
1292 check_file_in_pool $file $pool
1294 pool1=$($GETSTRIPE -v $file | grep "^pool:" |\
1295 tr -d '[:blank:]' | cut -f 2 -d ':')
1296 count1=$($GETSTRIPE -v $file | grep "^lmm_stripe_count:" |\
1297 tr -d '[:blank:]' | cut -f 2 -d ':')
1298 size1=$($GETSTRIPE -v $file | grep "^lmm_stripe_size:" |\
1299 tr -d '[:blank:]' | cut -f 2 -d ':')
1300 [[ "$pool" != "$pool1" ]] && \
1301 error "Pool name ($pool) not inherited in $file($pool1)"
1302 [[ "$count" != "$count1" ]] && \
1303 error "Stripe count ($count) not inherited in $file ($count1)"
1304 [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] && \
1305 error "Stripe size ($size) not inherited in $file ($size1)"
1313 run_test 24 "Independence of pool from other setstripe parameters"
1317 local dev=$(mdsdevname ${SINGLEMDS//mds/})
1318 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1322 for i in $(seq 10); do
1323 create_pool_nofail pool$i
1324 do_facet $SINGLEMDS "lctl pool_add $FSNAME.pool$i OST0000; sync"
1325 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.pool$i | \
1326 sort -u | tr '\n' ' ' " "$FSNAME-OST0000_UUID " || \
1327 error "pool_add failed: $1; $2"
1329 stop $SINGLEMDS || return 1
1330 start $SINGLEMDS ${dev} $MDS_MOUNT_OPTS || \
1331 { error "Failed to start $SINGLEMDS after stopping" && break; }
1332 wait_osc_import_state mds ost FULL
1336 # Veriy that the pool got created and is usable
1337 df $POOL_ROOT > /dev/null
1339 # Make sure OST0 can be striped on
1340 $SETSTRIPE -o 0 -c 1 $POOL_ROOT/$tfile
1341 STR=$($GETSTRIPE $POOL_ROOT/$tfile | grep 0x | cut -f2 | tr -d " ")
1342 rm $POOL_ROOT/$tfile
1343 if [[ "$STR" == "0" ]]; then
1344 echo "Creating a file in pool$i"
1345 create_file $POOL_ROOT/file$i pool$i || break
1346 check_file_in_pool $POOL_ROOT/file$i pool$i || break
1348 echo "OST 0 seems to be unavailable. Try later."
1354 run_test 25 "Create new pool and restart MDS ======================="
1357 local OSTCOUNT=`lctl get_param -n lov.$LOVNAME.*clilov*.numobd`
1358 [[ $OSTCOUNT -le 2 ]] && skip_env "Need at least 3 OSTs" && return
1360 local dev=$(mdsdevname ${SINGLEMDS//mds/})
1361 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1365 create_pool_nofail $POOL
1367 do_facet $SINGLEMDS "lctl pool_add $FSNAME.pool1 OST0000; sync"
1368 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.pool1 | \
1369 sort -u | grep $FSNAME-OST0000_UUID " "$FSNAME-OST0000_UUID" || \
1370 error "pool_add failed: $1; $2"
1372 do_facet $SINGLEMDS "lctl pool_add $FSNAME.pool1 OST0002; sync"
1373 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.pool1 | \
1374 sort -u | grep $FSNAME-OST0002_UUID" "$FSNAME-OST0002_UUID" || \
1375 error "pool_add failed: $1; $2"
1377 # Veriy that the pool got created and is usable
1379 echo "Creating files in $POOL"
1381 for ((i=0;i<10;i++)); do
1382 #OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
1383 #Fail OST0000 to make sure the objects create on the other ost in the pool
1384 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
1385 do_facet $SINGLEMDS lctl set_param fail_val=0
1386 create_file $POOL_ROOT/file$i $POOL 1 -1 || break
1387 do_facet $SINGLEMDS lctl set_param fail_loc=0
1388 check_file_in_pool $POOL_ROOT/file$i $POOL || break
1392 run_test 26 "Choose other OSTs in the pool first in the creation remedy"
1394 log "cleanup: ======================================================"
1396 cleanup_pools $FSNAME
1397 check_and_cleanup_lustre
1398 echo '=========================== finished ==============================='
1399 [ -f "$POOLSLOG" ] && cat $POOLSLOG && grep -q FAIL $POOLSLOG && exit 1 || true
1400 echo "$0: completed"