3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
8 export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
11 ALWAYS_EXCEPT="$OST_POOLS_EXCEPT"
12 # bug number for skipped test: -
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 [ "$ALWAYS_EXCEPT$EXCEPT" ] &&
16 echo "Skipping tests: $(echo $ALWAYS_EXCEPT $EXCEPT)"
21 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
22 . $LUSTRE/tests/test-framework.sh
24 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
27 check_and_setup_lustre
29 if ! combined_mgs_mds; then
30 do_facet mgs "mkdir -p $MOUNT"
31 zconf_mount $mgs_HOST $MOUNT $MOUNT_OPTS ||
32 error "unable to mount $MOUNT on the MGS"
36 [ "$SLOW" = "no" ] && EXCEPT_SLOW="18 23b"
43 MAXFREE=${MAXFREE:-$((2000000 * OSTCOUNT))}
47 POOL2=${POOL2:-${POOL}2}
48 POOL3=${POOL3:-${POOL}3}
49 NON_EXISTANT_POOL=nonexistantpool
50 NON_EXISTANT_FS=nonexistantfs
51 INVALID_POOL=some_invalid_pool_name
53 TGT_FIRST=$(printf %04x 0)
54 TGT_MAX=$(printf %04x $((TGT_COUNT-1)))
56 TGT_LIST=$(seq 0x$TGT_FIRST $TGT_STEP 0x$TGT_MAX)
57 TGT_LIST2=$(seq 0x$TGT_FIRST 2 0x$TGT_MAX)
59 TGT_ALL="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/1]"
60 TGT_HALF="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]"
62 TGT_UUID=$(for i in $TGT_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
63 TGT_UUID2=$(for i in $TGT_LIST2; do printf "$FSNAME-OST%04x_UUID " $i; done)
68 local count=${3:-"-1"}
72 if [[ -n $idx ]]; then
73 $LFS setstripe -c $count -p $pool -i $idx $dir
75 $LFS setstripe -c $count -p $pool $dir
77 [[ $? -eq 0 ]] || error "$LFS setstripe -p $pool $dir failed"
78 [[ "$($LFS getstripe --pool $dir)" == "$pool" ]] ||
79 error "$dir not created in expected pool '$pool'"
85 local count=${3:-"-1"}
86 local index=${4:-"-1"}
88 $LFS setstripe -i $index -c $count -p $pool $file
89 [[ $? -eq 0 ]] || error "$LFS setstripe -p $pool $file failed"
90 [[ "$($LFS getstripe --pool $file)" == "$pool" ]] ||
91 error "$file not created in '$pool'"
97 for i in $(list_pool $FSNAME.$pool |
98 sed -e 's/_UUID$//;s/^.*-OST//'); do
99 res="$res $(printf "%d" 0x$i)"
104 check_dir_in_pool() {
107 local res=$($LFS getstripe --pool $dir)
109 [ -n "$res" ] || error "dir '$dir' not in any pool"
111 [ "$res" == "$pool" ] ||
112 error "dir '$dir' in pool '$res' instead of '$pool'"
115 check_file_in_pool() {
119 local osts=$(osts_in_pool $pool)
120 local res=$($LFS getstripe --pool $file)
122 [ -n "$res" ] || error "file '$file' not in any pool"
124 [ "$res" == "$pool" ] ||
125 error "file '$file' in pool '$res' instead of '$pool'"
127 local osts=$(osts_in_pool $2)
128 check_file_in_osts "$file" "$osts" $count
131 check_file_in_osts() {
133 local ost_list=${2:-$TGT_LIST}
135 local res=$($LFS getstripe $file | awk '/0x/ { print $1 }')
139 found=$(echo :$ost_list: | tr " " ":" | grep :$i:)
140 if [[ "$found" == "" ]]; then
141 echo "ost list: $ost_list"
142 echo "striping: $res"
143 $LFS getstripe -v $file
144 error "$file not allocated from OSTs $ost_list."
148 local ost_count=$($LFS getstripe -c $file)
149 [[ -n "$count" ]] && [[ $ost_count -ne $count ]] &&
150 error "$file stripe count $count expected; got $ost_count" &&
155 check_file_not_in_pool() {
158 local res=$($LFS getstripe --pool $file)
160 [ "$res" != "$pool" ] || error "File '$file' is in pool: $res"
163 check_dir_not_in_pool() {
166 local res=$($LFS getstripe --pool $dir)
168 [ "$res" != "$pool" ] || error "Dir '$dir' is in pool: $res"
173 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool" "" ||
174 error "Failed to remove targets from pool: $pool"
180 local tgt="${3}$(lctl get_param -n lov.$FSNAME-*.pools.$pool |
181 sort -u | tr '\n' ' ')"
183 do_facet mgs lctl pool_add $FSNAME.$pool $osts
185 [[ $RC -ne 0 ]] && return $RC
187 # wait for OSTs to be added to the pool
188 for mds_id in $(seq $MDSCOUNT); do
189 local mdt_id=$((mds_id-1))
190 local lodname=$FSNAME-MDT$(printf "%04x" $mdt_id)-mdtlov
191 wait_update_facet mds$mds_id \
192 "lctl get_param -n lod.$lodname.pools.$pool |
193 sort -u | tr '\n' ' ' " "$tgt" >/dev/null ||
194 error "mds$mds_id:pool add failed $1; $2"
196 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool |
197 sort -u | tr '\n' ' ' " "$tgt" >/dev/null ||
198 error "pool_add failed: $1; $2"
202 create_pool_nofail() {
203 create_pool $FSNAME.$1
204 [[ $? -ne 0 ]] && error "Pool creation of $1 failed"
209 create_pool $FSNAME.$1
211 error "Pool creation of $1 succeeded; should have failed"
220 remote_mds_nodsh && skip "remote MDS with nodsh"
221 remote_ost_nodsh && skip "remote OST with nodsh"
224 # Tests for new commands added
229 run_test 1a "Create a pool with a 1 character pool name"
232 create_pool_nofail ${POOL}12
233 destroy_pool ${POOL}12
235 run_test 1b "Create a pool with a 10 char pool name"
238 create_pool_nofail ${POOL}1234567
239 destroy_pool ${POOL}1234567
241 run_test 1c "Create a pool with a 15 char pool name"
244 create_pool_fail ${POOL}12345678
246 run_test 1d "Create a pool with a 16 char pool name; should fail"
249 local pool_name="$POOL"
250 for ((i = 1; i <= 991; i++)); do pool_name=${pool_name}"o"; done
251 create_pool_fail $pool_name
253 run_test 1e "Create a pool with a 1000 char pool name; should fail"
258 error "pool_new did not fail even though fs-name was missing"
260 run_test 1f "pool_new should fail if fs-name is missing"
265 error "pool_new did not fail even though fs-name was missing"
267 run_test 1g "pool_new should fail if fs-name is missing"
270 create_pool ${FSNAME}.
272 error "pool_new did not fail even though pool name was missing"
274 run_test 1h "pool_new should fail if poolname is missing"
279 error "pool_new did not fail even if pool/fs-name was missing"
281 run_test 1i "pool_new should fail if poolname and fs-name are missing"
284 do_facet mgs lctl pool_new ${FSNAME},$POOL
286 error "pool_new did not fail even if poolname format was wrong"
288 run_test 1j "pool_new should fail if poolname format is wrong"
291 do_facet mgs lctl pool_new ${FSNAME}/$POOL
293 error "pool_new did not fail even if poolname format was wrong"
295 run_test 1k "pool_new should fail if poolname format is wrong"
298 create_pool_nofail $POOL2
299 create_pool ${FSNAME}.$POOL2
301 error "pool_new did not fail even though $POOL2 existed"
304 run_test 1m "pool_new did not fail even though $POOL2 existed"
307 create_pool_nofail ${POOL}1234567
309 add_pool ${POOL}1234567 "OST0000" "$FSNAME-OST0000_UUID "
310 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
311 create_dir $POOL_ROOT ${POOL}1234567
312 dd if=/dev/zero of=$POOL_ROOT/file bs=1M count=100
313 RC=$?; [[ $RC -eq 0 ]] ||
314 error "failed to write to $POOL_ROOT/file: $RC"
315 do_facet mgs lctl pool_remove $FSNAME.${POOL}1234567 OST0000
316 drain_pool ${POOL}1234567
318 destroy_pool ${POOL}1234567
320 run_test 1n "Pool with a 15 char pool name works well"
325 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
327 error "pool_add did not fail even though $POOL did not exist"
329 run_test 2a "pool_add: non-existant pool $POOL"
332 do_facet mgs lctl pool_add $FSNAME.${POOL}1234567890 \
333 $FSNAME-OST0000 2>/dev/null
335 error "pool_add did not fail even though pool name was invalid."
337 run_test 2b "pool_add: Invalid pool name"
339 # Testing various combinations of OST name list
344 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
345 [[ $? -ne 0 ]] || destroy_pool $POOL
347 create_pool_nofail $POOL
350 do_facet mgs lctl pool_add $FSNAME.$POOL OST0000
351 RC=$?; [[ $RC -eq 0 ]] ||
352 error "pool_add failed. $FSNAME $POOL OST0000: $RC"
353 do_facet mgs lctl pool_remove $FSNAME.$POOL OST0000
357 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
358 RC=$?; [[ $RC -eq 0 ]] ||
359 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000: $RC"
360 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
363 # 3. $FSNAME-OST0000_UUID
364 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
365 RC=$?; [[ $RC -eq 0 ]] ||
366 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000_UUID: $RC"
367 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
370 # 4. $FSNAME-OST[0,1,2,3,]
372 for i in $TGT_LIST; do TGT=${TGT}$(printf "%04x," $i); done
374 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT
375 [[ $? -eq 0 ]] || error "pool_add failed. $FSNAME.$POOL $TGT. $RC"
376 do_facet mgs lctl pool_remove $FSNAME.$POOL $TGT
379 # 5. $FSNAME-OST[0-5/1]
380 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT_ALL
381 RC=$?; [[ $RC -eq 0 ]] ||
382 error "pool_add failed. $FSNAME $POOL" "$TGT_ALL $RC"
383 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL |
384 sort -u | tr '\n' ' ' " "$TGT_UUID" ||
385 error "Add to pool failed"
386 do_facet mgs lctl pool_remove $FSNAME.$POOL $TGT_ALL
391 run_test 2c "pool_add: OST index combinations"
397 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
398 [[ $? -ne 0 ]] || destroy_pool $POOL
400 create_pool_nofail $POOL
402 TGT=$(printf "$FSNAME-OST%04x_UUID " $OSTCOUNT)
403 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT
404 RC=$?; [[ $RC -ne 0 ]] ||
405 error "pool_add succeeded for an OST ($TGT) that does not exist."
409 run_test 2d "pool_add: OSTs that don't exist should be rejected"
416 $LCTL get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
417 [[ $? -ne 0 ]] || destroy_pool $POOL
419 create_pool_nofail $POOL
421 TGT="$FSNAME-OST0000_UUID"
422 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT
423 wait_update_facet $SINGLEMDS \
424 "lctl pool_list $FSNAME.$POOL | sed '1d'" "$TGT" ||
425 error "Add $TGT to $FSNAME.$POOL failed"
426 RESULT=$(do_facet mgs \
427 "LOCALE=C $LCTL pool_add $FSNAME.$POOL $TGT 2>&1")
432 error "pool_add succeeded for an OST that was already in the pool."
434 [[ $(grep "already in pool" <<< $RESULT) ]] ||
435 error "pool_add failed as expected but error message not as expected."
439 run_test 2e "pool_add: OST already in a pool should be rejected"
442 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
443 [[ $? -ne 0 ]] || destroy_pool $POOL
446 lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
448 error "pool_remove did not fail even though pool did not exist."
450 run_test 3a "pool_remove: non-existant pool"
454 lctl pool_remove ${NON_EXISTANT_FS}.$POOL OST0000 2>/dev/null
456 error "pool_remove did not fail even though fsname did not exist."
458 run_test 3b "pool_remove: non-existant fsname"
461 do_facet mgs lctl pool_remove $FSNAME.p1234567891234567890 \
462 $FSNAME-OST0000 2>/dev/null
464 error "pool_remove did not fail even though pool name was invalid."
466 run_test 3c "pool_remove: Invalid pool name"
468 # Testing various combinations of OST name list
470 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
471 [[ $? -ne 0 ]] || destroy_pool $POOL
473 create_pool_nofail $POOL
474 do_facet mgs lctl pool_add $FSNAME.$POOL OST0000
475 do_facet mgs lctl pool_remove $FSNAME.$POOL OST0000
476 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL OST0000"
479 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
480 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
481 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000"
484 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
485 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
487 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000_UUID"
490 add_pool $POOL $TGT_ALL "$TGT_UUID"
491 do_facet mgs lctl pool_remove $FSNAME.$POOL $TGT_ALL
492 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL" $TGT_ALL
497 run_test 3d "pool_remove: OST index combinations"
500 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
501 [[ $? -ne 0 ]] || destroy_pool $POOL
503 do_facet mgs lctl pool_destroy $FSNAME.$POOL 2>/dev/null
505 error "pool_destroy did not fail even though pool did not exist."
507 run_test 4a "pool_destroy: non-existant pool"
510 do_facet mgs lctl pool_destroy ${NON_EXISTANT_FS}.$POOL 2>/dev/null
512 error "pool_destroy did not fail even though filesystem did not exist."
514 run_test 4b "pool_destroy: non-existant fs-name"
517 create_pool_nofail $POOL
518 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
520 do_facet mgs lctl pool_destroy ${FSNAME}.$POOL
521 [[ $? -ne 0 ]] || error "pool_destroy succeeded with a non-empty pool."
524 run_test 4c "pool_destroy: non-empty pool"
529 $LCMD pool_list 2>/dev/null
531 error "pool_list did not fail even though fsname missing."
533 destroy_pool $POOL 2>/dev/null
534 destroy_pool $POOL2 2>/dev/null
536 create_pool_nofail $POOL
537 create_pool_nofail $POOL2
538 $LCMD pool_list $FSNAME
539 [[ $? -eq 0 ]] || error "pool_list $FSNAME failed."
541 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT_ALL
543 $LCMD pool_list $FSNAME.$POOL
544 [[ $? -eq 0 ]] || error "pool_list $FSNAME.$POOL failed."
546 $LCMD pool_list ${NON_EXISTANT_FS} 2>/dev/null
548 error "pool_list did not fail for fsname $NON_EXISTANT_FS"
550 $LCMD pool_list ${FSNAME}.$NON_EXISTANT_POOL 2>/dev/null
552 error "pool_list did not fail for pool $NON_EXISTANT_POOL"
554 if [[ ! $(grep $SINGLEMDS <<< $LCMD) ]]; then
555 echo $LCMD pool_list $DIR
557 [[ $? -eq 0 ]] || error "pool_list failed for $DIR"
560 $LCMD pool_list ${DIR}/d1
561 [[ $? -eq 0 ]] || error "pool_list failed for ${DIR}/d1"
564 rm -rf ${DIR}nonexistant
565 $LCMD pool_list ${DIR}nonexistant 2>/dev/null
567 error "pool_list did not fail for invalid mountpoint ${DIR}nonexistant"
574 # Issue commands from client
577 run_test 5a "lfs pool_list from client"
580 sub_test_5 "do_facet $SINGLEMDS lctl"
582 run_test 5b "lctl pool_list from MDS"
585 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
586 local POOL_DIR=$POOL_ROOT/dir_tst
587 local POOL_FILE=$POOL_ROOT/file_tst
589 create_pool_nofail $POOL
591 do_facet $SINGLEMDS lctl pool_list $FSNAME
592 [[ $? -eq 0 ]] || error "pool_list $FSNAME failed."
594 add_pool $POOL $TGT_ALL "$TGT_UUID"
597 $SETSTRIPE -c -1 -p $POOL $POOL_DIR
598 [[ $? -eq 0 ]] || error "$SETSTRIPE -p $POOL failed."
599 check_dir_in_pool $POOL_DIR $POOL
601 # If an invalid pool name is specified, the command should fail
602 $SETSTRIPE -c 2 -p $INVALID_POOL $POOL_DIR 2>/dev/null
603 [[ $? -ne 0 ]] || error "setstripe to invalid pool did not fail."
605 # If the pool name does not exist, the command should fail
606 $SETSTRIPE -c 2 -p $NON_EXISTANT_POOL $POOL_DIR 2>/dev/null
607 [[ $? -ne 0 ]] || error "setstripe to non-existant pool did not fail."
609 # lfs setstripe should work as before if a pool name is not specified.
610 $SETSTRIPE -c -1 $POOL_DIR
611 [[ $? -eq 0 ]] || error "$SETSTRIPE -c -1 $POOL_DIR failed."
612 $SETSTRIPE -c -1 $POOL_FILE
613 [[ $? -eq 0 ]] || error "$SETSTRIPE -c -1 $POOL_FILE failed."
615 # lfs setstripe should fail if a start index that is outside the
617 create_pool_nofail $POOL2
618 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
619 $SETSTRIPE -i 1 -p $POOL2 $ROOT_POOL/$tfile 2>/dev/null
621 error "$SETSTRIPE with start index outside the pool did not fail."
623 run_test 6 "getstripe/setstripe"
627 # Create a pool, stripe a directory and file with it
630 pool_add $pool || error "pool_add failed"
631 pool_add_targets $pool 0 1 || error "pool_add_targets failed"
633 $SETSTRIPE -c 1 $DIR/$tdir/testfile1 --pool "$pool" ||
634 error "setstripe failed"
635 $SETSTRIPE -c 1 $DIR/$tdir/testfile2 --pool "$FSNAME.$pool" ||
636 error "setstripe failed"
638 mkdir $DIR/$tdir/testdir
639 $SETSTRIPE -c 1 $DIR/$tdir/testdir -p "$pool" ||
640 error "setstripe failed"
641 $SETSTRIPE -c 1 $DIR/$tdir/testdir -p "$FSNAME.$pool" ||
642 error "setstripe failed"
644 rm -f $DIR/$tdir/testfile1
645 rm -f $DIR/$tdir/testfile2
646 rmdir $DIR/$tdir/testdir
648 destroy_pool_int $FSNAME.$pool
653 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
657 # Generate pool with random name from 1 to 15 characters
659 POOLNAME=$(echo $$$RANDOM$RANDOM |
660 tr -dc 'a-zA-Z0-9' | fold -w $i |
662 echo set poolname to $POOLNAME
663 helper_test_7a $POOLNAME
666 run_test 7a "create various pool name"
672 [ $? -ne 22 ] && error "can create a pool with no fsname"
676 [ $? -ne 22 ] && error "can create a pool with no name"
679 create_pool $FSNAME.0123456789^bdef
680 [ $? -ne 22 ] && error "can create a pool with an invalid name"
683 create_pool $FSNAME.0123456789abdefg
684 [ $? -ne 36 ] && error "can create a pool with a name too long"
688 run_test 7b "try to create pool name with invalid lengths or names"
692 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
696 # Create a pool with 15 letters
697 local pool=0123456789abcde
698 pool_add $pool || error "pool_add failed"
699 pool_add_targets $pool 0 1 || error "pool_add_targets failed"
701 # setstripe with the same pool name plus 1 letter
702 $SETSTRIPE -c 1 $DIR/$tdir/testfile1 --pool "${pool}X" && \
703 error "setstripe succedeed"
705 # setstripe with the same pool name minus 1 letter
706 $SETSTRIPE -c 1 $DIR/$tdir/testfile1 --pool "${pool%?}" && \
707 error "setstripe succedeed"
709 rm -f $DIR/$tdir/testfile1
711 destroy_pool_int $FSNAME.$pool
713 run_test 7c "create a valid pool name and setstripe with a bad one"
716 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
718 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
720 create_pool_nofail $POOL
721 create_pool_nofail $POOL2
723 local start=$(printf %04x $((TGT_FIRST + 1)))
724 do_facet mgs lctl pool_add $FSNAME.$POOL2 \
725 $FSNAME-OST[$start-$TGT_MAX/2]
727 add_pool $POOL $TGT_HALF "$TGT_UUID2"
729 create_dir $POOL_ROOT/dir1 $POOL
730 create_dir $POOL_ROOT/dir2 $POOL2
733 createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
734 error "createmany $POOL_ROOT/dir1/$tfile failed!"
736 for file in $POOL_ROOT/dir1/*; do
737 check_file_in_pool $file $POOL
740 createmany -o $POOL_ROOT/dir2/$tfile $numfiles ||
741 error "createmany $POOL_ROOT/dir2/$tfile failed!"
742 for file in $POOL_ROOT/dir2/*; do
743 check_file_in_pool $file $POOL2
746 rm -rf $POOL_ROOT/dir?
750 run_test 11 "OSTs in overlapping/multiple pools"
753 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
755 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >=3 OSTs"
757 create_pool_nofail $POOL
758 create_pool_nofail $POOL2
760 local start=$(printf %04x $((TGT_FIRST + 1)))
761 do_facet mgs lctl pool_add $FSNAME.$POOL2 \
762 $FSNAME-OST[$start-$TGT_MAX/2]
764 add_pool $POOL $TGT_HALF "$TGT_UUID2"
766 echo creating some files in $POOL and $POOL2
768 create_dir $POOL_ROOT/dir1 $POOL
769 create_dir $POOL_ROOT/dir2 $POOL2
770 create_file $POOL_ROOT/file1 $POOL
771 create_file $POOL_ROOT/file2 $POOL2
773 echo Checking the files created
774 check_file_in_pool $POOL_ROOT/file1 $POOL
775 check_file_in_pool $POOL_ROOT/file2 $POOL2
777 echo Changing the pool membership
778 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST[$TGT_FIRST]
779 do_facet mgs lctl pool_list $FSNAME.$POOL
780 FIRST_UUID=$(echo $TGT_UUID | awk '{print $1}')
781 add_pool $POOL2 $FSNAME-OST[$TGT_FIRST] "$FIRST_UUID "
782 do_facet mgs lctl pool_list $FSNAME.$POOL2
784 echo Checking the files again
785 check_dir_in_pool $POOL_ROOT/dir1 $POOL
786 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
787 check_file_in_osts $POOL_ROOT/file1 "$TGT_LIST2"
788 check_file_in_osts $POOL_ROOT/file2 "$(seq 0x$start 2 0x$TGT_MAX)"
790 echo Creating some more files
791 create_dir $POOL_ROOT/dir3 $POOL
792 create_dir $POOL_ROOT/dir4 $POOL2
793 create_file $POOL_ROOT/file3 $POOL
794 create_file $POOL_ROOT/file4 $POOL2
796 echo Checking the new files
797 check_file_in_pool $POOL_ROOT/file3 $POOL
798 check_file_in_pool $POOL_ROOT/file4 $POOL2
802 run_test 12 "OST Pool Membership"
805 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >= 3 OSTs"
807 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
811 create_pool_nofail $POOL
812 add_pool $POOL $TGT_ALL "$TGT_UUID"
814 create_dir $POOL_ROOT/dir1 $POOL -1
815 createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
816 error "createmany $POOL_ROOT/dir1/$tfile failed!"
817 for file in $POOL_ROOT/dir1/*; do
818 check_file_in_pool $file $POOL $OSTCOUNT
821 create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
822 create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST + 1))
823 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST + 2))
824 check_file_in_osts $POOL_ROOT/dir1/file1 $((16#$TGT_FIRST))
825 check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST + 1))"
826 check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST + 2))"
828 create_dir $POOL_ROOT/dir2 $POOL $count
829 createmany -o $POOL_ROOT/dir2/$tfile- $numfiles ||
830 error "createmany $POOL_ROOT/dir2/$tfile- failed!"
831 for file in $POOL_ROOT/dir2/*; do
832 check_file_in_pool $file $POOL $count
835 create_dir $POOL_ROOT/dir3 $POOL $count $((TGT_FIRST + 1))
836 createmany -o $POOL_ROOT/dir3/$tfile- $numfiles ||
837 error "createmany $POOL_ROOT/dir3/$tfile- failed!"
838 for file in $POOL_ROOT/dir3/*; do
839 check_file_in_pool $file $POOL $count
842 create_dir $POOL_ROOT/dir4 $POOL 1
843 createmany -o $POOL_ROOT/dir4/$tfile- $numfiles ||
844 error "createmany $POOL_ROOT/dir4/$tfile- failed!"
845 for file in $POOL_ROOT/dir4/*; do
846 check_file_in_pool $file $POOL 1
849 create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST + 2))
850 createmany -o $POOL_ROOT/dir5/$tfile- $numfiles ||
851 error "createmany $POOL_ROOT/dir5/$tfile- failed!"
852 for file in $POOL_ROOT/dir5/*; do
853 check_file_in_pool $file $POOL 1
856 rm -rf $POOL_ROOT/dir[1-5]/
860 run_test 13 "Striping characteristics in a pool"
863 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >= 3 OSTs"
865 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
869 [ $OSTSIZE -gt $((MAXFREE / OSTCOUNT)) ] &&
870 skip_env "OST size $OSTSIZE is larger than $((MAXFREE / OSTCOUNT))"
872 create_pool_nofail $POOL
873 create_pool_nofail $POOL2
875 add_pool $POOL $TGT_HALF "$TGT_UUID2"
876 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
878 create_dir $POOL_ROOT/dir1 $POOL 1
879 create_file $POOL_ROOT/dir1/file $POOL 1
880 local ost=$($LFS getstripe -i $POOL_ROOT/dir1/file)
882 while [[ $i -lt $numfiles ]]; do
884 [[ $ost -gt $((16#$TGT_MAX)) ]] && ost=$TGT_FIRST
886 # echo "Iteration: $i OST: $ost"
887 create_file $POOL_ROOT/dir1/file${i} $POOL 1
888 check_file_in_pool $POOL_ROOT/dir1/file${i} $POOL
892 # Fill up OST0 until it is nearly full.
893 # Create 9 files of size OST0_SIZE/10 each.
894 create_dir $POOL_ROOT/dir2 $POOL2 1
895 $LFS df $POOL_ROOT/dir2
896 OST0_SIZE=$($LFS df $POOL_ROOT/dir2 | awk '/\[OST:0\]/ { print $4 }')
897 FILE_SIZE=$((OST0_SIZE/1024/10))
898 echo "Filling OST0 with 9 files of ${FILE_SIZE}MB in $POOL_ROOT/dir2"
900 while [[ $i -lt 10 ]]; do
901 dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1M count=$FILE_SIZE
904 sleep 1 # get new statfs info
905 $LFS df $POOL_ROOT/dir2
907 # OST $TGT_FIRST is no longer favored; but it may still be used.
908 create_dir $POOL_ROOT/dir3 $POOL 1
909 create_file $POOL_ROOT/dir3/file $POOL 1
910 createmany -o $POOL_ROOT/dir3/$tfile- $numfiles ||
911 error "createmany $POOL_ROOT/dir3/$tfile- failed!"
912 for file in $POOL_ROOT/dir3/*; do
913 check_file_in_pool $file $POOL
920 run_test 14 "Round robin and QOS striping within a pool"
923 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
927 while [[ $i -lt $OSTCOUNT ]]; do
928 create_pool_nofail $POOL${i}
930 local tgt=$(printf "$FSNAME-OST%04x_UUID " $i)
931 add_pool $POOL${i} "$FSNAME-OST[$(printf %04x $i)]" "$tgt"
932 create_dir $POOL_ROOT/dir${i} $POOL${i}
933 createmany -o $POOL_ROOT/dir$i/$tfile $numfiles ||
934 error "createmany $POOL_ROOT/dir$i/$tfile failed!"
936 for file in $POOL_ROOT/dir$i/*; do
937 check_file_in_osts $file $i
945 run_test 15 "One directory per OST/pool"
948 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
952 create_pool_nofail $POOL
954 add_pool $POOL $TGT_HALF "$TGT_UUID2"
956 local dir=$POOL_ROOT/$tdir
957 create_dir $dir $POOL
959 for i in $(seq 1 10); do
964 createmany -o $dir/$tfile $numfiles ||
965 error "createmany $dir/$tfile failed!"
967 for file in $dir/*; do
968 check_file_in_pool $file $POOL
971 rm -rf $POOL_ROOT/$tdir
975 run_test 16 "Inheritance of pool properties"
978 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
982 create_pool_nofail $POOL
984 add_pool $POOL $TGT_ALL "$TGT_UUID"
986 local dir=$POOL_ROOT/dir
987 create_dir $dir $POOL
989 createmany -o $dir/${tfile}1_ $numfiles ||
990 error "createmany $dir/${tfile}1_ failed!"
992 for file in $dir/*; do
993 check_file_in_pool $file $POOL
998 createmany -o $dir/${tfile}2_ $numfiles ||
999 error "createmany $dir/${tfile}2_ failed!"
1004 run_test 17 "Referencing an empty pool"
1013 wait_delete_completed >/dev/null # give pending IO a chance to go to disk
1014 stat=$(createmany -o $cdir/${tfile} -$numsec | tail -1)
1015 files=$(echo $stat | cut -f 2 -d ' ')
1017 unlinkmany $cdir/${tfile} $files > /dev/null
1024 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1027 local plaindir=$POOL_ROOT/plaindir
1028 local pooldir=$POOL_ROOT/pooldir
1034 for i in $(seq 1 $iter); do
1035 echo "Create performance, iteration $i, $numsec seconds x 3"
1037 local files1=$(create_perf $plaindir $numsec)
1038 [[ $files1 -eq 0 ]] && error "Zero files created without pool"
1040 echo "iter $i: $files1 creates without pool"
1042 create_pool_nofail $POOL > /dev/null
1043 add_pool $POOL $TGT_ALL "$TGT_UUID" > /dev/null
1044 create_dir $pooldir $POOL
1045 local files2=$(create_perf $pooldir $numsec)
1046 [[ $files2 -eq 0 ]] && error "Zero files created with pool"
1048 echo "iter $i: $files2 creates with pool"
1050 destroy_pool $POOL > /dev/null
1051 local files3=$(create_perf $pooldir $numsec)
1052 [[ $files3 -eq 0 ]] &&
1053 error "Zero files created with missing pool"
1055 echo "iter $i: $files3 creates with missing pool"
1060 echo Avg files created in $numsec seconds without pool: $((f1 / iter))
1061 echo Avg files created in $numsec seconds with pool: $((f2 / iter))
1062 echo Avg files created in $numsec seconds missing pool: $((f3 / iter))
1064 # Set this high until we establish a baseline for what the degradation
1068 diff=$((($f1 - $f2) * 100 / $f1))
1069 echo "No pool / wide pool: $diff %."
1070 [ $diff -gt $max ] &&
1071 error_ignore bz23408 "Degradation with wide pool is $diff% > $max%"
1074 diff=$((($f1 - $f3) * 100 / $f1))
1075 echo "No pool / missing pool: $diff %."
1076 [ $diff -gt $max ] &&
1077 error_ignore bz23408 "Degradation with wide pool is $diff% > $max%"
1081 run_test 18 "File create in a directory which references a deleted pool"
1084 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1086 local dir1=$POOL_ROOT/dir1
1087 local dir2=$POOL_ROOT/dir2
1090 create_pool_nofail $POOL
1092 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1094 create_dir $dir1 $POOL
1095 createmany -o $dir1/${tfile} $numfiles ||
1096 error "createmany $dir1/${tfile} failed!"
1097 for file in $dir1/*; do
1098 check_file_in_pool $file $POOL
1102 createmany -o $dir2/${tfile} $numfiles ||
1103 error "createmany $dir2/${tfile} failed!"
1104 for file in $dir2/*; do
1105 check_file_not_in_pool $file $POOL
1112 run_test 19 "Pools should not come into play when not specified"
1115 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
1117 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1119 local dir1=$POOL_ROOT/dir1
1120 local dir2=$dir1/dir2
1121 local dir3=$dir1/dir3
1125 create_pool_nofail $POOL
1126 create_pool_nofail $POOL2
1128 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1130 local start=$(printf %04x $((TGT_FIRST + 1)))
1131 TGT=$(for i in $(seq 0x$start 2 0x$TGT_MAX); do \
1132 printf "$FSNAME-OST%04x_UUID " $i; done)
1133 add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1135 create_dir $dir1 $POOL
1136 create_file $dir1/file1 $POOL2 # Should replace $dir1 pool with $POOL2
1137 create_dir $dir2 $POOL2
1138 touch $dir2/file2 # Should inherit $POOL2 from $dir2
1139 mkdir $dir3 # Should inherit $POOL from $dir1
1140 $SETSTRIPE -c 1 $dir3 # Should remain existing $POOL
1141 touch $dir3/file3 # Should inherit $POOL from $dir3
1142 $SETSTRIPE -c 1 $dir2/file4 # Should inherit $POOL2 from dir2
1143 $SETSTRIPE -S 64K $dir1/file5 # Should inderit $POOL from $dir1
1145 check_file_in_pool $dir1/file1 $POOL2
1146 check_file_in_pool $dir2/file2 $POOL2
1147 check_dir_not_in_pool $dir3 $POOL2
1148 check_file_not_in_pool $dir3/file3 $POOL2
1149 check_file_not_in_pool $dir2/file4 $POOL
1150 check_file_not_in_pool $dir1/file5 $POOL2
1152 if [ $(lustre_version_code mds1) -ge $(version_code 2.10.54) ]; then
1153 check_dir_in_pool $dir3 $POOL
1154 check_file_in_pool $dir3/file3 $POOL
1155 check_file_in_pool $dir2/file4 $POOL2
1156 check_file_in_pool $dir1/file5 $POOL
1163 run_test 20 "Different pools in a directory hierarchy."
1166 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1167 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1171 local dir=$POOL_ROOT/dir
1173 create_pool_nofail $POOL
1175 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1177 create_dir $dir $POOL $OSTCOUNT
1178 create_file $dir/file1 $POOL $OSTCOUNT
1179 $LFS getstripe -v $dir/file1
1180 check_file_in_pool $dir/file1 $POOL
1186 run_test 21 "OST pool with fewer OSTs than stripe count"
1194 for c in $(seq 1 10); do
1195 echo "Pool $pool, iteration $c"
1196 do_facet mgs lctl pool_add $FSNAME.$pool \
1197 OST[$TGT_FIRST-$TGT_MAX/$step] 2>/dev/null
1198 local TGT_SECOND=$(printf %04x $((TGT_FIRST + $step)))
1199 if [ $((16#$TGT_SECOND)) -le $((16#$TGT_MAX)) ]; then
1200 do_facet mgs lctl pool_remove $FSNAME.$pool \
1201 OST[$TGT_SECOND-$TGT_MAX/$step]
1204 echo loop for $pool complete
1208 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1209 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1213 create_pool_nofail $POOL
1214 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
1215 create_pool_nofail $POOL2
1216 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
1221 create_dir $POOL_ROOT $POOL
1222 createmany -o $POOL_ROOT/${tfile} $numfiles ||
1223 error "createmany $POOL_ROOT/${tfile} failed!"
1228 run_test 22 "Simultaneous manipulation of a pool"
1231 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1232 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1235 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS ||
1236 skip_env "User $RUNAS_ID does not exist - skipping"
1240 local BUNIT_SZ=1024 # min block quota unit(kB)
1241 local LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1)))
1242 local dir=$POOL_ROOT/dir
1243 local file="$dir/$tfile-quota"
1245 create_pool_nofail $POOL
1247 local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
1248 printf "$FSNAME-OST%04x_UUID " $i; done)
1249 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1250 create_dir $dir $POOL
1252 # XXX remove the interoperability code once we drop the old server
1253 # ( < 2.3.50) support.
1254 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
1255 $LFS quotaoff -ug $MOUNT
1256 $LFS quotacheck -ug $MOUNT
1258 if [[ $PERM_CMD = *"set_param -P"* ]]; then
1259 do_facet mgs $PERM_CMD \
1260 osd-*.$FSNAME-OST*.quota_slave.enable=ug
1262 do_facet mgs $PERM_CMD $FSNAME.quota.ost=ug
1267 $LFS setquota -u $RUNAS_ID -b $LIMIT -B $LIMIT $dir
1269 $LFS quota -v -u $RUNAS_ID $dir
1271 $SETSTRIPE -c 1 -p $POOL $file
1272 chown $RUNAS_ID.$RUNAS_GID $file
1275 # This does two "dd" runs to ensure that the quota failure is returned
1276 # to userspace when we check. The first "dd" might otherwise complete
1277 # without error if it is only writing into cache.
1278 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
1279 count=$((BUNIT_SZ*2)) 2>&1)
1280 echo $stat | grep "Disk quota exceeded" > /dev/null
1281 if [ $? -eq 0 ]; then
1282 $LFS quota -v -u $RUNAS_ID $dir
1283 cancel_lru_locks osc
1284 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
1285 count=$BUNIT_SZ seek=$((BUNIT_SZ*2)) 2>&1)
1288 [[ $RC -eq 0 ]] && error "second dd did not fail."
1289 echo $stat | grep "Disk quota exceeded" > /dev/null
1290 [[ $? -eq 1 ]] && error "second dd did not fail with EDQUOT."
1292 log "first dd failed with EDQUOT."
1294 $LFS quota -v -u $RUNAS_ID $dir
1296 run_test 23a "OST pools and quota"
1299 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1300 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1303 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS || {
1304 skip_env "User $RUNAS_ID does not exist - skipping"
1309 local dir=$POOL_ROOT/dir
1310 local file="$dir/$tfile-quota"
1312 create_pool_nofail $POOL
1314 local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
1315 printf "$FSNAME-OST%04x_UUID " $i; done)
1316 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1317 create_dir $dir $POOL
1319 local maxfree=$((1024 * 1024 * 30)) # 30G
1320 local AVAIL=$(lfs_df -p $POOL $dir | awk '/summary/ { print $4 }')
1321 [ $AVAIL -gt $maxfree ] &&
1322 skip_env "Filesystem space $AVAIL is larger than " \
1325 echo "OSTCOUNT=$OSTCOUNT, OSTSIZE=$OSTSIZE, AVAIL=$AVAIL"
1326 echo "MAXFREE=$maxfree, SLOW=$SLOW"
1328 # XXX remove the interoperability code once we drop the old server
1329 # ( < 2.3.50) support.
1330 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
1331 $LFS quotaoff -ug $MOUNT
1333 if [[ $PERM_CMD = *"set_param -P"* ]]; then
1334 do_facet mgs $PERM_CMD \
1335 osd-*.$FSNAME-OST*.quota_slave.enable=none
1337 do_facet mgs $PERM_CMD $FSNAME.quota.ost=none
1342 chown $RUNAS_ID.$RUNAS_ID $dir
1346 local stime=$(date +%s)
1350 local maxtime=300 # minimum speed: 5GB / 300sec ~= 17MB/s
1351 while [ $RC -eq 0 ]; do
1353 stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file}$i bs=1M \
1354 count=$((5 * 1024)) 2>&1)
1356 TOTAL=$((TOTAL + 1024 * 1024 * 5))
1357 echo "[$i iteration] $stat"
1358 echo "total written: $TOTAL"
1361 elapsed=$((etime - stime))
1362 echo "stime=$stime, etime=$etime, elapsed=$elapsed"
1364 if [ $RC -eq 1 ]; then
1365 echo $stat | grep -q "Disk quota exceeded"
1367 error "dd failed with EDQUOT with quota off"
1369 echo $stat | grep -q "No space left on device"
1371 error "dd did not fail with ENOSPC"
1372 elif [ $TOTAL -gt $AVAIL ]; then
1373 error "dd didn't fail with ENOSPC ($TOTAL > $AVAIL)"
1374 elif [ $i -eq 1 -a $elapsed -gt $maxtime ]; then
1375 log "The first 5G write used $elapsed (> $maxtime) " \
1376 "seconds, terminated"
1384 run_test 23b "OST pools and OOS"
1387 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1388 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1390 local server_version=$(lustre_version_code $SINGLEMDS)
1391 [[ $server_version -ge $(version_code 2.8.56) ]] ||
1392 skip "Need server version newer than 2.8.55"
1400 create_pool_nofail $POOL
1402 add_pool $POOL $TGT_ALL "$TGT_UUID"
1404 create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1406 mkdir $POOL_ROOT/dir2
1407 $SETSTRIPE -p $POOL -S 65536 -i 0 -c 1 $POOL_ROOT/dir2 ||
1408 error "$SETSTRIPE $POOL_ROOT/dir2 failed"
1410 mkdir $POOL_ROOT/dir3
1411 $SETSTRIPE -S 65536 -i 0 -c 1 $POOL_ROOT/dir3 ||
1412 error "$SETSTRIPE $POOL_ROOT/dir3 failed"
1414 mkdir $POOL_ROOT/dir4
1416 for i in 1 2 3 4; do
1417 dir=${POOL_ROOT}/dir${i}
1426 createmany -o $dir/${tfile} $numfiles ||
1427 error "createmany $dir/${tfile} failed!"
1428 pool=$($LFS getstripe --pool $dir)
1429 index=$($LFS getstripe -i $dir)
1430 size=$($LFS getstripe -S $dir)
1431 count=$($LFS getstripe -c $dir)
1433 for file in $dir/*; do
1434 if [ "$pool" != "" ]; then
1435 check_file_in_pool $file $pool
1437 pool1=$($LFS getstripe --pool $file)
1438 count1=$($LFS getstripe -c $file)
1439 size1=$($LFS getstripe -S $file)
1440 [[ "$pool" != "$pool1" ]] &&
1441 error "Pool '$pool' not on $file:$pool1"
1442 [[ "$count" != "$count1" ]] &&
1443 [[ "$count" != "-1" ]] &&
1444 error "Stripe count $count not on"\
1446 [[ "$count1" != "$OSTCOUNT" ]] &&
1447 [[ "$count" = "-1" ]] &&
1448 error "Stripe count $count1 not on"\
1450 [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] &&
1451 error "Stripe size $size not on $file:$size1"
1459 run_test 24 "Independence of pool from other setstripe parameters"
1462 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1466 for i in $(seq 10); do
1467 create_pool_nofail $POOL$i
1468 do_facet mgs "lctl pool_add $FSNAME.$POOL$i OST0000; sync"
1469 wait_update $HOSTNAME "lctl get_param -n \
1470 lov.$FSNAME-*.pools.$POOL$i | sort -u |
1471 tr '\n' ' ' " "$FSNAME-OST0000_UUID " >/dev/null ||
1472 error "pool_add failed: $1; $2"
1474 facet_failover $SINGLEMDS ||
1475 error "failed to failover $SINGLEMDS"
1476 wait_osc_import_state $SINGLEMDS ost FULL
1480 # Veriy that the pool got created and is usable
1481 df $POOL_ROOT > /dev/null
1484 # Make sure OST0 can be striped on
1485 $SETSTRIPE -i 0 -c 1 $POOL_ROOT/$tfile
1486 local STR=$($LFS getstripe -i $POOL_ROOT/$tfile)
1487 rm $POOL_ROOT/$tfile
1488 if [[ "$STR" == "0" ]]; then
1489 echo "Creating a file in pool$i"
1490 create_file $POOL_ROOT/file$i $POOL$i || break
1491 check_file_in_pool $POOL_ROOT/file$i $POOL$i || break
1493 echo "OST 0 seems to be unavailable. Try later."
1499 run_test 25 "Create new pool and restart MDS"
1502 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >= 3 OSTs"
1503 local dev=$(mdsdevname ${SINGLEMDS//mds/})
1504 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1508 create_pool_nofail $POOL2
1510 do_facet mgs "lctl pool_add $FSNAME.$POOL2 OST0000; sync"
1511 wait_update $HOSTNAME "lctl get_param -n \
1512 lov.$FSNAME-*.pools.$POOL2 | sort -u |
1513 grep $FSNAME-OST0000_UUID " "$FSNAME-OST0000_UUID" ||
1514 error "pool_add failed: $1; $2"
1516 do_facet mgs "lctl pool_add $FSNAME.$POOL2 OST0002; sync"
1517 wait_update $HOSTNAME "lctl get_param -n \
1518 lov.$FSNAME-*.pools.$POOL2 | sort -u |
1519 grep $FSNAME-OST0002_UUID" "$FSNAME-OST0002_UUID" ||
1520 error "pool_add failed: $1; $2"
1522 # Veriy that the pool got created and is usable
1524 echo "Creating files in $POOL2"
1526 for ((i = 0; i < 10; i++)); do
1527 #OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
1528 #Fail OST0000 to ensure objects create on
1529 #the other OST in the pool
1530 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
1531 do_facet $SINGLEMDS lctl set_param fail_val=0
1532 create_file $POOL_ROOT/file$i $POOL2 1 -1 || break
1533 do_facet $SINGLEMDS lctl set_param fail_loc=0
1534 check_file_in_pool $POOL_ROOT/file$i $POOL2 || break
1538 run_test 26 "Choose other OSTs in the pool first in the creation remedy"
1541 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs"
1545 local count=$OSTCOUNT
1547 create_pool_nofail $POOL
1548 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT_ALL
1549 wait_update_facet $SINGLEMDS \
1550 "lctl pool_list $FSNAME.$POOL | wc -l" "$((OSTCOUNT + 1))" ||
1551 error "MDS: pool_list $FSNAME.$POOL failed"
1552 osts=$(list_pool $FSNAME.$POOL)
1553 for ost in ${osts}; do
1555 if [[ $count -eq 0 ]]; then
1556 #define OBD_FAIL_OST_LIST_ASSERT 0x239
1557 do_facet $SINGLEMDS \
1558 $LCTL set_param fail_loc=0x239 fail_val=10
1559 list_pool $FSNAME.$POOL &
1562 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
1563 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $ost
1565 do_facet $SINGLEMDS $LCTL set_param fail_val=0
1567 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $ost
1572 run_test 27 "Race pool_list and pool_remove"
1575 create_pool_nofail $POOL
1576 create_pool_nofail $POOL2
1577 add_pool $POOL $TGT_ALL "$TGT_UUID"
1578 add_pool $POOL2 $TGT_ALL "$TGT_UUID"
1580 start_full_debug_logging
1581 #$LFS setstripe -E 4M -c 1 -p $POOL -E 16M -c 2 $DIR/$tfile
1582 $LFS setstripe -c 1 -p $POOL $DIR/$tfile
1583 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=1 seek=16
1584 local csum=$(cksum $DIR/$tfile)
1585 $LFS getstripe $DIR/$tfile
1586 local pool="$($LFS getstripe -p $DIR/$tfile)"
1587 [[ "$pool" == "$POOL" ]] ||
1588 error "$tfile is in '$pool', not created on $POOL"
1589 $LFS_MIGRATE -y -p $POOL2 $DIR/$tfile ||
1590 error "migrate $tfile to $POOL2 failed"
1591 $LFS getstripe $DIR/$tfile
1592 pool="$($LFS getstripe -p $DIR/$tfile)"
1593 [[ "$pool" == "$POOL2" ]] ||
1594 error "$tfile is in '$pool', not migrated to $POOL2"
1595 local csum2=$(cksum $DIR/$tfile)
1596 [[ "$csum" == "$csum2" ]] || error "checksum error after migration"
1597 stop_full_debug_logging
1599 run_test 28 "lfs_migrate with pool name"
1604 destroy_test_pools $FSNAME
1605 if ! combined_mgs_mds; then
1606 zconf_umount $mgs_HOST $MOUNT
1607 do_facet mgs "rm -rf $MOUNT"
1609 check_and_cleanup_lustre