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}
29 check_and_setup_lustre
34 POOLSLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
35 [ "$POOLSLOG" ] && rm -f $POOLSLOG || true
38 FAIL_ON_ERROR=${FAIL_ON_ERROR:-true}
42 SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
43 GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"}
46 TSTUSR=${TSTUSR:-"quota_usr"}
48 RUNAS="runas -u $TSTID -g $TSTID"
54 NON_EXISTANT_POOL=nonexistantpool
55 NON_EXISTANT_FS=nonexistantfs
56 INVALID_POOL=some_invalid_pool_name
59 TGT_MAX=$((TGT_COUNT-1))
61 TGT_LIST=$(seq $TGT_FIRST $TGT_STEP $TGT_MAX)
62 TGT_LIST2=$(seq $TGT_FIRST 2 $TGT_MAX)
64 TGT_ALL="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/1]"
65 TGT_HALF="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]"
67 TGT_UUID=$(for i in $TGT_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
68 TGT_UUID2=$(for i in $TGT_LIST2; do printf "$FSNAME-OST%04x_UUID " $i; done)
73 local count=${3:-"-1"}
78 $SETSTRIPE -c $count -p $pool $dir -o $idx
80 $SETSTRIPE -c $count -p $pool $dir
83 error "$SETSTRIPE -p $pool $dir failed."
89 local count=${3:-"-1"}
90 local index=${4:-"-1"}
92 $SETSTRIPE -o $index -c $count -p $pool $file
94 error "$SETSTRIPE -p $pool $file failed."
100 for i in $(do_facet $SINGLEMDS lctl pool_list $FSNAME.$pool | \
101 grep -v "^Pool:" | sed -e 's/_UUID$//;s/^.*-OST//'); do
102 res="$res $(printf "%d" 0x$i)"
107 check_dir_in_pool() {
110 local res=$($GETSTRIPE $dir | grep "^stripe_count:" \
111 | cut -d ':' -f 5 | tr -d "[:blank:]")
112 if [[ "$res" == "$pool" ]]; then
115 error found $res instead of $pool
120 check_file_in_pool() {
121 local osts=$(osts_in_pool $2)
122 check_file_in_osts $1 "$osts" $3
125 check_file_in_osts() {
127 local pool_list=${2:-$TGT_LIST}
129 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
133 found=$(echo :$pool_list: | tr " " ":" | grep :$i:)
134 if [[ "$found" == "" ]]; then
135 echo "pool list: $pool_list"
136 echo "striping: $res"
138 error "$file not allocated from OSTs $pool_list."
143 local ost_count=$($GETSTRIPE $file | grep 0x | wc -l)
144 [[ -n "$count" ]] && [[ $ost_count -ne $count ]] && \
145 { error "Stripe count $count expected; got $ost_count" && return 1; }
150 check_file_not_in_pool() {
153 local res=$($GETSTRIPE -v $file | grep "^pool:" | tr -d "[:blank:]" | cut -f 2 -d ':')
154 if [[ "$res" == "$pool" ]]; then
155 error "File $file is in pool: $res"
162 check_dir_not_in_pool() {
165 local res=$($GETSTRIPE -v $dir | grep "^stripe_count" | head -1 | \
167 if [[ "$res" == "$pool" ]]; then
168 error "File $dir is in pool: $res"
177 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool" ""\
178 ||error "Failed to remove targets from pool: $pool"
184 local tgt="${3}$(lctl get_param -n lov.$FSNAME-*.pools.$pool | \
185 sort -u | tr '\n' ' ')"
187 do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool $osts
189 [[ $RC -ne 0 ]] && return $RC
191 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool | \
192 sort -u | tr '\n' ' ' " "$tgt" || RC=1
193 [[ $RC -ne 0 ]] && error "pool_add failed: $1; $2"
197 create_pool_nofail() {
198 create_pool $FSNAME.$1
201 error "Pool creation of $1 failed"
206 create_pool $FSNAME.$1
209 error "Pool creation of $1 succeeded; should have failed"
214 # Destroy pools from previous test runs
215 for p in $(do_facet $SINGLEMDS lctl pool_list $FSNAME | \
216 grep $FSNAME.pool[0-$OSTCOUNT]); do
219 rm -rf $DIR/d0.${TESTSUITE}
228 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
229 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
232 trap "cleanup_pools $FSNAME" EXIT
234 # Tests for new commands added
236 echo "Creating a pool with a 1 character pool name"
239 echo "Creating a pool with a 10 character pool name"
240 create_pool_nofail p123456789
241 destroy_pool p123456789
243 echo "Creating a pool with a 16 character pool name"
244 create_pool_nofail p123456789123456
245 destroy_pool p123456789123456
247 echo "Creating a pool with a 17 character pool name; should fail"
248 create_pool_fail p1234567891234567
250 echo "Creating a pool with a 1000 character pool name; should fail"
252 for i in `seq 1 999`; do NAME=${NAME}"o"; done
253 create_pool_fail $NAME
255 echo "pool_new should fail if fs-name or poolname are missing."
256 do_facet $SINGLEMDS lctl pool_new .pool1 2>/dev/null
258 error "pool_new did not fail even though fs-name was missing."
259 do_facet $SINGLEMDS lctl pool_new pool1 2>/dev/null
261 error "pool_new did not fail even though fs-name was missing."
262 do_facet $SINGLEMDS lctl pool_new ${FSNAME}. 2>/dev/null
264 error "pool_new did not fail even though pool name was missing."
265 do_facet $SINGLEMDS lctl pool_new . 2>/dev/null
267 error "pool_new did not fail even though pool name and fs-name " \
269 do_facet $SINGLEMDS lctl pool_new ${FSNAME},pool1 2>/dev/null
271 error "pool_new did not fail even though pool name format was wrong"
272 do_facet $SINGLEMDS lctl pool_new ${FSNAME}/pool1 2>/dev/null
274 error "pool_new did not fail even though pool name format was wrong"
276 do_facet $SINGLEMDS lctl pool_new ${FSNAME}.p 2>/dev/null
278 error "pool_new did not fail even though pool1 existed"
282 run_test 1 "Test lctl pool_new ========================================="
287 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
289 error " pool_add did not fail even though pool did " \
292 run_test 2a "pool_add: non-existant pool"
295 do_facet $SINGLEMDS lctl pool_add $FSNAME.p1234567891234567890 \
296 $FSNAME-OST0000 2>/dev/null
298 error "pool_add did not fail even though pool name was invalid."
300 run_test 2b "pool_add: Invalid pool name"
302 # Testing various combinations of OST name list
307 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
311 create_pool_nofail $POOL
314 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
315 RC=$?; [[ $RC -eq 0 ]] || \
316 error "pool_add failed. $FSNAME $POOL OST0000: $RC"
317 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
321 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
322 RC=$?; [[ $RC -eq 0 ]] || \
323 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000: $RC"
324 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
327 # 3. lustre-OST0000_UUID
328 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
329 RC=$?; [[ $RC -eq 0 ]] || \
330 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000_UUID: $RC"
331 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
334 # 4. lustre-OST[0,1,2,3,]
336 for i in $TGT_LIST; do TGT=${TGT}$(printf "$i," $i); done
338 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
340 error "pool_add failed. $FSNAME.$POOL $TGT. $RC"
341 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT
344 # 5. lustre-OST[0-5/1]
345 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
346 RC=$?; [[ $RC -eq 0 ]] || \
347 error "pool_add failed. $FSNAME $POOL" "$TGT_ALL $RC"
348 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
349 sort -u | tr '\n' ' ' " "$TGT_UUID" || error "Add to pool failed"
350 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
355 run_test 2c "pool_add: OST index combinations ==========================="
361 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
365 create_pool_nofail $POOL
367 TGT=$(printf "$FSNAME-OST%04x_UUID " $OSTCOUNT)
368 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
369 RC=$?; [[ $RC -ne 0 ]] || \
370 error "pool_add succeeded for an OST ($TGT) that does not exist."
374 run_test 2d "pool_add: OSTs that don't exist should be rejected ========"
381 $LCTL get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
385 create_pool_nofail $POOL
387 TGT="$FSNAME-OST0000_UUID "
388 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
389 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
390 sort -u | tr '\n' ' ' " "$TGT" || error "Add to pool failed"
391 RESULT=$(do_facet $SINGLEMDS \
392 "LOCALE=C $LCTL pool_add $FSNAME.$POOL $TGT 2>&1")
397 error "pool_add succeeded for an OST that was already in the pool."
399 [[ $(grep "already in pool" <<< $RESULT) ]] || \
400 error "pool_add failed as expected but error message not as expected."
404 run_test 2e "pool_add: OST already in a pool should be rejected ========"
407 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
411 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
413 error "pool_remove did not fail even though pool did not exist."
415 run_test 3a "pool_remove: non-existant pool"
418 do_facet $SINGLEMDS lctl pool_remove ${NON_EXISTANT_FS}.$POOL OST0000 2>/dev/null
420 error "pool_remove did not fail even though fsname did not exist."
422 run_test 3b "pool_remove: non-existant fsname"
425 do_facet $SINGLEMDS lctl pool_remove $FSNAME.p1234567891234567890 \
426 $FSNAME-OST0000 2>/dev/null
428 error "pool_remove did not fail even though pool name was invalid."
430 run_test 3c "pool_remove: Invalid pool name"
432 # Testing various combinations of OST name list
434 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
438 create_pool_nofail $POOL
439 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
440 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
442 error "pool_remove failed. $FSNAME $POOL OST0000"
445 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
446 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
448 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000"
451 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
452 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
454 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000_UUID"
457 add_pool $POOL $TGT_ALL "$TGT_UUID"
458 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
460 error "pool_remove failed. $FSNAME $POOL" $TGT_ALL
465 run_test 3d "pool_remove: OST index combinations ==========================="
468 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
472 do_facet $SINGLEMDS lctl pool_destroy $FSNAME.$POOL 2>/dev/null
474 error "pool_destroy did not fail even though pool did not exist."
476 run_test 4a "pool_destroy: non-existant pool"
479 do_facet $SINGLEMDS lctl pool_destroy ${NON_EXISTANT_FS}.$POOL 2>/dev/null
481 error "pool_destroy did not fail even though the filesystem did not exist."
483 run_test 4b "pool_destroy: non-existant fs-name"
486 create_pool_nofail $POOL
487 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
489 do_facet $SINGLEMDS lctl pool_destroy ${FSNAME}.$POOL
491 error "pool_destroy succeeded with a non-empty pool."
494 run_test 4c "pool_destroy: non-empty pool ==============================="
499 $LCMD pool_list 2>/dev/null
501 error "pool_list did not fail even though fsname was not mentioned."
503 destroy_pool $POOL 2>/dev/null
504 destroy_pool $POOL2 2>/dev/null
506 create_pool_nofail $POOL
507 create_pool_nofail $POOL2
508 $LCMD pool_list $FSNAME
510 error "pool_list $FSNAME failed."
512 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
514 $LCMD pool_list $FSNAME.$POOL
516 error "pool_list $FSNAME.$POOL failed."
518 $LCMD pool_list ${NON_EXISTANT_FS} 2>/dev/null
520 error "pool_list did not fail for a non-existant fsname $NON_EXISTANT_FS"
522 $LCMD pool_list ${FSNAME}.$NON_EXISTANT_POOL 2>/dev/null
524 error "pool_list did not fail for a non-existant pool $NON_EXISTANT_POOL"
526 if [[ ! $(grep $SINGLEMDS <<< $LCMD) ]]; then
527 echo $LCMD pool_list $DIR
530 error "pool_list failed for $DIR"
533 $LCMD pool_list ${DIR}/d1
535 error "pool_list failed for ${DIR}/d1"
538 rm -rf ${DIR}nonexistant
539 $LCMD pool_list ${DIR}nonexistant 2>/dev/null
541 error "pool_list did not fail for invalid mountpoint ${DIR}nonexistant"
548 # Issue commands from client
552 # Issue commands from MDS
553 sub_test_5 "do_facet $SINGLEMDS lctl"
554 sub_test_5 "do_facet $SINGLEMDS lfs"
557 run_test 5 "lfs/lctl pool_list"
560 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
561 local POOL_DIR=$POOL_ROOT/dir_tst
562 local POOL_FILE=$POOL_ROOT/file_tst
564 create_pool_nofail $POOL
566 do_facet $SINGLEMDS lctl pool_list $FSNAME
568 error "pool_list $FSNAME failed."
570 add_pool $POOL $TGT_ALL "$TGT_UUID"
573 $SETSTRIPE -c -1 -p $POOL $POOL_DIR
575 error "$SETSTRIPE -p $POOL failed."
576 check_dir_in_pool $POOL_DIR $POOL
578 # If an invalid pool name is specified, the command should fail
579 $SETSTRIPE -c 2 -p $INVALID_POOL $POOL_DIR 2>/dev/null
581 error "setstripe to invalid pool did not fail."
583 # If the pool name does not exist, the command should fail
584 $SETSTRIPE -c 2 -p $NON_EXISTANT_POOL $POOL_DIR 2>/dev/null
586 error "setstripe to non-existant pool did not fail."
588 # lfs setstripe should work as before if a pool name is not specified.
589 $SETSTRIPE -c -1 $POOL_DIR
591 error "$SETSTRIPE -p $POOL_DIR failed."
592 $SETSTRIPE -c -1 $POOL_FILE
594 error "$SETSTRIPE -p $POOL_FILE failed."
596 # lfs setstripe should fail if a start index that is outside the
598 create_pool_nofail $POOL2
599 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
600 $SETSTRIPE -o 1 -p $POOL2 $ROOT_POOL/$tfile 2>/dev/null
602 error "$SETSTRIPE with start index outside the pool did not fail."
607 run_test 6 "getstripe/setstripe"
610 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
612 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
614 create_pool_nofail $POOL
615 create_pool_nofail $POOL2
617 local start=$((TGT_FIRST+1))
618 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
619 $FSNAME-OST[$start-$TGT_MAX/2]
621 add_pool $POOL $TGT_HALF "$TGT_UUID2"
623 create_dir $POOL_ROOT/dir1 $POOL
624 create_dir $POOL_ROOT/dir2 $POOL2
625 check_dir_in_pool $POOL_ROOT/dir1 $POOL
626 check_dir_in_pool $POOL_ROOT/dir1 $POOL
629 createmany -o $POOL_ROOT/dir1/$tfile $numfiles || \
630 error "createmany $POOL_ROOT/dir1/$tfile failed!"
632 for file in $POOL_ROOT/dir1/*; do
633 check_file_in_pool $file $POOL
636 createmany -o $POOL_ROOT/dir2/$tfile $numfiles || \
637 error "createmany $POOL_ROOT/dir2/$tfile failed!"
638 for file in $POOL_ROOT/dir2/*; do
639 check_file_in_pool $file $POOL2
642 rm -rf $POOL_ROOT/dir?
649 run_test 11 "OSTs in overlapping/multiple pools"
652 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
654 [[ $OSTCOUNT -le 2 ]] && skip_env "Need atleast 3 OSTs" && return
656 create_pool_nofail $POOL
657 create_pool_nofail $POOL2
659 local start=$((TGT_FIRST+1))
660 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
661 $FSNAME-OST[$start-$TGT_MAX/2]
663 add_pool $POOL $TGT_HALF "$TGT_UUID2"
665 echo creating some files in $POOL and $POOL2
667 create_dir $POOL_ROOT/dir1 $POOL
668 create_dir $POOL_ROOT/dir2 $POOL2
669 create_file $POOL_ROOT/file1 $POOL
670 create_file $POOL_ROOT/file2 $POOL2
672 echo Checking the files created
673 check_dir_in_pool $POOL_ROOT/dir1 $POOL
674 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
675 check_file_in_pool $POOL_ROOT/file1 $POOL
676 check_file_in_pool $POOL_ROOT/file2 $POOL2
678 echo Changing the pool membership
679 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST[$TGT_FIRST]
680 do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL
681 FIRST_UUID=$(echo $TGT_UUID | awk '{print $1}')
682 add_pool $POOL2 $FSNAME-OST[$TGT_FIRST] "$FIRST_UUID "
683 do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL2
685 echo Checking the files again
686 check_dir_in_pool $POOL_ROOT/dir1 $POOL
687 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
688 check_file_in_osts $POOL_ROOT/file1 "$TGT_LIST2"
689 check_file_in_osts $POOL_ROOT/file2 "$(seq $start 2 $TGT_MAX)"
691 echo Creating some more files
692 create_dir $POOL_ROOT/dir3 $POOL
693 create_dir $POOL_ROOT/dir4 $POOL2
694 create_file $POOL_ROOT/file3 $POOL
695 create_file $POOL_ROOT/file4 $POOL2
697 echo Checking the new files
698 check_file_in_pool $POOL_ROOT/file3 $POOL
699 check_file_in_pool $POOL_ROOT/file4 $POOL2
706 run_test 12 "OST Pool Membership"
709 [[ $OSTCOUNT -le 2 ]] && skip_env "Need atleast 3 OSTs" && return
711 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
715 create_pool_nofail $POOL
716 add_pool $POOL $TGT_ALL "$TGT_UUID"
718 create_dir $POOL_ROOT/dir1 $POOL -1
719 createmany -o $POOL_ROOT/dir1/$tfile $numfiles || \
720 error "createmany $POOL_ROOT/dir1/$tfile failed!"
721 for file in $POOL_ROOT/dir1/*; do
722 check_file_in_pool $file $POOL $OSTCOUNT
725 create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
726 create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST+1))
727 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST+2))
728 check_file_in_pool $POOL_ROOT/dir1/file1 $POOL 1
729 check_file_in_pool $POOL_ROOT/dir1/file2 $POOL 1
730 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST+2))
731 check_file_in_osts $POOL_ROOT/dir1/file1 "$TGT_FIRST"
732 check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST+1))"
733 check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST+2))"
735 create_dir $POOL_ROOT/dir2 $POOL $count
736 createmany -o $POOL_ROOT/dir2/$tfile $numfiles || \
737 error "createmany $POOL_ROOT/dir2/$tfile failed!"
738 for file in $POOL_ROOT/dir2/*; do
739 check_file_in_pool $file $POOL $count
742 create_dir $POOL_ROOT/dir3 $POOL $count $((TGT_FIRST+1))
743 createmany -o $POOL_ROOT/dir3/$tfile_ $numfiles || \
744 error "createmany $POOL_ROOT/dir3/$tfile_ failed!"
745 for file in $POOL_ROOT/dir3/*; do
746 check_file_in_pool $file $POOL $count
749 create_dir $POOL_ROOT/dir4 $POOL 1
750 createmany -o $POOL_ROOT/dir4/$tfile_ $numfiles || \
751 error "createmany $POOL_ROOT/dir4/$tfile_ failed!"
752 for file in $POOL_ROOT/dir4/*; do
753 check_file_in_pool $file $POOL 1
756 create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST+2))
757 createmany -o $POOL_ROOT/dir5/$tfile_ $numfiles || \
758 error "createmany $POOL_ROOT/dir5/$tfile_ failed!"
759 for file in $POOL_ROOT/dir5/*; do
760 check_file_in_pool $file $POOL 1
761 check_file_in_osts $file "$((TGT_FIRST+2))"
764 rm -rf create_dir $POOL_ROOT/dir?
769 run_test 13 "Striping characteristics in a pool"
772 [[ $OSTCOUNT -le 2 ]] && skip_env "Need atleast 3 OSTs" && return
774 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
778 # Create a new filesystem that is guaranteed to be balanced.
782 create_pool_nofail $POOL
783 create_pool_nofail $POOL2
785 add_pool $POOL $TGT_HALF "$TGT_UUID2"
786 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
788 create_dir $POOL_ROOT/dir1 $POOL 1
789 create_file $POOL_ROOT/dir1/file $POOL 1
790 local OST=$($GETSTRIPE $POOL_ROOT/dir1/file | grep 0x | cut -f2)
792 while [[ $i -lt $numfiles ]];
795 [[ $OST -gt $TGT_MAX ]] && OST=$TGT_FIRST
797 # echo "Iteration: $i OST: $OST"
798 create_file $POOL_ROOT/dir1/file${i} $POOL 1
799 check_file_in_osts $POOL_ROOT/dir1/file${i} $OST
803 # Fill OST $TGT_FIRST with 10M files
804 create_dir $POOL_ROOT/dir2 $POOL2 1
807 while [[ $RC -eq 0 ]];
809 dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1k count=$((1024*10))
814 # Leave some space on the OST
815 rm -f $POOL_ROOT/dir2/f0
818 # OST $TGT_FIRST is no longer favored; but it may still be used.
819 create_dir $POOL_ROOT/dir3 $POOL 1
820 create_file $POOL_ROOT/dir3/file $POOL 1
821 createmany -o $POOL_ROOT/dir3/$tfile_ $numfiles || \
822 error "createmany $POOL_ROOT/dir3/$tfile_ failed!"
823 for file in $POOL_ROOT/dir3/*; do
824 check_file_in_pool $file $POOL
832 run_test 14 "Round robin and QOS striping within a pool"
835 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
839 while [[ $i -lt $OSTCOUNT ]]
841 create_pool_nofail pool${i}
843 local tgt=$(printf "$FSNAME-OST%04x_UUID " $i)
844 add_pool pool${i} "$FSNAME-OST[$i]" "$tgt"
845 create_dir $POOL_ROOT/dir${i} pool${i}
846 createmany -o $POOL_ROOT/dir$i/$tfile $numfiles || \
847 error "createmany $POOL_ROOT/dir$i/$tfile failed!"
849 for file in $POOL_ROOT/dir$i/*; do
850 check_file_in_osts $file $i
857 while [[ $i -lt $OSTCOUNT ]]
859 destroy_pool pool${i}
865 run_test 15 "One directory per OST/pool"
868 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
872 create_pool_nofail $POOL
874 add_pool $POOL $TGT_HALF "$TGT_UUID2"
876 local dir=$POOL_ROOT/$tdir
877 create_dir $dir $POOL
879 for i in $(seq 1 10); do
884 createmany -o $dir/$tfile $numfiles || \
885 error "createmany $dir/$tfile failed!"
887 for file in $dir/*; do
888 check_file_in_pool $file $POOL
891 rm -rf $POOL_ROOT/$tdir
897 run_test 16 "Inheritance of pool properties"
900 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
904 create_pool_nofail $POOL
906 add_pool $POOL $TGT_ALL "$TGT_UUID"
908 local dir=$POOL_ROOT/dir
909 create_dir $dir $POOL
911 createmany -o $dir/${tfile}1_ $numfiles || \
912 error "createmany $dir/${tfile}1_ failed!"
914 for file in $dir/*; do
915 check_file_in_pool $file $POOL
920 createmany -o $dir/${tfile}2_ $numfiles || \
921 error "createmany $dir/${tfile}2_ failed!"
926 run_test 17 "Referencing an empty pool"
934 sync; sleep 5 # give pending IO a chance to go to disk
935 stat=$(createmany -o $dir/${tfile} $numfiles)
938 time=$(echo $stat | cut -f 5 -d ' ')
939 echo $stat > /dev/stderr
944 local t1=$(create_perf_one $1 $2)
945 local t2=$(create_perf_one $1 $2)
946 local t3=$(create_perf_one $1 $2)
947 local time=$(echo "scale=2; ( $t1 + $t2 + $t3 ) / 3" | bc)
953 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
959 local dir=$POOL_ROOT/dir
963 time1=$(create_perf $dir $numfiles)
965 create_pool_nofail $POOL
967 add_pool $POOL $TGT_ALL "$TGT_UUID"
969 create_dir $dir $POOL
970 time2=$(create_perf $dir $numfiles)
974 time3=$(create_perf $dir $numfiles)
976 echo Time taken for $numfiles creates without pools: $time1
977 echo Time taken for $numfiles creates with pools: $time2
978 echo Time taken for $numfiles creates without pools: $time3
980 deg=$(echo "scale=2; (($time2 - $time3) * 100 / $time3) > 5" | bc)
981 diff=$(echo "scale=2; ($time2 - $time3) * 100 / $time3" | bc)
983 if [[ "$deg" == "1" ]]; then
984 error "Performance degradation with pools is $diff %."
986 echo "Performance degradation with pools is $diff %."
990 run_test 18 "File create in a directory which references a deleted pool"
994 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
996 local dir1=$POOL_ROOT/dir1
997 local dir2=$POOL_ROOT/dir2
1000 create_pool_nofail $POOL
1002 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1004 create_dir $dir1 $POOL
1005 createmany -o $dir1/${tfile} $numfiles || \
1006 error "createmany $dir1/${tfile} failed!"
1007 for file in $dir1/*; do
1008 check_file_in_pool $file $POOL
1012 createmany -o $dir2/${tfile} $numfiles || \
1013 error "createmany $dir2/${tfile} failed!"
1014 for file in $dir2/*; do
1015 check_file_not_in_pool $file $POOL
1023 run_test 19 "Pools should not come into play when not specified"
1026 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1028 local dir1=$POOL_ROOT/dir1
1029 local dir2=$dir1/dir2
1030 local dir3=$dir1/dir3
1034 create_pool_nofail $POOL
1035 create_pool_nofail $POOL2
1037 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1039 local start=$((TGT_FIRST+1))
1040 TGT=$(for i in `seq $start 2 $TGT_MAX`; \
1041 do printf "$FSNAME-OST%04x_UUID " $i; done)
1042 add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1044 create_dir $dir1 $POOL
1045 create_file $dir1/file1 $POOL2
1046 create_dir $dir2 $POOL2
1049 $SETSTRIPE -c 1 $dir3 # No pool assignment
1051 $SETSTRIPE -c 1 $dir2/file4 # No pool assignment
1053 check_file_in_pool $dir1/file1 $POOL2
1054 check_file_in_pool $dir2/file2 $POOL2
1056 check_dir_not_in_pool $dir3 $POOL
1057 check_dir_not_in_pool $dir3 $POOL2
1059 check_file_not_in_pool $dir3/file3 $POOL
1060 check_file_not_in_pool $dir3/file3 $POOL2
1062 check_file_not_in_pool $dir2/file4 $POOL
1063 check_file_not_in_pool $dir2/file4 $POOL2
1071 run_test 20 "Different pools in a directory hierarchy."
1074 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1075 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
1079 local dir=$POOL_ROOT/dir
1081 create_pool_nofail $POOL
1083 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1085 create_dir $dir $POOL $OSTCOUNT
1086 create_file $dir/file1 $POOL $OSTCOUNT
1087 $GETSTRIPE -v $dir/file1
1088 check_file_in_pool $dir/file1 $POOL
1095 run_test 21 "OST pool with fewer OSTs than stripe count"
1103 for c in $(seq 1 10);
1105 echo "Pool $pool, iteration $c"
1106 do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool OST[$TGT_FIRST-$TGT_MAX/$step] 2>/dev/null
1107 local TGT_SECOND=$(($TGT_FIRST+$step))
1108 if [ "$TGT_SECOND" -le "$TGT_MAX" ]; then
1109 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$pool OST[$TGT_SECOND-$TGT_MAX/$step]
1112 echo loop for $pool complete
1116 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1117 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1121 create_pool_nofail $POOL
1122 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
1123 create_pool_nofail $POOL2
1124 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
1129 create_dir $POOL_ROOT $POOL
1130 createmany -o $POOL_ROOT/${tfile} $numfiles || \
1131 error "createmany $POOL_ROOT/${tfile} failed!"
1139 run_test 22 "Simultaneous manipulation of a pool"
1142 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1143 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
1146 check_runas_id $TSTID $TSTID $RUNAS || {
1147 skip_env "User $RUNAS_ID does not exist - skipping"
1154 local BUNIT_SZ=1024 # min block quota unit(kB)
1155 local LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
1156 local OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
1158 local dir=$POOL_ROOT/dir
1159 local file="$dir/$tfile-quota"
1161 create_pool_nofail $POOL
1163 local TGT=$(for i in `seq $TGT_FIRST 3 $TGT_MAX`; \
1164 do printf "$FSNAME-OST%04x_UUID " $i; done)
1165 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1166 create_dir $dir $POOL
1168 $LFS quotaoff -ug $MOUNT
1169 $LFS quotacheck -ug $MOUNT
1170 LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1)))
1171 $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir
1173 $LFS quota -v -u $TSTUSR $dir
1175 $LFS setstripe $file -c 1 -p $POOL
1176 chown $TSTUSR.$TSTUSR $file
1180 LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BLK_SZ count=$((BUNIT_SZ*2)) || true
1181 $LFS quota -v -u $TSTUSR $dir
1182 cancel_lru_locks osc
1183 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ*2)) 2>&1)
1186 [[ $RC -eq 0 ]] && error "dd did not fail with EDQUOT."
1187 echo $stat | grep "Disk quota exceeded" > /dev/null
1188 [[ $? -eq 1 ]] && error "dd did not fail with EDQUOT."
1189 $LFS quota -v -u $TSTUSR $dir
1192 $LFS quotaoff -ug $MOUNT
1193 # $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir
1194 chown $TSTUSR.$TSTUSR $dir
1197 while [ $RC -eq 0 ];
1200 stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file}$i bs=1M \
1201 count=$((LIMIT*LIMIT)) 2>&1)
1203 if [ $RC -eq 1 ]; then
1205 echo $stat | grep "Disk quota exceeded"
1206 [[ $? -eq 0 ]] && error "dd failed with EDQUOT"
1208 echo $stat | grep "No space left on device"
1209 [[ $? -ne 0 ]] && error "dd did not fail with ENOSPC; " \
1221 run_test 23 "OST pools and quota"
1224 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1225 [[ $OSTCOUNT -le 1 ]] && skip_env "Need atleast 2 OSTs" && return
1234 create_pool_nofail $POOL
1236 add_pool $POOL $TGT_ALL "$TGT_UUID"
1238 create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1240 mkdir $POOL_ROOT/dir2
1241 $SETSTRIPE $POOL_ROOT/dir2 -p $POOL -s 65536 -i 0 -c 1 || \
1242 error "$SETSTRIPE $POOL_ROOT/dir2 failed"
1244 mkdir $POOL_ROOT/dir3
1245 $SETSTRIPE $POOL_ROOT/dir3 -s 65536 -i 0 -c 1 || \
1246 error "$SETSTRIPE $POOL_ROOT/dir3 failed"
1248 mkdir $POOL_ROOT/dir4
1250 for i in $(seq 1 4);
1252 dir=${POOL_ROOT}/dir${i}
1261 createmany -o $dir/${tfile} $numfiles || \
1262 error "createmany $dir/${tfile} failed!"
1263 res=$($GETSTRIPE -v $dir | grep "^stripe_count:")
1264 if [ $? -ne 0 ]; then
1265 res=$($GETSTRIPE -v $dir | grep "^(Default) ")
1266 pool=$(cut -f 9 -d ' ' <<< $res)
1267 index=$(cut -f 7 -d ' ' <<< $res)
1268 size=$(cut -f 5 -d ' ' <<< $res)
1269 count=$(cut -f 3 -d ' ' <<< $res)
1271 pool=$(cut -f 8 -d ' ' <<< $res)
1272 index=$(cut -f 6 -d ' ' <<< $res)
1273 size=$(cut -f 4 -d ' ' <<< $res)
1274 count=$(cut -f 2 -d ' ' <<< $res)
1277 for file in $dir/*; do
1278 if [ "$pool" != "" ]; then
1279 check_file_in_pool $file $pool
1281 pool1=$($GETSTRIPE -v $file | grep "^pool:" |\
1282 tr -d '[:blank:]' | cut -f 2 -d ':')
1283 count1=$($GETSTRIPE -v $file | grep "^lmm_stripe_count:" |\
1284 tr -d '[:blank:]' | cut -f 2 -d ':')
1285 size1=$($GETSTRIPE -v $file | grep "^lmm_stripe_size:" |\
1286 tr -d '[:blank:]' | cut -f 2 -d ':')
1287 [[ "$pool" != "$pool1" ]] && \
1288 error "Pool name ($pool) not inherited in $file($pool1)"
1289 [[ "$count" != "$count1" ]] && \
1290 error "Stripe count ($count) not inherited in $file ($count1)"
1291 [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] && \
1292 error "Stripe size ($size) not inherited in $file ($size1)"
1301 run_test 24 "Independence of pool from other setstripe parameters"
1304 local dev=$(mdsdevname ${SINGLEMDS//mds/})
1305 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1309 for i in $(seq 10); do
1310 create_pool_nofail pool$i
1311 do_facet $SINGLEMDS lctl pool_add $FSNAME.pool$i OST0000
1312 stop $SINGLEMDS || return 1
1313 start $SINGLEMDS ${dev} $MDS_MOUNT_OPTS || \
1314 { error "Failed to start $SINGLEMDS after stopping" && break; }
1317 # Veriy that the pool got created and is usable
1318 echo "Creating a file in pool$i"
1319 create_file $POOL_ROOT/file$i pool$i || break
1320 check_file_in_pool $POOL_ROOT/file$i pool$i || break
1324 for i in $(seq 10); do
1328 run_test 25 "Create new pool and restart MDS ======================="
1330 log "cleanup: ======================================================"
1332 cleanup_pools $FSNAME
1333 check_and_cleanup_lustre
1334 echo '=========================== finished ==============================='
1335 [ -f "$POOLSLOG" ] && cat $POOLSLOG && grep -q FAIL $POOLSLOG && exit 1 || true
1336 echo "$0: completed"