3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
10 LUSTRE=${LUSTRE:-$(dirname $0)/..}
11 . $LUSTRE/tests/test-framework.sh
15 ALWAYS_EXCEPT="$OST_POOLS_EXCEPT"
16 # bug number for skipped test: -
17 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
21 check_and_setup_lustre
23 if ! combined_mgs_mds; then
24 do_facet mgs "mkdir -p $MOUNT"
25 zconf_mount $mgs_HOST $MOUNT $MOUNT_OPTS ||
26 error "unable to mount $MOUNT on the MGS"
32 MAXFREE=${MAXFREE:-$((2000000 * OSTCOUNT))}
36 POOL2=${POOL2:-${POOL}2}
37 POOL3=${POOL3:-${POOL}3}
38 NON_EXISTANT_POOL=nonexistantpool
39 NON_EXISTANT_FS=nonexistantfs
40 INVALID_POOL=some_invalid_pool_name
42 TGT_FIRST=$(printf %04x 0)
43 TGT_MAX=$(printf %04x $((TGT_COUNT-1)))
45 TGT_LIST=$(seq 0x$TGT_FIRST $TGT_STEP 0x$TGT_MAX)
46 TGT_LIST2=$(seq 0x$TGT_FIRST 2 0x$TGT_MAX)
48 TGT_ALL="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/1]"
49 TGT_HALF="$FSNAME-OST[$TGT_FIRST-$TGT_MAX/2]"
51 TGT_UUID=$(for i in $TGT_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
52 TGT_UUID2=$(for i in $TGT_LIST2; do printf "$FSNAME-OST%04x_UUID " $i; done)
57 local count=${3:-"-1"}
61 if [[ -n $idx ]]; then
62 $LFS setstripe -c $count -p $pool -i $idx $dir
64 $LFS setstripe -c $count -p $pool -i -1 $dir
66 [[ $? -eq 0 ]] || error "$LFS setstripe -p $pool $dir failed"
67 [[ "$($LFS getstripe --pool $dir)" == "$pool" ]] ||
68 error "$dir not created in expected pool '$pool'"
74 local count=${3:-"-1"}
75 local index=${4:-"-1"}
77 $LFS setstripe -i $index -c $count -p $pool $file
78 [[ $? -eq 0 ]] || error "$LFS setstripe -p $pool $file failed"
79 [[ "$($LFS getstripe --pool $file)" == "$pool" ]] ||
80 error "$file not created in '$pool'"
86 for i in $(list_pool $FSNAME.$pool |
87 sed -e 's/_UUID$//;s/^.*-OST//'); do
88 res="$res $(printf "%d" 0x$i)"
96 local res=$($LFS getstripe --pool $dir)
98 [ -n "$res" ] || error "dir '$dir' not in any pool"
100 [ "$res" == "$pool" ] ||
101 error "dir '$dir' in pool '$res' instead of '$pool'"
104 check_file_in_pool() {
108 local osts=$(osts_in_pool $pool)
109 local res=$($LFS getstripe --pool $file)
111 [ -n "$res" ] || error "file '$file' not in any pool"
113 [ "$res" == "$pool" ] ||
114 error "file '$file' in pool '$res' instead of '$pool'"
116 local osts=$(osts_in_pool $2)
117 check_file_in_osts "$file" "$osts" $count
120 check_file_in_osts() {
122 local ost_list=${2:-$TGT_LIST}
124 local res=$($LFS getstripe $file | awk '/0x/ { print $1 }')
128 found=$(echo :$ost_list: | tr " " ":" | grep :$i:)
129 if [[ "$found" == "" ]]; then
130 echo "ost list: $ost_list"
131 echo "striping: $res"
132 $LFS getstripe -v $file
133 error "$file not allocated from OSTs $ost_list."
137 local ost_count=$($LFS getstripe -c $file)
138 [[ -n "$count" ]] && [[ $ost_count -ne $count ]] &&
139 error "$file stripe count $count expected; got $ost_count" &&
144 check_file_not_in_pool() {
147 local res=$($LFS getstripe --pool $file)
149 [ "$res" != "$pool" ] || error "File '$file' is in pool: $res"
152 check_dir_not_in_pool() {
155 local res=$($LFS getstripe --pool $dir)
157 [ "$res" != "$pool" ] || error "Dir '$dir' is in pool: $res"
162 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool" "" ||
163 error "Failed to remove targets from pool: $pool"
169 local tgt="${3}$(lctl get_param -n lov.$FSNAME-*.pools.$pool |
170 sort -u | tr '\n' ' ')"
172 do_facet mgs lctl pool_add $FSNAME.$pool $osts
174 [[ $RC -ne 0 ]] && return $RC
176 # wait for OSTs to be added to the pool
177 for mds_id in $(seq $MDSCOUNT); do
178 local mdt_id=$((mds_id-1))
179 local lodname=$FSNAME-MDT$(printf "%04x" $mdt_id)-mdtlov
180 wait_update_facet mds$mds_id \
181 "lctl get_param -n lod.$lodname.pools.$pool |
182 sort -u | tr '\n' ' ' " "$tgt" >/dev/null ||
183 error "mds$mds_id:pool add failed $1; $2"
185 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool |
186 sort -u | tr '\n' ' ' " "$tgt" >/dev/null ||
187 error "pool_add failed: $1; $2"
191 create_pool_nofail() {
192 create_pool $FSNAME.$1
193 [[ $? -ne 0 ]] && error "Pool creation of $1 failed"
198 create_pool $FSNAME.$1
200 error "Pool creation of $1 succeeded; should have failed"
209 remote_mds_nodsh && skip "remote MDS with nodsh"
210 remote_ost_nodsh && skip "remote OST with nodsh"
212 # reset root directory's stripe offset
213 $LFS getstripe -d $MOUNT
214 save_layout_restore_at_exit $MOUNT
215 $LFS setstripe -i -1 $MOUNT
217 # Tests for new commands added
222 run_test 1a "Create a pool with a 1 character pool name"
225 create_pool_nofail ${POOL}12
226 destroy_pool ${POOL}12
228 run_test 1b "Create a pool with a 10 char pool name"
231 create_pool_nofail ${POOL}1234567
232 destroy_pool ${POOL}1234567
234 run_test 1c "Create a pool with a 15 char pool name"
237 create_pool_fail ${POOL}12345678
239 run_test 1d "Create a pool with a 16 char pool name; should fail"
242 local pool_name="$POOL"
243 for ((i = 1; i <= 991; i++)); do pool_name=${pool_name}"o"; done
244 create_pool_fail $pool_name
246 run_test 1e "Create a pool with a 1000 char pool name; should fail"
251 error "pool_new did not fail even though fs-name was missing"
253 run_test 1f "pool_new should fail if fs-name is missing"
258 error "pool_new did not fail even though fs-name was missing"
260 run_test 1g "pool_new should fail if fs-name is missing"
263 create_pool ${FSNAME}.
265 error "pool_new did not fail even though pool name was missing"
267 run_test 1h "pool_new should fail if poolname is missing"
272 error "pool_new did not fail even if pool/fs-name was missing"
274 run_test 1i "pool_new should fail if poolname and fs-name are missing"
277 do_facet mgs lctl pool_new ${FSNAME},$POOL
279 error "pool_new did not fail even if poolname format was wrong"
281 run_test 1j "pool_new should fail if poolname format is wrong"
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 1k "pool_new should fail if poolname format is wrong"
291 create_pool_nofail $POOL2
292 create_pool ${FSNAME}.$POOL2
294 error "pool_new did not fail even though $POOL2 existed"
297 run_test 1m "pool_new did not fail even though $POOL2 existed"
300 create_pool_nofail ${POOL}1234567
302 add_pool ${POOL}1234567 "OST0000" "$FSNAME-OST0000_UUID "
303 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
304 create_dir $POOL_ROOT ${POOL}1234567
305 dd if=/dev/zero of=$POOL_ROOT/file bs=1M count=100
306 RC=$?; [[ $RC -eq 0 ]] ||
307 error "failed to write to $POOL_ROOT/file: $RC"
308 do_facet mgs lctl pool_remove $FSNAME.${POOL}1234567 OST0000
309 drain_pool ${POOL}1234567
311 destroy_pool ${POOL}1234567
313 run_test 1n "Pool with a 15 char pool name works well"
318 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
320 error "pool_add did not fail even though $POOL did not exist"
322 run_test 2a "pool_add: non-existant pool $POOL"
325 do_facet mgs lctl pool_add $FSNAME.${POOL}1234567890 \
326 $FSNAME-OST0000 2>/dev/null
328 error "pool_add did not fail even though pool name was invalid."
330 run_test 2b "pool_add: Invalid pool name"
332 # Testing various combinations of OST name list
337 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
338 [[ $? -ne 0 ]] || destroy_pool $POOL
340 create_pool_nofail $POOL
343 do_facet mgs lctl pool_add $FSNAME.$POOL OST0000
344 RC=$?; [[ $RC -eq 0 ]] ||
345 error "pool_add failed. $FSNAME $POOL OST0000: $RC"
346 do_facet mgs lctl pool_remove $FSNAME.$POOL OST0000
350 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
351 RC=$?; [[ $RC -eq 0 ]] ||
352 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000: $RC"
353 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
356 # 3. $FSNAME-OST0000_UUID
357 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
358 RC=$?; [[ $RC -eq 0 ]] ||
359 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000_UUID: $RC"
360 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
363 # 4. $FSNAME-OST[0,1,2,3,]
365 for i in $TGT_LIST; do TGT=${TGT}$(printf "%04x," $i); done
367 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT
368 [[ $? -eq 0 ]] || error "pool_add failed. $FSNAME.$POOL $TGT. $RC"
369 do_facet mgs lctl pool_remove $FSNAME.$POOL $TGT
372 # 5. $FSNAME-OST[0-5/1]
373 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT_ALL
374 RC=$?; [[ $RC -eq 0 ]] ||
375 error "pool_add failed. $FSNAME $POOL" "$TGT_ALL $RC"
376 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL |
377 sort -u | tr '\n' ' ' " "$TGT_UUID" ||
378 error "Add to pool failed"
379 do_facet mgs lctl pool_remove $FSNAME.$POOL $TGT_ALL
384 run_test 2c "pool_add: OST index combinations"
390 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
391 [[ $? -ne 0 ]] || destroy_pool $POOL
393 create_pool_nofail $POOL
395 TGT=$(printf "$FSNAME-OST%04x_UUID " $OSTCOUNT)
396 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT
397 RC=$?; [[ $RC -ne 0 ]] ||
398 error "pool_add succeeded for an OST ($TGT) that does not exist."
402 run_test 2d "pool_add: OSTs that don't exist should be rejected"
409 $LCTL get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
410 [[ $? -ne 0 ]] || destroy_pool $POOL
412 create_pool_nofail $POOL
414 TGT="$FSNAME-OST0000_UUID"
415 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT
416 wait_update_facet $SINGLEMDS \
417 "lctl pool_list $FSNAME.$POOL | sed '1d'" "$TGT" ||
418 error "Add $TGT to $FSNAME.$POOL failed"
419 RESULT=$(do_facet mgs \
420 "LOCALE=C $LCTL pool_add $FSNAME.$POOL $TGT 2>&1")
425 error "pool_add succeeded for an OST that was already in the pool."
427 [[ $(grep "already in pool" <<< $RESULT) ]] ||
428 error "pool_add failed as expected but error message not as expected."
432 run_test 2e "pool_add: OST already in a pool should be rejected"
435 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
436 [[ $? -ne 0 ]] || destroy_pool $POOL
439 lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
441 error "pool_remove did not fail even though pool did not exist."
443 run_test 3a "pool_remove: non-existant pool"
447 lctl pool_remove ${NON_EXISTANT_FS}.$POOL OST0000 2>/dev/null
449 error "pool_remove did not fail even though fsname did not exist."
451 run_test 3b "pool_remove: non-existant fsname"
454 do_facet mgs lctl pool_remove $FSNAME.p1234567891234567890 \
455 $FSNAME-OST0000 2>/dev/null
457 error "pool_remove did not fail even though pool name was invalid."
459 run_test 3c "pool_remove: Invalid pool name"
461 # Testing various combinations of OST name list
463 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
464 [[ $? -ne 0 ]] || destroy_pool $POOL
466 create_pool_nofail $POOL
467 do_facet mgs lctl pool_add $FSNAME.$POOL OST0000
468 do_facet mgs lctl pool_remove $FSNAME.$POOL OST0000
469 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL OST0000"
472 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
473 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
474 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000"
477 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
478 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
480 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000_UUID"
483 add_pool $POOL $TGT_ALL "$TGT_UUID"
484 do_facet mgs lctl pool_remove $FSNAME.$POOL $TGT_ALL
485 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL" $TGT_ALL
490 run_test 3d "pool_remove: OST index combinations"
493 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
494 [[ $? -ne 0 ]] || destroy_pool $POOL
496 do_facet mgs lctl pool_destroy $FSNAME.$POOL 2>/dev/null
498 error "pool_destroy did not fail even though pool did not exist."
500 run_test 4a "pool_destroy: non-existant pool"
503 do_facet mgs lctl pool_destroy ${NON_EXISTANT_FS}.$POOL 2>/dev/null
505 error "pool_destroy did not fail even though filesystem did not exist."
507 run_test 4b "pool_destroy: non-existant fs-name"
510 create_pool_nofail $POOL
511 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
513 do_facet mgs lctl pool_destroy ${FSNAME}.$POOL
514 [[ $? -ne 0 ]] || error "pool_destroy succeeded with a non-empty pool."
517 run_test 4c "pool_destroy: non-empty pool"
522 $LCMD pool_list 2>/dev/null
524 error "pool_list did not fail even though fsname missing."
526 destroy_pool $POOL 2>/dev/null
527 destroy_pool $POOL2 2>/dev/null
529 create_pool_nofail $POOL
530 create_pool_nofail $POOL2
531 $LCMD pool_list $FSNAME
532 [[ $? -eq 0 ]] || error "pool_list $FSNAME failed."
534 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT_ALL
536 $LCMD pool_list $FSNAME.$POOL
537 [[ $? -eq 0 ]] || error "pool_list $FSNAME.$POOL failed."
539 $LCMD pool_list ${NON_EXISTANT_FS} 2>/dev/null
541 error "pool_list did not fail for fsname $NON_EXISTANT_FS"
543 $LCMD pool_list ${FSNAME}.$NON_EXISTANT_POOL 2>/dev/null
545 error "pool_list did not fail for pool $NON_EXISTANT_POOL"
547 if [[ ! $(grep $SINGLEMDS <<< $LCMD) ]]; then
548 echo $LCMD pool_list $DIR
550 [[ $? -eq 0 ]] || error "pool_list failed for $DIR"
553 $LCMD pool_list ${DIR}/d1
554 [[ $? -eq 0 ]] || error "pool_list failed for ${DIR}/d1"
557 rm -rf ${DIR}nonexistant
558 $LCMD pool_list ${DIR}nonexistant 2>/dev/null
560 error "pool_list did not fail for invalid mountpoint ${DIR}nonexistant"
567 # Issue commands from client
570 run_test 5a "lfs pool_list from client"
573 sub_test_5 "do_facet $SINGLEMDS lctl"
575 run_test 5b "lctl pool_list from MDS"
578 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
579 local POOL_DIR=$POOL_ROOT/dir_tst
580 local POOL_FILE=$POOL_ROOT/file_tst
582 create_pool_nofail $POOL
584 do_facet $SINGLEMDS lctl pool_list $FSNAME
585 [[ $? -eq 0 ]] || error "pool_list $FSNAME failed."
587 add_pool $POOL $TGT_ALL "$TGT_UUID"
590 $LFS setstripe -c -1 -p $POOL $POOL_DIR
591 [[ $? -eq 0 ]] || error "$LFS setstripe -p $POOL failed."
592 check_dir_in_pool $POOL_DIR $POOL
594 # If an invalid pool name is specified, the command should fail
595 $LFS setstripe -c 2 -p $INVALID_POOL $POOL_DIR 2>/dev/null
596 [[ $? -ne 0 ]] || error "setstripe to invalid pool did not fail."
598 # If the pool name does not exist, the command should fail
599 $LFS setstripe -c 2 -p $NON_EXISTANT_POOL $POOL_DIR 2>/dev/null
600 [[ $? -ne 0 ]] || error "setstripe to non-existant pool did not fail."
602 # lfs setstripe should work as before if a pool name is not specified.
603 $LFS setstripe -c -1 $POOL_DIR
604 [[ $? -eq 0 ]] || error "$LFS setstripe -c -1 $POOL_DIR failed."
605 $LFS setstripe -c -1 $POOL_FILE
606 [[ $? -eq 0 ]] || error "$LFS setstripe -c -1 $POOL_FILE failed."
608 # lfs setstripe should fail if a start index that is outside the
610 create_pool_nofail $POOL2
611 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
612 $LFS setstripe -i 1 -p $POOL2 $ROOT_POOL/$tfile 2>/dev/null
614 error "$LFS setstripe with start index outside the pool did not fail."
616 run_test 6 "getstripe/setstripe"
620 # Create a pool, stripe a directory and file with it
623 pool_add $pool || error "pool_add failed"
624 pool_add_targets $pool 0 1 || error "pool_add_targets failed"
626 $LFS setstripe -c 1 $DIR/$tdir/testfile1 --pool "$pool" ||
627 error "setstripe failed"
628 $LFS setstripe -c 1 $DIR/$tdir/testfile2 --pool "$FSNAME.$pool" ||
629 error "setstripe failed"
631 mkdir $DIR/$tdir/testdir
632 $LFS setstripe -c 1 $DIR/$tdir/testdir -p "$pool" ||
633 error "setstripe failed"
634 $LFS setstripe -c 1 $DIR/$tdir/testdir -p "$FSNAME.$pool" ||
635 error "setstripe failed"
637 rm -f $DIR/$tdir/testfile1
638 rm -f $DIR/$tdir/testfile2
639 rmdir $DIR/$tdir/testdir
641 destroy_pool_int $FSNAME.$pool
646 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
650 # Generate pool with random name from 1 to 15 characters
652 POOLNAME=$(echo $$$RANDOM$RANDOM |
653 tr -dc 'a-zA-Z0-9' | fold -w $i |
655 echo set poolname to $POOLNAME
656 helper_test_7a $POOLNAME
659 run_test 7a "create various pool name"
665 [ $? -ne 22 ] && error "can create a pool with no fsname"
669 [ $? -ne 22 ] && error "can create a pool with no name"
672 create_pool $FSNAME.0123456789^bdef
673 [ $? -ne 22 ] && error "can create a pool with an invalid name"
676 create_pool $FSNAME.0123456789abdefg
677 [ $? -ne 36 ] && error "can create a pool with a name too long"
681 run_test 7b "try to create pool name with invalid lengths or names"
685 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
689 # Create a pool with 15 letters
690 local pool=0123456789abcde
691 pool_add $pool || error "pool_add failed"
692 pool_add_targets $pool 0 1 || error "pool_add_targets failed"
694 # setstripe with the same pool name plus 1 letter
695 $LFS setstripe -c 1 $DIR/$tdir/testfile1 --pool "${pool}X" &&
696 error "setstripe succedeed"
698 # setstripe with the same pool name minus 1 letter
699 $LFS setstripe -c 1 $DIR/$tdir/testfile1 --pool "${pool%?}" &&
700 error "setstripe succedeed"
702 rm -f $DIR/$tdir/testfile1
704 destroy_pool_int $FSNAME.$pool
706 run_test 7c "create a valid pool name and setstripe with a bad one"
709 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
711 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
713 create_pool_nofail $POOL
714 create_pool_nofail $POOL2
716 local start=$(printf %04x $((TGT_FIRST + 1)))
717 do_facet mgs lctl pool_add $FSNAME.$POOL2 \
718 $FSNAME-OST[$start-$TGT_MAX/2]
720 add_pool $POOL $TGT_HALF "$TGT_UUID2"
722 create_dir $POOL_ROOT/dir1 $POOL
723 create_dir $POOL_ROOT/dir2 $POOL2
726 createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
727 error "createmany $POOL_ROOT/dir1/$tfile failed!"
729 for file in $POOL_ROOT/dir1/*; do
730 check_file_in_pool $file $POOL
733 createmany -o $POOL_ROOT/dir2/$tfile $numfiles ||
734 error "createmany $POOL_ROOT/dir2/$tfile failed!"
735 for file in $POOL_ROOT/dir2/*; do
736 check_file_in_pool $file $POOL2
739 rm -rf $POOL_ROOT/dir?
743 run_test 11 "OSTs in overlapping/multiple pools"
746 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
748 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >=3 OSTs"
750 create_pool_nofail $POOL
751 create_pool_nofail $POOL2
753 local start=$(printf %04x $((TGT_FIRST + 1)))
754 do_facet mgs lctl pool_add $FSNAME.$POOL2 \
755 $FSNAME-OST[$start-$TGT_MAX/2]
757 add_pool $POOL $TGT_HALF "$TGT_UUID2"
759 echo creating some files in $POOL and $POOL2
761 create_dir $POOL_ROOT/dir1 $POOL
762 create_dir $POOL_ROOT/dir2 $POOL2
763 create_file $POOL_ROOT/file1 $POOL
764 create_file $POOL_ROOT/file2 $POOL2
766 echo Checking the files created
767 check_file_in_pool $POOL_ROOT/file1 $POOL
768 check_file_in_pool $POOL_ROOT/file2 $POOL2
770 echo Changing the pool membership
771 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST[$TGT_FIRST]
772 do_facet mgs lctl pool_list $FSNAME.$POOL
773 FIRST_UUID=$(echo $TGT_UUID | awk '{print $1}')
774 add_pool $POOL2 $FSNAME-OST[$TGT_FIRST] "$FIRST_UUID "
775 do_facet mgs lctl pool_list $FSNAME.$POOL2
777 echo Checking the files again
778 check_dir_in_pool $POOL_ROOT/dir1 $POOL
779 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
780 check_file_in_osts $POOL_ROOT/file1 "$TGT_LIST2"
781 check_file_in_osts $POOL_ROOT/file2 "$(seq 0x$start 2 0x$TGT_MAX)"
783 echo Creating some more files
784 create_dir $POOL_ROOT/dir3 $POOL
785 create_dir $POOL_ROOT/dir4 $POOL2
786 create_file $POOL_ROOT/file3 $POOL
787 create_file $POOL_ROOT/file4 $POOL2
789 echo Checking the new files
790 check_file_in_pool $POOL_ROOT/file3 $POOL
791 check_file_in_pool $POOL_ROOT/file4 $POOL2
795 run_test 12 "OST Pool Membership"
798 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >= 3 OSTs"
800 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
804 create_pool_nofail $POOL
805 add_pool $POOL $TGT_ALL "$TGT_UUID"
807 create_dir $POOL_ROOT/dir1 $POOL -1
808 createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
809 error "createmany $POOL_ROOT/dir1/$tfile failed!"
810 for file in $POOL_ROOT/dir1/*; do
811 check_file_in_pool $file $POOL $OSTCOUNT
814 create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
815 create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST + 1))
816 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST + 2))
817 check_file_in_osts $POOL_ROOT/dir1/file1 $((16#$TGT_FIRST))
818 check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST + 1))"
819 check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST + 2))"
821 create_dir $POOL_ROOT/dir2 $POOL $count
822 createmany -o $POOL_ROOT/dir2/$tfile- $numfiles ||
823 error "createmany $POOL_ROOT/dir2/$tfile- failed!"
824 for file in $POOL_ROOT/dir2/*; do
825 check_file_in_pool $file $POOL $count
828 create_dir $POOL_ROOT/dir3 $POOL $count $((TGT_FIRST + 1))
829 createmany -o $POOL_ROOT/dir3/$tfile- $numfiles ||
830 error "createmany $POOL_ROOT/dir3/$tfile- failed!"
831 for file in $POOL_ROOT/dir3/*; do
832 check_file_in_pool $file $POOL $count
835 create_dir $POOL_ROOT/dir4 $POOL 1
836 createmany -o $POOL_ROOT/dir4/$tfile- $numfiles ||
837 error "createmany $POOL_ROOT/dir4/$tfile- failed!"
838 for file in $POOL_ROOT/dir4/*; do
839 check_file_in_pool $file $POOL 1
842 create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST + 2))
843 createmany -o $POOL_ROOT/dir5/$tfile- $numfiles ||
844 error "createmany $POOL_ROOT/dir5/$tfile- failed!"
845 for file in $POOL_ROOT/dir5/*; do
846 check_file_in_pool $file $POOL 1
849 rm -rf $POOL_ROOT/dir[1-5]/
853 run_test 13 "Striping characteristics in a pool"
856 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >= 3 OSTs"
858 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
862 [ $OSTSIZE -gt $((MAXFREE / OSTCOUNT)) ] &&
863 skip_env "OST size $OSTSIZE is larger than $((MAXFREE / OSTCOUNT))"
865 create_pool_nofail $POOL
866 create_pool_nofail $POOL2
868 add_pool $POOL $TGT_HALF "$TGT_UUID2"
869 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
871 create_dir $POOL_ROOT/dir1 $POOL 1
872 create_file $POOL_ROOT/dir1/file $POOL 1
873 local ost=$($LFS getstripe -i $POOL_ROOT/dir1/file)
875 while [[ $i -lt $numfiles ]]; do
877 [[ $ost -gt $((16#$TGT_MAX)) ]] && ost=$TGT_FIRST
879 # echo "Iteration: $i OST: $ost"
880 create_file $POOL_ROOT/dir1/file${i} $POOL 1
881 check_file_in_pool $POOL_ROOT/dir1/file${i} $POOL
885 # Fill up OST0 until it is nearly full.
886 # Create 9 files of size OST0_SIZE/10 each.
887 create_dir $POOL_ROOT/dir2 $POOL2 1
888 $LFS df $POOL_ROOT/dir2
889 OST0_SIZE=$($LFS df $POOL_ROOT/dir2 | awk '/\[OST:0\]/ { print $4 }')
890 FILE_SIZE=$((OST0_SIZE/1024/10))
891 echo "Filling OST0 with 9 files of ${FILE_SIZE}MB in $POOL_ROOT/dir2"
893 while [[ $i -lt 10 ]]; do
894 dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1M count=$FILE_SIZE
897 sleep 1 # get new statfs info
898 $LFS df $POOL_ROOT/dir2
900 # OST $TGT_FIRST is no longer favored; but it may still be used.
901 create_dir $POOL_ROOT/dir3 $POOL 1
902 create_file $POOL_ROOT/dir3/file $POOL 1
903 createmany -o $POOL_ROOT/dir3/$tfile- $numfiles ||
904 error "createmany $POOL_ROOT/dir3/$tfile- failed!"
905 for file in $POOL_ROOT/dir3/*; do
906 check_file_in_pool $file $POOL
913 run_test 14 "Round robin and QOS striping within a pool"
916 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
920 while [[ $i -lt $OSTCOUNT ]]; do
921 create_pool_nofail $POOL${i}
923 local tgt=$(printf "$FSNAME-OST%04x_UUID " $i)
924 add_pool $POOL${i} "$FSNAME-OST[$(printf %04x $i)]" "$tgt"
925 create_dir $POOL_ROOT/dir${i} $POOL${i}
926 createmany -o $POOL_ROOT/dir$i/$tfile $numfiles ||
927 error "createmany $POOL_ROOT/dir$i/$tfile failed!"
929 for file in $POOL_ROOT/dir$i/*; do
930 check_file_in_osts $file $i
938 run_test 15 "One directory per OST/pool"
941 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
945 create_pool_nofail $POOL
947 add_pool $POOL $TGT_HALF "$TGT_UUID2"
949 local dir=$POOL_ROOT/$tdir
950 create_dir $dir $POOL
952 for i in $(seq 1 10); do
957 createmany -o $dir/$tfile $numfiles ||
958 error "createmany $dir/$tfile failed!"
960 for file in $dir/*; do
961 check_file_in_pool $file $POOL
964 rm -rf $POOL_ROOT/$tdir
968 run_test 16 "Inheritance of pool properties"
971 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
975 create_pool_nofail $POOL
977 add_pool $POOL $TGT_ALL "$TGT_UUID"
979 local dir=$POOL_ROOT/dir
980 create_dir $dir $POOL
982 createmany -o $dir/${tfile}1_ $numfiles ||
983 error "createmany $dir/${tfile}1_ failed!"
985 for file in $dir/*; do
986 check_file_in_pool $file $POOL
991 createmany -o $dir/${tfile}2_ $numfiles ||
992 error "createmany $dir/${tfile}2_ failed!"
997 run_test 17 "Referencing an empty pool"
1006 wait_delete_completed >/dev/null # give pending IO a chance to go to disk
1007 stat=$(createmany -o $cdir/${tfile} -$numsec | tail -1)
1008 files=$(echo $stat | cut -f 2 -d ' ')
1010 unlinkmany $cdir/${tfile} $files > /dev/null
1017 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1020 local plaindir=$POOL_ROOT/plaindir
1021 local pooldir=$POOL_ROOT/pooldir
1027 for i in $(seq 1 $iter); do
1028 echo "Create performance, iteration $i, $numsec seconds x 3"
1030 local files1=$(create_perf $plaindir $numsec)
1031 [[ $files1 -eq 0 ]] && error "Zero files created without pool"
1033 echo "iter $i: $files1 creates without pool"
1035 create_pool_nofail $POOL > /dev/null
1036 add_pool $POOL $TGT_ALL "$TGT_UUID" > /dev/null
1037 create_dir $pooldir $POOL
1038 local files2=$(create_perf $pooldir $numsec)
1039 [[ $files2 -eq 0 ]] && error "Zero files created with pool"
1041 echo "iter $i: $files2 creates with pool"
1043 destroy_pool $POOL > /dev/null
1044 local files3=$(create_perf $pooldir $numsec)
1045 [[ $files3 -eq 0 ]] &&
1046 error "Zero files created with missing pool"
1048 echo "iter $i: $files3 creates with missing pool"
1053 echo Avg files created in $numsec seconds without pool: $((f1 / iter))
1054 echo Avg files created in $numsec seconds with pool: $((f2 / iter))
1055 echo Avg files created in $numsec seconds missing pool: $((f3 / iter))
1057 # Set this high until we establish a baseline for what the degradation
1061 diff=$((($f1 - $f2) * 100 / $f1))
1062 echo "No pool / wide pool: $diff %."
1063 [ $diff -gt $max ] &&
1064 error_ignore bz23408 "Degradation with wide pool is $diff% > $max%"
1067 diff=$((($f1 - $f3) * 100 / $f1))
1068 echo "No pool / missing pool: $diff %."
1069 [ $diff -gt $max ] &&
1070 error_ignore bz23408 "Degradation with wide pool is $diff% > $max%"
1074 run_test 18 "File create in a directory which references a deleted pool"
1077 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1079 local dir1=$POOL_ROOT/dir1
1080 local dir2=$POOL_ROOT/dir2
1083 create_pool_nofail $POOL
1085 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1087 create_dir $dir1 $POOL
1088 createmany -o $dir1/${tfile} $numfiles ||
1089 error "createmany $dir1/${tfile} failed!"
1090 for file in $dir1/*; do
1091 check_file_in_pool $file $POOL
1095 createmany -o $dir2/${tfile} $numfiles ||
1096 error "createmany $dir2/${tfile} failed!"
1097 for file in $dir2/*; do
1098 check_file_not_in_pool $file $POOL
1105 run_test 19 "Pools should not come into play when not specified"
1108 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
1110 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1112 local dir1=$POOL_ROOT/dir1
1113 local dir2=$dir1/dir2
1114 local dir3=$dir1/dir3
1118 create_pool_nofail $POOL
1119 create_pool_nofail $POOL2
1121 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1123 local start=$(printf %04x $((TGT_FIRST + 1)))
1124 TGT=$(for i in $(seq 0x$start 2 0x$TGT_MAX); do \
1125 printf "$FSNAME-OST%04x_UUID " $i; done)
1126 add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1128 create_dir $dir1 $POOL
1129 create_file $dir1/file1 $POOL2 # Should replace $dir1 pool with $POOL2
1130 create_dir $dir2 $POOL2
1131 touch $dir2/file2 # Should inherit $POOL2 from $dir2
1132 mkdir $dir3 # Should inherit $POOL from $dir1
1133 $LFS setstripe -c 1 $dir3 # Should remain existing $POOL
1134 touch $dir3/file3 # Should inherit $POOL from $dir3
1135 $LFS setstripe -c 1 $dir2/file4 # Should inherit $POOL2 from dir2
1136 $LFS setstripe -S 64K $dir1/file5 # Should inderit $POOL from $dir1
1138 check_file_in_pool $dir1/file1 $POOL2
1139 check_file_in_pool $dir2/file2 $POOL2
1140 check_dir_not_in_pool $dir3 $POOL2
1141 check_file_not_in_pool $dir3/file3 $POOL2
1142 check_file_not_in_pool $dir2/file4 $POOL
1143 check_file_not_in_pool $dir1/file5 $POOL2
1145 if [ "$MDS1_VERSION" -ge $(version_code 2.10.54) ]; then
1146 check_dir_in_pool $dir3 $POOL
1147 check_file_in_pool $dir3/file3 $POOL
1148 check_file_in_pool $dir2/file4 $POOL2
1149 check_file_in_pool $dir1/file5 $POOL
1156 run_test 20 "Different pools in a directory hierarchy."
1159 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1160 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1164 local dir=$POOL_ROOT/dir
1166 create_pool_nofail $POOL
1168 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1170 create_dir $dir $POOL $OSTCOUNT
1171 create_file $dir/file1 $POOL $OSTCOUNT
1172 $LFS getstripe -v $dir/file1
1173 check_file_in_pool $dir/file1 $POOL
1179 run_test 21 "OST pool with fewer OSTs than stripe count"
1187 for c in $(seq 1 10); do
1188 echo "Pool $pool, iteration $c"
1189 do_facet mgs lctl pool_add $FSNAME.$pool \
1190 OST[$TGT_FIRST-$TGT_MAX/$step] 2>/dev/null
1191 local TGT_SECOND=$(printf %04x $((TGT_FIRST + $step)))
1192 if [ $((16#$TGT_SECOND)) -le $((16#$TGT_MAX)) ]; then
1193 do_facet mgs lctl pool_remove $FSNAME.$pool \
1194 OST[$TGT_SECOND-$TGT_MAX/$step]
1197 echo loop for $pool complete
1201 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1202 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1206 create_pool_nofail $POOL
1207 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
1208 create_pool_nofail $POOL2
1209 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
1214 create_dir $POOL_ROOT $POOL
1215 createmany -o $POOL_ROOT/${tfile} $numfiles ||
1216 error "createmany $POOL_ROOT/${tfile} failed!"
1221 run_test 22 "Simultaneous manipulation of a pool"
1224 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1225 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1228 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS ||
1229 skip_env "User $RUNAS_ID does not exist - skipping"
1233 local BUNIT_SZ=1024 # min block quota unit(kB)
1234 local LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1)))
1235 local dir=$POOL_ROOT/dir
1236 local file="$dir/$tfile-quota"
1238 create_pool_nofail $POOL
1240 local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
1241 printf "$FSNAME-OST%04x_UUID " $i; done)
1242 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1243 create_dir $dir $POOL
1245 # XXX remove the interoperability code once we drop the old server
1246 # ( < 2.3.50) support.
1247 if [ "$MDS1_VERSION" -lt $(version_code 2.3.50) ]; then
1248 $LFS quotaoff -ug $MOUNT
1249 $LFS quotacheck -ug $MOUNT
1251 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1252 do_facet mgs $PERM_CMD \
1253 osd-*.$FSNAME-OST*.quota_slave.enable=ug
1255 do_facet mgs $PERM_CMD $FSNAME.quota.ost=ug
1260 $LFS setquota -u $RUNAS_ID -b $LIMIT -B $LIMIT $dir
1262 $LFS quota -v -u $RUNAS_ID $dir
1264 $LFS setstripe -c 1 -p $POOL $file
1265 chown $RUNAS_ID.$RUNAS_GID $file
1268 # This does two "dd" runs to ensure that the quota failure is returned
1269 # to userspace when we check. The first "dd" might otherwise complete
1270 # without error if it is only writing into cache.
1271 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
1272 count=$((BUNIT_SZ*2)) 2>&1)
1273 echo $stat | grep "Disk quota exceeded" > /dev/null
1274 if [ $? -eq 0 ]; then
1275 $LFS quota -v -u $RUNAS_ID $dir
1276 cancel_lru_locks osc
1277 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
1278 count=$BUNIT_SZ seek=$((BUNIT_SZ*2)) 2>&1)
1281 [[ $RC -eq 0 ]] && error "second dd did not fail."
1282 echo $stat | grep "Disk quota exceeded" > /dev/null
1283 [[ $? -eq 1 ]] && error "second dd did not fail with EDQUOT."
1285 log "first dd failed with EDQUOT."
1287 $LFS quota -v -u $RUNAS_ID $dir
1289 run_test 23a "OST pools and quota"
1292 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1293 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1296 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS || {
1297 skip_env "User $RUNAS_ID does not exist - skipping"
1302 local dir=$POOL_ROOT/dir
1303 local file="$dir/$tfile-quota"
1305 create_pool_nofail $POOL
1307 local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
1308 printf "$FSNAME-OST%04x_UUID " $i; done)
1309 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1310 create_dir $dir $POOL
1312 local maxfree=$((1024 * 1024 * 30)) # 30G
1313 local AVAIL=$(lfs_df -p $POOL $dir | awk '/summary/ { print $4 }')
1314 [ $AVAIL -gt $maxfree ] &&
1315 skip_env "Filesystem space $AVAIL is larger than " \
1318 echo "OSTCOUNT=$OSTCOUNT, OSTSIZE=$OSTSIZE, AVAIL=$AVAIL"
1319 echo "MAXFREE=$maxfree, SLOW=$SLOW"
1321 # XXX remove the interoperability code once we drop the old server
1322 # ( < 2.3.50) support.
1323 if [ "$MDS1_VERSION" -lt $(version_code 2.3.50) ]; then
1324 $LFS quotaoff -ug $MOUNT
1326 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1327 do_facet mgs $PERM_CMD \
1328 osd-*.$FSNAME-OST*.quota_slave.enable=none
1330 do_facet mgs $PERM_CMD $FSNAME.quota.ost=none
1335 chown $RUNAS_ID.$RUNAS_ID $dir
1339 local stime=$(date +%s)
1343 local maxtime=300 # minimum speed: 5GB / 300sec ~= 17MB/s
1344 while [ $RC -eq 0 ]; do
1346 stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file}$i bs=1M \
1347 count=$((5 * 1024)) 2>&1)
1349 TOTAL=$((TOTAL + 1024 * 1024 * 5))
1350 echo "[$i iteration] $stat"
1351 echo "total written: $TOTAL"
1354 elapsed=$((etime - stime))
1355 echo "stime=$stime, etime=$etime, elapsed=$elapsed"
1357 if [ $RC -eq 1 ]; then
1358 echo $stat | grep -q "Disk quota exceeded"
1360 error "dd failed with EDQUOT with quota off"
1362 echo $stat | grep -q "No space left on device"
1364 error "dd did not fail with ENOSPC"
1365 elif [ $TOTAL -gt $AVAIL ]; then
1366 error "dd didn't fail with ENOSPC ($TOTAL > $AVAIL)"
1367 elif [ $i -eq 1 -a $elapsed -gt $maxtime ]; then
1368 log "The first 5G write used $elapsed (> $maxtime) " \
1369 "seconds, terminated"
1377 run_test 23b "OST pools and OOS"
1380 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1381 [[ "$MDS1_VERSION" -ge $(version_code 2.8.56) ]] ||
1382 skip "Need server version newer than 2.8.55"
1384 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1391 create_pool_nofail $POOL
1393 add_pool $POOL $TGT_ALL "$TGT_UUID"
1395 create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1397 mkdir $POOL_ROOT/dir2
1398 $LFS setstripe -p $POOL -S 65536 -i 0 -c 1 $POOL_ROOT/dir2 ||
1399 error "$LFS setstripe $POOL_ROOT/dir2 failed"
1401 mkdir $POOL_ROOT/dir3
1402 $LFS setstripe -S 65536 -i 0 -c 1 $POOL_ROOT/dir3 ||
1403 error "$LFS setstripe $POOL_ROOT/dir3 failed"
1405 mkdir $POOL_ROOT/dir4
1407 for i in 1 2 3 4; do
1408 dir=${POOL_ROOT}/dir${i}
1417 createmany -o $dir/${tfile} $numfiles ||
1418 error "createmany $dir/${tfile} failed!"
1419 pool=$($LFS getstripe --pool $dir)
1420 index=$($LFS getstripe -i $dir)
1421 size=$($LFS getstripe -S $dir)
1422 count=$($LFS getstripe -c $dir)
1424 for file in $dir/*; do
1425 if [ "$pool" != "" ]; then
1426 check_file_in_pool $file $pool
1428 pool1=$($LFS getstripe --pool $file)
1429 count1=$($LFS getstripe -c $file)
1430 size1=$($LFS getstripe -S $file)
1431 [[ "$pool" != "$pool1" ]] &&
1432 error "Pool '$pool' not on $file:$pool1"
1433 [[ "$count" != "$count1" ]] &&
1434 [[ "$count" != "-1" ]] &&
1435 error "Stripe count $count not on"\
1437 [[ "$count1" != "$OSTCOUNT" ]] &&
1438 [[ "$count" = "-1" ]] &&
1439 error "Stripe count $count1 not on"\
1441 [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] &&
1442 error "Stripe size $size not on $file:$size1"
1450 run_test 24 "Independence of pool from other setstripe parameters"
1453 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1455 mkdir_on_mdt0 $POOL_ROOT
1457 for i in $(seq 10); do
1458 create_pool_nofail $POOL$i
1459 do_facet mgs "lctl pool_add $FSNAME.$POOL$i OST0000; sync"
1460 wait_update $HOSTNAME "lctl get_param -n \
1461 lov.$FSNAME-*.pools.$POOL$i | sort -u |
1462 tr '\n' ' ' " "$FSNAME-OST0000_UUID " >/dev/null ||
1463 error "pool_add failed: $1; $2"
1465 facet_failover $SINGLEMDS ||
1466 error "failed to failover $SINGLEMDS"
1467 wait_osc_import_state $SINGLEMDS ost FULL
1471 # Veriy that the pool got created and is usable
1472 df $POOL_ROOT > /dev/null
1475 # Make sure OST0 can be striped on
1476 $LFS setstripe -i 0 -c 1 $POOL_ROOT/$tfile
1477 local STR=$($LFS getstripe -i $POOL_ROOT/$tfile)
1478 rm $POOL_ROOT/$tfile
1479 if [[ "$STR" == "0" ]]; then
1480 echo "Creating a file in pool$i"
1481 create_file $POOL_ROOT/file$i $POOL$i || break
1482 check_file_in_pool $POOL_ROOT/file$i $POOL$i || break
1484 echo "OST 0 seems to be unavailable. Try later."
1490 run_test 25 "Create new pool and restart MDS"
1493 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >= 3 OSTs"
1494 local dev=$(mdsdevname ${SINGLEMDS//mds/})
1495 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1499 create_pool_nofail $POOL2
1501 do_facet mgs "lctl pool_add $FSNAME.$POOL2 OST0000; sync"
1502 wait_update $HOSTNAME "lctl get_param -n \
1503 lov.$FSNAME-*.pools.$POOL2 | sort -u |
1504 grep $FSNAME-OST0000_UUID " "$FSNAME-OST0000_UUID" ||
1505 error "pool_add failed: $1; $2"
1507 do_facet mgs "lctl pool_add $FSNAME.$POOL2 OST0002; sync"
1508 wait_update $HOSTNAME "lctl get_param -n \
1509 lov.$FSNAME-*.pools.$POOL2 | sort -u |
1510 grep $FSNAME-OST0002_UUID" "$FSNAME-OST0002_UUID" ||
1511 error "pool_add failed: $1; $2"
1513 # Veriy that the pool got created and is usable
1515 echo "Creating files in $POOL2"
1517 for ((i = 0; i < 10; i++)); do
1518 #OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
1519 #Fail OST0000 to ensure objects create on
1520 #the other OST in the pool
1521 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
1522 do_facet $SINGLEMDS lctl set_param fail_val=0
1523 create_file $POOL_ROOT/file$i $POOL2 1 -1 || break
1524 do_facet $SINGLEMDS lctl set_param fail_loc=0
1525 check_file_in_pool $POOL_ROOT/file$i $POOL2 || break
1529 run_test 26 "Choose other OSTs in the pool first in the creation remedy"
1532 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs"
1536 local count=$OSTCOUNT
1538 create_pool_nofail $POOL
1539 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT_ALL
1540 wait_update_facet $SINGLEMDS \
1541 "lctl pool_list $FSNAME.$POOL | wc -l" "$((OSTCOUNT + 1))" ||
1542 error "MDS: pool_list $FSNAME.$POOL failed"
1543 osts=$(list_pool $FSNAME.$POOL)
1544 for ost in ${osts}; do
1546 if [[ $count -eq 0 ]]; then
1547 #define OBD_FAIL_OST_LIST_ASSERT 0x239
1548 do_facet $SINGLEMDS \
1549 $LCTL set_param fail_loc=0x239 fail_val=10
1550 list_pool $FSNAME.$POOL &
1553 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
1554 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $ost
1556 do_facet $SINGLEMDS $LCTL set_param fail_val=0
1558 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $ost
1563 run_test 27 "Race pool_list and pool_remove"
1566 create_pool_nofail $POOL
1567 create_pool_nofail $POOL2
1568 add_pool $POOL $TGT_ALL "$TGT_UUID"
1569 add_pool $POOL2 $TGT_ALL "$TGT_UUID"
1571 start_full_debug_logging
1572 #$LFS setstripe -E 4M -c 1 -p $POOL -E 16M -c 2 $DIR/$tfile
1573 $LFS setstripe -c 1 -p $POOL $DIR/$tfile
1574 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=1 seek=16
1575 local csum=$(cksum $DIR/$tfile)
1576 $LFS getstripe $DIR/$tfile
1577 local pool="$($LFS getstripe -p $DIR/$tfile)"
1578 [[ "$pool" == "$POOL" ]] ||
1579 error "$tfile is in '$pool', not created on $POOL"
1580 $LFS_MIGRATE -y -p $POOL2 $DIR/$tfile ||
1581 error "migrate $tfile to $POOL2 failed"
1582 $LFS getstripe $DIR/$tfile
1583 pool="$($LFS getstripe -p $DIR/$tfile)"
1584 [[ "$pool" == "$POOL2" ]] ||
1585 error "$tfile is in '$pool', not migrated to $POOL2"
1586 local csum2=$(cksum $DIR/$tfile)
1587 [[ "$csum" == "$csum2" ]] || error "checksum error after migration"
1588 stop_full_debug_logging
1590 run_test 28 "lfs_migrate with pool name"
1592 function fill_ost_pool() {
1595 local tmpfile=$DIR/$tdir/$tfile-$pool-filler
1598 lfs setstripe $tmpfile -p $pool -c -1
1600 local dfa=($(lfs_df -p $pool | grep _summary))
1601 local total=${dfa[1]}
1602 local used=${dfa[2]}
1603 local towrite=$(( (total * (threshold + 1) / 100) - used ))
1605 echo "total $total, used $used, towrite $towrite"
1606 (( towrite > 0 )) && {
1607 fallocate -l$((towrite * 1024)) $tmpfile ||
1608 error "can't fallocate"
1613 local pool1=${TESTNAME}-1
1614 local pool2=${TESTNAME}-2
1615 local mdts=$(comma_list $(mdts_nodes))
1617 local prefix="lod.$FSNAME-MDT*.pool.$pool1"
1618 local cmd="$LCTL get_param -n $prefix"
1620 (( $MDS1_VERSION >= $(version_code 2.14.53) )) ||
1621 skip "Need MDS version at least 2.14.53"
1622 (( $OSTCOUNT >= 4 )) || skip "needs >= 4 OSTs"
1623 check_set_fallocate_or_skip
1626 stack_trap "rm -rf $DIR/$tdir"
1628 pool_add $pool1 || error "Pool creation failed"
1629 pool_add_targets $pool1 0 1 || error "pool_add_targets failed"
1631 pool_add $pool2 || error "Pool creation failed"
1632 pool_add_targets $pool2 2 3 || error "pool_add_targets failed"
1634 do_nodes $mdts $LCTL set_param $prefix.spill_target=$pool2
1635 do_nodes $mdts $LCTL set_param $prefix.spill_threshold_pct=$threshold
1636 stack_trap "do_nodes $mdts $LCTL set_param $prefix.spill_threshold_pct=0"
1638 [[ $(do_facet mds1 "$cmd.spill_target" | uniq) == "$pool2" ]] ||
1639 error "spill target wasn't set"
1640 [[ $(do_facet mds1 "$cmd.spill_threshold_pct" | uniq) == "$threshold" ]] ||
1641 error "spill threshold wasn't set"
1642 lfs_df -p $pool1 | grep summary
1643 fill_ost_pool $pool1 $threshold
1644 cancel_lru_locks osc
1645 local delay=$(do_facet mds1 lctl get_param -n lo[vd].*.qos_maxage |
1646 awk '{ print $1 * 2; exit; }')
1647 sleep $((delay + 1))
1648 lfs_df -p $pool1 | grep summary
1650 # in a directory with default striping
1651 $LFS setstripe -p $pool1 $DIR/$tdir || error "can't set default layout"
1652 touch $DIR/$tdir/$tfile-2
1653 [[ $($LFS getstripe -p $DIR/$tdir/$tfile-2) == "$pool2" ]] || {
1654 $LFS getstripe $DIR/$tdir/$tfile-2
1655 error "old pool on $tfile-2"
1657 # when striping is specified explicitly
1658 $LFS setstripe -p $pool1 $DIR/$tdir/$tfile-3 || error "can't setstripe"
1659 touch $DIR/$tdir/$tfile-3
1660 [[ $($LFS getstripe -p $DIR/$tdir/$tfile-3) == "$pool2" ]] || {
1661 $LFS getstripe $DIR/$tdir/$tfile-2
1662 error "old pool on $tfile-3"
1665 # spill is revalidated at object creation
1666 wait_update_facet mds1 "$cmd.spill_is_active | uniq" "1" ||
1667 error "spilling is still inactive"
1669 rm -f $DIR/$tdir/$tfile* || error "can't rm $DIR/$tfile*"
1670 wait_delete_completed
1674 touch $DIR/$tdir/$tfile-2
1675 [[ $($LFS getstripe -p $DIR/$tdir/$tfile-2) == "$pool1" ]] || {
1676 $LFS getstripe $DIR/$tdir/$tfile-2
1677 error "new pool != $pool1"
1679 # spill is revaluated at object creation
1680 wait_update_facet mds1 "$cmd.spill_is_active | uniq" "0" ||
1681 error "spilling is still active"
1683 do_nodes $mdts $LCTL set_param $prefix.spill_threshold_pct=0
1684 [[ $(do_facet mds1 "$cmd.spill_threshold_pct" | uniq) == "0" ]] ||
1685 error "spill threshold wasn't reset"
1687 run_test 29 "check OST pool spilling"
1690 local MDT_DEV=$(mdsdevname 1)
1691 local mdts=$(comma_list $(mdts_nodes))
1692 local pool1=${TESTNAME}-1
1693 local pool2=${TESTNAME}-2
1696 local prefix="lod.$FSNAME-MDT0000*.pool.$pool1"
1697 local cmd="$LCTL get_param -n $prefix"
1699 (( $MDS1_VERSION >= $(version_code 2.14.53) )) ||
1700 skip "Need MDS version at least 2.14.53"
1701 (( $OSTCOUNT >= 4 )) || skip "needs >= 4 OSTs"
1703 pool_add $pool1 || error "Pool creation failed"
1704 pool_add_targets $pool1 0 1 || error "pool_add_targets failed"
1706 pool_add $pool2 || error "Pool creation failed"
1707 pool_add_targets $pool2 2 3 || error "pool_add_targets failed"
1710 do_facet mds1 $LCTL set_param $prefix.spill_target="0123456789ABCDEF" &&
1712 do_facet mds1 $LCTL set_param $prefix.spill_target="$pool1-2" &&
1713 error "non-exising pool"
1714 do_facet mds1 $LCTL set_param $prefix.spill_target="$pool1" &&
1716 do_facet mds1 $LCTL set_param $prefix.spill_threshold_pct="101" &&
1719 # set persistent spilling
1720 do_facet mgs $LCTL set_param -P $prefix.spill_target="$pool2"
1721 do_facet mgs $LCTL set_param -P $prefix.spill_threshold_pct=$threshold
1722 wait_update_facet mds1 "$cmd.spill_target" "$pool2" ||
1723 error "spill target wasn't set"
1724 wait_update_facet mds1 "$cmd.spill_threshold_pct" $threshold ||
1725 error "spill target wasn't set"
1727 stop mds1 || error "Fail to stop MDT."
1728 start mds1 $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
1729 wait_update_facet mds1 "$cmd.spill_target" "$pool2" ||
1730 error "spill target wasn't set after restart"
1731 wait_update_facet mds1 "$cmd.spill_threshold_pct" $threshold ||
1732 error "spill target wasn't set after restart"
1734 # now reset spilling
1735 do_facet mgs $LCTL set_param -P $prefix.spill_threshold_pct=0
1736 wait_update_facet mds1 "$cmd.spill_threshold_pct" 0 ||
1737 error "spill target wasn't set"
1739 stop mds1 || error "Fail to stop MDT."
1740 start mds1 $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
1741 wait_update_facet mds1 "$cmd.spill_threshold_pct" 0 ||
1742 error "spill target wasn't set"
1744 run_test 30 "persistent OST pool spilling"
1747 local MDT_DEV=$(mdsdevname mds1)
1748 local mdts=$(comma_list $(mdts_nodes))
1749 local pool1=${TESTNAME}-1
1750 local pool2=${TESTNAME}-2
1751 local pool3=${TESTNAME}-3
1752 local pool4=${TESTNAME}-4
1756 (( $MDS1_VERSION >= $(version_code 2.14.53) )) ||
1757 skip "Need MDS version at least 2.14.53"
1758 (( $OSTCOUNT >= 4 )) || skip "needs >= 4 OSTs"
1759 check_set_fallocate_or_skip
1761 pool_add $pool1 || error "Pool creation failed"
1762 pool_add_targets $pool1 0 0 || error "pool_add_targets failed"
1764 pool_add $pool2 || error "Pool creation failed"
1765 pool_add_targets $pool2 1 1 || error "pool_add_targets failed"
1767 pool_add $pool3 || error "Pool creation failed"
1768 pool_add_targets $pool3 2 2 || error "pool_add_targets failed"
1770 pool_add $pool4 || error "Pool creation failed"
1771 pool_add_targets $pool4 3 3 || error "pool_add_targets failed"
1773 fill_ost_pool $pool1 $threshold
1774 fill_ost_pool $pool2 $threshold
1775 fill_ost_pool $pool3 $threshold
1776 cancel_lru_locks osc
1777 local delay=$(do_facet mds1 lctl get_param -n lo[vd].*.qos_maxage |
1778 awk '{ print $1 * 2; exit; }')
1779 sleep $((delay + 1))
1781 do_nodes $mdts $LCTL set_param lod.*.pool.$pool1.spill_target="$pool2"
1782 do_nodes $mdts $LCTL set_param lod.*.pool.$pool1.spill_threshold_pct="$threshold"
1784 do_nodes $mdts $LCTL set_param lod.*.pool.$pool2.spill_target="$pool3"
1785 do_nodes $mdts $LCTL set_param lod.*.pool.$pool2.spill_threshold_pct="$threshold"
1787 do_nodes $mdts $LCTL set_param lod.*.pool.$pool3.spill_target="$pool4"
1788 do_nodes $mdts $LCTL set_param lod.*.pool.$pool3.spill_threshold_pct="$threshold"
1790 do_nodes $mdts $LCTL get_param lod.*.pool.*
1792 $LFS setstripe -p $pool1 $DIR/$tdir || error "can't set default layout"
1793 local tmpfile=$DIR/$tdir/$tfile-2
1795 $LFS getstripe $tmpfile | grep -q pool.*$pool4 || {
1796 $LFS getstripe $tmpfile
1797 error "old pool is not $pool4"
1800 run_test 31 "OST pool spilling chained"
1805 destroy_test_pools $FSNAME
1806 if ! combined_mgs_mds; then
1807 zconf_umount $mgs_HOST $MOUNT
1808 do_facet mgs "rm -rf $MOUNT"
1810 check_and_cleanup_lustre