3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # Run test by setting NOSETUP=true when ltest has setup env for us
9 export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
12 ALWAYS_EXCEPT="$OST_POOLS_EXCEPT"
13 # bug number for skipped test: -
14 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
16 [ "$ALWAYS_EXCEPT$EXCEPT" ] && \
17 echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT`"
22 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
23 . $LUSTRE/tests/test-framework.sh
25 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
27 check_and_setup_lustre
32 POOLSLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
33 [ "$POOLSLOG" ] && rm -f $POOLSLOG || true
36 FAIL_ON_ERROR=${FAIL_ON_ERROR:-true}
40 SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
41 GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"}
44 TSTUSR=${TSTUSR:-"quota_usr"}
46 RUNAS="runas -u $TSTID -g $TSTID"
52 NON_EXISTANT_POOL=nonexistantpool
53 NON_EXISTANT_FS=nonexistantfs
54 INVALID_POOL=some_invalid_pool_name
57 TGT_MAX=$((TGT_COUNT-1))
59 TGT_LIST=$(seq $TGT_FIRST $TGT_STEP $TGT_MAX)
60 TGT_LIST2=$(seq $TGT_FIRST 2 $TGT_MAX)
62 TGT_ALL="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/1]"
63 TGT_HALF="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]"
65 TGT_UUID=$(for i in $TGT_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
66 TGT_UUID2=$(for i in $TGT_LIST2; do printf "$FSNAME-OST%04x_UUID " $i; done)
71 local count=${3:-"-1"}
76 $SETSTRIPE -c $count -p $pool $dir -o $idx
78 $SETSTRIPE -c $count -p $pool $dir
81 error "$SETSTRIPE -p $pool $dir failed."
87 local count=${3:-"-1"}
88 local index=${4:-"-1"}
90 $SETSTRIPE -o $index -c $count -p $pool $file
92 error "$SETSTRIPE -p $pool $file failed."
98 for i in $(do_facet mds lctl pool_list $FSNAME.$pool | grep -v "^Pool:" \
99 | sed -e 's/_UUID$//;s/^.*-OST//'); do
100 res="$res $(printf "%d" 0x$i)"
105 check_dir_in_pool() {
108 local res=$($GETSTRIPE $dir | grep "^stripe_count:" \
109 | cut -d ':' -f 5 | tr -d "[:blank:]")
110 if [[ "$res" == "$pool" ]]; then
113 error found $res instead of $pool
118 check_file_in_pool() {
119 local osts=$(osts_in_pool $2)
120 check_file_in_osts $1 "$osts" $3
123 check_file_in_osts() {
125 local pool_list=${2:-$TGT_LIST}
127 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
131 found=$(echo :$pool_list: | tr " " ":" | grep :$i:)
132 if [[ "$found" == "" ]]; then
133 echo "pool list: $pool_list"
134 echo "striping: $res"
136 error "$file not allocated from OSTs $pool_list."
141 local ost_count=$($GETSTRIPE $file | grep 0x | wc -l)
142 [[ -n "$count" ]] && [[ $ost_count -ne $count ]] && \
143 error "Stripe count $count expected; got $ost_count"
148 check_file_not_in_pool() {
151 local res=$($GETSTRIPE -v $file | grep "^pool:" | tr -d "[:blank:]" | cut -f 2 -d ':')
152 if [[ "$res" == "$pool" ]]; then
153 error "File $file is in pool: $res"
160 check_dir_not_in_pool() {
163 local res=$($GETSTRIPE -v $dir | grep "^stripe_count" | head -1 | cut -f 8 -d ' ')
164 if [[ "$res" == "$pool" ]]; then
165 error "File $dir is in pool: $res"
173 do_facet mds lctl pool_new $FSNAME.$1
175 # get param should return err until pool is created
176 [[ $RC -ne 0 ]] && return $RC
178 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$1 \
179 2>/dev/null || echo foo" "" || RC=1
180 [[ $RC -ne 0 ]] && error "pool_new failed"
185 OSTS=$(do_facet mds lctl pool_list $1 | awk '$1 !~ /^Pool:/ {print $1}')
188 do_facet mds lctl pool_remove $1 $ost
190 do_facet mds lctl pool_destroy $1
196 do_facet mds lctl pool_list $FSNAME.$1
198 [[ $RC -ne 0 ]] && return $RC
200 destroy_pool_int $FSNAME.$1
202 [[ $RC -ne 0 ]] && return $RC
204 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$1 \
205 2>/dev/null || echo foo" "foo" && return 0
211 local tgt="${3}$(lctl get_param -n lov.$FSNAME-*.pools.$pool | sort -u | tr '\n' ' ')"
213 do_facet mds lctl pool_add $FSNAME.$pool $osts
215 [[ $RC -ne 0 ]] && return $RC
217 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool | sort -u | tr '\n' ' ' " "$tgt" || RC=1
218 [[ $RC -ne 0 ]] && error "pool_add failed: $1; $2"
222 create_pool_nofail() {
226 error "Pool creation of $1 failed"
234 error "Pool creation of $1 succeeded; should have failed"
239 # Destroy pools from previous test runs
240 for p in $(do_facet mds lctl pool_list $FSNAME | grep $FSNAME.pool[0-$OSTCOUNT]); do
243 rm -rf $DIR/d0.${TESTSUITE}
252 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
253 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
256 # Tests for new commands added
259 echo "Creating a pool with a 1 character pool name"
262 echo "Creating a pool with a 10 character pool name"
263 create_pool_nofail p123456789
264 destroy_pool p123456789
266 echo "Creating a pool with a 16 character pool name"
267 create_pool_nofail p123456789123456
268 destroy_pool p123456789123456
270 echo "Creating a pool with a 17 character pool name; should fail"
271 create_pool_fail p1234567891234567
273 echo "Creating a pool with a 1000 character pool name; should fail"
275 for i in `seq 1 999`; do NAME=${NAME}"o"; done
276 create_pool_fail $NAME
278 echo "pool_new should fail if fs-name or poolname are missing."
279 do_facet mds lctl pool_new .pool1
281 error "pool_new did not fail even though fs-name was missing."
282 do_facet mds lctl pool_new pool1
284 error "pool_new did not fail even though fs-name was missing."
285 do_facet mds lctl pool_new ${FSNAME}.
287 error "pool_new did not fail even though pool name was missing."
288 do_facet mds lctl pool_new .
290 error "pool_new did not fail even though pool name and fs-name " \
292 do_facet mds lctl pool_new ${FSNAME},pool1
294 error "pool_new did not fail even though pool name format was wrong"
295 do_facet mds lctl pool_new ${FSNAME}/pool1
297 error "pool_new did not fail even though pool name format was wrong"
299 do_facet mds lctl pool_new ${FSNAME}.p
301 error "pool_new did not fail even though pool1 existed"
305 run_test 1 "Test lctl pool_new ========================================="
310 do_facet mds lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
312 error " pool_add did not fail even though pool did " \
315 run_test 2a "pool_add: non-existant pool"
318 do_facet mds lctl pool_add $FSNAME.p1234567891234567890 $FSNAME-OST0000
320 error "pool_add did not fail even though pool name was invalid."
322 run_test 2b "pool_add: Invalid pool name"
324 # Testing various combinations of OST name list
329 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
333 create_pool_nofail $POOL
336 do_facet mds lctl pool_add $FSNAME.$POOL OST0000
337 RC=$?; [[ $RC -eq 0 ]] || \
338 error "pool_add failed. $FSNAME $POOL OST0000: $RC"
339 do_facet mds lctl pool_remove $FSNAME.$POOL OST0000
342 do_facet mds lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
343 RC=$?; [[ $RC -eq 0 ]] || \
344 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000: $RC"
345 do_facet mds lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
347 # 3. lustreÂOST0000_UUID
348 do_facet mds lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
349 RC=$?; [[ $RC -eq 0 ]] || \
350 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000_UUID: $RC"
351 do_facet mds lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
353 # 4. lustreÂOST[0,1,2,3,]
355 for i in $TGT_LIST; do TGT=${TGT}$(printf "$i," $i); done
357 do_facet mds lctl pool_add $FSNAME.$POOL $TGT
359 error "pool_add failed. $FSNAME.$POOL $TGT. $RC"
360 do_facet mds lctl pool_remove $FSNAME.$POOL $TGT
362 # 5. lustreÂOST[0-5/1]
363 do_facet mds lctl pool_add $FSNAME.$POOL $TGT_ALL
364 RC=$?; [[ $RC -eq 0 ]] || \
365 error "pool_add failed. $FSNAME $POOL" "$TGT_ALL $RC"
366 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
367 sort -u | tr '\n' ' ' " "$TGT_UUID" || error "Add to pool failed"
368 do_facet mds lctl pool_remove $FSNAME.$POOL $TGT_ALL
372 run_test 2c "pool_add: OST index combinations ==========================="
378 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
382 create_pool_nofail $POOL
384 TGT=$(printf "$FSNAME-OST%04x_UUID " $OSTCOUNT)
385 do_facet mds lctl pool_add $FSNAME.$POOL $TGT
386 RC=$?; [[ $RC -ne 0 ]] || \
387 error "pool_add succeeded for an OST ($TGT) that does not exist."
391 run_test 2d "pool_add: OSTs that don't exist should be rejected ========"
398 $LCTL get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
402 create_pool_nofail $POOL
404 TGT="$FSNAME-OST0000_UUID "
405 do_facet mds lctl pool_add $FSNAME.$POOL $TGT
406 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
407 sort -u | tr '\n' ' ' " "$TGT" || error "Add to pool failed"
408 RESULT=$(do_facet mds "LOCALE=C $LCTL pool_add $FSNAME.$POOL $TGT 2>&1")
413 error "pool_add succeeded for an OST that was already in the pool."
415 [[ $(grep "already in pool" <<< $RESULT) ]] || \
416 error "pool_add failed as expected but error message not as expected."
420 run_test 2e "pool_add: OST already in a pool should be rejected ========"
423 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
427 do_facet mds lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
429 error "pool_remove did not fail even though" \
430 "pool did not exist."
432 run_test 3a "pool_remove: non-existant pool"
435 do_facet mds lctl pool_remove ${NON_EXISTANT_FS}.$POOL OST0000
437 error "pool_remove did not fail even though fsname did not exist."
439 run_test 3b "pool_remove: non-existant fsname"
442 do_facet mds lctl pool_remove $FSNAME.p1234567891234567890 $FSNAME-OST0000
444 error "pool_remove did not fail even though pool name was invalid."
446 run_test 3c "pool_remove: Invalid pool name"
449 # Testing various combinations of OST name list
451 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
455 create_pool_nofail $POOL
456 do_facet mds lctl pool_add $FSNAME.$POOL OST0000
457 do_facet mds lctl pool_remove $FSNAME.$POOL OST0000
459 error "pool_remove failed. $FSNAME $POOL OST0000"
461 do_facet mds lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
462 do_facet mds lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
464 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000"
466 do_facet mds lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
467 do_facet mds lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
469 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000_UUID"
471 add_pool $POOL $TGT_ALL "$TGT_UUID"
473 do_facet mds lctl pool_remove $FSNAME.$POOL $TGT_ALL
475 error "pool_remove failed. $FSNAME $POOL" $TGT_ALL
479 run_test 3d "pool_remove: OST index combinations ==========================="
482 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
486 do_facet mds lctl pool_destroy $FSNAME.$POOL
488 error "pool_destroy did not fail even though pool did not exist."
490 run_test 4a "pool_destroy: non-existant pool"
493 do_facet mds lctl pool_destroy ${NON_EXISTANT_FS}.$POOL
495 error "pool_destroy did not fail even though the filesystem did not exist."
497 run_test 4b "pool_destroy: non-existant fs-name"
500 create_pool_nofail $POOL
501 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
503 do_facet mds lctl pool_destroy ${FSNAME}.$POOL
505 error "pool_destroy succeeded with a non-empty pool name."
508 run_test 4c "pool_destroy: non-empty pool ==============================="
515 error "pool_list did not fail even though fsname was not mentioned."
520 create_pool_nofail $POOL
521 create_pool_nofail $POOL2
522 $LCMD pool_list $FSNAME
524 error "pool_list $FSNAME failed."
526 do_facet mds lctl pool_add $FSNAME.$POOL $TGT_ALL
528 $LCMD pool_list $FSNAME.$POOL
530 error "pool_list $FSNAME.$POOL failed."
532 $LCMD pool_list ${NON_EXISTANT_FS}
534 error "pool_list did not fail for a non-existant fsname $NON_EXISTANT_FS"
536 $LCMD pool_list ${FSNAME}.$NON_EXISTANT_POOL
538 error "pool_list did not fail for a non-existant pool $NON_EXISTANT_POOL"
540 if [[ ! $(grep mds <<< $LCMD) ]]; then
541 echo $LCMD pool_list $DIR
544 error "pool_list failed for $DIR"
547 $LCMD pool_list ${DIR}/d1
549 error "pool_list failed for ${DIR}/d1"
552 rm -rf ${DIR}nonexistant
553 $LCMD pool_list ${DIR}nonexistant
555 error "pool_list did not fail for invalid mountpoint ${DIR}nonexistant"
562 # Issue commands from client
566 # Issue commands from MDS
567 sub_test_5 "do_facet mds lctl"
568 sub_test_5 "do_facet mds lfs"
571 run_test 5 "lfs/lctl pool_list"
574 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
575 local POOL_DIR=$POOL_ROOT/dir_tst
576 local POOL_FILE=$POOL_ROOT/file_tst
578 create_pool_nofail $POOL
580 do_facet mds lctl pool_list $FSNAME
582 error "pool_list $FSNAME failed."
584 do_facet mds lctl pool_add $FSNAME.$POOL $TGT_ALL
587 $SETSTRIPE -c -1 -p $POOL $POOL_DIR
589 error "$SETSTRIPE -p $POOL failed."
590 check_dir_in_pool $POOL_DIR $POOL
592 # If an invalid pool name is specified, the command should fail
593 $SETSTRIPE -c 2 -p $INVALID_POOL $POOL_DIR
595 error_ignore 19919 "setstripe to invalid pool did not fail."
597 # If the pool name does not exist, the command should fail
598 $SETSTRIPE -c 2 -p $NON_EXISTANT_POOL $POOL_DIR
600 error_ignore 19919 "setstripe to non-existant pool did not fail."
602 # lfs setstripe should work as before if a pool name is not specified.
603 $SETSTRIPE -c -1 $POOL_DIR
605 error "$SETSTRIPE -p $POOL_DIR failed."
606 $SETSTRIPE -c -1 $POOL_FILE
608 error "$SETSTRIPE -p $POOL_FILE failed."
610 # lfs setstripe should fail if a start index that is outside the
612 create_pool_nofail $POOL2
613 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
614 $SETSTRIPE -o 1 -p $POOL2 $ROOT_POOL/$tfile
616 error "$SETSTRIPE with start index outside the pool did not fail."
621 run_test 6 "getstripe/setstripe"
624 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
626 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
628 create_pool_nofail $POOL
629 create_pool_nofail $POOL2
631 do_facet mds lctl pool_add $FSNAME.$POOL \
632 $FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]
633 local start=$((TGT_FIRST+1))
634 do_facet mds lctl pool_add $FSNAME.$POOL2 \
635 $FSNAME-OST[$start-$TGT_MAX/2]
637 create_dir $POOL_ROOT/dir1 $POOL
638 create_dir $POOL_ROOT/dir2 $POOL2
639 check_dir_in_pool $POOL_ROOT/dir1 $POOL
640 check_dir_in_pool $POOL_ROOT/dir1 $POOL
643 createmany -o $POOL_ROOT/dir1/$tfile $numfiles || \
644 error "createmany $POOL_ROOT/dir1/$tfile failed!"
646 for file in $POOL_ROOT/dir1/*; do
647 check_file_in_pool $file $POOL
650 createmany -o $POOL_ROOT/dir2/$tfile $numfiles || \
651 error "createmany $POOL_ROOT/dir2/$tfile failed!"
652 for file in $POOL_ROOT/dir2/*; do
653 check_file_in_pool $file $POOL2
656 rm -rf $POOL_ROOT/dir?
663 run_test 11 "OSTs in overlapping/multiple pools"
666 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
668 [[ $OSTCOUNT -le 2 ]] && skip "Need atleast 3 OSTs" && return
670 create_pool_nofail $POOL
671 create_pool_nofail $POOL2
673 do_facet mds lctl pool_add $FSNAME.$POOL \
674 $FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]
675 local start=$((TGT_FIRST+1))
676 do_facet mds lctl pool_add $FSNAME.$POOL2 \
677 $FSNAME-OST[$start-$TGT_MAX/2]
679 echo creating some files in $POOL and $POOL2
681 create_dir $POOL_ROOT/dir1 $POOL
682 create_dir $POOL_ROOT/dir2 $POOL2
683 create_file $POOL_ROOT/file1 $POOL
684 create_file $POOL_ROOT/file2 $POOL2
686 echo Checking the files created
687 check_dir_in_pool $POOL_ROOT/dir1 $POOL
688 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
689 check_file_in_pool $POOL_ROOT/file1 $POOL
690 check_file_in_pool $POOL_ROOT/file2 $POOL2
692 echo Changing the pool membership
693 do_facet mds lctl pool_remove $FSNAME.$POOL $FSNAME-OST[$TGT_FIRST]
694 do_facet mds lctl pool_list $FSNAME.$POOL
695 do_facet mds lctl pool_add $FSNAME.$POOL2 $FSNAME-OST[$TGT_FIRST]
696 do_facet mds lctl pool_list $FSNAME.$POOL2
698 echo Checking the files again
699 check_dir_in_pool $POOL_ROOT/dir1 $POOL
700 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
701 check_file_in_osts $POOL_ROOT/file1 "$TGT_LIST2"
702 check_file_in_osts $POOL_ROOT/file2 "$(seq $start 2 $TGT_MAX)"
704 echo Creating some more files
705 create_dir $POOL_ROOT/dir3 $POOL
706 create_dir $POOL_ROOT/dir4 POOL2
707 create_file $POOL_ROOT/file3 $POOL
708 create_file $POOL_ROOT/file4 $POOL2
710 echo Checking the new files
711 check_file_in_pool $POOL_ROOT/file3 $POOL
712 check_file_in_pool $POOL_ROOT/file4 $POOL2
719 run_test 12 "OST Pool Membership"
722 [[ $OSTCOUNT -le 2 ]] && skip "Need atleast 3 OSTs" && return
724 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
728 create_pool_nofail $POOL
729 do_facet mds lctl pool_add $FSNAME.$POOL $TGT_ALL
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?
782 run_test 13 "Striping characteristics in a pool"
785 [[ $OSTCOUNT -le 2 ]] && skip "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_osts $POOL_ROOT/dir1/file${i} $OST
816 # Fill OST $TGT_FIRST with 10M files
817 create_dir $POOL_ROOT/dir2 $POOL2 1
820 while [[ $RC -eq 0 ]];
822 dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1k count=$((1024*10))
827 # Leave some space on the OST
828 rm -f $POOL_ROOT/dir2/f0
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
845 run_test 14 "Round robin and QOS striping within a pool"
848 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
852 while [[ $i -lt $OSTCOUNT ]]
854 create_pool_nofail pool${i}
856 local tgt=$(printf "$FSNAME-OST%04x_UUID " $i)
857 add_pool pool${i} "$FSNAME-OST[$i]" "$tgt"
858 create_dir $POOL_ROOT/dir${i} pool${i}
859 createmany -o $POOL_ROOT/dir$i/$tfile $numfiles || \
860 error "createmany $POOL_ROOT/dir$i/$tfile failed!"
862 for file in $POOL_ROOT/dir$i/*; do
863 check_file_in_osts $file $i
870 while [[ $i -lt $OSTCOUNT ]]
872 destroy_pool pool${i}
878 run_test 15 "One directory per OST/pool"
881 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
885 create_pool_nofail $POOL
887 add_pool $POOL $TGT_HALF "$TGT_UUID2"
889 local dir=$POOL_ROOT/$tdir
890 create_dir $dir $POOL
892 for i in $(seq 1 10); do
897 createmany -o $dir/$tfile $numfiles || \
898 error "createmany $dir/$tfile failed!"
900 for file in $dir/*; do
901 check_file_in_pool $file $POOL
904 rm -rf $POOL_ROOT/$tdir
910 run_test 16 "Inheritance of pool properties"
913 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
917 create_pool_nofail $POOL
919 add_pool $POOL $TGT_ALL "$TGT_UUID"
921 local dir=$POOL_ROOT/dir
922 create_dir $dir $POOL
924 createmany -o $dir/${tfile}1_ $numfiles || \
925 error "createmany $dir/${tfile}1_ failed!"
927 for file in $dir/*; do
928 check_file_in_pool $file $POOL
933 createmany -o $dir/${tfile}2_ $numfiles || \
934 error "createmany $dir/${tfile}2_ failed!"
939 run_test 17 "Referencing an empty pool"
947 sync; sleep 5 # give pending IO a chance to go to disk
948 stat=$(createmany -o $dir/${tfile} $numfiles)
951 time=$(echo $stat | cut -f 5 -d ' ')
952 echo $stat > /dev/stderr
957 local t1=$(create_perf_one $1 $2)
958 local t2=$(create_perf_one $1 $2)
959 local t3=$(create_perf_one $1 $2)
960 local time=$(echo "scale=2; ( $t1 + $t2 + $t3 ) / 3" | bc)
966 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
972 local dir=$POOL_ROOT/dir
976 time1=$(create_perf $dir $numfiles)
978 create_pool_nofail $POOL
980 add_pool $POOL $TGT_ALL "$TGT_UUID"
982 create_dir $dir $POOL
983 time2=$(create_perf $dir $numfiles)
987 time3=$(create_perf $dir $numfiles)
989 echo Time taken for $numfiles creates without pools: $time1
990 echo Time taken for $numfiles creates with pools: $time2
991 echo Time taken for $numfiles creates without pools: $time3
993 deg=$(echo "scale=2; (($time2 - $time3) * 100 / $time3) > 5" | bc)
994 diff=$(echo "scale=2; ($time2 - $time3) * 100 / $time3" | bc)
996 if [[ "$deg" == "1" ]]; then
997 error "Performance degradation with pools is $diff %."
999 echo "Performance degradation with pools is $diff %."
1003 run_test 18 "File create in a directory which references a deleted pool"
1007 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1009 local dir1=$POOL_ROOT/dir1
1010 local dir2=$POOL_ROOT/dir2
1013 create_pool_nofail $POOL
1015 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1017 create_dir $dir1 $POOL
1018 createmany -o $dir1/${tfile} $numfiles || \
1019 error "createmany $dir1/${tfile} failed!"
1020 for file in $dir1/*; do
1021 check_file_in_pool $file $POOL
1025 createmany -o $dir2/${tfile} $numfiles || \
1026 error "createmany $dir2/${tfile} failed!"
1027 for file in $dir2/*; do
1028 check_file_not_in_pool $file $POOL
1036 run_test 19 "Pools should not come into play when not specified"
1039 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1041 local dir1=$POOL_ROOT/dir1
1042 local dir2=$dir1/dir2
1043 local dir3=$dir1/dir3
1047 create_pool_nofail $POOL
1048 create_pool_nofail $POOL2
1050 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1052 local start=$((TGT_FIRST+1))
1053 TGT=$(for i in `seq $start 2 $TGT_MAX`; \
1054 do printf "$FSNAME-OST%04x_UUID " $i; done)
1055 add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1057 create_dir $dir1 $POOL
1058 create_file $dir1/file1 $POOL2
1059 create_dir $dir2 $POOL2
1062 $SETSTRIPE -c 1 $dir3 # No pool assignment
1064 $SETSTRIPE -c 1 $dir2/file4 # No pool assignment
1066 check_file_in_pool $dir1/file1 $POOL2
1067 check_file_in_pool $dir2/file2 $POOL2
1069 check_dir_not_in_pool $dir3 $POOL
1070 check_dir_not_in_pool $dir3 $POOL2
1072 check_file_not_in_pool $dir3/file3 $POOL
1073 check_file_not_in_pool $dir3/file3 $POOL2
1075 check_file_not_in_pool $dir2/file4 $POOL
1076 check_file_not_in_pool $dir2/file4 $POOL2
1084 run_test 20 "Different pools in a directory hierarchy."
1087 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1088 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1092 local dir=$POOL_ROOT/dir
1094 create_pool_nofail $POOL
1096 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1098 create_dir $dir $POOL $OSTCOUNT
1099 create_file $dir/file1 $POOL $OSTCOUNT
1100 $GETSTRIPE -v $dir/file1
1101 check_file_in_pool $dir/file1 $POOL
1108 run_test 21 "OST pool with fewer OSTs than stripe count"
1116 for c in $(seq 1 10);
1118 echo "Pool $pool, iteration $c"
1119 create_pool_nofail $pool
1120 local TGT=$(for i in `seq $TGT_FIRST $step $TGT_MAX`; \
1121 do printf "$FSNAME-OST%04x_UUID " $i; done)
1122 add_pool $pool "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/$step]" "$TGT"
1124 do_facet mds lctl pool_list $FSNAME
1126 echo loop for $pool complete
1130 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1131 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1138 create_dir $POOL_ROOT $POOL
1139 createmany -o $POOL_ROOT/${tfile} $numfiles || \
1140 error "createmany $POOL_ROOT/${tfile} failed!"
1145 run_test 22 "Simultaneous manipulation of a pool"
1148 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1149 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1152 check_runas_id $TSTID $TSTID $RUNAS || {
1153 skip "User $RUNAS_ID does not exist - skipping"
1161 local dir=$POOL_ROOT/dir
1162 local file1="$dir/$tfile-quota1"
1163 local file2="$dir/$tfile-quota2"
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 $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir #-i 5 -I 5 $dir
1176 $LFS setstripe $file1 -c 1 -p $POOL
1177 chown $TSTUSR.$TSTUSR $file1
1181 stat=$(LC_ALL=C $RUNAS dd if=/dev/zero of=$file1 bs=1024 count=$((LIMIT*2)) 2>&1)
1184 [[ $RC -eq 0 ]] && error "dd did not fail with EDQUOT."
1185 echo $stat | grep "Disk quota exceeded"
1186 [[ $? -eq 1 ]] && error "dd did not fail with EDQUOT."
1189 $LFS quotaoff -ug $MOUNT
1190 # $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir
1191 chown $TSTUSR.$TSTUSR $dir
1194 while [ $RC -eq 0 ];
1197 stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file2}$i bs=1024 \
1198 count=$((LIMIT*LIMIT)) 2>&1)
1200 if [ $RC -eq 1 ]; then
1202 echo $stat | grep "Disk quota exceeded"
1203 [[ $? -eq 0 ]] && error "dd failed with EDQUOT"
1205 echo $stat | grep "No space left on device"
1206 [[ $? -ne 0 ]] && error "dd did not fail with ENOSPC; " \
1218 run_test 23 "OST pools and quota"
1221 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1222 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1231 create_pool_nofail $POOL
1233 add_pool $POOL $TGT_ALL "$TGT_UUID"
1235 create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1237 mkdir $POOL_ROOT/dir2
1238 $SETSTRIPE $POOL_ROOT/dir2 -p $POOL -s 65536 -i 0 -c 1 || \
1239 error "$SETSTRIPE $POOL_ROOT/dir2 failed"
1241 mkdir $POOL_ROOT/dir3
1242 $SETSTRIPE $POOL_ROOT/dir3 -s 65536 -i 0 -c 1 || \
1243 error "$SETSTRIPE $POOL_ROOT/dir3 failed"
1245 mkdir $POOL_ROOT/dir4
1247 for i in $(seq 1 4);
1249 dir=${POOL_ROOT}/dir${i}
1258 createmany -o $dir/${tfile} $numfiles || \
1259 error "createmany $dir/${tfile} failed!"
1260 res=$($GETSTRIPE -v $dir | grep "^stripe_count:")
1261 if [ $? -ne 0 ]; then
1262 res=$($GETSTRIPE -v $dir | grep "^(Default) ")
1263 pool=$(cut -f 9 -d ' ' <<< $res)
1264 index=$(cut -f 7 -d ' ' <<< $res)
1265 size=$(cut -f 5 -d ' ' <<< $res)
1266 count=$(cut -f 3 -d ' ' <<< $res)
1268 pool=$(cut -f 8 -d ' ' <<< $res)
1269 index=$(cut -f 6 -d ' ' <<< $res)
1270 size=$(cut -f 4 -d ' ' <<< $res)
1271 count=$(cut -f 2 -d ' ' <<< $res)
1274 for file in $dir/*; do
1275 if [ "$pool" != "" ]; then
1276 check_file_in_pool $file $pool
1278 pool1=$($GETSTRIPE -v $file | grep "^pool:" |\
1279 tr -d '[:blank:]' | cut -f 2 -d ':')
1280 count1=$($GETSTRIPE -v $file | grep "^lmm_stripe_count:" |\
1281 tr -d '[:blank:]' | cut -f 2 -d ':')
1282 size1=$($GETSTRIPE -v $file | grep "^lmm_stripe_size:" |\
1283 tr -d '[:blank:]' | cut -f 2 -d ':')
1284 [[ "$pool" != "$pool1" ]] && \
1285 error "Pool name ($pool) not inherited in $file($pool1)"
1286 [[ "$count" != "$count1" ]] && \
1287 error "Stripe count ($count) not inherited in $file ($count1)"
1288 [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] && \
1289 error "Stripe size ($size) not inherited in $file ($size1)"
1298 run_test 24 "Independence of pool from other setstripe parameters"
1300 log "cleanup: ======================================================"
1303 check_and_cleanup_lustre
1304 echo '=========================== finished ==============================='
1305 [ -f "$POOLSLOG" ] && cat $POOLSLOG && grep -q FAIL $POOLSLOG && exit 1 || true
1306 echo "$0: completed"