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
32 [ "$SLOW" = "no" ] && EXCEPT_SLOW="23b"
39 SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
40 GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"}
44 MAXFREE=${MAXFREE:-$((2000000 * OSTCOUNT))}
48 POOL2=${POOL2:-${POOL}2}
49 POOL3=${POOL3:-${POOL}3}
50 NON_EXISTANT_POOL=nonexistantpool
51 NON_EXISTANT_FS=nonexistantfs
52 INVALID_POOL=some_invalid_pool_name
54 TGT_FIRST=$(printf %04x 0)
55 TGT_MAX=$(printf %04x $((TGT_COUNT-1)))
57 TGT_LIST=$(seq 0x$TGT_FIRST $TGT_STEP 0x$TGT_MAX)
58 TGT_LIST2=$(seq 0x$TGT_FIRST 2 0x$TGT_MAX)
60 TGT_ALL="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/1]"
61 TGT_HALF="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]"
63 TGT_UUID=$(for i in $TGT_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
64 TGT_UUID2=$(for i in $TGT_LIST2; do printf "$FSNAME-OST%04x_UUID " $i; done)
69 local count=${3:-"-1"}
74 $SETSTRIPE -c $count -p $pool $dir -o $idx
76 $SETSTRIPE -c $count -p $pool $dir
79 error "$SETSTRIPE -p $pool $dir failed."
85 local count=${3:-"-1"}
86 local index=${4:-"-1"}
88 $SETSTRIPE -o $index -c $count -p $pool $file
90 error "$SETSTRIPE -p $pool $file failed."
96 for i in $(do_facet $SINGLEMDS lctl pool_list $FSNAME.$pool |
97 grep -v "^Pool:" | sed -e 's/_UUID$//;s/^.*-OST//'); do
98 res="$res $(printf "%d" 0x$i)"
103 check_dir_in_pool() {
106 local res=$($GETSTRIPE $dir | grep "^stripe_count:" |
107 cut -d ':' -f 5 | tr -d "[:blank:]")
108 if [[ "$res" != "$pool" ]]; then
109 error found $res instead of $pool
116 check_file_in_pool() {
117 local osts=$(osts_in_pool $2)
118 check_file_in_osts $1 "$osts" $3
121 check_file_in_osts() {
123 local pool_list=${2:-$TGT_LIST}
125 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
128 found=$(echo :$pool_list: | tr " " ":" | grep :$i:)
129 if [[ "$found" == "" ]]; then
130 echo "pool list: $pool_list"
131 echo "striping: $res"
133 error "$file not allocated from OSTs $pool_list."
138 local ost_count=$($GETSTRIPE $file | grep 0x | wc -l)
139 [[ -n "$count" ]] && [[ $ost_count -ne $count ]] &&
140 { error "Stripe count $count expected; got $ost_count" && return 1;}
146 $GETSTRIPE -v $1 | grep "^lmm_pool:" | tr -d "[:blank:]" | cut -f 2 -d ':'
149 check_file_not_in_pool() {
152 local res=$(file_pool $file)
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"
176 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool" "" ||
177 error "Failed to remove targets from pool: $pool"
183 local tgt="${3}$(lctl get_param -n lov.$FSNAME-*.pools.$pool |
184 sort -u | tr '\n' ' ')"
186 do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool $osts
188 [[ $RC -ne 0 ]] && return $RC
190 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool |
191 sort -u | tr '\n' ' ' " "$tgt" >/dev/null || RC=1
192 [[ $RC -ne 0 ]] && error "pool_add failed: $1; $2"
196 create_pool_nofail() {
197 create_pool $FSNAME.$1
198 if [[ $? != 0 ]]; then
199 error "Pool creation of $1 failed"
204 create_pool $FSNAME.$1
205 if [[ $? == 0 ]]; then
206 error "Pool creation of $1 succeeded; should have failed"
211 # Destroy pools from previous test runs
212 for p in $(do_facet $SINGLEMDS lctl pool_list $FSNAME | grep $POOL); do
215 rm -rf $DIR/d0.${TESTSUITE}
223 trap "cleanup_tests $FSNAME" EXIT
227 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
228 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
232 # Tests for new commands added
238 run_test 1a "Create a pool with a 1 character pool name"
242 create_pool_nofail ${POOL}12
243 destroy_pool ${POOL}12
245 run_test 1b "Create a pool with a 10 character pool name"
249 create_pool_nofail ${POOL}12345678
250 destroy_pool ${POOL}12345678
252 run_test 1c "Create a pool with a 16 character pool name"
256 create_pool_fail ${POOL}123456789
258 run_test 1d "Create a pool with a 17 char pool name; should fail"
262 local pool_name="$POOL"
263 for ((i = 1; i <= 991; i++)); do pool_name=${pool_name}"o"; done
264 create_pool_fail $pool_name
266 run_test 1e "Create a pool with a 1000 char pool name; should fail"
270 do_facet $SINGLEMDS lctl pool_new .$POOL 2>/dev/null
272 error "pool_new did not fail even though fs-name was missing"
274 run_test 1f "pool_new should fail if fs-name is missing"
278 do_facet $SINGLEMDS lctl pool_new $POOL 2>/dev/null
280 error "pool_new did not fail even though fs-name was missing"
282 run_test 1g "pool_new should fail if fs-name is missing"
286 do_facet $SINGLEMDS lctl pool_new ${FSNAME}. 2>/dev/null
288 error "pool_new did not fail even though pool name was missing"
290 run_test 1h "pool_new should fail if poolname is missing"
294 do_facet $SINGLEMDS lctl pool_new . 2>/dev/null
296 error "pool_new did not fail even if pool and fs-name were missing"
298 run_test 1i "pool_new should fail if poolname and fs-name are missing"
302 do_facet $SINGLEMDS lctl pool_new ${FSNAME},$POOL 2>/dev/null
304 error "pool_new did not fail even though pool name format was wrong"
306 run_test 1j "pool_new should fail if poolname format is wrong"
310 do_facet $SINGLEMDS lctl pool_new ${FSNAME}/$POOL 2>/dev/null
312 error "pool_new did not fail even though pool name format was wrong"
314 run_test 1k "pool_new should fail if poolname format is wrong"
318 create_pool_nofail $POOL2
319 do_facet $SINGLEMDS lctl pool_new ${FSNAME}.$POOL2 2>/dev/null
321 error "pool_new did not fail even though $POOL2 existed"
324 run_test 1m "pool_new did not fail even though $POOL2 existed"
330 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
332 error "pool_add did not fail even though $POOL did not exist"
334 run_test 2a "pool_add: non-existant pool $POOL"
338 do_facet $SINGLEMDS lctl pool_add $FSNAME.${POOL}1234567890 \
339 $FSNAME-OST0000 2>/dev/null
341 error "pool_add did not fail even though pool name was invalid."
343 run_test 2b "pool_add: Invalid pool name"
345 # Testing various combinations of OST name list
351 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
352 [[ $? -ne 0 ]] || destroy_pool $POOL
354 create_pool_nofail $POOL
357 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
358 RC=$?; [[ $RC -eq 0 ]] ||
359 error "pool_add failed. $FSNAME $POOL OST0000: $RC"
360 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
364 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
365 RC=$?; [[ $RC -eq 0 ]] ||
366 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000: $RC"
367 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
370 # 3. lustre-OST0000_UUID
371 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
372 RC=$?; [[ $RC -eq 0 ]] ||
373 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000_UUID: $RC"
374 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
377 # 4. lustre-OST[0,1,2,3,]
379 for i in $TGT_LIST; do TGT=${TGT}$(printf "%04x," $i); done
381 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
382 [[ $? -eq 0 ]] || error "pool_add failed. $FSNAME.$POOL $TGT. $RC"
383 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT
386 # 5. lustre-OST[0-5/1]
387 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
388 RC=$?; [[ $RC -eq 0 ]] ||
389 error "pool_add failed. $FSNAME $POOL" "$TGT_ALL $RC"
390 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL |
391 sort -u | tr '\n' ' ' " "$TGT_UUID" || error "Add to pool failed"
392 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
397 run_test 2c "pool_add: OST index combinations"
404 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
405 [[ $? -ne 0 ]] || destroy_pool $POOL
407 create_pool_nofail $POOL
409 TGT=$(printf "$FSNAME-OST%04x_UUID " $OSTCOUNT)
410 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
411 RC=$?; [[ $RC -ne 0 ]] ||
412 error "pool_add succeeded for an OST ($TGT) that does not exist."
416 run_test 2d "pool_add: OSTs that don't exist should be rejected"
424 $LCTL get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
425 [[ $? -ne 0 ]] || destroy_pool $POOL
427 create_pool_nofail $POOL
429 TGT="$FSNAME-OST0000_UUID "
430 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT
431 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL |
432 sort -u | tr '\n' ' ' " "$TGT" || error "Add to pool failed"
433 RESULT=$(do_facet $SINGLEMDS \
434 "LOCALE=C $LCTL pool_add $FSNAME.$POOL $TGT 2>&1")
439 error "pool_add succeeded for an OST that was already in the pool."
441 [[ $(grep "already in pool" <<< $RESULT) ]] ||
442 error "pool_add failed as expected but error message not as expected."
446 run_test 2e "pool_add: OST already in a pool should be rejected"
450 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
451 [[ $? -ne 0 ]] || destroy_pool $POOL
453 do_facet $SINGLEMDS \
454 lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
456 error "pool_remove did not fail even though pool did not exist."
458 run_test 3a "pool_remove: non-existant pool"
462 do_facet $SINGLEMDS \
463 lctl pool_remove ${NON_EXISTANT_FS}.$POOL OST0000 2>/dev/null
465 error "pool_remove did not fail even though fsname did not exist."
467 run_test 3b "pool_remove: non-existant fsname"
471 do_facet $SINGLEMDS lctl pool_remove $FSNAME.p1234567891234567890 \
472 $FSNAME-OST0000 2>/dev/null
474 error "pool_remove did not fail even though pool name was invalid."
476 run_test 3c "pool_remove: Invalid pool name"
478 # Testing various combinations of OST name list
481 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
482 [[ $? -ne 0 ]] || destroy_pool $POOL
484 create_pool_nofail $POOL
485 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL OST0000
486 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL OST0000
487 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL OST0000"
490 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
491 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
492 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000"
495 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
496 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
498 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000_UUID"
501 add_pool $POOL $TGT_ALL "$TGT_UUID"
502 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $TGT_ALL
503 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL" $TGT_ALL
508 run_test 3d "pool_remove: OST index combinations"
512 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
513 [[ $? -ne 0 ]] || destroy_pool $POOL
515 do_facet $SINGLEMDS lctl pool_destroy $FSNAME.$POOL 2>/dev/null
517 error "pool_destroy did not fail even though pool did not exist."
519 run_test 4a "pool_destroy: non-existant pool"
523 do_facet $SINGLEMDS lctl pool_destroy ${NON_EXISTANT_FS}.$POOL 2>/dev/null
525 error "pool_destroy did not fail even though filesystem did not exist."
527 run_test 4b "pool_destroy: non-existant fs-name"
531 create_pool_nofail $POOL
532 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
534 do_facet $SINGLEMDS lctl pool_destroy ${FSNAME}.$POOL
535 [[ $? -ne 0 ]] || error "pool_destroy succeeded with a non-empty pool."
538 run_test 4c "pool_destroy: non-empty pool"
543 $LCMD pool_list 2>/dev/null
544 [[ $? -ne 0 ]] || error "pool_list did not fail even though fsname missing."
546 destroy_pool $POOL 2>/dev/null
547 destroy_pool $POOL2 2>/dev/null
549 create_pool_nofail $POOL
550 create_pool_nofail $POOL2
551 $LCMD pool_list $FSNAME
552 [[ $? -eq 0 ]] || error "pool_list $FSNAME failed."
554 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL $TGT_ALL
556 $LCMD pool_list $FSNAME.$POOL
557 [[ $? -eq 0 ]] || error "pool_list $FSNAME.$POOL failed."
559 $LCMD pool_list ${NON_EXISTANT_FS} 2>/dev/null
560 [[ $? -ne 0 ]] || error "pool_list did not fail for fsname $NON_EXISTANT_FS"
562 $LCMD pool_list ${FSNAME}.$NON_EXISTANT_POOL 2>/dev/null
563 [[ $? -ne 0 ]] || error "pool_list did not fail for pool $NON_EXISTANT_POOL"
565 if [[ ! $(grep $SINGLEMDS <<< $LCMD) ]]; then
566 echo $LCMD pool_list $DIR
568 [[ $? -eq 0 ]] || error "pool_list failed for $DIR"
571 $LCMD pool_list ${DIR}/d1
572 [[ $? -eq 0 ]] || error "pool_list failed for ${DIR}/d1"
575 rm -rf ${DIR}nonexistant
576 $LCMD pool_list ${DIR}nonexistant 2>/dev/null
578 error "pool_list did not fail for invalid mountpoint ${DIR}nonexistant"
586 # Issue commands from client
590 # Issue commands from MDS
591 sub_test_5 "do_facet $SINGLEMDS lctl"
592 sub_test_5 "do_facet $SINGLEMDS lfs"
595 run_test 5 "lfs/lctl pool_list"
599 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
600 local POOL_DIR=$POOL_ROOT/dir_tst
601 local POOL_FILE=$POOL_ROOT/file_tst
603 create_pool_nofail $POOL
605 do_facet $SINGLEMDS lctl pool_list $FSNAME
606 [[ $? -eq 0 ]] || error "pool_list $FSNAME failed."
608 add_pool $POOL $TGT_ALL "$TGT_UUID"
611 $SETSTRIPE -c -1 -p $POOL $POOL_DIR
612 [[ $? -eq 0 ]] || error "$SETSTRIPE -p $POOL failed."
613 check_dir_in_pool $POOL_DIR $POOL
615 # If an invalid pool name is specified, the command should fail
616 $SETSTRIPE -c 2 -p $INVALID_POOL $POOL_DIR 2>/dev/null
617 [[ $? -ne 0 ]] || error "setstripe to invalid pool did not fail."
619 # If the pool name does not exist, the command should fail
620 $SETSTRIPE -c 2 -p $NON_EXISTANT_POOL $POOL_DIR 2>/dev/null
621 [[ $? -ne 0 ]] || error "setstripe to non-existant pool did not fail."
623 # lfs setstripe should work as before if a pool name is not specified.
624 $SETSTRIPE -c -1 $POOL_DIR
625 [[ $? -eq 0 ]] || error "$SETSTRIPE -p $POOL_DIR failed."
626 $SETSTRIPE -c -1 $POOL_FILE
627 [[ $? -eq 0 ]] || error "$SETSTRIPE -p $POOL_FILE failed."
629 # lfs setstripe should fail if a start index that is outside the
631 create_pool_nofail $POOL2
632 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
633 $SETSTRIPE -o 1 -p $POOL2 $ROOT_POOL/$tfile 2>/dev/null
635 error "$SETSTRIPE with start index outside the pool did not fail."
640 run_test 6 "getstripe/setstripe"
644 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
646 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
648 create_pool_nofail $POOL
649 create_pool_nofail $POOL2
651 local start=$(printf %04x $((TGT_FIRST + 1)))
652 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
653 $FSNAME-OST[$start-$TGT_MAX/2]
655 add_pool $POOL $TGT_HALF "$TGT_UUID2"
657 create_dir $POOL_ROOT/dir1 $POOL
658 create_dir $POOL_ROOT/dir2 $POOL2
659 check_dir_in_pool $POOL_ROOT/dir1 $POOL
660 check_dir_in_pool $POOL_ROOT/dir1 $POOL
663 createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
664 error "createmany $POOL_ROOT/dir1/$tfile failed!"
666 for file in $POOL_ROOT/dir1/*; do
667 check_file_in_pool $file $POOL
670 createmany -o $POOL_ROOT/dir2/$tfile $numfiles ||
671 error "createmany $POOL_ROOT/dir2/$tfile failed!"
672 for file in $POOL_ROOT/dir2/*; do
673 check_file_in_pool $file $POOL2
676 rm -rf $POOL_ROOT/dir?
683 run_test 11 "OSTs in overlapping/multiple pools"
687 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
689 [[ $OSTCOUNT -le 2 ]] && skip_env "Need at least 3 OSTs" && return
691 create_pool_nofail $POOL
692 create_pool_nofail $POOL2
694 local start=$(printf %04x $((TGT_FIRST + 1)))
695 do_facet $SINGLEMDS lctl pool_add $FSNAME.$POOL2 \
696 $FSNAME-OST[$start-$TGT_MAX/2]
698 add_pool $POOL $TGT_HALF "$TGT_UUID2"
700 echo creating some files in $POOL and $POOL2
702 create_dir $POOL_ROOT/dir1 $POOL
703 create_dir $POOL_ROOT/dir2 $POOL2
704 create_file $POOL_ROOT/file1 $POOL
705 create_file $POOL_ROOT/file2 $POOL2
707 echo Checking the files created
708 check_dir_in_pool $POOL_ROOT/dir1 $POOL
709 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
710 check_file_in_pool $POOL_ROOT/file1 $POOL
711 check_file_in_pool $POOL_ROOT/file2 $POOL2
713 echo Changing the pool membership
714 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$POOL $FSNAME-OST[$TGT_FIRST]
715 do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL
716 FIRST_UUID=$(echo $TGT_UUID | awk '{print $1}')
717 add_pool $POOL2 $FSNAME-OST[$TGT_FIRST] "$FIRST_UUID "
718 do_facet $SINGLEMDS lctl pool_list $FSNAME.$POOL2
720 echo Checking the files again
721 check_dir_in_pool $POOL_ROOT/dir1 $POOL
722 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
723 check_file_in_osts $POOL_ROOT/file1 "$TGT_LIST2"
724 check_file_in_osts $POOL_ROOT/file2 "$(seq 0x$start 2 0x$TGT_MAX)"
726 echo Creating some more files
727 create_dir $POOL_ROOT/dir3 $POOL
728 create_dir $POOL_ROOT/dir4 $POOL2
729 create_file $POOL_ROOT/file3 $POOL
730 create_file $POOL_ROOT/file4 $POOL2
732 echo Checking the new files
733 check_file_in_pool $POOL_ROOT/file3 $POOL
734 check_file_in_pool $POOL_ROOT/file4 $POOL2
741 run_test 12 "OST Pool Membership"
745 [[ $OSTCOUNT -le 2 ]] && skip_env "Need at least 3 OSTs" && return
747 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
751 create_pool_nofail $POOL
752 add_pool $POOL $TGT_ALL "$TGT_UUID"
754 create_dir $POOL_ROOT/dir1 $POOL -1
755 createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
756 error "createmany $POOL_ROOT/dir1/$tfile failed!"
757 for file in $POOL_ROOT/dir1/*; do
758 check_file_in_pool $file $POOL $OSTCOUNT
761 create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
762 create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST + 1))
763 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST + 2))
764 check_file_in_pool $POOL_ROOT/dir1/file1 $POOL 1
765 check_file_in_pool $POOL_ROOT/dir1/file2 $POOL 1
766 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST + 2))
767 check_file_in_osts $POOL_ROOT/dir1/file1 $((16#$TGT_FIRST))
768 check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST + 1))"
769 check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST + 2))"
771 create_dir $POOL_ROOT/dir2 $POOL $count
772 createmany -o $POOL_ROOT/dir2/$tfile- $numfiles ||
773 error "createmany $POOL_ROOT/dir2/$tfile- failed!"
774 for file in $POOL_ROOT/dir2/*; do
775 check_file_in_pool $file $POOL $count
778 create_dir $POOL_ROOT/dir3 $POOL $count $((TGT_FIRST + 1))
779 createmany -o $POOL_ROOT/dir3/$tfile- $numfiles ||
780 error "createmany $POOL_ROOT/dir3/$tfile- failed!"
781 for file in $POOL_ROOT/dir3/*; do
782 check_file_in_pool $file $POOL $count
785 create_dir $POOL_ROOT/dir4 $POOL 1
786 createmany -o $POOL_ROOT/dir4/$tfile- $numfiles ||
787 error "createmany $POOL_ROOT/dir4/$tfile- failed!"
788 for file in $POOL_ROOT/dir4/*; do
789 check_file_in_pool $file $POOL 1
792 create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST + 2))
793 createmany -o $POOL_ROOT/dir5/$tfile- $numfiles ||
794 error "createmany $POOL_ROOT/dir5/$tfile- failed!"
795 for file in $POOL_ROOT/dir5/*; do
796 check_file_in_pool $file $POOL 1
797 check_file_in_osts $file "$((TGT_FIRST + 2))"
800 rm -rf $POOL_ROOT/dir[1-5]/
805 run_test 13 "Striping characteristics in a pool"
809 [[ $OSTCOUNT -le 2 ]] && skip_env "Need at least 3 OSTs" && return
811 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
815 [ $OSTSIZE -gt $((MAXFREE / OSTCOUNT)) ] &&
816 skip_env "OST size $OSTSIZE is larger than $((MAXFREE / OSTCOUNT))" &&
819 create_pool_nofail $POOL
820 create_pool_nofail $POOL2
822 add_pool $POOL $TGT_HALF "$TGT_UUID2"
823 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
825 create_dir $POOL_ROOT/dir1 $POOL 1
826 create_file $POOL_ROOT/dir1/file $POOL 1
827 local OST=$($GETSTRIPE -i $POOL_ROOT/dir1/file)
829 while [[ $i -lt $numfiles ]]; do
831 [[ $OST -gt $((16#$TGT_MAX)) ]] && OST=$TGT_FIRST
833 # echo "Iteration: $i OST: $OST"
834 create_file $POOL_ROOT/dir1/file${i} $POOL 1
835 check_file_in_pool $POOL_ROOT/dir1/file${i} $POOL
839 # Fill up OST0 until it is nearly full.
840 # Create 9 files of size OST0_SIZE/10 each.
841 create_dir $POOL_ROOT/dir2 $POOL2 1
842 $LFS df $POOL_ROOT/dir2
843 OST0_SIZE=$($LFS df $POOL_ROOT/dir2 | awk '/\[OST:0\]/ { print $4 }')
844 FILE_SIZE=$((OST0_SIZE/1024/10))
845 echo "Filling OST0 with 9 files of ${FILE_SIZE}MB in $POOL_ROOT/dir2"
847 while [[ $i -lt 10 ]]; do
848 dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1M count=$FILE_SIZE
851 sleep 1 # get new statfs info
852 $LFS df $POOL_ROOT/dir2
854 # OST $TGT_FIRST is no longer favored; but it may still be used.
855 create_dir $POOL_ROOT/dir3 $POOL 1
856 create_file $POOL_ROOT/dir3/file $POOL 1
857 createmany -o $POOL_ROOT/dir3/$tfile- $numfiles ||
858 error "createmany $POOL_ROOT/dir3/$tfile- failed!"
859 for file in $POOL_ROOT/dir3/*; do
860 check_file_in_pool $file $POOL
869 run_test 14 "Round robin and QOS striping within a pool"
873 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
877 while [[ $i -lt $OSTCOUNT ]]; do
878 create_pool_nofail $POOL${i}
880 local tgt=$(printf "$FSNAME-OST%04x_UUID " $i)
881 add_pool $POOL${i} "$FSNAME-OST[$(printf %04x $i)]" "$tgt"
882 create_dir $POOL_ROOT/dir${i} $POOL${i}
883 createmany -o $POOL_ROOT/dir$i/$tfile $numfiles ||
884 error "createmany $POOL_ROOT/dir$i/$tfile failed!"
886 for file in $POOL_ROOT/dir$i/*; do
887 check_file_in_osts $file $i
894 while [[ $i -lt $OSTCOUNT ]]; do
895 destroy_pool $POOL${i}
901 run_test 15 "One directory per OST/pool"
905 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
909 create_pool_nofail $POOL
911 add_pool $POOL $TGT_HALF "$TGT_UUID2"
913 local dir=$POOL_ROOT/$tdir
914 create_dir $dir $POOL
916 for i in $(seq 1 10); do
921 createmany -o $dir/$tfile $numfiles ||
922 error "createmany $dir/$tfile failed!"
924 for file in $dir/*; do
925 check_file_in_pool $file $POOL
928 rm -rf $POOL_ROOT/$tdir
934 run_test 16 "Inheritance of pool properties"
938 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
942 create_pool_nofail $POOL
944 add_pool $POOL $TGT_ALL "$TGT_UUID"
946 local dir=$POOL_ROOT/dir
947 create_dir $dir $POOL
949 createmany -o $dir/${tfile}1_ $numfiles ||
950 error "createmany $dir/${tfile}1_ failed!"
952 for file in $dir/*; do
953 check_file_in_pool $file $POOL
958 createmany -o $dir/${tfile}2_ $numfiles ||
959 error "createmany $dir/${tfile}2_ failed!"
964 run_test 17 "Referencing an empty pool"
973 wait_delete_completed >/dev/null # give pending IO a chance to go to disk
974 stat=$(createmany -o $cdir/${tfile} -$numsec | tail -1)
975 files=$(echo $stat | cut -f 2 -d ' ')
977 unlinkmany $cdir/${tfile} $files > /dev/null
985 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
988 local plaindir=$POOL_ROOT/plaindir
989 local pooldir=$POOL_ROOT/pooldir
995 for i in $(seq 1 $iter); do
996 echo "Create performance, iteration $i, $numsec seconds x 3"
998 files1=$(create_perf $plaindir $numsec)
999 echo "iter $i: $files1 creates without pool"
1000 f1=$(($f1 + $files1))
1002 create_pool_nofail $POOL > /dev/null
1003 add_pool $POOL $TGT_ALL "$TGT_UUID" > /dev/null
1004 create_dir $pooldir $POOL
1005 files2=$(create_perf $pooldir $numsec)
1006 echo "iter $i: $files2 creates with pool"
1007 f2=$(($f2 + $files2))
1009 destroy_pool $POOL > /dev/null
1010 files3=$(create_perf $pooldir $numsec)
1011 echo "iter $i: $files3 creates with missing pool"
1012 f3=$(($f3 + $files3))
1017 echo Avg files created in $numsec seconds without pool: $((files1 / iter))
1018 echo Avg files created in $numsec seconds with pool: $((files2 / iter))
1019 echo Avg files created in $numsec seconds missing pool: $((files3 / iter))
1021 # Set this high until we establish a baseline for what the degradation
1024 diff=$((($files1 - $files2) * 100 / $files1))
1025 echo "No pool / wide pool: $diff %."
1026 [ $diff -gt $max ] &&
1027 error_ignore 23408 "Degradation with wide pool is $diff% > $max%"
1030 diff=$((($files1 - $files3) * 100 / $files1))
1031 echo "No pool / missing pool: $diff %."
1032 [ $diff -gt $max ] &&
1033 error_ignore 23408 "Degradation with wide pool is $diff% > $max%"
1037 run_test 18 "File create in a directory which references a deleted pool"
1041 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1043 local dir1=$POOL_ROOT/dir1
1044 local dir2=$POOL_ROOT/dir2
1047 create_pool_nofail $POOL
1049 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1051 create_dir $dir1 $POOL
1052 createmany -o $dir1/${tfile} $numfiles ||
1053 error "createmany $dir1/${tfile} failed!"
1054 for file in $dir1/*; do
1055 check_file_in_pool $file $POOL
1059 createmany -o $dir2/${tfile} $numfiles ||
1060 error "createmany $dir2/${tfile} failed!"
1061 for file in $dir2/*; do
1062 check_file_not_in_pool $file $POOL
1070 run_test 19 "Pools should not come into play when not specified"
1074 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1076 local dir1=$POOL_ROOT/dir1
1077 local dir2=$dir1/dir2
1078 local dir3=$dir1/dir3
1082 create_pool_nofail $POOL
1083 create_pool_nofail $POOL2
1085 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1087 local start=$(printf %04x $((TGT_FIRST + 1)))
1088 TGT=$(for i in $(seq 0x$start 2 0x$TGT_MAX); do \
1089 printf "$FSNAME-OST%04x_UUID " $i; done)
1090 add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1092 create_dir $dir1 $POOL
1093 create_file $dir1/file1 $POOL2
1094 create_dir $dir2 $POOL2
1097 $SETSTRIPE -c 1 $dir3 # No pool assignment
1099 $SETSTRIPE -c 1 $dir2/file4 # No pool assignment
1101 check_file_in_pool $dir1/file1 $POOL2
1102 check_file_in_pool $dir2/file2 $POOL2
1104 check_dir_not_in_pool $dir3 $POOL
1105 check_dir_not_in_pool $dir3 $POOL2
1107 check_file_not_in_pool $dir3/file3 $POOL
1108 check_file_not_in_pool $dir3/file3 $POOL2
1110 check_file_not_in_pool $dir2/file4 $POOL
1111 check_file_not_in_pool $dir2/file4 $POOL2
1119 run_test 20 "Different pools in a directory hierarchy."
1123 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1124 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1128 local dir=$POOL_ROOT/dir
1130 create_pool_nofail $POOL
1132 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1134 create_dir $dir $POOL $OSTCOUNT
1135 create_file $dir/file1 $POOL $OSTCOUNT
1136 $GETSTRIPE -v $dir/file1
1137 check_file_in_pool $dir/file1 $POOL
1144 run_test 21 "OST pool with fewer OSTs than stripe count"
1152 for c in $(seq 1 10); do
1153 echo "Pool $pool, iteration $c"
1154 do_facet $SINGLEMDS lctl pool_add $FSNAME.$pool \
1155 OST[$TGT_FIRST-$TGT_MAX/$step] 2>/dev/null
1156 local TGT_SECOND=$(printf %04x $((TGT_FIRST + $step)))
1157 if [ $((16#$TGT_SECOND)) -le $((16#$TGT_MAX)) ]; then
1158 do_facet $SINGLEMDS lctl pool_remove $FSNAME.$pool \
1159 OST[$TGT_SECOND-$TGT_MAX/$step]
1162 echo loop for $pool complete
1167 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1168 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1172 create_pool_nofail $POOL
1173 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
1174 create_pool_nofail $POOL2
1175 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
1180 create_dir $POOL_ROOT $POOL
1181 createmany -o $POOL_ROOT/${tfile} $numfiles ||
1182 error "createmany $POOL_ROOT/${tfile} failed!"
1190 run_test 22 "Simultaneous manipulation of a pool"
1194 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1195 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1198 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS || {
1199 skip_env "User $RUNAS_ID does not exist - skipping"
1205 local BUNIT_SZ=1024 # min block quota unit(kB)
1206 local LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1)))
1207 local dir=$POOL_ROOT/dir
1208 local file="$dir/$tfile-quota"
1210 create_pool_nofail $POOL
1212 local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
1213 printf "$FSNAME-OST%04x_UUID " $i; done)
1214 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1215 create_dir $dir $POOL
1217 # XXX remove the interoperability code once we drop the old server
1218 # (< 2.3.50) support.
1219 if [ $(lustre_version_code mds) -lt $(version_code 2.3.50) ]; then
1220 $LFS quotaoff -ug $MOUNT
1221 $LFS quotacheck -ug $MOUNT
1223 do_facet mgs $LCTL conf_param $FSNAME.quota.ost=ug
1227 $LFS setquota -u $RUNAS_ID -b $LIMIT -B $LIMIT $dir
1229 $LFS quota -v -u $RUNAS_ID $dir
1231 $LFS setstripe $file -c 1 -p $POOL
1232 chown $RUNAS_ID.$RUNAS_GID $file
1235 # This does two "dd" runs to ensure that the quota failure is returned
1236 # to userspace when we check. The first "dd" might otherwise complete
1237 # without error if it is only writing into cache.
1238 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
1239 count=$((BUNIT_SZ*2)) 2>&1)
1240 echo $stat | grep "Disk quota exceeded" > /dev/null
1241 if [ $? -eq 0 ]; then
1242 $LFS quota -v -u $RUNAS_ID $dir
1243 cancel_lru_locks osc
1244 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
1245 count=$BUNIT_SZ seek=$((BUNIT_SZ*2)) 2>&1)
1248 [[ $RC -eq 0 ]] && error "second dd did not fail."
1249 echo $stat | grep "Disk quota exceeded" > /dev/null
1250 [[ $? -eq 1 ]] && error "second dd did not fail with EDQUOT."
1252 log "first dd failed with EDQUOT."
1254 $LFS quota -v -u $RUNAS_ID $dir
1256 run_test 23a "OST pools and quota"
1260 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1261 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return 0
1264 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS || {
1265 skip_env "User $RUNAS_ID does not exist - skipping"
1271 local dir=$POOL_ROOT/dir
1272 local file="$dir/$tfile-quota"
1274 create_pool_nofail $POOL
1276 local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
1277 printf "$FSNAME-OST%04x_UUID " $i; done)
1278 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1279 create_dir $dir $POOL
1281 local maxfree=$((1024 * 1024 * 30)) # 30G
1282 local AVAIL=$(lfs_df -p $POOL $dir | awk '/summary/ { print $4 }')
1283 [ $AVAIL -gt $maxfree ] &&
1284 skip_env "Filesystem space $AVAIL is larger than $maxfree limit" &&
1286 log "OSTCOUNT=$OSTCOUNT, OSTSIZE=$OSTSIZE"
1287 log "MAXFREE=$MAXFREE, AVAIL=$AVAIL, SLOW=$SLOW"
1289 # XXX remove the interoperability code once we drop the old server
1290 # (< 2.3.50) support.
1291 if [ $(lustre_version_code mds) -lt $(version_code 2.3.50) ]; then
1292 $LFS quotaoff -ug $MOUNT
1294 do_facet mgs $LCTL conf_param $FSNAME.quota.ost=none
1298 chown $RUNAS_ID.$RUNAS_ID $dir
1302 local stime=$(date +%s)
1306 local maxtime=300 # minimum speed: 5GB / 300sec ~= 17MB/s
1307 while [ $RC -eq 0 ]; do
1309 stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file}$i bs=1M \
1310 count=$((5 * 1024)) 2>&1)
1312 TOTAL=$((TOTAL + 1024 * 1024 * 5))
1313 echo "[$i iteration] $stat"
1314 echo "total written: $TOTAL"
1317 elapsed=$((etime - stime))
1318 echo "stime=$stime, etime=$etime, elapsed=$elapsed"
1320 if [ $RC -eq 1 ]; then
1321 echo $stat | grep -q "Disk quota exceeded"
1322 [[ $? -eq 0 ]] && error "dd failed with EDQUOT with quota off"
1324 echo $stat | grep -q "No space left on device"
1325 [[ $? -ne 0 ]] && error "dd did not fail with ENOSPC"
1326 elif [ $TOTAL -gt $AVAIL ]; then
1327 error "dd didn't fail with ENOSPC ($TOTAL > $AVAIL)"
1328 elif [ $i -eq 1 -a $elapsed -gt $maxtime ]; then
1329 log "The first 5G write used $elapsed (> $maxtime) " \
1330 "seconds, terminated"
1339 run_test 23b "OST pools and OOS"
1343 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1344 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1352 create_pool_nofail $POOL
1354 add_pool $POOL $TGT_ALL "$TGT_UUID"
1356 create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1358 mkdir $POOL_ROOT/dir2
1359 $SETSTRIPE $POOL_ROOT/dir2 -p $POOL -s 65536 -i 0 -c 1 ||
1360 error "$SETSTRIPE $POOL_ROOT/dir2 failed"
1362 mkdir $POOL_ROOT/dir3
1363 $SETSTRIPE $POOL_ROOT/dir3 -s 65536 -i 0 -c 1 ||
1364 error "$SETSTRIPE $POOL_ROOT/dir3 failed"
1366 mkdir $POOL_ROOT/dir4
1368 for i in 1 2 3 4; do
1369 dir=${POOL_ROOT}/dir${i}
1378 createmany -o $dir/${tfile} $numfiles ||
1379 error "createmany $dir/${tfile} failed!"
1380 res=$($GETSTRIPE -v $dir | grep "^stripe_count:")
1381 if [ $? -ne 0 ]; then
1382 res=$($GETSTRIPE -v $dir | grep "^(Default) ")
1383 pool=$(cut -f 9 -d ' ' <<< $res)
1384 index=$(cut -f 7 -d ' ' <<< $res)
1385 size=$(cut -f 5 -d ' ' <<< $res)
1386 count=$(cut -f 3 -d ' ' <<< $res)
1388 pool=$(cut -f 8 -d ' ' <<< $res)
1389 index=$(cut -f 6 -d ' ' <<< $res)
1390 size=$(cut -f 4 -d ' ' <<< $res)
1391 count=$(cut -f 2 -d ' ' <<< $res)
1394 for file in $dir/*; do
1395 if [ "$pool" != "" ]; then
1396 check_file_in_pool $file $pool
1398 pool1=$($GETSTRIPE -v $file | grep "^pool:" |
1399 tr -d '[:blank:]' | cut -f 2 -d ':')
1400 count1=$($GETSTRIPE -v $file | grep "^lmm_stripe_count:" |
1401 tr -d '[:blank:]' | cut -f 2 -d ':')
1402 size1=$($GETSTRIPE -v $file | grep "^lmm_stripe_size:" |
1403 tr -d '[:blank:]' | cut -f 2 -d ':')
1404 [[ "$pool" != "$pool1" ]] &&
1405 error "Pool name ($pool) not inherited in $file($pool1)"
1406 [[ "$count" != "$count1" ]] &&
1407 error "Stripe count ($count) not inherited in $file ($count1)"
1408 [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] &&
1409 error "Stripe size ($size) not inherited in $file ($size1)"
1418 run_test 24 "Independence of pool from other setstripe parameters"
1422 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1426 for i in $(seq 10); do
1427 create_pool_nofail $POOL$i
1428 do_facet $SINGLEMDS "lctl pool_add $FSNAME.$POOL$i OST0000; sync"
1429 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL$i |
1430 sort -u | tr '\n' ' ' " "$FSNAME-OST0000_UUID " >/dev/null ||
1431 error "pool_add failed: $1; $2"
1433 stop $SINGLEMDS || return 1
1434 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS ||
1435 { error "Failed to start $SINGLEMDS after stopping" && break; }
1436 wait_osc_import_state mds ost FULL
1439 # Verify that the pool got created and is usable
1440 df $POOL_ROOT > /dev/null
1442 # Make sure OST0 can be striped on
1443 $SETSTRIPE -o 0 -c 1 $POOL_ROOT/$tfile
1444 STR=$($GETSTRIPE $POOL_ROOT/$tfile | grep 0x | cut -f2 | tr -d " ")
1445 rm $POOL_ROOT/$tfile
1446 if [[ "$STR" == "0" ]]; then
1447 echo "Creating a file in $POOL$i"
1448 create_file $POOL_ROOT/file$i $POOL$i || break
1449 check_file_in_pool $POOL_ROOT/file$i $POOL$i || break
1451 echo "OST 0 seems to be unavailable. Try later."
1456 for i in $(seq 10); do
1457 destroy_pool $POOL$i
1460 run_test 25 "Create new pool and restart MDS"
1464 complete $(basename $0) $SECONDS
1465 cleanup_pools $FSNAME
1466 check_and_cleanup_lustre