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 $dir/${tfile} $numfiles)
943 time=$(echo $stat | cut -f 5 -d ' ')
944 echo $stat > /dev/stderr
949 local t1=$(create_perf_one $1 $2)
950 local t2=$(create_perf_one $1 $2)
951 local t3=$(create_perf_one $1 $2)
952 local time=$(echo "scale=2; ( $t1 + $t2 + $t3 ) / 3" | bc)
959 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
965 local dir=$POOL_ROOT/dir
969 time1=$(create_perf $dir $numfiles)
971 create_pool_nofail $POOL
973 add_pool $POOL $TGT_ALL "$TGT_UUID"
975 create_dir $dir $POOL
976 time2=$(create_perf $dir $numfiles)
980 time3=$(create_perf $dir $numfiles)
982 echo Time taken for $numfiles creates without pools: $time1
983 echo Time taken for $numfiles creates with pools: $time2
984 echo Time taken for $numfiles creates without pools: $time3
986 deg=$(echo "scale=2; (($time2 - $time3) * 100 / $time3) > 5" | bc)
987 diff=$(echo "scale=2; ($time2 - $time3) * 100 / $time3" | bc)
989 if [[ "$deg" == "1" ]]; then
990 error "Performance degradation with pools is $diff %."
992 echo "Performance degradation with pools is $diff %."
996 run_test 18 "File create in a directory which references a deleted pool"
1001 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1003 local dir1=$POOL_ROOT/dir1
1004 local dir2=$POOL_ROOT/dir2
1007 create_pool_nofail $POOL
1009 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1011 create_dir $dir1 $POOL
1012 createmany -o $dir1/${tfile} $numfiles || \
1013 error "createmany $dir1/${tfile} failed!"
1014 for file in $dir1/*; do
1015 check_file_in_pool $file $POOL
1019 createmany -o $dir2/${tfile} $numfiles || \
1020 error "createmany $dir2/${tfile} failed!"
1021 for file in $dir2/*; do
1022 check_file_not_in_pool $file $POOL
1029 run_test 19 "Pools should not come into play when not specified"
1033 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1035 local dir1=$POOL_ROOT/dir1
1036 local dir2=$dir1/dir2
1037 local dir3=$dir1/dir3
1041 create_pool_nofail $POOL
1042 create_pool_nofail $POOL2
1044 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1046 local start=$((TGT_FIRST+1))
1047 TGT=$(for i in `seq $start 2 $TGT_MAX`; \
1048 do printf "$FSNAME-OST%04x_UUID " $i; done)
1049 add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1051 create_dir $dir1 $POOL
1052 create_file $dir1/file1 $POOL2
1053 create_dir $dir2 $POOL2
1056 $SETSTRIPE -c 1 $dir3 # No pool assignment
1058 $SETSTRIPE -c 1 $dir2/file4 # No pool assignment
1060 check_file_in_pool $dir1/file1 $POOL2
1061 check_file_in_pool $dir2/file2 $POOL2
1063 check_dir_not_in_pool $dir3 $POOL
1064 check_dir_not_in_pool $dir3 $POOL2
1066 check_file_not_in_pool $dir3/file3 $POOL
1067 check_file_not_in_pool $dir3/file3 $POOL2
1069 check_file_not_in_pool $dir2/file4 $POOL
1070 check_file_not_in_pool $dir2/file4 $POOL2
1076 run_test 20 "Different pools in a directory hierarchy."
1080 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1081 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
1085 local dir=$POOL_ROOT/dir
1087 create_pool_nofail $POOL
1089 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1091 create_dir $dir $POOL $OSTCOUNT
1092 create_file $dir/file1 $POOL $OSTCOUNT
1093 $GETSTRIPE -v $dir/file1
1094 check_file_in_pool $dir/file1 $POOL
1100 run_test 21 "OST pool with fewer OSTs than stripe count"
1108 for c in $(seq 1 10);
1110 echo "Pool $pool, iteration $c"
1111 do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool OST[$TGT_FIRST-$TGT_MAX/$step] 2>/dev/null
1112 local TGT_SECOND=$(($TGT_FIRST+$step))
1113 if [ "$TGT_SECOND" -le "$TGT_MAX" ]; then
1114 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$pool OST[$TGT_SECOND-$TGT_MAX/$step]
1117 echo loop for $pool complete
1122 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1123 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1127 create_pool_nofail $POOL
1128 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
1129 create_pool_nofail $POOL2
1130 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
1135 create_dir $POOL_ROOT $POOL
1136 createmany -o $POOL_ROOT/${tfile} $numfiles || \
1137 error "createmany $POOL_ROOT/${tfile} failed!"
1142 run_test 22 "Simultaneous manipulation of a pool"
1146 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1147 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
1150 check_runas_id $TSTID $TSTID $RUNAS || {
1151 skip_env "User $RUNAS_ID does not exist - skipping"
1158 local BUNIT_SZ=1024 # min block quota unit(kB)
1159 local LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
1160 local OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
1162 local dir=$POOL_ROOT/dir
1163 local file="$dir/$tfile-quota"
1165 create_pool_nofail $POOL
1167 local TGT=$(for i in `seq $TGT_FIRST 3 $TGT_MAX`; \
1168 do printf "$FSNAME-OST%04x_UUID " $i; done)
1169 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1170 create_dir $dir $POOL
1172 $LFS quotaoff -ug $MOUNT
1173 $LFS quotacheck -ug $MOUNT
1174 LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1)))
1175 $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir
1177 $LFS quota -v -u $TSTUSR $dir
1179 $LFS setstripe $file -c 1 -p $POOL
1180 chown $TSTUSR.$TSTUSR $file
1184 LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BLK_SZ count=$((BUNIT_SZ*2)) || true
1185 $LFS quota -v -u $TSTUSR $dir
1186 cancel_lru_locks osc
1187 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ*2)) 2>&1)
1190 [[ $RC -eq 0 ]] && error "dd did not fail with EDQUOT."
1191 echo $stat | grep "Disk quota exceeded" > /dev/null
1192 [[ $? -eq 1 ]] && error "dd did not fail with EDQUOT."
1193 $LFS quota -v -u $TSTUSR $dir
1196 $LFS quotaoff -ug $MOUNT
1197 # $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir
1198 chown $TSTUSR.$TSTUSR $dir
1201 while [ $RC -eq 0 ];
1204 stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file}$i bs=1M \
1205 count=$((LIMIT*LIMIT)) 2>&1)
1207 if [ $RC -eq 1 ]; then
1209 echo $stat | grep "Disk quota exceeded"
1210 [[ $? -eq 0 ]] && error "dd failed with EDQUOT"
1212 echo $stat | grep "No space left on device"
1213 [[ $? -ne 0 ]] && error "dd did not fail with ENOSPC; " \
1224 run_test 23 "OST pools and quota"
1228 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1229 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
1238 create_pool_nofail $POOL
1240 add_pool $POOL $TGT_ALL "$TGT_UUID"
1242 create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1244 mkdir $POOL_ROOT/dir2
1245 $SETSTRIPE $POOL_ROOT/dir2 -p $POOL -s 65536 -i 0 -c 1 || \
1246 error "$SETSTRIPE $POOL_ROOT/dir2 failed"
1248 mkdir $POOL_ROOT/dir3
1249 $SETSTRIPE $POOL_ROOT/dir3 -s 65536 -i 0 -c 1 || \
1250 error "$SETSTRIPE $POOL_ROOT/dir3 failed"
1252 mkdir $POOL_ROOT/dir4
1254 for i in $(seq 1 4);
1256 dir=${POOL_ROOT}/dir${i}
1265 createmany -o $dir/${tfile} $numfiles || \
1266 error "createmany $dir/${tfile} failed!"
1267 res=$($GETSTRIPE -v $dir | grep "^stripe_count:")
1268 if [ $? -ne 0 ]; then
1269 res=$($GETSTRIPE -v $dir | grep "^(Default) ")
1270 pool=$(cut -f 9 -d ' ' <<< $res)
1271 index=$(cut -f 7 -d ' ' <<< $res)
1272 size=$(cut -f 5 -d ' ' <<< $res)
1273 count=$(cut -f 3 -d ' ' <<< $res)
1275 pool=$(cut -f 8 -d ' ' <<< $res)
1276 index=$(cut -f 6 -d ' ' <<< $res)
1277 size=$(cut -f 4 -d ' ' <<< $res)
1278 count=$(cut -f 2 -d ' ' <<< $res)
1281 for file in $dir/*; do
1282 if [ "$pool" != "" ]; then
1283 check_file_in_pool $file $pool
1285 pool1=$($GETSTRIPE -v $file | grep "^pool:" |\
1286 tr -d '[:blank:]' | cut -f 2 -d ':')
1287 count1=$($GETSTRIPE -v $file | grep "^lmm_stripe_count:" |\
1288 tr -d '[:blank:]' | cut -f 2 -d ':')
1289 size1=$($GETSTRIPE -v $file | grep "^lmm_stripe_size:" |\
1290 tr -d '[:blank:]' | cut -f 2 -d ':')
1291 [[ "$pool" != "$pool1" ]] && \
1292 error "Pool name ($pool) not inherited in $file($pool1)"
1293 [[ "$count" != "$count1" ]] && \
1294 error "Stripe count ($count) not inherited in $file ($count1)"
1295 [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] && \
1296 error "Stripe size ($size) not inherited in $file ($size1)"
1304 run_test 24 "Independence of pool from other setstripe parameters"
1308 local dev=$(mdsdevname ${SINGLEMDS//mds/})
1309 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1313 for i in $(seq 10); do
1314 create_pool_nofail pool$i
1315 do_facet $SINGLEMDS "lctl pool_add $FSNAME.pool$i OST0000; sync"
1316 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.pool$i | \
1317 sort -u | tr '\n' ' ' " "$FSNAME-OST0000_UUID " || \
1318 error "pool_add failed: $1; $2"
1320 stop $SINGLEMDS || return 1
1321 start $SINGLEMDS ${dev} $MDS_MOUNT_OPTS || \
1322 { error "Failed to start $SINGLEMDS after stopping" && break; }
1323 wait_osc_import_state mds ost FULL
1326 # Veriy that the pool got created and is usable
1328 echo "Creating a file in pool$i"
1329 create_file $POOL_ROOT/file$i pool$i || break
1330 check_file_in_pool $POOL_ROOT/file$i pool$i || break
1335 run_test 25 "Create new pool and restart MDS ======================="
1337 log "cleanup: ======================================================"
1339 cleanup_pools $FSNAME
1340 check_and_cleanup_lustre
1341 echo '=========================== finished ==============================='
1342 [ -f "$POOLSLOG" ] && cat $POOLSLOG && grep -q FAIL $POOLSLOG && exit 1 || true
1343 echo "$0: completed"