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"
40 MAXFREE=${MAXFREE:-$((2000000 * OSTCOUNT))}
44 POOL2=${POOL2:-${POOL}2}
45 POOL3=${POOL3:-${POOL}3}
46 NON_EXISTANT_POOL=nonexistantpool
47 NON_EXISTANT_FS=nonexistantfs
48 INVALID_POOL=some_invalid_pool_name
50 TGT_FIRST=$(printf %04x 0)
51 TGT_MAX=$(printf %04x $((TGT_COUNT-1)))
53 TGT_LIST=$(seq 0x$TGT_FIRST $TGT_STEP 0x$TGT_MAX)
54 TGT_LIST2=$(seq 0x$TGT_FIRST 2 0x$TGT_MAX)
56 TGT_ALL="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/1]"
57 TGT_HALF="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]"
59 TGT_UUID=$(for i in $TGT_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
60 TGT_UUID2=$(for i in $TGT_LIST2; do printf "$FSNAME-OST%04x_UUID " $i; done)
65 local count=${3:-"-1"}
69 if [[ -n $idx ]]; then
70 $LFS setstripe -c $count -p $pool -i $idx $dir
72 $LFS setstripe -c $count -p $pool $dir
74 [[ $? -eq 0 ]] || error "$LFS setstripe -p $pool $dir failed"
75 [[ "$($LFS getstripe --pool $dir)" == "$pool" ]] ||
76 error "$dir not created in expected pool '$pool'"
82 local count=${3:-"-1"}
83 local index=${4:-"-1"}
85 $LFS setstripe -i $index -c $count -p $pool $file
86 [[ $? -eq 0 ]] || error "$LFS setstripe -p $pool $file failed"
87 [[ "$($LFS getstripe --pool $file)" == "$pool" ]] ||
88 error "$file not created in '$pool'"
94 for i in $(list_pool $FSNAME.$pool |
95 sed -e 's/_UUID$//;s/^.*-OST//'); do
96 res="$res $(printf "%d" 0x$i)"
101 check_dir_in_pool() {
104 local res=$($LFS getstripe --pool $dir)
106 [ -n "$res" ] || error "dir '$dir' not in any pool"
108 [ "$res" == "$pool" ] ||
109 error "dir '$dir' in pool '$res' instead of '$pool'"
112 check_file_in_pool() {
116 local osts=$(osts_in_pool $pool)
117 local res=$($LFS getstripe --pool $file)
119 [ -n "$res" ] || error "file '$file' not in any pool"
121 [ "$res" == "$pool" ] ||
122 error "file '$file' in pool '$res' instead of '$pool'"
124 local osts=$(osts_in_pool $2)
125 check_file_in_osts "$file" "$osts" $count
128 check_file_in_osts() {
130 local ost_list=${2:-$TGT_LIST}
132 local res=$($LFS getstripe $file | awk '/0x/ { print $1 }')
136 found=$(echo :$ost_list: | tr " " ":" | grep :$i:)
137 if [[ "$found" == "" ]]; then
138 echo "ost list: $ost_list"
139 echo "striping: $res"
140 $LFS getstripe -v $file
141 error "$file not allocated from OSTs $ost_list."
145 local ost_count=$($LFS getstripe -c $file)
146 [[ -n "$count" ]] && [[ $ost_count -ne $count ]] &&
147 error "$file stripe count $count expected; got $ost_count" &&
152 check_file_not_in_pool() {
155 local res=$($LFS getstripe --pool $file)
157 [ "$res" != "$pool" ] || error "File '$file' is in pool: $res"
160 check_dir_not_in_pool() {
163 local res=$($LFS getstripe --pool $dir)
165 [ "$res" != "$pool" ] || error "Dir '$dir' is in pool: $res"
170 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool" "" ||
171 error "Failed to remove targets from pool: $pool"
177 local tgt="${3}$(lctl get_param -n lov.$FSNAME-*.pools.$pool |
178 sort -u | tr '\n' ' ')"
180 do_facet mgs lctl pool_add $FSNAME.$pool $osts
182 [[ $RC -ne 0 ]] && return $RC
184 # wait for OSTs to be added to the pool
185 for mds_id in $(seq $MDSCOUNT); do
186 local mdt_id=$((mds_id-1))
187 local lodname=$FSNAME-MDT$(printf "%04x" $mdt_id)-mdtlov
188 wait_update_facet mds$mds_id \
189 "lctl get_param -n lod.$lodname.pools.$pool |
190 sort -u | tr '\n' ' ' " "$tgt" >/dev/null ||
191 error "mds$mds_id:pool add failed $1; $2"
193 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool |
194 sort -u | tr '\n' ' ' " "$tgt" >/dev/null ||
195 error "pool_add failed: $1; $2"
199 create_pool_nofail() {
200 create_pool $FSNAME.$1
201 [[ $? -ne 0 ]] && error "Pool creation of $1 failed"
206 create_pool $FSNAME.$1
208 error "Pool creation of $1 succeeded; should have failed"
217 remote_mds_nodsh && skip "remote MDS with nodsh"
218 remote_ost_nodsh && skip "remote OST with nodsh"
221 # Tests for new commands added
226 run_test 1a "Create a pool with a 1 character pool name"
229 create_pool_nofail ${POOL}12
230 destroy_pool ${POOL}12
232 run_test 1b "Create a pool with a 10 char pool name"
235 create_pool_nofail ${POOL}1234567
236 destroy_pool ${POOL}1234567
238 run_test 1c "Create a pool with a 15 char pool name"
241 create_pool_fail ${POOL}12345678
243 run_test 1d "Create a pool with a 16 char pool name; should fail"
246 local pool_name="$POOL"
247 for ((i = 1; i <= 991; i++)); do pool_name=${pool_name}"o"; done
248 create_pool_fail $pool_name
250 run_test 1e "Create a pool with a 1000 char pool name; should fail"
255 error "pool_new did not fail even though fs-name was missing"
257 run_test 1f "pool_new should fail if fs-name is missing"
262 error "pool_new did not fail even though fs-name was missing"
264 run_test 1g "pool_new should fail if fs-name is missing"
267 create_pool ${FSNAME}.
269 error "pool_new did not fail even though pool name was missing"
271 run_test 1h "pool_new should fail if poolname is missing"
276 error "pool_new did not fail even if pool/fs-name was missing"
278 run_test 1i "pool_new should fail if poolname and fs-name are missing"
281 create_pool ${FSNAME},$POOL
283 error "pool_new did not fail even if poolname format was wrong"
285 run_test 1j "pool_new should fail if poolname format is wrong"
288 create_pool ${FSNAME}/$POOL
290 error "pool_new did not fail even if poolname format was wrong"
292 run_test 1k "pool_new should fail if poolname format is wrong"
295 create_pool_nofail $POOL2
296 create_pool ${FSNAME}.$POOL2
298 error "pool_new did not fail even though $POOL2 existed"
301 run_test 1m "pool_new did not fail even though $POOL2 existed"
304 create_pool_nofail ${POOL}1234567
306 add_pool ${POOL}1234567 "OST0000" "$FSNAME-OST0000_UUID "
307 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
308 create_dir $POOL_ROOT ${POOL}1234567
309 dd if=/dev/zero of=$POOL_ROOT/file bs=1M count=100
310 RC=$?; [[ $RC -eq 0 ]] ||
311 error "failed to write to $POOL_ROOT/file: $RC"
312 do_facet mgs lctl pool_remove $FSNAME.${POOL}1234567 OST0000
313 drain_pool ${POOL}1234567
315 destroy_pool ${POOL}1234567
317 run_test 1n "Pool with a 15 char pool name works well"
322 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
324 error "pool_add did not fail even though $POOL did not exist"
326 run_test 2a "pool_add: non-existant pool $POOL"
329 do_facet mgs lctl pool_add $FSNAME.${POOL}1234567890 \
330 $FSNAME-OST0000 2>/dev/null
332 error "pool_add did not fail even though pool name was invalid."
334 run_test 2b "pool_add: Invalid pool name"
336 # Testing various combinations of OST name list
341 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
342 [[ $? -ne 0 ]] || destroy_pool $POOL
344 create_pool_nofail $POOL
347 do_facet mgs lctl pool_add $FSNAME.$POOL OST0000
348 RC=$?; [[ $RC -eq 0 ]] ||
349 error "pool_add failed. $FSNAME $POOL OST0000: $RC"
350 do_facet mgs lctl pool_remove $FSNAME.$POOL OST0000
354 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
355 RC=$?; [[ $RC -eq 0 ]] ||
356 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000: $RC"
357 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
360 # 3. $FSNAME-OST0000_UUID
361 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
362 RC=$?; [[ $RC -eq 0 ]] ||
363 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000_UUID: $RC"
364 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
367 # 4. $FSNAME-OST[0,1,2,3,]
369 for i in $TGT_LIST; do TGT=${TGT}$(printf "%04x," $i); done
371 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT
372 [[ $? -eq 0 ]] || error "pool_add failed. $FSNAME.$POOL $TGT. $RC"
373 do_facet mgs lctl pool_remove $FSNAME.$POOL $TGT
376 # 5. $FSNAME-OST[0-5/1]
377 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT_ALL
378 RC=$?; [[ $RC -eq 0 ]] ||
379 error "pool_add failed. $FSNAME $POOL" "$TGT_ALL $RC"
380 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL |
381 sort -u | tr '\n' ' ' " "$TGT_UUID" ||
382 error "Add to pool failed"
383 do_facet mgs lctl pool_remove $FSNAME.$POOL $TGT_ALL
388 run_test 2c "pool_add: OST index combinations"
394 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
395 [[ $? -ne 0 ]] || destroy_pool $POOL
397 create_pool_nofail $POOL
399 TGT=$(printf "$FSNAME-OST%04x_UUID " $OSTCOUNT)
400 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT
401 RC=$?; [[ $RC -ne 0 ]] ||
402 error "pool_add succeeded for an OST ($TGT) that does not exist."
406 run_test 2d "pool_add: OSTs that don't exist should be rejected"
413 $LCTL get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
414 [[ $? -ne 0 ]] || destroy_pool $POOL
416 create_pool_nofail $POOL
418 TGT="$FSNAME-OST0000_UUID"
419 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT
420 wait_update_facet $SINGLEMDS \
421 "lctl pool_list $FSNAME.$POOL | sed '1d'" "$TGT" ||
422 error "Add $TGT to $FSNAME.$POOL failed"
423 RESULT=$(do_facet mgs \
424 "LOCALE=C $LCTL pool_add $FSNAME.$POOL $TGT 2>&1")
429 error "pool_add succeeded for an OST that was already in the pool."
431 [[ $(grep "already in pool" <<< $RESULT) ]] ||
432 error "pool_add failed as expected but error message not as expected."
436 run_test 2e "pool_add: OST already in a pool should be rejected"
439 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
440 [[ $? -ne 0 ]] || destroy_pool $POOL
443 lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
445 error "pool_remove did not fail even though pool did not exist."
447 run_test 3a "pool_remove: non-existant pool"
451 lctl pool_remove ${NON_EXISTANT_FS}.$POOL OST0000 2>/dev/null
453 error "pool_remove did not fail even though fsname did not exist."
455 run_test 3b "pool_remove: non-existant fsname"
458 do_facet mgs lctl pool_remove $FSNAME.p1234567891234567890 \
459 $FSNAME-OST0000 2>/dev/null
461 error "pool_remove did not fail even though pool name was invalid."
463 run_test 3c "pool_remove: Invalid pool name"
465 # Testing various combinations of OST name list
467 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
468 [[ $? -ne 0 ]] || destroy_pool $POOL
470 create_pool_nofail $POOL
471 do_facet mgs lctl pool_add $FSNAME.$POOL OST0000
472 do_facet mgs lctl pool_remove $FSNAME.$POOL OST0000
473 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL OST0000"
476 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
477 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
478 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000"
481 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
482 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
484 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000_UUID"
487 add_pool $POOL $TGT_ALL "$TGT_UUID"
488 do_facet mgs lctl pool_remove $FSNAME.$POOL $TGT_ALL
489 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL" $TGT_ALL
494 run_test 3d "pool_remove: OST index combinations"
497 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
498 [[ $? -ne 0 ]] || destroy_pool $POOL
500 do_facet mgs lctl pool_destroy $FSNAME.$POOL 2>/dev/null
502 error "pool_destroy did not fail even though pool did not exist."
504 run_test 4a "pool_destroy: non-existant pool"
507 do_facet mgs lctl pool_destroy ${NON_EXISTANT_FS}.$POOL 2>/dev/null
509 error "pool_destroy did not fail even though filesystem did not exist."
511 run_test 4b "pool_destroy: non-existant fs-name"
514 create_pool_nofail $POOL
515 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
517 do_facet mgs lctl pool_destroy ${FSNAME}.$POOL
518 [[ $? -ne 0 ]] || error "pool_destroy succeeded with a non-empty pool."
521 run_test 4c "pool_destroy: non-empty pool"
526 $LCMD pool_list 2>/dev/null
528 error "pool_list did not fail even though fsname missing."
530 destroy_pool $POOL 2>/dev/null
531 destroy_pool $POOL2 2>/dev/null
533 create_pool_nofail $POOL
534 create_pool_nofail $POOL2
535 $LCMD pool_list $FSNAME
536 [[ $? -eq 0 ]] || error "pool_list $FSNAME failed."
538 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT_ALL
540 $LCMD pool_list $FSNAME.$POOL
541 [[ $? -eq 0 ]] || error "pool_list $FSNAME.$POOL failed."
543 $LCMD pool_list ${NON_EXISTANT_FS} 2>/dev/null
545 error "pool_list did not fail for fsname $NON_EXISTANT_FS"
547 $LCMD pool_list ${FSNAME}.$NON_EXISTANT_POOL 2>/dev/null
549 error "pool_list did not fail for pool $NON_EXISTANT_POOL"
551 if [[ ! $(grep $SINGLEMDS <<< $LCMD) ]]; then
552 echo $LCMD pool_list $DIR
554 [[ $? -eq 0 ]] || error "pool_list failed for $DIR"
557 $LCMD pool_list ${DIR}/d1
558 [[ $? -eq 0 ]] || error "pool_list failed for ${DIR}/d1"
561 rm -rf ${DIR}nonexistant
562 $LCMD pool_list ${DIR}nonexistant 2>/dev/null
564 error "pool_list did not fail for invalid mountpoint ${DIR}nonexistant"
571 # Issue commands from client
574 run_test 5a "lfs pool_list from client"
577 sub_test_5 "do_facet $SINGLEMDS lctl"
579 run_test 5b "lctl pool_list from MDS"
582 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
583 local POOL_DIR=$POOL_ROOT/dir_tst
584 local POOL_FILE=$POOL_ROOT/file_tst
586 create_pool_nofail $POOL
588 do_facet $SINGLEMDS lctl pool_list $FSNAME
589 [[ $? -eq 0 ]] || error "pool_list $FSNAME failed."
591 add_pool $POOL $TGT_ALL "$TGT_UUID"
594 $LFS setstripe -c -1 -p $POOL $POOL_DIR
595 [[ $? -eq 0 ]] || error "$LFS setstripe -p $POOL failed."
596 check_dir_in_pool $POOL_DIR $POOL
598 # If an invalid pool name is specified, the command should fail
599 $LFS setstripe -c 2 -p $INVALID_POOL $POOL_DIR 2>/dev/null
600 [[ $? -ne 0 ]] || error "setstripe to invalid pool did not fail."
602 # If the pool name does not exist, the command should fail
603 $LFS setstripe -c 2 -p $NON_EXISTANT_POOL $POOL_DIR 2>/dev/null
604 [[ $? -ne 0 ]] || error "setstripe to non-existant pool did not fail."
606 # lfs setstripe should work as before if a pool name is not specified.
607 $LFS setstripe -c -1 $POOL_DIR
608 [[ $? -eq 0 ]] || error "$LFS setstripe -c -1 $POOL_DIR failed."
609 $LFS setstripe -c -1 $POOL_FILE
610 [[ $? -eq 0 ]] || error "$LFS setstripe -c -1 $POOL_FILE failed."
612 # lfs setstripe should fail if a start index that is outside the
614 create_pool_nofail $POOL2
615 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
616 $LFS setstripe -i 1 -p $POOL2 $ROOT_POOL/$tfile 2>/dev/null
618 error "$LFS setstripe with start index outside the pool did not fail."
620 run_test 6 "getstripe/setstripe"
624 # Create a pool, stripe a directory and file with it
627 pool_add $pool || error "pool_add failed"
628 pool_add_targets $pool 0 1 || error "pool_add_targets failed"
630 $LFS setstripe -c 1 $DIR/$tdir/testfile1 --pool "$pool" ||
631 error "setstripe failed"
632 $LFS setstripe -c 1 $DIR/$tdir/testfile2 --pool "$FSNAME.$pool" ||
633 error "setstripe failed"
635 mkdir $DIR/$tdir/testdir
636 $LFS setstripe -c 1 $DIR/$tdir/testdir -p "$pool" ||
637 error "setstripe failed"
638 $LFS setstripe -c 1 $DIR/$tdir/testdir -p "$FSNAME.$pool" ||
639 error "setstripe failed"
641 rm -f $DIR/$tdir/testfile1
642 rm -f $DIR/$tdir/testfile2
643 rmdir $DIR/$tdir/testdir
645 destroy_pool_int $FSNAME.$pool
650 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
654 # Generate pool with random name from 1 to 15 characters
656 POOLNAME=$(echo $$$RANDOM$RANDOM |
657 tr -dc 'a-zA-Z0-9' | fold -w $i |
659 echo set poolname to $POOLNAME
660 helper_test_7a $POOLNAME
663 run_test 7a "create various pool name"
669 [ $? -ne 22 ] && error "can create a pool with no fsname"
673 [ $? -ne 22 ] && error "can create a pool with no name"
676 create_pool $FSNAME.0123456789^bdef
677 [ $? -ne 22 ] && error "can create a pool with an invalid name"
680 create_pool $FSNAME.0123456789abdefg
681 [ $? -ne 36 ] && error "can create a pool with a name too long"
685 run_test 7b "try to create pool name with invalid lengths or names"
689 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
693 # Create a pool with 15 letters
694 local pool=0123456789abcde
695 pool_add $pool || error "pool_add failed"
696 pool_add_targets $pool 0 1 || error "pool_add_targets failed"
698 # setstripe with the same pool name plus 1 letter
699 $LFS setstripe -c 1 $DIR/$tdir/testfile1 --pool "${pool}X" &&
700 error "setstripe succedeed"
702 # setstripe with the same pool name minus 1 letter
703 $LFS setstripe -c 1 $DIR/$tdir/testfile1 --pool "${pool%?}" &&
704 error "setstripe succedeed"
706 rm -f $DIR/$tdir/testfile1
708 destroy_pool_int $FSNAME.$pool
710 run_test 7c "create a valid pool name and setstripe with a bad one"
713 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
715 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
717 create_pool_nofail $POOL
718 create_pool_nofail $POOL2
720 local start=$(printf %04x $((TGT_FIRST + 1)))
721 do_facet mgs lctl pool_add $FSNAME.$POOL2 \
722 $FSNAME-OST[$start-$TGT_MAX/2]
724 add_pool $POOL $TGT_HALF "$TGT_UUID2"
726 create_dir $POOL_ROOT/dir1 $POOL
727 create_dir $POOL_ROOT/dir2 $POOL2
730 createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
731 error "createmany $POOL_ROOT/dir1/$tfile failed!"
733 for file in $POOL_ROOT/dir1/*; do
734 check_file_in_pool $file $POOL
737 createmany -o $POOL_ROOT/dir2/$tfile $numfiles ||
738 error "createmany $POOL_ROOT/dir2/$tfile failed!"
739 for file in $POOL_ROOT/dir2/*; do
740 check_file_in_pool $file $POOL2
743 rm -rf $POOL_ROOT/dir?
747 run_test 11 "OSTs in overlapping/multiple pools"
750 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
752 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >=3 OSTs"
754 create_pool_nofail $POOL
755 create_pool_nofail $POOL2
757 local start=$(printf %04x $((TGT_FIRST + 1)))
758 do_facet mgs lctl pool_add $FSNAME.$POOL2 \
759 $FSNAME-OST[$start-$TGT_MAX/2]
761 add_pool $POOL $TGT_HALF "$TGT_UUID2"
763 echo creating some files in $POOL and $POOL2
765 create_dir $POOL_ROOT/dir1 $POOL
766 create_dir $POOL_ROOT/dir2 $POOL2
767 create_file $POOL_ROOT/file1 $POOL
768 create_file $POOL_ROOT/file2 $POOL2
770 echo Checking the files created
771 check_file_in_pool $POOL_ROOT/file1 $POOL
772 check_file_in_pool $POOL_ROOT/file2 $POOL2
774 echo Changing the pool membership
775 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST[$TGT_FIRST]
776 do_facet mgs lctl pool_list $FSNAME.$POOL
777 FIRST_UUID=$(echo $TGT_UUID | awk '{print $1}')
778 add_pool $POOL2 $FSNAME-OST[$TGT_FIRST] "$FIRST_UUID "
779 do_facet mgs lctl pool_list $FSNAME.$POOL2
781 echo Checking the files again
782 check_dir_in_pool $POOL_ROOT/dir1 $POOL
783 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
784 check_file_in_osts $POOL_ROOT/file1 "$TGT_LIST2"
785 check_file_in_osts $POOL_ROOT/file2 "$(seq 0x$start 2 0x$TGT_MAX)"
787 echo Creating some more files
788 create_dir $POOL_ROOT/dir3 $POOL
789 create_dir $POOL_ROOT/dir4 $POOL2
790 create_file $POOL_ROOT/file3 $POOL
791 create_file $POOL_ROOT/file4 $POOL2
793 echo Checking the new files
794 check_file_in_pool $POOL_ROOT/file3 $POOL
795 check_file_in_pool $POOL_ROOT/file4 $POOL2
799 run_test 12 "OST Pool Membership"
802 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >= 3 OSTs"
804 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
808 create_pool_nofail $POOL
809 add_pool $POOL $TGT_ALL "$TGT_UUID"
811 create_dir $POOL_ROOT/dir1 $POOL -1
812 createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
813 error "createmany $POOL_ROOT/dir1/$tfile failed!"
814 for file in $POOL_ROOT/dir1/*; do
815 check_file_in_pool $file $POOL $OSTCOUNT
818 create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
819 create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST + 1))
820 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST + 2))
821 check_file_in_osts $POOL_ROOT/dir1/file1 $((16#$TGT_FIRST))
822 check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST + 1))"
823 check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST + 2))"
825 create_dir $POOL_ROOT/dir2 $POOL $count
826 createmany -o $POOL_ROOT/dir2/$tfile- $numfiles ||
827 error "createmany $POOL_ROOT/dir2/$tfile- failed!"
828 for file in $POOL_ROOT/dir2/*; do
829 check_file_in_pool $file $POOL $count
832 create_dir $POOL_ROOT/dir3 $POOL $count $((TGT_FIRST + 1))
833 createmany -o $POOL_ROOT/dir3/$tfile- $numfiles ||
834 error "createmany $POOL_ROOT/dir3/$tfile- failed!"
835 for file in $POOL_ROOT/dir3/*; do
836 check_file_in_pool $file $POOL $count
839 create_dir $POOL_ROOT/dir4 $POOL 1
840 createmany -o $POOL_ROOT/dir4/$tfile- $numfiles ||
841 error "createmany $POOL_ROOT/dir4/$tfile- failed!"
842 for file in $POOL_ROOT/dir4/*; do
843 check_file_in_pool $file $POOL 1
846 create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST + 2))
847 createmany -o $POOL_ROOT/dir5/$tfile- $numfiles ||
848 error "createmany $POOL_ROOT/dir5/$tfile- failed!"
849 for file in $POOL_ROOT/dir5/*; do
850 check_file_in_pool $file $POOL 1
853 rm -rf $POOL_ROOT/dir[1-5]/
857 run_test 13 "Striping characteristics in a pool"
860 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >= 3 OSTs"
862 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
866 [ $OSTSIZE -gt $((MAXFREE / OSTCOUNT)) ] &&
867 skip_env "OST size $OSTSIZE is larger than $((MAXFREE / OSTCOUNT))"
869 create_pool_nofail $POOL
870 create_pool_nofail $POOL2
872 add_pool $POOL $TGT_HALF "$TGT_UUID2"
873 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
875 create_dir $POOL_ROOT/dir1 $POOL 1
876 create_file $POOL_ROOT/dir1/file $POOL 1
877 local ost=$($LFS getstripe -i $POOL_ROOT/dir1/file)
879 while [[ $i -lt $numfiles ]]; do
881 [[ $ost -gt $((16#$TGT_MAX)) ]] && ost=$TGT_FIRST
883 # echo "Iteration: $i OST: $ost"
884 create_file $POOL_ROOT/dir1/file${i} $POOL 1
885 check_file_in_pool $POOL_ROOT/dir1/file${i} $POOL
889 # Fill up OST0 until it is nearly full.
890 # Create 9 files of size OST0_SIZE/10 each.
891 create_dir $POOL_ROOT/dir2 $POOL2 1
892 $LFS df $POOL_ROOT/dir2
893 OST0_SIZE=$($LFS df $POOL_ROOT/dir2 | awk '/\[OST:0\]/ { print $4 }')
894 FILE_SIZE=$((OST0_SIZE/1024/10))
895 echo "Filling OST0 with 9 files of ${FILE_SIZE}MB in $POOL_ROOT/dir2"
897 while [[ $i -lt 10 ]]; do
898 dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1M count=$FILE_SIZE
901 sleep 1 # get new statfs info
902 $LFS df $POOL_ROOT/dir2
904 # OST $TGT_FIRST is no longer favored; but it may still be used.
905 create_dir $POOL_ROOT/dir3 $POOL 1
906 create_file $POOL_ROOT/dir3/file $POOL 1
907 createmany -o $POOL_ROOT/dir3/$tfile- $numfiles ||
908 error "createmany $POOL_ROOT/dir3/$tfile- failed!"
909 for file in $POOL_ROOT/dir3/*; do
910 check_file_in_pool $file $POOL
917 run_test 14 "Round robin and QOS striping within a pool"
920 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
924 while [[ $i -lt $OSTCOUNT ]]; do
925 create_pool_nofail $POOL${i}
927 local tgt=$(printf "$FSNAME-OST%04x_UUID " $i)
928 add_pool $POOL${i} "$FSNAME-OST[$(printf %04x $i)]" "$tgt"
929 create_dir $POOL_ROOT/dir${i} $POOL${i}
930 createmany -o $POOL_ROOT/dir$i/$tfile $numfiles ||
931 error "createmany $POOL_ROOT/dir$i/$tfile failed!"
933 for file in $POOL_ROOT/dir$i/*; do
934 check_file_in_osts $file $i
942 run_test 15 "One directory per OST/pool"
945 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
949 create_pool_nofail $POOL
951 add_pool $POOL $TGT_HALF "$TGT_UUID2"
953 local dir=$POOL_ROOT/$tdir
954 create_dir $dir $POOL
956 for i in $(seq 1 10); do
961 createmany -o $dir/$tfile $numfiles ||
962 error "createmany $dir/$tfile failed!"
964 for file in $dir/*; do
965 check_file_in_pool $file $POOL
968 rm -rf $POOL_ROOT/$tdir
972 run_test 16 "Inheritance of pool properties"
975 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
979 create_pool_nofail $POOL
981 add_pool $POOL $TGT_ALL "$TGT_UUID"
983 local dir=$POOL_ROOT/dir
984 create_dir $dir $POOL
986 createmany -o $dir/${tfile}1_ $numfiles ||
987 error "createmany $dir/${tfile}1_ failed!"
989 for file in $dir/*; do
990 check_file_in_pool $file $POOL
995 createmany -o $dir/${tfile}2_ $numfiles ||
996 error "createmany $dir/${tfile}2_ failed!"
1001 run_test 17 "Referencing an empty pool"
1010 wait_delete_completed >/dev/null # give pending IO a chance to go to disk
1011 stat=$(createmany -o $cdir/${tfile} -$numsec | tail -1)
1012 files=$(echo $stat | cut -f 2 -d ' ')
1014 unlinkmany $cdir/${tfile} $files > /dev/null
1021 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1024 local plaindir=$POOL_ROOT/plaindir
1025 local pooldir=$POOL_ROOT/pooldir
1031 for i in $(seq 1 $iter); do
1032 echo "Create performance, iteration $i, $numsec seconds x 3"
1034 local files1=$(create_perf $plaindir $numsec)
1035 [[ $files1 -eq 0 ]] && error "Zero files created without pool"
1037 echo "iter $i: $files1 creates without pool"
1039 create_pool_nofail $POOL > /dev/null
1040 add_pool $POOL $TGT_ALL "$TGT_UUID" > /dev/null
1041 create_dir $pooldir $POOL
1042 local files2=$(create_perf $pooldir $numsec)
1043 [[ $files2 -eq 0 ]] && error "Zero files created with pool"
1045 echo "iter $i: $files2 creates with pool"
1047 destroy_pool $POOL > /dev/null
1048 local files3=$(create_perf $pooldir $numsec)
1049 [[ $files3 -eq 0 ]] &&
1050 error "Zero files created with missing pool"
1052 echo "iter $i: $files3 creates with missing pool"
1057 echo Avg files created in $numsec seconds without pool: $((f1 / iter))
1058 echo Avg files created in $numsec seconds with pool: $((f2 / iter))
1059 echo Avg files created in $numsec seconds missing pool: $((f3 / iter))
1061 # Set this high until we establish a baseline for what the degradation
1065 diff=$((($f1 - $f2) * 100 / $f1))
1066 echo "No pool / wide pool: $diff %."
1067 [ $diff -gt $max ] &&
1068 error_ignore bz23408 "Degradation with wide pool is $diff% > $max%"
1071 diff=$((($f1 - $f3) * 100 / $f1))
1072 echo "No pool / missing pool: $diff %."
1073 [ $diff -gt $max ] &&
1074 error_ignore bz23408 "Degradation with wide pool is $diff% > $max%"
1078 run_test 18 "File create in a directory which references a deleted pool"
1081 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1083 local dir1=$POOL_ROOT/dir1
1084 local dir2=$POOL_ROOT/dir2
1087 create_pool_nofail $POOL
1089 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1091 create_dir $dir1 $POOL
1092 createmany -o $dir1/${tfile} $numfiles ||
1093 error "createmany $dir1/${tfile} failed!"
1094 for file in $dir1/*; do
1095 check_file_in_pool $file $POOL
1099 createmany -o $dir2/${tfile} $numfiles ||
1100 error "createmany $dir2/${tfile} failed!"
1101 for file in $dir2/*; do
1102 check_file_not_in_pool $file $POOL
1109 run_test 19 "Pools should not come into play when not specified"
1112 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
1114 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1116 local dir1=$POOL_ROOT/dir1
1117 local dir2=$dir1/dir2
1118 local dir3=$dir1/dir3
1122 create_pool_nofail $POOL
1123 create_pool_nofail $POOL2
1125 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1127 local start=$(printf %04x $((TGT_FIRST + 1)))
1128 TGT=$(for i in $(seq 0x$start 2 0x$TGT_MAX); do \
1129 printf "$FSNAME-OST%04x_UUID " $i; done)
1130 add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1132 create_dir $dir1 $POOL
1133 create_file $dir1/file1 $POOL2 # Should replace $dir1 pool with $POOL2
1134 create_dir $dir2 $POOL2
1135 touch $dir2/file2 # Should inherit $POOL2 from $dir2
1136 mkdir $dir3 # Should inherit $POOL from $dir1
1137 $LFS setstripe -c 1 $dir3 # Should remain existing $POOL
1138 touch $dir3/file3 # Should inherit $POOL from $dir3
1139 $LFS setstripe -c 1 $dir2/file4 # Should inherit $POOL2 from dir2
1140 $LFS setstripe -S 64K $dir1/file5 # Should inderit $POOL from $dir1
1142 check_file_in_pool $dir1/file1 $POOL2
1143 check_file_in_pool $dir2/file2 $POOL2
1144 check_dir_not_in_pool $dir3 $POOL2
1145 check_file_not_in_pool $dir3/file3 $POOL2
1146 check_file_not_in_pool $dir2/file4 $POOL
1147 check_file_not_in_pool $dir1/file5 $POOL2
1149 if [ $(lustre_version_code mds1) -ge $(version_code 2.10.54) ]; then
1150 check_dir_in_pool $dir3 $POOL
1151 check_file_in_pool $dir3/file3 $POOL
1152 check_file_in_pool $dir2/file4 $POOL2
1153 check_file_in_pool $dir1/file5 $POOL
1160 run_test 20 "Different pools in a directory hierarchy."
1163 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1164 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1168 local dir=$POOL_ROOT/dir
1170 create_pool_nofail $POOL
1172 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1174 create_dir $dir $POOL $OSTCOUNT
1175 create_file $dir/file1 $POOL $OSTCOUNT
1176 $LFS getstripe -v $dir/file1
1177 check_file_in_pool $dir/file1 $POOL
1183 run_test 21 "OST pool with fewer OSTs than stripe count"
1191 for c in $(seq 1 10); do
1192 echo "Pool $pool, iteration $c"
1193 do_facet mgs lctl pool_add $FSNAME.$pool \
1194 OST[$TGT_FIRST-$TGT_MAX/$step] 2>/dev/null
1195 local TGT_SECOND=$(printf %04x $((TGT_FIRST + $step)))
1196 if [ $((16#$TGT_SECOND)) -le $((16#$TGT_MAX)) ]; then
1197 do_facet mgs lctl pool_remove $FSNAME.$pool \
1198 OST[$TGT_SECOND-$TGT_MAX/$step]
1201 echo loop for $pool complete
1205 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1206 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1210 create_pool_nofail $POOL
1211 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
1212 create_pool_nofail $POOL2
1213 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
1218 create_dir $POOL_ROOT $POOL
1219 createmany -o $POOL_ROOT/${tfile} $numfiles ||
1220 error "createmany $POOL_ROOT/${tfile} failed!"
1225 run_test 22 "Simultaneous manipulation of a pool"
1228 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1229 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1232 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS ||
1233 skip_env "User $RUNAS_ID does not exist - skipping"
1237 local BUNIT_SZ=1024 # min block quota unit(kB)
1238 local LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1)))
1239 local dir=$POOL_ROOT/dir
1240 local file="$dir/$tfile-quota"
1242 create_pool_nofail $POOL
1244 local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
1245 printf "$FSNAME-OST%04x_UUID " $i; done)
1246 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1247 create_dir $dir $POOL
1249 # XXX remove the interoperability code once we drop the old server
1250 # ( < 2.3.50) support.
1251 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
1252 $LFS quotaoff -ug $MOUNT
1253 $LFS quotacheck -ug $MOUNT
1255 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1256 do_facet mgs $PERM_CMD \
1257 osd-*.$FSNAME-OST*.quota_slave.enable=ug
1259 do_facet mgs $PERM_CMD $FSNAME.quota.ost=ug
1264 $LFS setquota -u $RUNAS_ID -b $LIMIT -B $LIMIT $dir
1266 $LFS quota -v -u $RUNAS_ID $dir
1268 $LFS setstripe -c 1 -p $POOL $file
1269 chown $RUNAS_ID.$RUNAS_GID $file
1272 # This does two "dd" runs to ensure that the quota failure is returned
1273 # to userspace when we check. The first "dd" might otherwise complete
1274 # without error if it is only writing into cache.
1275 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
1276 count=$((BUNIT_SZ*2)) 2>&1)
1277 echo $stat | grep "Disk quota exceeded" > /dev/null
1278 if [ $? -eq 0 ]; then
1279 $LFS quota -v -u $RUNAS_ID $dir
1280 cancel_lru_locks osc
1281 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
1282 count=$BUNIT_SZ seek=$((BUNIT_SZ*2)) 2>&1)
1285 [[ $RC -eq 0 ]] && error "second dd did not fail."
1286 echo $stat | grep "Disk quota exceeded" > /dev/null
1287 [[ $? -eq 1 ]] && error "second dd did not fail with EDQUOT."
1289 log "first dd failed with EDQUOT."
1291 $LFS quota -v -u $RUNAS_ID $dir
1293 run_test 23a "OST pools and quota"
1296 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1297 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1300 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS || {
1301 skip_env "User $RUNAS_ID does not exist - skipping"
1306 local dir=$POOL_ROOT/dir
1307 local file="$dir/$tfile-quota"
1309 create_pool_nofail $POOL
1311 local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
1312 printf "$FSNAME-OST%04x_UUID " $i; done)
1313 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1314 create_dir $dir $POOL
1316 local maxfree=$((1024 * 1024 * 30)) # 30G
1317 local AVAIL=$(lfs_df -p $POOL $dir | awk '/summary/ { print $4 }')
1318 [ $AVAIL -gt $maxfree ] &&
1319 skip_env "Filesystem space $AVAIL is larger than " \
1322 echo "OSTCOUNT=$OSTCOUNT, OSTSIZE=$OSTSIZE, AVAIL=$AVAIL"
1323 echo "MAXFREE=$maxfree, SLOW=$SLOW"
1325 # XXX remove the interoperability code once we drop the old server
1326 # ( < 2.3.50) support.
1327 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
1328 $LFS quotaoff -ug $MOUNT
1330 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1331 do_facet mgs $PERM_CMD \
1332 osd-*.$FSNAME-OST*.quota_slave.enable=none
1334 do_facet mgs $PERM_CMD $FSNAME.quota.ost=none
1339 chown $RUNAS_ID.$RUNAS_ID $dir
1343 local stime=$(date +%s)
1347 local maxtime=300 # minimum speed: 5GB / 300sec ~= 17MB/s
1348 while [ $RC -eq 0 ]; do
1350 stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file}$i bs=1M \
1351 count=$((5 * 1024)) 2>&1)
1353 TOTAL=$((TOTAL + 1024 * 1024 * 5))
1354 echo "[$i iteration] $stat"
1355 echo "total written: $TOTAL"
1358 elapsed=$((etime - stime))
1359 echo "stime=$stime, etime=$etime, elapsed=$elapsed"
1361 if [ $RC -eq 1 ]; then
1362 echo $stat | grep -q "Disk quota exceeded"
1364 error "dd failed with EDQUOT with quota off"
1366 echo $stat | grep -q "No space left on device"
1368 error "dd did not fail with ENOSPC"
1369 elif [ $TOTAL -gt $AVAIL ]; then
1370 error "dd didn't fail with ENOSPC ($TOTAL > $AVAIL)"
1371 elif [ $i -eq 1 -a $elapsed -gt $maxtime ]; then
1372 log "The first 5G write used $elapsed (> $maxtime) " \
1373 "seconds, terminated"
1381 run_test 23b "OST pools and OOS"
1384 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1385 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1387 local server_version=$(lustre_version_code $SINGLEMDS)
1388 [[ $server_version -ge $(version_code 2.8.56) ]] ||
1389 skip "Need server version newer than 2.8.55"
1397 create_pool_nofail $POOL
1399 add_pool $POOL $TGT_ALL "$TGT_UUID"
1401 create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1403 mkdir $POOL_ROOT/dir2
1404 $LFS setstripe -p $POOL -S 65536 -i 0 -c 1 $POOL_ROOT/dir2 ||
1405 error "$LFS setstripe $POOL_ROOT/dir2 failed"
1407 mkdir $POOL_ROOT/dir3
1408 $LFS setstripe -S 65536 -i 0 -c 1 $POOL_ROOT/dir3 ||
1409 error "$LFS setstripe $POOL_ROOT/dir3 failed"
1411 mkdir $POOL_ROOT/dir4
1413 for i in 1 2 3 4; do
1414 dir=${POOL_ROOT}/dir${i}
1423 createmany -o $dir/${tfile} $numfiles ||
1424 error "createmany $dir/${tfile} failed!"
1425 pool=$($LFS getstripe --pool $dir)
1426 index=$($LFS getstripe -i $dir)
1427 size=$($LFS getstripe -S $dir)
1428 count=$($LFS getstripe -c $dir)
1430 for file in $dir/*; do
1431 if [ "$pool" != "" ]; then
1432 check_file_in_pool $file $pool
1434 pool1=$($LFS getstripe --pool $file)
1435 count1=$($LFS getstripe -c $file)
1436 size1=$($LFS getstripe -S $file)
1437 [[ "$pool" != "$pool1" ]] &&
1438 error "Pool '$pool' not on $file:$pool1"
1439 [[ "$count" != "$count1" ]] &&
1440 [[ "$count" != "-1" ]] &&
1441 error "Stripe count $count not on"\
1443 [[ "$count1" != "$OSTCOUNT" ]] &&
1444 [[ "$count" = "-1" ]] &&
1445 error "Stripe count $count1 not on"\
1447 [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] &&
1448 error "Stripe size $size not on $file:$size1"
1456 run_test 24 "Independence of pool from other setstripe parameters"
1459 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1463 for i in $(seq 10); do
1464 create_pool_nofail $POOL$i
1465 do_facet mgs "lctl pool_add $FSNAME.$POOL$i OST0000; sync"
1466 wait_update $HOSTNAME "lctl get_param -n \
1467 lov.$FSNAME-*.pools.$POOL$i | sort -u |
1468 tr '\n' ' ' " "$FSNAME-OST0000_UUID " >/dev/null ||
1469 error "pool_add failed: $1; $2"
1471 facet_failover $SINGLEMDS ||
1472 error "failed to failover $SINGLEMDS"
1473 wait_osc_import_state $SINGLEMDS ost FULL
1477 # Veriy that the pool got created and is usable
1478 df $POOL_ROOT > /dev/null
1481 # Make sure OST0 can be striped on
1482 $LFS setstripe -i 0 -c 1 $POOL_ROOT/$tfile
1483 local STR=$($LFS getstripe -i $POOL_ROOT/$tfile)
1484 rm $POOL_ROOT/$tfile
1485 if [[ "$STR" == "0" ]]; then
1486 echo "Creating a file in pool$i"
1487 create_file $POOL_ROOT/file$i $POOL$i || break
1488 check_file_in_pool $POOL_ROOT/file$i $POOL$i || break
1490 echo "OST 0 seems to be unavailable. Try later."
1496 run_test 25 "Create new pool and restart MDS"
1499 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >= 3 OSTs"
1500 local dev=$(mdsdevname ${SINGLEMDS//mds/})
1501 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1505 create_pool_nofail $POOL2
1507 do_facet mgs "lctl pool_add $FSNAME.$POOL2 OST0000; sync"
1508 wait_update $HOSTNAME "lctl get_param -n \
1509 lov.$FSNAME-*.pools.$POOL2 | sort -u |
1510 grep $FSNAME-OST0000_UUID " "$FSNAME-OST0000_UUID" ||
1511 error "pool_add failed: $1; $2"
1513 do_facet mgs "lctl pool_add $FSNAME.$POOL2 OST0002; sync"
1514 wait_update $HOSTNAME "lctl get_param -n \
1515 lov.$FSNAME-*.pools.$POOL2 | sort -u |
1516 grep $FSNAME-OST0002_UUID" "$FSNAME-OST0002_UUID" ||
1517 error "pool_add failed: $1; $2"
1519 # Veriy that the pool got created and is usable
1521 echo "Creating files in $POOL2"
1523 for ((i = 0; i < 10; i++)); do
1524 #OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
1525 #Fail OST0000 to ensure objects create on
1526 #the other OST in the pool
1527 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
1528 do_facet $SINGLEMDS lctl set_param fail_val=0
1529 create_file $POOL_ROOT/file$i $POOL2 1 -1 || break
1530 do_facet $SINGLEMDS lctl set_param fail_loc=0
1531 check_file_in_pool $POOL_ROOT/file$i $POOL2 || break
1535 run_test 26 "Choose other OSTs in the pool first in the creation remedy"
1538 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs"
1542 local count=$OSTCOUNT
1544 create_pool_nofail $POOL
1545 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT_ALL
1546 wait_update_facet $SINGLEMDS \
1547 "lctl pool_list $FSNAME.$POOL | wc -l" "$((OSTCOUNT + 1))" ||
1548 error "MDS: pool_list $FSNAME.$POOL failed"
1549 osts=$(list_pool $FSNAME.$POOL)
1550 for ost in ${osts}; do
1552 if [[ $count -eq 0 ]]; then
1553 #define OBD_FAIL_OST_LIST_ASSERT 0x239
1554 do_facet $SINGLEMDS \
1555 $LCTL set_param fail_loc=0x239 fail_val=10
1556 list_pool $FSNAME.$POOL &
1559 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
1560 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $ost
1562 do_facet $SINGLEMDS $LCTL set_param fail_val=0
1564 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $ost
1569 run_test 27 "Race pool_list and pool_remove"
1574 destroy_test_pools $FSNAME
1575 if ! combined_mgs_mds; then
1576 zconf_umount $mgs_HOST $MOUNT
1577 do_facet mgs "rm -rf $MOUNT"
1579 check_and_cleanup_lustre