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
30 [ "$SLOW" = "no" ] && EXCEPT_SLOW="18 23b"
37 MAXFREE=${MAXFREE:-$((2000000 * OSTCOUNT))}
41 POOL2=${POOL2:-${POOL}2}
42 POOL3=${POOL3:-${POOL}3}
43 NON_EXISTANT_POOL=nonexistantpool
44 NON_EXISTANT_FS=nonexistantfs
45 INVALID_POOL=some_invalid_pool_name
47 TGT_FIRST=$(printf %04x 0)
48 TGT_MAX=$(printf %04x $((TGT_COUNT-1)))
50 TGT_LIST=$(seq 0x$TGT_FIRST $TGT_STEP 0x$TGT_MAX)
51 TGT_LIST2=$(seq 0x$TGT_FIRST 2 0x$TGT_MAX)
53 TGT_ALL="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/1]"
54 TGT_HALF="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]"
56 TGT_UUID=$(for i in $TGT_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
57 TGT_UUID2=$(for i in $TGT_LIST2; do printf "$FSNAME-OST%04x_UUID " $i; done)
62 local count=${3:-"-1"}
66 if [[ -n $idx ]]; then
67 $LFS setstripe -c $count -p $pool -i $idx $dir
69 $LFS setstripe -c $count -p $pool $dir
71 [[ $? -eq 0 ]] || error "$LFS setstripe -p $pool $dir failed"
72 [[ "$($LFS getstripe --pool $dir)" == "$pool" ]] ||
73 error "$dir not created in expected pool '$pool'"
79 local count=${3:-"-1"}
80 local index=${4:-"-1"}
82 $LFS setstripe -i $index -c $count -p $pool $file
83 [[ $? -eq 0 ]] || error "$LFS setstripe -p $pool $file failed"
84 [[ "$($LFS getstripe --pool $file)" == "$pool" ]] ||
85 error "$file not created in '$pool'"
91 for i in $(list_pool $FSNAME.$pool |
92 sed -e 's/_UUID$//;s/^.*-OST//'); do
93 res="$res $(printf "%d" 0x$i)"
101 local res=$($LFS getstripe --pool $dir)
103 [ -n "$res" ] || error "dir '$dir' not in any pool"
105 [ "$res" == "$pool" ] ||
106 error "dir '$dir' in pool '$res' instead of '$pool'"
109 check_file_in_pool() {
113 local osts=$(osts_in_pool $pool)
114 local res=$($LFS getstripe --pool $file)
116 [ -n "$res" ] || error "file '$file' not in any pool"
118 [ "$res" == "$pool" ] ||
119 error "file '$file' in pool '$res' instead of '$pool'"
121 local osts=$(osts_in_pool $2)
122 check_file_in_osts "$file" "$osts" $count
125 check_file_in_osts() {
127 local ost_list=${2:-$TGT_LIST}
129 local res=$($LFS getstripe $file | awk '/0x/ { print $1 }')
133 found=$(echo :$ost_list: | tr " " ":" | grep :$i:)
134 if [[ "$found" == "" ]]; then
135 echo "ost list: $ost_list"
136 echo "striping: $res"
137 $LFS getstripe -v $file
138 error "$file not allocated from OSTs $ost_list."
142 local ost_count=$($LFS getstripe -c $file)
143 [[ -n "$count" ]] && [[ $ost_count -ne $count ]] &&
144 error "$file stripe count $count expected; got $ost_count" &&
149 check_file_not_in_pool() {
152 local res=$($LFS getstripe --pool $file)
154 [ "$res" != "$pool" ] || error "File '$file' is in pool: $res"
157 check_dir_not_in_pool() {
160 local res=$($LFS getstripe --pool $dir)
162 [ "$res" != "$pool" ] || error "Dir '$dir' is in pool: $res"
167 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool" "" ||
168 error "Failed to remove targets from pool: $pool"
174 local tgt="${3}$(lctl get_param -n lov.$FSNAME-*.pools.$pool |
175 sort -u | tr '\n' ' ')"
177 do_facet mgs lctl pool_add $FSNAME.$pool $osts
179 [[ $RC -ne 0 ]] && return $RC
181 # wait for OSTs to be added to the pool
182 for mds_id in $(seq $MDSCOUNT); do
183 local mdt_id=$((mds_id-1))
184 local lodname=$FSNAME-MDT$(printf "%04x" $mdt_id)-mdtlov
185 wait_update_facet mds$mds_id \
186 "lctl get_param -n lod.$lodname.pools.$pool |
187 sort -u | tr '\n' ' ' " "$tgt" >/dev/null ||
188 error "mds$mds_id:pool add failed $1; $2"
190 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool |
191 sort -u | tr '\n' ' ' " "$tgt" >/dev/null ||
192 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 $(list_pool $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 char pool name"
249 create_pool_nofail ${POOL}1234567
250 destroy_pool ${POOL}1234567
252 run_test 1c "Create a pool with a 15 char pool name"
256 create_pool_fail ${POOL}12345678
258 run_test 1d "Create a pool with a 16 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 mgs 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 mgs 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 mgs 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 mgs 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 mgs 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 mgs 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 mgs 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"
328 create_pool_nofail ${POOL}1234567
330 add_pool ${POOL}1234567 "OST0000" "$FSNAME-OST0000_UUID "
331 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
332 create_dir $POOL_ROOT ${POOL}1234567
333 dd if=/dev/zero of=$POOL_ROOT/file bs=1M count=100
334 RC=$?; [[ $RC -eq 0 ]] ||
335 error "failed to write to $POOL_ROOT/file: $RC"
336 do_facet mgs lctl pool_remove $FSNAME.${POOL}1234567 OST0000
337 drain_pool ${POOL}1234567
339 destroy_pool ${POOL}1234567
341 run_test 1n "Pool with a 15 char pool name works well"
347 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
349 error "pool_add did not fail even though $POOL did not exist"
351 run_test 2a "pool_add: non-existant pool $POOL"
355 do_facet mgs lctl pool_add $FSNAME.${POOL}1234567890 \
356 $FSNAME-OST0000 2>/dev/null
358 error "pool_add did not fail even though pool name was invalid."
360 run_test 2b "pool_add: Invalid pool name"
362 # Testing various combinations of OST name list
368 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
369 [[ $? -ne 0 ]] || destroy_pool $POOL
371 create_pool_nofail $POOL
374 do_facet mgs lctl pool_add $FSNAME.$POOL OST0000
375 RC=$?; [[ $RC -eq 0 ]] ||
376 error "pool_add failed. $FSNAME $POOL OST0000: $RC"
377 do_facet mgs lctl pool_remove $FSNAME.$POOL OST0000
381 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
382 RC=$?; [[ $RC -eq 0 ]] ||
383 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000: $RC"
384 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
387 # 3. $FSNAME-OST0000_UUID
388 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
389 RC=$?; [[ $RC -eq 0 ]] ||
390 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000_UUID: $RC"
391 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
394 # 4. $FSNAME-OST[0,1,2,3,]
396 for i in $TGT_LIST; do TGT=${TGT}$(printf "%04x," $i); done
398 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT
399 [[ $? -eq 0 ]] || error "pool_add failed. $FSNAME.$POOL $TGT. $RC"
400 do_facet mgs lctl pool_remove $FSNAME.$POOL $TGT
403 # 5. $FSNAME-OST[0-5/1]
404 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT_ALL
405 RC=$?; [[ $RC -eq 0 ]] ||
406 error "pool_add failed. $FSNAME $POOL" "$TGT_ALL $RC"
407 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL |
408 sort -u | tr '\n' ' ' " "$TGT_UUID" ||
409 error "Add to pool failed"
410 do_facet mgs lctl pool_remove $FSNAME.$POOL $TGT_ALL
415 run_test 2c "pool_add: OST index combinations"
422 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
423 [[ $? -ne 0 ]] || destroy_pool $POOL
425 create_pool_nofail $POOL
427 TGT=$(printf "$FSNAME-OST%04x_UUID " $OSTCOUNT)
428 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT
429 RC=$?; [[ $RC -ne 0 ]] ||
430 error "pool_add succeeded for an OST ($TGT) that does not exist."
434 run_test 2d "pool_add: OSTs that don't exist should be rejected"
442 $LCTL get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
443 [[ $? -ne 0 ]] || destroy_pool $POOL
445 create_pool_nofail $POOL
447 TGT="$FSNAME-OST0000_UUID "
448 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT
449 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL |
450 sort -u | tr '\n' ' ' " "$TGT" || error "Add to pool failed"
451 RESULT=$(do_facet mgs \
452 "LOCALE=C $LCTL pool_add $FSNAME.$POOL $TGT 2>&1")
457 error "pool_add succeeded for an OST that was already in the pool."
459 [[ $(grep "already in pool" <<< $RESULT) ]] ||
460 error "pool_add failed as expected but error message not as expected."
464 run_test 2e "pool_add: OST already in a pool should be rejected"
468 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
469 [[ $? -ne 0 ]] || destroy_pool $POOL
472 lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
474 error "pool_remove did not fail even though pool did not exist."
476 run_test 3a "pool_remove: non-existant pool"
481 lctl pool_remove ${NON_EXISTANT_FS}.$POOL OST0000 2>/dev/null
483 error "pool_remove did not fail even though fsname did not exist."
485 run_test 3b "pool_remove: non-existant fsname"
489 do_facet mgs lctl pool_remove $FSNAME.p1234567891234567890 \
490 $FSNAME-OST0000 2>/dev/null
492 error "pool_remove did not fail even though pool name was invalid."
494 run_test 3c "pool_remove: Invalid pool name"
496 # Testing various combinations of OST name list
499 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
500 [[ $? -ne 0 ]] || destroy_pool $POOL
502 create_pool_nofail $POOL
503 do_facet mgs lctl pool_add $FSNAME.$POOL OST0000
504 do_facet mgs lctl pool_remove $FSNAME.$POOL OST0000
505 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL OST0000"
508 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
509 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
510 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000"
513 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
514 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
516 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000_UUID"
519 add_pool $POOL $TGT_ALL "$TGT_UUID"
520 do_facet mgs lctl pool_remove $FSNAME.$POOL $TGT_ALL
521 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL" $TGT_ALL
526 run_test 3d "pool_remove: OST index combinations"
530 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
531 [[ $? -ne 0 ]] || destroy_pool $POOL
533 do_facet mgs lctl pool_destroy $FSNAME.$POOL 2>/dev/null
535 error "pool_destroy did not fail even though pool did not exist."
537 run_test 4a "pool_destroy: non-existant pool"
541 do_facet mgs lctl pool_destroy ${NON_EXISTANT_FS}.$POOL 2>/dev/null
543 error "pool_destroy did not fail even though filesystem did not exist."
545 run_test 4b "pool_destroy: non-existant fs-name"
549 create_pool_nofail $POOL
550 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
552 do_facet mgs lctl pool_destroy ${FSNAME}.$POOL
553 [[ $? -ne 0 ]] || error "pool_destroy succeeded with a non-empty pool."
556 run_test 4c "pool_destroy: non-empty pool"
561 $LCMD pool_list 2>/dev/null
563 error "pool_list did not fail even though fsname missing."
565 destroy_pool $POOL 2>/dev/null
566 destroy_pool $POOL2 2>/dev/null
568 create_pool_nofail $POOL
569 create_pool_nofail $POOL2
570 $LCMD pool_list $FSNAME
571 [[ $? -eq 0 ]] || error "pool_list $FSNAME failed."
573 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT_ALL
575 $LCMD pool_list $FSNAME.$POOL
576 [[ $? -eq 0 ]] || error "pool_list $FSNAME.$POOL failed."
578 $LCMD pool_list ${NON_EXISTANT_FS} 2>/dev/null
580 error "pool_list did not fail for fsname $NON_EXISTANT_FS"
582 $LCMD pool_list ${FSNAME}.$NON_EXISTANT_POOL 2>/dev/null
584 error "pool_list did not fail for pool $NON_EXISTANT_POOL"
586 if [[ ! $(grep $SINGLEMDS <<< $LCMD) ]]; then
587 echo $LCMD pool_list $DIR
589 [[ $? -eq 0 ]] || error "pool_list failed for $DIR"
592 $LCMD pool_list ${DIR}/d1
593 [[ $? -eq 0 ]] || error "pool_list failed for ${DIR}/d1"
596 rm -rf ${DIR}nonexistant
597 $LCMD pool_list ${DIR}nonexistant 2>/dev/null
599 error "pool_list did not fail for invalid mountpoint ${DIR}nonexistant"
607 # Issue commands from client
610 run_test 5a "lfs pool_list from client"
614 sub_test_5 "do_facet $SINGLEMDS lctl"
616 run_test 5b "lctl pool_list from MDS"
620 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
621 local POOL_DIR=$POOL_ROOT/dir_tst
622 local POOL_FILE=$POOL_ROOT/file_tst
624 create_pool_nofail $POOL
626 do_facet $SINGLEMDS lctl pool_list $FSNAME
627 [[ $? -eq 0 ]] || error "pool_list $FSNAME failed."
629 add_pool $POOL $TGT_ALL "$TGT_UUID"
632 $SETSTRIPE -c -1 -p $POOL $POOL_DIR
633 [[ $? -eq 0 ]] || error "$SETSTRIPE -p $POOL failed."
634 check_dir_in_pool $POOL_DIR $POOL
636 # If an invalid pool name is specified, the command should fail
637 $SETSTRIPE -c 2 -p $INVALID_POOL $POOL_DIR 2>/dev/null
638 [[ $? -ne 0 ]] || error "setstripe to invalid pool did not fail."
640 # If the pool name does not exist, the command should fail
641 $SETSTRIPE -c 2 -p $NON_EXISTANT_POOL $POOL_DIR 2>/dev/null
642 [[ $? -ne 0 ]] || error "setstripe to non-existant pool did not fail."
644 # lfs setstripe should work as before if a pool name is not specified.
645 $SETSTRIPE -c -1 $POOL_DIR
646 [[ $? -eq 0 ]] || error "$SETSTRIPE -p $POOL_DIR failed."
647 $SETSTRIPE -c -1 $POOL_FILE
648 [[ $? -eq 0 ]] || error "$SETSTRIPE -p $POOL_FILE failed."
650 # lfs setstripe should fail if a start index that is outside the
652 create_pool_nofail $POOL2
653 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
654 $SETSTRIPE -i 1 -p $POOL2 $ROOT_POOL/$tfile 2>/dev/null
656 error "$SETSTRIPE with start index outside the pool did not fail."
659 run_test 6 "getstripe/setstripe"
663 # Create a pool, stripe a directory and file with it
666 pool_add $pool || error "pool_add failed"
667 pool_add_targets $pool 0 1 || error "pool_add_targets failed"
669 $SETSTRIPE -c 1 $DIR/$tdir/testfile1 --pool "$pool" || \
670 error "setstripe failed"
671 $SETSTRIPE -c 1 $DIR/$tdir/testfile2 --pool "$FSNAME.$pool" || \
672 error "setstripe failed"
674 mkdir $DIR/$tdir/testdir
675 $SETSTRIPE -c 1 $DIR/$tdir/testdir -p "$pool" || \
676 error "setstripe failed"
677 $SETSTRIPE -c 1 $DIR/$tdir/testdir -p "$FSNAME.$pool" || \
678 error "setstripe failed"
680 rm -f $DIR/$tdir/testfile1
681 rm -f $DIR/$tdir/testfile2
682 rmdir $DIR/$tdir/testdir
684 destroy_pool_int $FSNAME.$pool
689 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
693 # Generate pool with random name from 1 to 15 characters
695 POOLNAME=$(echo $$$RANDOM$RANDOM |
696 tr -dc 'a-zA-Z0-9' | fold -w $i |
698 echo set poolname to $POOLNAME
699 helper_test_7a $POOLNAME
702 run_test 7a "create various pool name"
707 do_facet mgs lctl pool_new qwerty
708 [ $? -ne 22 ] && error "can create a pool with no fsname"
711 do_facet mgs lctl pool_new $FSNAME.
712 [ $? -ne 22 ] && error "can create a pool with no name"
715 do_facet mgs lctl pool_new $FSNAME.0123456789^bdef
716 [ $? -ne 22 ] && error "can create a pool with an invalid name"
719 do_facet mgs lctl pool_new $FSNAME.0123456789abdefg
720 [ $? -ne 36 ] && error "can create a pool with a name too long"
724 run_test 7b "try to create pool name with invalid lengths or names"
728 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
732 # Create a pool with 15 letters
733 local pool=0123456789abcde
734 pool_add $pool || error "pool_add failed"
735 pool_add_targets $pool 0 1 || error "pool_add_targets failed"
737 # setstripe with the same pool name plus 1 letter
738 $SETSTRIPE -c 1 $DIR/$tdir/testfile1 --pool "${pool}X" && \
739 error "setstripe succedeed"
741 # setstripe with the same pool name minus 1 letter
742 $SETSTRIPE -c 1 $DIR/$tdir/testfile1 --pool "${pool%?}" && \
743 error "setstripe succedeed"
745 rm -f $DIR/$tdir/testfile1
747 destroy_pool_int $FSNAME.$pool
749 run_test 7c "create a valid pool name and setstripe with a bad one"
753 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
755 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
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 create_dir $POOL_ROOT/dir1 $POOL
767 create_dir $POOL_ROOT/dir2 $POOL2
770 createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
771 error "createmany $POOL_ROOT/dir1/$tfile failed!"
773 for file in $POOL_ROOT/dir1/*; do
774 check_file_in_pool $file $POOL
777 createmany -o $POOL_ROOT/dir2/$tfile $numfiles ||
778 error "createmany $POOL_ROOT/dir2/$tfile failed!"
779 for file in $POOL_ROOT/dir2/*; do
780 check_file_in_pool $file $POOL2
783 rm -rf $POOL_ROOT/dir?
787 run_test 11 "OSTs in overlapping/multiple pools"
791 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
793 [[ $OSTCOUNT -le 2 ]] && skip_env "Need at least 3 OSTs" && return
795 create_pool_nofail $POOL
796 create_pool_nofail $POOL2
798 local start=$(printf %04x $((TGT_FIRST + 1)))
799 do_facet mgs lctl pool_add $FSNAME.$POOL2 \
800 $FSNAME-OST[$start-$TGT_MAX/2]
802 add_pool $POOL $TGT_HALF "$TGT_UUID2"
804 echo creating some files in $POOL and $POOL2
806 create_dir $POOL_ROOT/dir1 $POOL
807 create_dir $POOL_ROOT/dir2 $POOL2
808 create_file $POOL_ROOT/file1 $POOL
809 create_file $POOL_ROOT/file2 $POOL2
811 echo Checking the files created
812 check_file_in_pool $POOL_ROOT/file1 $POOL
813 check_file_in_pool $POOL_ROOT/file2 $POOL2
815 echo Changing the pool membership
816 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST[$TGT_FIRST]
817 do_facet mgs lctl pool_list $FSNAME.$POOL
818 FIRST_UUID=$(echo $TGT_UUID | awk '{print $1}')
819 add_pool $POOL2 $FSNAME-OST[$TGT_FIRST] "$FIRST_UUID "
820 do_facet mgs lctl pool_list $FSNAME.$POOL2
822 echo Checking the files again
823 check_dir_in_pool $POOL_ROOT/dir1 $POOL
824 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
825 check_file_in_osts $POOL_ROOT/file1 "$TGT_LIST2"
826 check_file_in_osts $POOL_ROOT/file2 "$(seq 0x$start 2 0x$TGT_MAX)"
828 echo Creating some more files
829 create_dir $POOL_ROOT/dir3 $POOL
830 create_dir $POOL_ROOT/dir4 $POOL2
831 create_file $POOL_ROOT/file3 $POOL
832 create_file $POOL_ROOT/file4 $POOL2
834 echo Checking the new files
835 check_file_in_pool $POOL_ROOT/file3 $POOL
836 check_file_in_pool $POOL_ROOT/file4 $POOL2
840 run_test 12 "OST Pool Membership"
844 [[ $OSTCOUNT -le 2 ]] && skip_env "Need at least 3 OSTs" && return
846 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
850 create_pool_nofail $POOL
851 add_pool $POOL $TGT_ALL "$TGT_UUID"
853 create_dir $POOL_ROOT/dir1 $POOL -1
854 createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
855 error "createmany $POOL_ROOT/dir1/$tfile failed!"
856 for file in $POOL_ROOT/dir1/*; do
857 check_file_in_pool $file $POOL $OSTCOUNT
860 create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
861 create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST + 1))
862 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST + 2))
863 check_file_in_osts $POOL_ROOT/dir1/file1 $((16#$TGT_FIRST))
864 check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST + 1))"
865 check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST + 2))"
867 create_dir $POOL_ROOT/dir2 $POOL $count
868 createmany -o $POOL_ROOT/dir2/$tfile- $numfiles ||
869 error "createmany $POOL_ROOT/dir2/$tfile- failed!"
870 for file in $POOL_ROOT/dir2/*; do
871 check_file_in_pool $file $POOL $count
874 create_dir $POOL_ROOT/dir3 $POOL $count $((TGT_FIRST + 1))
875 createmany -o $POOL_ROOT/dir3/$tfile- $numfiles ||
876 error "createmany $POOL_ROOT/dir3/$tfile- failed!"
877 for file in $POOL_ROOT/dir3/*; do
878 check_file_in_pool $file $POOL $count
881 create_dir $POOL_ROOT/dir4 $POOL 1
882 createmany -o $POOL_ROOT/dir4/$tfile- $numfiles ||
883 error "createmany $POOL_ROOT/dir4/$tfile- failed!"
884 for file in $POOL_ROOT/dir4/*; do
885 check_file_in_pool $file $POOL 1
888 create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST + 2))
889 createmany -o $POOL_ROOT/dir5/$tfile- $numfiles ||
890 error "createmany $POOL_ROOT/dir5/$tfile- failed!"
891 for file in $POOL_ROOT/dir5/*; do
892 check_file_in_pool $file $POOL 1
895 rm -rf $POOL_ROOT/dir[1-5]/
899 run_test 13 "Striping characteristics in a pool"
903 [[ $OSTCOUNT -le 2 ]] && skip_env "Need at least 3 OSTs" && return
905 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
909 [ $OSTSIZE -gt $((MAXFREE / OSTCOUNT)) ] &&
910 skip_env "OST size $OSTSIZE is larger than $((MAXFREE / OSTCOUNT))" &&
913 create_pool_nofail $POOL
914 create_pool_nofail $POOL2
916 add_pool $POOL $TGT_HALF "$TGT_UUID2"
917 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
919 create_dir $POOL_ROOT/dir1 $POOL 1
920 create_file $POOL_ROOT/dir1/file $POOL 1
921 local ost=$($LFS getstripe -i $POOL_ROOT/dir1/file)
923 while [[ $i -lt $numfiles ]]; do
925 [[ $ost -gt $((16#$TGT_MAX)) ]] && ost=$TGT_FIRST
927 # echo "Iteration: $i OST: $ost"
928 create_file $POOL_ROOT/dir1/file${i} $POOL 1
929 check_file_in_pool $POOL_ROOT/dir1/file${i} $POOL
933 # Fill up OST0 until it is nearly full.
934 # Create 9 files of size OST0_SIZE/10 each.
935 create_dir $POOL_ROOT/dir2 $POOL2 1
936 $LFS df $POOL_ROOT/dir2
937 OST0_SIZE=$($LFS df $POOL_ROOT/dir2 | awk '/\[OST:0\]/ { print $4 }')
938 FILE_SIZE=$((OST0_SIZE/1024/10))
939 echo "Filling OST0 with 9 files of ${FILE_SIZE}MB in $POOL_ROOT/dir2"
941 while [[ $i -lt 10 ]]; do
942 dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1M count=$FILE_SIZE
945 sleep 1 # get new statfs info
946 $LFS df $POOL_ROOT/dir2
948 # OST $TGT_FIRST is no longer favored; but it may still be used.
949 create_dir $POOL_ROOT/dir3 $POOL 1
950 create_file $POOL_ROOT/dir3/file $POOL 1
951 createmany -o $POOL_ROOT/dir3/$tfile- $numfiles ||
952 error "createmany $POOL_ROOT/dir3/$tfile- failed!"
953 for file in $POOL_ROOT/dir3/*; do
954 check_file_in_pool $file $POOL
961 run_test 14 "Round robin and QOS striping within a pool"
965 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
969 while [[ $i -lt $OSTCOUNT ]]; do
970 create_pool_nofail $POOL${i}
972 local tgt=$(printf "$FSNAME-OST%04x_UUID " $i)
973 add_pool $POOL${i} "$FSNAME-OST[$(printf %04x $i)]" "$tgt"
974 create_dir $POOL_ROOT/dir${i} $POOL${i}
975 createmany -o $POOL_ROOT/dir$i/$tfile $numfiles ||
976 error "createmany $POOL_ROOT/dir$i/$tfile failed!"
978 for file in $POOL_ROOT/dir$i/*; do
979 check_file_in_osts $file $i
987 run_test 15 "One directory per OST/pool"
991 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
995 create_pool_nofail $POOL
997 add_pool $POOL $TGT_HALF "$TGT_UUID2"
999 local dir=$POOL_ROOT/$tdir
1000 create_dir $dir $POOL
1002 for i in $(seq 1 10); do
1007 createmany -o $dir/$tfile $numfiles ||
1008 error "createmany $dir/$tfile failed!"
1010 for file in $dir/*; do
1011 check_file_in_pool $file $POOL
1014 rm -rf $POOL_ROOT/$tdir
1018 run_test 16 "Inheritance of pool properties"
1022 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1026 create_pool_nofail $POOL
1028 add_pool $POOL $TGT_ALL "$TGT_UUID"
1030 local dir=$POOL_ROOT/dir
1031 create_dir $dir $POOL
1033 createmany -o $dir/${tfile}1_ $numfiles ||
1034 error "createmany $dir/${tfile}1_ failed!"
1036 for file in $dir/*; do
1037 check_file_in_pool $file $POOL
1042 createmany -o $dir/${tfile}2_ $numfiles ||
1043 error "createmany $dir/${tfile}2_ failed!"
1048 run_test 17 "Referencing an empty pool"
1057 wait_delete_completed >/dev/null # give pending IO a chance to go to disk
1058 stat=$(createmany -o $cdir/${tfile} -$numsec | tail -1)
1059 files=$(echo $stat | cut -f 2 -d ' ')
1061 unlinkmany $cdir/${tfile} $files > /dev/null
1069 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1072 local plaindir=$POOL_ROOT/plaindir
1073 local pooldir=$POOL_ROOT/pooldir
1079 for i in $(seq 1 $iter); do
1080 echo "Create performance, iteration $i, $numsec seconds x 3"
1082 local files1=$(create_perf $plaindir $numsec)
1083 [[ $files1 -eq 0 ]] && error "Zero files created without pool"
1085 echo "iter $i: $files1 creates without pool"
1087 create_pool_nofail $POOL > /dev/null
1088 add_pool $POOL $TGT_ALL "$TGT_UUID" > /dev/null
1089 create_dir $pooldir $POOL
1090 local files2=$(create_perf $pooldir $numsec)
1091 [[ $files2 -eq 0 ]] && error "Zero files created with pool"
1093 echo "iter $i: $files2 creates with pool"
1095 destroy_pool $POOL > /dev/null
1096 local files3=$(create_perf $pooldir $numsec)
1097 [[ $files3 -eq 0 ]] &&
1098 error "Zero files created with missing pool"
1100 echo "iter $i: $files3 creates with missing pool"
1105 echo Avg files created in $numsec seconds without pool: $((f1 / iter))
1106 echo Avg files created in $numsec seconds with pool: $((f2 / iter))
1107 echo Avg files created in $numsec seconds missing pool: $((f3 / iter))
1109 # Set this high until we establish a baseline for what the degradation
1113 diff=$((($f1 - $f2) * 100 / $f1))
1114 echo "No pool / wide pool: $diff %."
1115 [ $diff -gt $max ] &&
1116 error_ignore bz23408 "Degradation with wide pool is $diff% > $max%"
1119 diff=$((($f1 - $f3) * 100 / $f1))
1120 echo "No pool / missing pool: $diff %."
1121 [ $diff -gt $max ] &&
1122 error_ignore bz23408 "Degradation with wide pool is $diff% > $max%"
1126 run_test 18 "File create in a directory which references a deleted pool"
1130 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1132 local dir1=$POOL_ROOT/dir1
1133 local dir2=$POOL_ROOT/dir2
1136 create_pool_nofail $POOL
1138 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1140 create_dir $dir1 $POOL
1141 createmany -o $dir1/${tfile} $numfiles ||
1142 error "createmany $dir1/${tfile} failed!"
1143 for file in $dir1/*; do
1144 check_file_in_pool $file $POOL
1148 createmany -o $dir2/${tfile} $numfiles ||
1149 error "createmany $dir2/${tfile} failed!"
1150 for file in $dir2/*; do
1151 check_file_not_in_pool $file $POOL
1158 run_test 19 "Pools should not come into play when not specified"
1162 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1164 local dir1=$POOL_ROOT/dir1
1165 local dir2=$dir1/dir2
1166 local dir3=$dir1/dir3
1170 create_pool_nofail $POOL
1171 create_pool_nofail $POOL2
1173 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1175 local start=$(printf %04x $((TGT_FIRST + 1)))
1176 TGT=$(for i in $(seq 0x$start 2 0x$TGT_MAX); do \
1177 printf "$FSNAME-OST%04x_UUID " $i; done)
1178 add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1180 create_dir $dir1 $POOL
1181 create_file $dir1/file1 $POOL2
1182 create_dir $dir2 $POOL2
1185 $SETSTRIPE -c 1 $dir3 # No pool assignment
1187 $SETSTRIPE -c 1 $dir2/file4 # No pool assignment
1189 check_file_in_pool $dir1/file1 $POOL2
1190 check_file_in_pool $dir2/file2 $POOL2
1192 check_dir_not_in_pool $dir3 $POOL
1193 check_dir_not_in_pool $dir3 $POOL2
1195 check_file_not_in_pool $dir3/file3 $POOL
1196 check_file_not_in_pool $dir3/file3 $POOL2
1198 check_file_not_in_pool $dir2/file4 $POOL
1199 check_file_not_in_pool $dir2/file4 $POOL2
1205 run_test 20 "Different pools in a directory hierarchy."
1209 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1210 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1214 local dir=$POOL_ROOT/dir
1216 create_pool_nofail $POOL
1218 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1220 create_dir $dir $POOL $OSTCOUNT
1221 create_file $dir/file1 $POOL $OSTCOUNT
1222 $LFS getstripe -v $dir/file1
1223 check_file_in_pool $dir/file1 $POOL
1229 run_test 21 "OST pool with fewer OSTs than stripe count"
1237 for c in $(seq 1 10); do
1238 echo "Pool $pool, iteration $c"
1239 do_facet mgs lctl pool_add $FSNAME.$pool \
1240 OST[$TGT_FIRST-$TGT_MAX/$step] 2>/dev/null
1241 local TGT_SECOND=$(printf %04x $((TGT_FIRST + $step)))
1242 if [ $((16#$TGT_SECOND)) -le $((16#$TGT_MAX)) ]; then
1243 do_facet mgs lctl pool_remove $FSNAME.$pool \
1244 OST[$TGT_SECOND-$TGT_MAX/$step]
1247 echo loop for $pool complete
1252 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1253 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1257 create_pool_nofail $POOL
1258 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
1259 create_pool_nofail $POOL2
1260 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
1265 create_dir $POOL_ROOT $POOL
1266 createmany -o $POOL_ROOT/${tfile} $numfiles ||
1267 error "createmany $POOL_ROOT/${tfile} failed!"
1272 run_test 22 "Simultaneous manipulation of a pool"
1276 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1277 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1280 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS || {
1281 skip_env "User $RUNAS_ID does not exist - skipping"
1287 local BUNIT_SZ=1024 # min block quota unit(kB)
1288 local LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1)))
1289 local dir=$POOL_ROOT/dir
1290 local file="$dir/$tfile-quota"
1292 create_pool_nofail $POOL
1294 local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
1295 printf "$FSNAME-OST%04x_UUID " $i; done)
1296 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1297 create_dir $dir $POOL
1299 # XXX remove the interoperability code once we drop the old server
1300 # ( < 2.3.50) support.
1301 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
1302 $LFS quotaoff -ug $MOUNT
1303 $LFS quotacheck -ug $MOUNT
1305 do_facet mgs $LCTL conf_param $FSNAME.quota.ost=ug
1309 $LFS setquota -u $RUNAS_ID -b $LIMIT -B $LIMIT $dir
1311 $LFS quota -v -u $RUNAS_ID $dir
1313 $SETSTRIPE -c 1 -p $POOL $file
1314 chown $RUNAS_ID.$RUNAS_GID $file
1317 # This does two "dd" runs to ensure that the quota failure is returned
1318 # to userspace when we check. The first "dd" might otherwise complete
1319 # without error if it is only writing into cache.
1320 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
1321 count=$((BUNIT_SZ*2)) 2>&1)
1322 echo $stat | grep "Disk quota exceeded" > /dev/null
1323 if [ $? -eq 0 ]; then
1324 $LFS quota -v -u $RUNAS_ID $dir
1325 cancel_lru_locks osc
1326 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
1327 count=$BUNIT_SZ seek=$((BUNIT_SZ*2)) 2>&1)
1330 [[ $RC -eq 0 ]] && error "second dd did not fail."
1331 echo $stat | grep "Disk quota exceeded" > /dev/null
1332 [[ $? -eq 1 ]] && error "second dd did not fail with EDQUOT."
1334 log "first dd failed with EDQUOT."
1336 $LFS quota -v -u $RUNAS_ID $dir
1338 run_test 23a "OST pools and quota"
1342 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1343 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return 0
1346 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS || {
1347 skip_env "User $RUNAS_ID does not exist - skipping"
1353 local dir=$POOL_ROOT/dir
1354 local file="$dir/$tfile-quota"
1356 create_pool_nofail $POOL
1358 local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
1359 printf "$FSNAME-OST%04x_UUID " $i; done)
1360 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1361 create_dir $dir $POOL
1363 local maxfree=$((1024 * 1024 * 30)) # 30G
1364 local AVAIL=$(lfs_df -p $POOL $dir | awk '/summary/ { print $4 }')
1365 [ $AVAIL -gt $maxfree ] &&
1366 skip_env "Filesystem space $AVAIL is larger than " \
1367 "$maxfree limit" && return 0
1369 echo "OSTCOUNT=$OSTCOUNT, OSTSIZE=$OSTSIZE, AVAIL=$AVAIL"
1370 echo "MAXFREE=$maxfree, SLOW=$SLOW"
1372 # XXX remove the interoperability code once we drop the old server
1373 # ( < 2.3.50) support.
1374 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
1375 $LFS quotaoff -ug $MOUNT
1377 do_facet mgs $LCTL conf_param $FSNAME.quota.ost=none
1381 chown $RUNAS_ID.$RUNAS_ID $dir
1385 local stime=$(date +%s)
1389 local maxtime=300 # minimum speed: 5GB / 300sec ~= 17MB/s
1390 while [ $RC -eq 0 ]; do
1392 stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file}$i bs=1M \
1393 count=$((5 * 1024)) 2>&1)
1395 TOTAL=$((TOTAL + 1024 * 1024 * 5))
1396 echo "[$i iteration] $stat"
1397 echo "total written: $TOTAL"
1400 elapsed=$((etime - stime))
1401 echo "stime=$stime, etime=$etime, elapsed=$elapsed"
1403 if [ $RC -eq 1 ]; then
1404 echo $stat | grep -q "Disk quota exceeded"
1406 error "dd failed with EDQUOT with quota off"
1408 echo $stat | grep -q "No space left on device"
1410 error "dd did not fail with ENOSPC"
1411 elif [ $TOTAL -gt $AVAIL ]; then
1412 error "dd didn't fail with ENOSPC ($TOTAL > $AVAIL)"
1413 elif [ $i -eq 1 -a $elapsed -gt $maxtime ]; then
1414 log "The first 5G write used $elapsed (> $maxtime) " \
1415 "seconds, terminated"
1423 run_test 23b "OST pools and OOS"
1427 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1428 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs" && return
1430 local server_version=$(lustre_version_code $SINGLEMDS)
1431 [[ $server_version -ge $(version_code 2.8.56) ]] ||
1432 { skip "Need server version newer than 2.8.55"; return 0; }
1440 create_pool_nofail $POOL
1442 add_pool $POOL $TGT_ALL "$TGT_UUID"
1444 create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1446 mkdir $POOL_ROOT/dir2
1447 $SETSTRIPE -p $POOL -S 65536 -i 0 -c 1 $POOL_ROOT/dir2 ||
1448 error "$SETSTRIPE $POOL_ROOT/dir2 failed"
1450 mkdir $POOL_ROOT/dir3
1451 $SETSTRIPE -S 65536 -i 0 -c 1 $POOL_ROOT/dir3 ||
1452 error "$SETSTRIPE $POOL_ROOT/dir3 failed"
1454 mkdir $POOL_ROOT/dir4
1456 for i in 1 2 3 4; do
1457 dir=${POOL_ROOT}/dir${i}
1466 createmany -o $dir/${tfile} $numfiles ||
1467 error "createmany $dir/${tfile} failed!"
1468 pool=$($LFS getstripe --pool $dir)
1469 index=$($LFS getstripe -i $dir)
1470 size=$($LFS getstripe -S $dir)
1471 count=$($LFS getstripe -c $dir)
1473 for file in $dir/*; do
1474 if [ "$pool" != "" ]; then
1475 check_file_in_pool $file $pool
1477 pool1=$($LFS getstripe --pool $file)
1478 count1=$($LFS getstripe -c $file)
1479 size1=$($LFS getstripe -S $file)
1480 [[ "$pool" != "$pool1" ]] &&
1481 error "Pool '$pool' not on $file:$pool1"
1482 [[ "$count" != "$count1" ]] &&
1483 error "Stripe count $count not on $file:$count1"
1484 [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] &&
1485 error "Stripe size $size not on $file:$size1"
1493 run_test 24 "Independence of pool from other setstripe parameters"
1497 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1501 for i in $(seq 10); do
1502 create_pool_nofail $POOL$i
1503 do_facet mgs "lctl pool_add $FSNAME.$POOL$i OST0000; sync"
1504 wait_update $HOSTNAME "lctl get_param -n \
1505 lov.$FSNAME-*.pools.$POOL$i | sort -u |
1506 tr '\n' ' ' " "$FSNAME-OST0000_UUID " >/dev/null ||
1507 error "pool_add failed: $1; $2"
1509 facet_failover $SINGLEMDS ||
1510 error "failed to failover $SINGLEMDS"
1511 wait_osc_import_state $SINGLEMDS ost FULL
1515 # Veriy that the pool got created and is usable
1516 df $POOL_ROOT > /dev/null
1519 # Make sure OST0 can be striped on
1520 $SETSTRIPE -i 0 -c 1 $POOL_ROOT/$tfile
1521 local STR=$($LFS getstripe -i $POOL_ROOT/$tfile)
1522 rm $POOL_ROOT/$tfile
1523 if [[ "$STR" == "0" ]]; then
1524 echo "Creating a file in pool$i"
1525 create_file $POOL_ROOT/file$i $POOL$i || break
1526 check_file_in_pool $POOL_ROOT/file$i $POOL$i || break
1528 echo "OST 0 seems to be unavailable. Try later."
1534 run_test 25 "Create new pool and restart MDS"
1537 [[ $OSTCOUNT -le 2 ]] && skip_env "Need at least 3 OSTs" && return
1539 local dev=$(mdsdevname ${SINGLEMDS//mds/})
1540 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1544 create_pool_nofail $POOL2
1546 do_facet mgs "lctl pool_add $FSNAME.$POOL2 OST0000; sync"
1547 wait_update $HOSTNAME "lctl get_param -n \
1548 lov.$FSNAME-*.pools.$POOL2 | sort -u |
1549 grep $FSNAME-OST0000_UUID " "$FSNAME-OST0000_UUID" ||
1550 error "pool_add failed: $1; $2"
1552 do_facet mgs "lctl pool_add $FSNAME.$POOL2 OST0002; sync"
1553 wait_update $HOSTNAME "lctl get_param -n \
1554 lov.$FSNAME-*.pools.$POOL2 | sort -u |
1555 grep $FSNAME-OST0002_UUID" "$FSNAME-OST0002_UUID" ||
1556 error "pool_add failed: $1; $2"
1558 # Veriy that the pool got created and is usable
1560 echo "Creating files in $POOL2"
1562 for ((i = 0; i < 10; i++)); do
1563 #OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
1564 #Fail OST0000 to ensure objects create on
1565 #the other OST in the pool
1566 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
1567 do_facet $SINGLEMDS lctl set_param fail_val=0
1568 create_file $POOL_ROOT/file$i $POOL2 1 -1 || break
1569 do_facet $SINGLEMDS lctl set_param fail_loc=0
1570 check_file_in_pool $POOL_ROOT/file$i $POOL2 || break
1574 run_test 26 "Choose other OSTs in the pool first in the creation remedy"
1579 cleanup_pools $FSNAME
1580 check_and_cleanup_lustre