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"
186 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool" ""\
187 ||error "Failed to remove targets from pool: $pool"
191 OSTS=$(do_facet mds lctl pool_list $1 | awk '$1 !~ /^Pool:/ {print $1}')
194 do_facet mds lctl pool_remove $1 $ost
196 do_facet mds lctl pool_destroy $1
202 do_facet mds lctl pool_list $FSNAME.$1
204 [[ $RC -ne 0 ]] && return $RC
206 destroy_pool_int $FSNAME.$1
208 [[ $RC -ne 0 ]] && return $RC
210 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$1 \
211 2>/dev/null || echo foo" "foo" && return 0
217 local tgt="${3}$(lctl get_param -n lov.$FSNAME-*.pools.$pool | sort -u | tr '\n' ' ')"
219 do_facet mds lctl pool_add $FSNAME.$pool $osts
221 [[ $RC -ne 0 ]] && return $RC
223 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool | sort -u | tr '\n' ' ' " "$tgt" || RC=1
224 [[ $RC -ne 0 ]] && error "pool_add failed: $1; $2"
228 create_pool_nofail() {
232 error "Pool creation of $1 failed"
240 error "Pool creation of $1 succeeded; should have failed"
245 # Destroy pools from previous test runs
246 for p in $(do_facet mds lctl pool_list $FSNAME | grep $FSNAME.pool[0-$OSTCOUNT]); do
249 rm -rf $DIR/d0.${TESTSUITE}
258 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
259 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
262 # Tests for new commands added
265 echo "Creating a pool with a 1 character pool name"
268 echo "Creating a pool with a 10 character pool name"
269 create_pool_nofail p123456789
270 destroy_pool p123456789
272 echo "Creating a pool with a 16 character pool name"
273 create_pool_nofail p123456789123456
274 destroy_pool p123456789123456
276 echo "Creating a pool with a 17 character pool name; should fail"
277 create_pool_fail p1234567891234567
279 echo "Creating a pool with a 1000 character pool name; should fail"
281 for i in `seq 1 999`; do NAME=${NAME}"o"; done
282 create_pool_fail $NAME
284 echo "pool_new should fail if fs-name or poolname are missing."
285 do_facet mds lctl pool_new .pool1
287 error "pool_new did not fail even though fs-name was missing."
288 do_facet mds lctl pool_new pool1
290 error "pool_new did not fail even though fs-name was missing."
291 do_facet mds lctl pool_new ${FSNAME}.
293 error "pool_new did not fail even though pool name was missing."
294 do_facet mds lctl pool_new .
296 error "pool_new did not fail even though pool name and fs-name " \
298 do_facet mds lctl pool_new ${FSNAME},pool1
300 error "pool_new did not fail even though pool name format was wrong"
301 do_facet mds lctl pool_new ${FSNAME}/pool1
303 error "pool_new did not fail even though pool name format was wrong"
305 do_facet mds lctl pool_new ${FSNAME}.p
307 error "pool_new did not fail even though pool1 existed"
311 run_test 1 "Test lctl pool_new ========================================="
316 do_facet mds lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
318 error " pool_add did not fail even though pool did " \
321 run_test 2a "pool_add: non-existant pool"
324 do_facet mds lctl pool_add $FSNAME.p1234567891234567890 $FSNAME-OST0000
326 error "pool_add did not fail even though pool name was invalid."
328 run_test 2b "pool_add: Invalid pool name"
330 # Testing various combinations of OST name list
335 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
339 create_pool_nofail $POOL
342 do_facet mds lctl pool_add $FSNAME.$POOL OST0000
343 RC=$?; [[ $RC -eq 0 ]] || \
344 error "pool_add failed. $FSNAME $POOL OST0000: $RC"
345 do_facet mds lctl pool_remove $FSNAME.$POOL OST0000
349 do_facet mds lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
350 RC=$?; [[ $RC -eq 0 ]] || \
351 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000: $RC"
352 do_facet mds lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
355 # 3. lustre-OST0000_UUID
356 do_facet mds lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
357 RC=$?; [[ $RC -eq 0 ]] || \
358 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000_UUID: $RC"
359 do_facet mds lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
362 # 4. lustre-OST[0,1,2,3,]
364 for i in $TGT_LIST; do TGT=${TGT}$(printf "$i," $i); done
366 do_facet mds lctl pool_add $FSNAME.$POOL $TGT
368 error "pool_add failed. $FSNAME.$POOL $TGT. $RC"
369 do_facet mds lctl pool_remove $FSNAME.$POOL $TGT
372 # 5. lustre-OST[0-5/1]
373 do_facet mds lctl pool_add $FSNAME.$POOL $TGT_ALL
374 RC=$?; [[ $RC -eq 0 ]] || \
375 error "pool_add failed. $FSNAME $POOL" "$TGT_ALL $RC"
376 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
377 sort -u | tr '\n' ' ' " "$TGT_UUID" || error "Add to pool failed"
378 do_facet mds lctl pool_remove $FSNAME.$POOL $TGT_ALL
383 run_test 2c "pool_add: OST index combinations ==========================="
389 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
393 create_pool_nofail $POOL
395 TGT=$(printf "$FSNAME-OST%04x_UUID " $OSTCOUNT)
396 do_facet mds lctl pool_add $FSNAME.$POOL $TGT
397 RC=$?; [[ $RC -ne 0 ]] || \
398 error "pool_add succeeded for an OST ($TGT) that does not exist."
402 run_test 2d "pool_add: OSTs that don't exist should be rejected ========"
409 $LCTL get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
413 create_pool_nofail $POOL
415 TGT="$FSNAME-OST0000_UUID "
416 do_facet mds lctl pool_add $FSNAME.$POOL $TGT
417 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | \
418 sort -u | tr '\n' ' ' " "$TGT" || error "Add to pool failed"
419 RESULT=$(do_facet mds "LOCALE=C $LCTL pool_add $FSNAME.$POOL $TGT 2>&1")
424 error "pool_add succeeded for an OST that was already in the pool."
426 [[ $(grep "already in pool" <<< $RESULT) ]] || \
427 error "pool_add failed as expected but error message not as expected."
431 run_test 2e "pool_add: OST already in a pool should be rejected ========"
434 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
438 do_facet mds lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
440 error "pool_remove did not fail even though" \
441 "pool did not exist."
443 run_test 3a "pool_remove: non-existant pool"
446 do_facet mds lctl pool_remove ${NON_EXISTANT_FS}.$POOL OST0000
448 error "pool_remove did not fail even though fsname did not exist."
450 run_test 3b "pool_remove: non-existant fsname"
453 do_facet mds lctl pool_remove $FSNAME.p1234567891234567890 $FSNAME-OST0000
455 error "pool_remove did not fail even though pool name was invalid."
457 run_test 3c "pool_remove: Invalid pool name"
460 # Testing various combinations of OST name list
462 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
466 create_pool_nofail $POOL
467 do_facet mds lctl pool_add $FSNAME.$POOL OST0000
468 do_facet mds lctl pool_remove $FSNAME.$POOL OST0000
470 error "pool_remove failed. $FSNAME $POOL OST0000"
473 do_facet mds lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
474 do_facet mds lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
476 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000"
479 do_facet mds lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
480 do_facet mds lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
482 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000_UUID"
485 add_pool $POOL $TGT_ALL "$TGT_UUID"
486 do_facet mds lctl pool_remove $FSNAME.$POOL $TGT_ALL
488 error "pool_remove failed. $FSNAME $POOL" $TGT_ALL
493 run_test 3d "pool_remove: OST index combinations ==========================="
496 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
500 do_facet mds lctl pool_destroy $FSNAME.$POOL
502 error "pool_destroy did not fail even though pool did not exist."
504 run_test 4a "pool_destroy: non-existant pool"
507 do_facet mds lctl pool_destroy ${NON_EXISTANT_FS}.$POOL
509 error "pool_destroy did not fail even though the filesystem did not exist."
511 run_test 4b "pool_destroy: non-existant fs-name"
514 create_pool_nofail $POOL
515 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
517 do_facet mds lctl pool_destroy ${FSNAME}.$POOL
519 error "pool_destroy succeeded with a non-empty pool name."
522 run_test 4c "pool_destroy: non-empty pool ==============================="
529 error "pool_list did not fail even though fsname was not mentioned."
534 create_pool_nofail $POOL
535 create_pool_nofail $POOL2
536 $LCMD pool_list $FSNAME
538 error "pool_list $FSNAME failed."
540 do_facet mds lctl pool_add $FSNAME.$POOL $TGT_ALL
542 $LCMD pool_list $FSNAME.$POOL
544 error "pool_list $FSNAME.$POOL failed."
546 $LCMD pool_list ${NON_EXISTANT_FS}
548 error "pool_list did not fail for a non-existant fsname $NON_EXISTANT_FS"
550 $LCMD pool_list ${FSNAME}.$NON_EXISTANT_POOL
552 error "pool_list did not fail for a non-existant pool $NON_EXISTANT_POOL"
554 if [[ ! $(grep mds <<< $LCMD) ]]; then
555 echo $LCMD pool_list $DIR
558 error "pool_list failed for $DIR"
561 $LCMD pool_list ${DIR}/d1
563 error "pool_list failed for ${DIR}/d1"
566 rm -rf ${DIR}nonexistant
567 $LCMD pool_list ${DIR}nonexistant
569 error "pool_list did not fail for invalid mountpoint ${DIR}nonexistant"
576 # Issue commands from client
580 # Issue commands from MDS
581 sub_test_5 "do_facet mds lctl"
582 sub_test_5 "do_facet mds lfs"
585 run_test 5 "lfs/lctl pool_list"
588 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
589 local POOL_DIR=$POOL_ROOT/dir_tst
590 local POOL_FILE=$POOL_ROOT/file_tst
592 create_pool_nofail $POOL
594 do_facet mds lctl pool_list $FSNAME
596 error "pool_list $FSNAME failed."
598 do_facet mds lctl pool_add $FSNAME.$POOL $TGT_ALL
601 $SETSTRIPE -c -1 -p $POOL $POOL_DIR
603 error "$SETSTRIPE -p $POOL failed."
604 check_dir_in_pool $POOL_DIR $POOL
606 # If an invalid pool name is specified, the command should fail
607 $SETSTRIPE -c 2 -p $INVALID_POOL $POOL_DIR
609 error_ignore 19919 "setstripe to invalid pool did not fail."
611 # If the pool name does not exist, the command should fail
612 $SETSTRIPE -c 2 -p $NON_EXISTANT_POOL $POOL_DIR
614 error_ignore 19919 "setstripe to non-existant pool did not fail."
616 # lfs setstripe should work as before if a pool name is not specified.
617 $SETSTRIPE -c -1 $POOL_DIR
619 error "$SETSTRIPE -p $POOL_DIR failed."
620 $SETSTRIPE -c -1 $POOL_FILE
622 error "$SETSTRIPE -p $POOL_FILE failed."
624 # lfs setstripe should fail if a start index that is outside the
626 create_pool_nofail $POOL2
627 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
628 $SETSTRIPE -o 1 -p $POOL2 $ROOT_POOL/$tfile
630 error "$SETSTRIPE with start index outside the pool did not fail."
635 run_test 6 "getstripe/setstripe"
638 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
640 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
642 create_pool_nofail $POOL
643 create_pool_nofail $POOL2
645 do_facet mds lctl pool_add $FSNAME.$POOL \
646 $FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]
647 local start=$((TGT_FIRST+1))
648 do_facet mds lctl pool_add $FSNAME.$POOL2 \
649 $FSNAME-OST[$start-$TGT_MAX/2]
651 create_dir $POOL_ROOT/dir1 $POOL
652 create_dir $POOL_ROOT/dir2 $POOL2
653 check_dir_in_pool $POOL_ROOT/dir1 $POOL
654 check_dir_in_pool $POOL_ROOT/dir1 $POOL
657 createmany -o $POOL_ROOT/dir1/$tfile $numfiles || \
658 error "createmany $POOL_ROOT/dir1/$tfile failed!"
660 for file in $POOL_ROOT/dir1/*; do
661 check_file_in_pool $file $POOL
664 createmany -o $POOL_ROOT/dir2/$tfile $numfiles || \
665 error "createmany $POOL_ROOT/dir2/$tfile failed!"
666 for file in $POOL_ROOT/dir2/*; do
667 check_file_in_pool $file $POOL2
670 rm -rf $POOL_ROOT/dir?
677 run_test 11 "OSTs in overlapping/multiple pools"
680 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
682 [[ $OSTCOUNT -le 2 ]] && skip "Need atleast 3 OSTs" && return
684 create_pool_nofail $POOL
685 create_pool_nofail $POOL2
687 do_facet mds lctl pool_add $FSNAME.$POOL \
688 $FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]
689 local start=$((TGT_FIRST+1))
690 do_facet mds lctl pool_add $FSNAME.$POOL2 \
691 $FSNAME-OST[$start-$TGT_MAX/2]
693 echo creating some files in $POOL and $POOL2
695 create_dir $POOL_ROOT/dir1 $POOL
696 create_dir $POOL_ROOT/dir2 $POOL2
697 create_file $POOL_ROOT/file1 $POOL
698 create_file $POOL_ROOT/file2 $POOL2
700 echo Checking the files created
701 check_dir_in_pool $POOL_ROOT/dir1 $POOL
702 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
703 check_file_in_pool $POOL_ROOT/file1 $POOL
704 check_file_in_pool $POOL_ROOT/file2 $POOL2
706 echo Changing the pool membership
707 do_facet mds lctl pool_remove $FSNAME.$POOL $FSNAME-OST[$TGT_FIRST]
708 do_facet mds lctl pool_list $FSNAME.$POOL
709 do_facet mds lctl pool_add $FSNAME.$POOL2 $FSNAME-OST[$TGT_FIRST]
710 do_facet mds lctl pool_list $FSNAME.$POOL2
712 echo Checking the files again
713 check_dir_in_pool $POOL_ROOT/dir1 $POOL
714 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
715 check_file_in_osts $POOL_ROOT/file1 "$TGT_LIST2"
716 check_file_in_osts $POOL_ROOT/file2 "$(seq $start 2 $TGT_MAX)"
718 echo Creating some more files
719 create_dir $POOL_ROOT/dir3 $POOL
720 create_dir $POOL_ROOT/dir4 POOL2
721 create_file $POOL_ROOT/file3 $POOL
722 create_file $POOL_ROOT/file4 $POOL2
724 echo Checking the new files
725 check_file_in_pool $POOL_ROOT/file3 $POOL
726 check_file_in_pool $POOL_ROOT/file4 $POOL2
733 run_test 12 "OST Pool Membership"
736 [[ $OSTCOUNT -le 2 ]] && skip "Need atleast 3 OSTs" && return
738 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
742 create_pool_nofail $POOL
743 do_facet mds lctl pool_add $FSNAME.$POOL $TGT_ALL
745 create_dir $POOL_ROOT/dir1 $POOL -1
746 createmany -o $POOL_ROOT/dir1/$tfile $numfiles || \
747 error "createmany $POOL_ROOT/dir1/$tfile failed!"
748 for file in $POOL_ROOT/dir1/*; do
749 check_file_in_pool $file $POOL $OSTCOUNT
752 create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
753 create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST+1))
754 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST+2))
755 check_file_in_pool $POOL_ROOT/dir1/file1 $POOL 1
756 check_file_in_pool $POOL_ROOT/dir1/file2 $POOL 1
757 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST+2))
758 check_file_in_osts $POOL_ROOT/dir1/file1 "$TGT_FIRST"
759 check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST+1))"
760 check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST+2))"
762 create_dir $POOL_ROOT/dir2 $POOL $count
763 createmany -o $POOL_ROOT/dir2/$tfile $numfiles || \
764 error "createmany $POOL_ROOT/dir2/$tfile failed!"
765 for file in $POOL_ROOT/dir2/*; do
766 check_file_in_pool $file $POOL $count
769 create_dir $POOL_ROOT/dir3 $POOL $count $((TGT_FIRST+1))
770 createmany -o $POOL_ROOT/dir3/$tfile_ $numfiles || \
771 error "createmany $POOL_ROOT/dir3/$tfile_ failed!"
772 for file in $POOL_ROOT/dir3/*; do
773 check_file_in_pool $file $POOL $count
776 create_dir $POOL_ROOT/dir4 $POOL 1
777 createmany -o $POOL_ROOT/dir4/$tfile_ $numfiles || \
778 error "createmany $POOL_ROOT/dir4/$tfile_ failed!"
779 for file in $POOL_ROOT/dir4/*; do
780 check_file_in_pool $file $POOL 1
783 create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST+2))
784 createmany -o $POOL_ROOT/dir5/$tfile_ $numfiles || \
785 error "createmany $POOL_ROOT/dir5/$tfile_ failed!"
786 for file in $POOL_ROOT/dir5/*; do
787 check_file_in_pool $file $POOL 1
788 check_file_in_osts $file "$((TGT_FIRST+2))"
791 rm -rf create_dir $POOL_ROOT/dir?
796 run_test 13 "Striping characteristics in a pool"
799 [[ $OSTCOUNT -le 2 ]] && skip "Need atleast 3 OSTs" && return
801 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
805 # Create a new filesystem that is guaranteed to be balanced.
809 create_pool_nofail $POOL
810 create_pool_nofail $POOL2
812 add_pool $POOL $TGT_HALF "$TGT_UUID2"
813 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
815 create_dir $POOL_ROOT/dir1 $POOL 1
816 create_file $POOL_ROOT/dir1/file $POOL 1
817 local OST=$($GETSTRIPE $POOL_ROOT/dir1/file | grep 0x | cut -f2)
819 while [[ $i -lt $numfiles ]];
822 [[ $OST -gt $TGT_MAX ]] && OST=$TGT_FIRST
824 # echo "Iteration: $i OST: $OST"
825 create_file $POOL_ROOT/dir1/file${i} $POOL 1
826 check_file_in_osts $POOL_ROOT/dir1/file${i} $OST
830 # Fill OST $TGT_FIRST with 10M files
831 create_dir $POOL_ROOT/dir2 $POOL2 1
834 while [[ $RC -eq 0 ]];
836 dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1k count=$((1024*10))
841 # Leave some space on the OST
842 rm -f $POOL_ROOT/dir2/f0
845 # OST $TGT_FIRST is no longer favored; but it may still be used.
846 create_dir $POOL_ROOT/dir3 $POOL 1
847 create_file $POOL_ROOT/dir3/file $POOL 1
848 createmany -o $POOL_ROOT/dir3/$tfile_ $numfiles || \
849 error "createmany $POOL_ROOT/dir3/$tfile_ failed!"
850 for file in $POOL_ROOT/dir3/*; do
851 check_file_in_pool $file $POOL
859 run_test 14 "Round robin and QOS striping within a pool"
862 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
866 while [[ $i -lt $OSTCOUNT ]]
868 create_pool_nofail pool${i}
870 local tgt=$(printf "$FSNAME-OST%04x_UUID " $i)
871 add_pool pool${i} "$FSNAME-OST[$i]" "$tgt"
872 create_dir $POOL_ROOT/dir${i} pool${i}
873 createmany -o $POOL_ROOT/dir$i/$tfile $numfiles || \
874 error "createmany $POOL_ROOT/dir$i/$tfile failed!"
876 for file in $POOL_ROOT/dir$i/*; do
877 check_file_in_osts $file $i
884 while [[ $i -lt $OSTCOUNT ]]
886 destroy_pool pool${i}
892 run_test 15 "One directory per OST/pool"
895 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
899 create_pool_nofail $POOL
901 add_pool $POOL $TGT_HALF "$TGT_UUID2"
903 local dir=$POOL_ROOT/$tdir
904 create_dir $dir $POOL
906 for i in $(seq 1 10); do
911 createmany -o $dir/$tfile $numfiles || \
912 error "createmany $dir/$tfile failed!"
914 for file in $dir/*; do
915 check_file_in_pool $file $POOL
918 rm -rf $POOL_ROOT/$tdir
924 run_test 16 "Inheritance of pool properties"
927 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
931 create_pool_nofail $POOL
933 add_pool $POOL $TGT_ALL "$TGT_UUID"
935 local dir=$POOL_ROOT/dir
936 create_dir $dir $POOL
938 createmany -o $dir/${tfile}1_ $numfiles || \
939 error "createmany $dir/${tfile}1_ failed!"
941 for file in $dir/*; do
942 check_file_in_pool $file $POOL
947 createmany -o $dir/${tfile}2_ $numfiles || \
948 error "createmany $dir/${tfile}2_ failed!"
953 run_test 17 "Referencing an empty pool"
961 sync; sleep 5 # give pending IO a chance to go to disk
962 stat=$(createmany -o $dir/${tfile} $numfiles)
965 time=$(echo $stat | cut -f 5 -d ' ')
966 echo $stat > /dev/stderr
971 local t1=$(create_perf_one $1 $2)
972 local t2=$(create_perf_one $1 $2)
973 local t3=$(create_perf_one $1 $2)
974 local time=$(echo "scale=2; ( $t1 + $t2 + $t3 ) / 3" | bc)
980 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
986 local dir=$POOL_ROOT/dir
990 time1=$(create_perf $dir $numfiles)
992 create_pool_nofail $POOL
994 add_pool $POOL $TGT_ALL "$TGT_UUID"
996 create_dir $dir $POOL
997 time2=$(create_perf $dir $numfiles)
1001 time3=$(create_perf $dir $numfiles)
1003 echo Time taken for $numfiles creates without pools: $time1
1004 echo Time taken for $numfiles creates with pools: $time2
1005 echo Time taken for $numfiles creates without pools: $time3
1007 deg=$(echo "scale=2; (($time2 - $time3) * 100 / $time3) > 5" | bc)
1008 diff=$(echo "scale=2; ($time2 - $time3) * 100 / $time3" | bc)
1010 if [[ "$deg" == "1" ]]; then
1011 error "Performance degradation with pools is $diff %."
1013 echo "Performance degradation with pools is $diff %."
1017 run_test 18 "File create in a directory which references a deleted pool"
1021 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1023 local dir1=$POOL_ROOT/dir1
1024 local dir2=$POOL_ROOT/dir2
1027 create_pool_nofail $POOL
1029 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1031 create_dir $dir1 $POOL
1032 createmany -o $dir1/${tfile} $numfiles || \
1033 error "createmany $dir1/${tfile} failed!"
1034 for file in $dir1/*; do
1035 check_file_in_pool $file $POOL
1039 createmany -o $dir2/${tfile} $numfiles || \
1040 error "createmany $dir2/${tfile} failed!"
1041 for file in $dir2/*; do
1042 check_file_not_in_pool $file $POOL
1050 run_test 19 "Pools should not come into play when not specified"
1053 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1055 local dir1=$POOL_ROOT/dir1
1056 local dir2=$dir1/dir2
1057 local dir3=$dir1/dir3
1061 create_pool_nofail $POOL
1062 create_pool_nofail $POOL2
1064 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1066 local start=$((TGT_FIRST+1))
1067 TGT=$(for i in `seq $start 2 $TGT_MAX`; \
1068 do printf "$FSNAME-OST%04x_UUID " $i; done)
1069 add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1071 create_dir $dir1 $POOL
1072 create_file $dir1/file1 $POOL2
1073 create_dir $dir2 $POOL2
1076 $SETSTRIPE -c 1 $dir3 # No pool assignment
1078 $SETSTRIPE -c 1 $dir2/file4 # No pool assignment
1080 check_file_in_pool $dir1/file1 $POOL2
1081 check_file_in_pool $dir2/file2 $POOL2
1083 check_dir_not_in_pool $dir3 $POOL
1084 check_dir_not_in_pool $dir3 $POOL2
1086 check_file_not_in_pool $dir3/file3 $POOL
1087 check_file_not_in_pool $dir3/file3 $POOL2
1089 check_file_not_in_pool $dir2/file4 $POOL
1090 check_file_not_in_pool $dir2/file4 $POOL2
1098 run_test 20 "Different pools in a directory hierarchy."
1101 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1102 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1106 local dir=$POOL_ROOT/dir
1108 create_pool_nofail $POOL
1110 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1112 create_dir $dir $POOL $OSTCOUNT
1113 create_file $dir/file1 $POOL $OSTCOUNT
1114 $GETSTRIPE -v $dir/file1
1115 check_file_in_pool $dir/file1 $POOL
1122 run_test 21 "OST pool with fewer OSTs than stripe count"
1130 for c in $(seq 1 10);
1132 echo "Pool $pool, iteration $c"
1133 create_pool_nofail $pool
1134 local TGT=$(for i in `seq $TGT_FIRST $step $TGT_MAX`; \
1135 do printf "$FSNAME-OST%04x_UUID " $i; done)
1136 add_pool $pool "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/$step]" "$TGT"
1138 do_facet mds lctl pool_list $FSNAME
1140 echo loop for $pool complete
1144 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1145 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1152 create_dir $POOL_ROOT $POOL
1153 createmany -o $POOL_ROOT/${tfile} $numfiles || \
1154 error "createmany $POOL_ROOT/${tfile} failed!"
1159 run_test 22 "Simultaneous manipulation of a pool"
1162 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1163 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1166 check_runas_id $TSTID $TSTID $RUNAS || {
1167 skip "User $RUNAS_ID does not exist - skipping"
1175 local dir=$POOL_ROOT/dir
1176 local file1="$dir/$tfile-quota1"
1177 local file2="$dir/$tfile-quota2"
1179 create_pool_nofail $POOL
1181 local TGT=$(for i in `seq $TGT_FIRST 3 $TGT_MAX`; \
1182 do printf "$FSNAME-OST%04x_UUID " $i; done)
1183 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1184 create_dir $dir $POOL
1186 $LFS quotaoff -ug $MOUNT
1187 $LFS quotacheck -ug $MOUNT
1188 $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir #-i 5 -I 5 $dir
1190 $LFS setstripe $file1 -c 1 -p $POOL
1191 chown $TSTUSR.$TSTUSR $file1
1195 stat=$(LC_ALL=C $RUNAS dd if=/dev/zero of=$file1 bs=1024 count=$((LIMIT*2)) 2>&1)
1198 [[ $RC -eq 0 ]] && error "dd did not fail with EDQUOT."
1199 echo $stat | grep "Disk quota exceeded"
1200 [[ $? -eq 1 ]] && error "dd did not fail with EDQUOT."
1203 $LFS quotaoff -ug $MOUNT
1204 # $LFS setquota -u $TSTUSR -b $LIMIT -B $LIMIT $dir
1205 chown $TSTUSR.$TSTUSR $dir
1208 while [ $RC -eq 0 ];
1211 stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file2}$i bs=1024 \
1212 count=$((LIMIT*LIMIT)) 2>&1)
1214 if [ $RC -eq 1 ]; then
1216 echo $stat | grep "Disk quota exceeded"
1217 [[ $? -eq 0 ]] && error "dd failed with EDQUOT"
1219 echo $stat | grep "No space left on device"
1220 [[ $? -ne 0 ]] && error "dd did not fail with ENOSPC; " \
1232 run_test 23 "OST pools and quota"
1235 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1236 [[ $OSTCOUNT -le 1 ]] && skip "Need atleast 2 OSTs" && return
1245 create_pool_nofail $POOL
1247 add_pool $POOL $TGT_ALL "$TGT_UUID"
1249 create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1251 mkdir $POOL_ROOT/dir2
1252 $SETSTRIPE $POOL_ROOT/dir2 -p $POOL -s 65536 -i 0 -c 1 || \
1253 error "$SETSTRIPE $POOL_ROOT/dir2 failed"
1255 mkdir $POOL_ROOT/dir3
1256 $SETSTRIPE $POOL_ROOT/dir3 -s 65536 -i 0 -c 1 || \
1257 error "$SETSTRIPE $POOL_ROOT/dir3 failed"
1259 mkdir $POOL_ROOT/dir4
1261 for i in $(seq 1 4);
1263 dir=${POOL_ROOT}/dir${i}
1272 createmany -o $dir/${tfile} $numfiles || \
1273 error "createmany $dir/${tfile} failed!"
1274 res=$($GETSTRIPE -v $dir | grep "^stripe_count:")
1275 if [ $? -ne 0 ]; then
1276 res=$($GETSTRIPE -v $dir | grep "^(Default) ")
1277 pool=$(cut -f 9 -d ' ' <<< $res)
1278 index=$(cut -f 7 -d ' ' <<< $res)
1279 size=$(cut -f 5 -d ' ' <<< $res)
1280 count=$(cut -f 3 -d ' ' <<< $res)
1282 pool=$(cut -f 8 -d ' ' <<< $res)
1283 index=$(cut -f 6 -d ' ' <<< $res)
1284 size=$(cut -f 4 -d ' ' <<< $res)
1285 count=$(cut -f 2 -d ' ' <<< $res)
1288 for file in $dir/*; do
1289 if [ "$pool" != "" ]; then
1290 check_file_in_pool $file $pool
1292 pool1=$($GETSTRIPE -v $file | grep "^pool:" |\
1293 tr -d '[:blank:]' | cut -f 2 -d ':')
1294 count1=$($GETSTRIPE -v $file | grep "^lmm_stripe_count:" |\
1295 tr -d '[:blank:]' | cut -f 2 -d ':')
1296 size1=$($GETSTRIPE -v $file | grep "^lmm_stripe_size:" |\
1297 tr -d '[:blank:]' | cut -f 2 -d ':')
1298 [[ "$pool" != "$pool1" ]] && \
1299 error "Pool name ($pool) not inherited in $file($pool1)"
1300 [[ "$count" != "$count1" ]] && \
1301 error "Stripe count ($count) not inherited in $file ($count1)"
1302 [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] && \
1303 error "Stripe size ($size) not inherited in $file ($size1)"
1312 run_test 24 "Independence of pool from other setstripe parameters"
1315 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1319 for i in $(seq 10); do
1320 create_pool_nofail pool$i
1321 stop mds -f || return 1
1323 start mds $MDSDEV $MDS_MOUNT_OPTS || \
1324 error "Failed to start MDS after stopping"
1326 # Veriy that the pool got created and is usable
1327 echo "Creating a file in pool$i"
1328 create_file $POOL_ROOT/file$i pool$i
1329 check_file_in_pool $POOL_ROOT/file$i pool$i
1333 for i in $(seq 10); do
1337 run_test 25 "Create new pool and restart MDS ======================="
1339 log "cleanup: ======================================================"
1342 check_and_cleanup_lustre
1343 echo '=========================== finished ==============================='
1344 [ -f "$POOLSLOG" ] && cat $POOLSLOG && grep -q FAIL $POOLSLOG && exit 1 || true
1345 echo "$0: completed"