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 stack_trap "rm -f $POOL_ROOT/file"
306 dd if=/dev/zero of=$POOL_ROOT/file bs=1M count=100
307 RC=$?; [[ $RC -eq 0 ]] ||
308 error "failed to write to $POOL_ROOT/file: $RC"
309 do_facet mgs lctl pool_remove $FSNAME.${POOL}1234567 OST0000
310 drain_pool ${POOL}1234567
312 destroy_pool ${POOL}1234567
314 run_test 1n "Pool with a 15 char pool name works well"
319 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
321 error "pool_add did not fail even though $POOL did not exist"
323 run_test 2a "pool_add: non-existant pool $POOL"
326 do_facet mgs lctl pool_add $FSNAME.${POOL}1234567890 \
327 $FSNAME-OST0000 2>/dev/null
329 error "pool_add did not fail even though pool name was invalid."
331 run_test 2b "pool_add: Invalid pool name"
333 # Testing various combinations of OST name list
338 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
339 [[ $? -ne 0 ]] || destroy_pool $POOL
341 create_pool_nofail $POOL
344 do_facet mgs lctl pool_add $FSNAME.$POOL OST0000
345 RC=$?; [[ $RC -eq 0 ]] ||
346 error "pool_add failed. $FSNAME $POOL OST0000: $RC"
347 do_facet mgs lctl pool_remove $FSNAME.$POOL OST0000
351 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
352 RC=$?; [[ $RC -eq 0 ]] ||
353 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000: $RC"
354 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
357 # 3. $FSNAME-OST0000_UUID
358 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
359 RC=$?; [[ $RC -eq 0 ]] ||
360 error "pool_add failed. $FSNAME $POOL $FSNAME-OST0000_UUID: $RC"
361 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
364 # 4. $FSNAME-OST[0,1,2,3,]
366 for i in $TGT_LIST; do TGT=${TGT}$(printf "%04x," $i); done
368 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT
369 [[ $? -eq 0 ]] || error "pool_add failed. $FSNAME.$POOL $TGT. $RC"
370 do_facet mgs lctl pool_remove $FSNAME.$POOL $TGT
373 # 5. $FSNAME-OST[0-5/1]
374 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT_ALL
375 RC=$?; [[ $RC -eq 0 ]] ||
376 error "pool_add failed. $FSNAME $POOL" "$TGT_ALL $RC"
377 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL |
378 sort -u | tr '\n' ' ' " "$TGT_UUID" ||
379 error "Add to pool failed"
380 do_facet mgs lctl pool_remove $FSNAME.$POOL $TGT_ALL
385 run_test 2c "pool_add: OST index combinations"
391 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
392 [[ $? -ne 0 ]] || destroy_pool $POOL
394 create_pool_nofail $POOL
396 TGT=$(printf "$FSNAME-OST%04x_UUID " $OSTCOUNT)
397 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT
398 RC=$?; [[ $RC -ne 0 ]] ||
399 error "pool_add succeeded for an OST ($TGT) that does not exist."
403 run_test 2d "pool_add: OSTs that don't exist should be rejected"
410 $LCTL get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
411 [[ $? -ne 0 ]] || destroy_pool $POOL
413 create_pool_nofail $POOL
415 TGT="$FSNAME-OST0000_UUID"
416 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT
417 wait_update_facet $SINGLEMDS \
418 "lctl pool_list $FSNAME.$POOL | sed '1d'" "$TGT" ||
419 error "Add $TGT to $FSNAME.$POOL failed"
420 RESULT=$(do_facet mgs \
421 "LOCALE=C $LCTL pool_add $FSNAME.$POOL $TGT 2>&1")
426 error "pool_add succeeded for an OST that was already in the pool."
428 [[ $(grep "already in pool" <<< $RESULT) ]] ||
429 error "pool_add failed as expected but error message not as expected."
433 run_test 2e "pool_add: OST already in a pool should be rejected"
436 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
437 [[ $? -ne 0 ]] || destroy_pool $POOL
440 lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
442 error "pool_remove did not fail even though pool did not exist."
444 run_test 3a "pool_remove: non-existant pool"
448 lctl pool_remove ${NON_EXISTANT_FS}.$POOL OST0000 2>/dev/null
450 error "pool_remove did not fail even though fsname did not exist."
452 run_test 3b "pool_remove: non-existant fsname"
455 do_facet mgs lctl pool_remove $FSNAME.p1234567891234567890 \
456 $FSNAME-OST0000 2>/dev/null
458 error "pool_remove did not fail even though pool name was invalid."
460 run_test 3c "pool_remove: Invalid pool name"
462 # Testing various combinations of OST name list
464 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
465 [[ $? -ne 0 ]] || destroy_pool $POOL
467 create_pool_nofail $POOL
468 do_facet mgs lctl pool_add $FSNAME.$POOL OST0000
469 do_facet mgs lctl pool_remove $FSNAME.$POOL OST0000
470 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL OST0000"
473 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
474 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
475 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000"
478 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
479 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
481 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000_UUID"
484 add_pool $POOL $TGT_ALL "$TGT_UUID"
485 do_facet mgs lctl pool_remove $FSNAME.$POOL $TGT_ALL
486 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL" $TGT_ALL
491 run_test 3d "pool_remove: OST index combinations"
494 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
495 [[ $? -ne 0 ]] || destroy_pool $POOL
497 do_facet mgs lctl pool_destroy $FSNAME.$POOL 2>/dev/null
499 error "pool_destroy did not fail even though pool did not exist."
501 run_test 4a "pool_destroy: non-existant pool"
504 do_facet mgs lctl pool_destroy ${NON_EXISTANT_FS}.$POOL 2>/dev/null
506 error "pool_destroy did not fail even though filesystem did not exist."
508 run_test 4b "pool_destroy: non-existant fs-name"
511 create_pool_nofail $POOL
512 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
514 do_facet mgs lctl pool_destroy ${FSNAME}.$POOL
515 [[ $? -ne 0 ]] || error "pool_destroy succeeded with a non-empty pool."
518 run_test 4c "pool_destroy: non-empty pool"
523 $LCMD pool_list 2>/dev/null
525 error "pool_list did not fail even though fsname missing."
527 destroy_pool $POOL 2>/dev/null
528 destroy_pool $POOL2 2>/dev/null
530 create_pool_nofail $POOL
531 create_pool_nofail $POOL2
532 $LCMD pool_list $FSNAME
533 [[ $? -eq 0 ]] || error "pool_list $FSNAME failed."
535 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT_ALL
537 $LCMD pool_list $FSNAME.$POOL
538 [[ $? -eq 0 ]] || error "pool_list $FSNAME.$POOL failed."
540 $LCMD pool_list ${NON_EXISTANT_FS} 2>/dev/null
542 error "pool_list did not fail for fsname $NON_EXISTANT_FS"
544 $LCMD pool_list ${FSNAME}.$NON_EXISTANT_POOL 2>/dev/null
546 error "pool_list did not fail for pool $NON_EXISTANT_POOL"
548 if [[ ! $(grep $SINGLEMDS <<< $LCMD) ]]; then
549 echo $LCMD pool_list $DIR
551 [[ $? -eq 0 ]] || error "pool_list failed for $DIR"
554 $LCMD pool_list ${DIR}/d1
555 [[ $? -eq 0 ]] || error "pool_list failed for ${DIR}/d1"
558 rm -rf ${DIR}nonexistant
559 $LCMD pool_list ${DIR}nonexistant 2>/dev/null
561 error "pool_list did not fail for invalid mountpoint ${DIR}nonexistant"
568 # Issue commands from client
571 run_test 5a "lfs pool_list from client"
574 sub_test_5 "do_facet $SINGLEMDS lctl"
576 run_test 5b "lctl pool_list from MDS"
579 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
580 local POOL_DIR=$POOL_ROOT/dir_tst
581 local POOL_FILE=$POOL_ROOT/file_tst
583 create_pool_nofail $POOL
585 do_facet $SINGLEMDS lctl pool_list $FSNAME
586 [[ $? -eq 0 ]] || error "pool_list $FSNAME failed."
588 add_pool $POOL $TGT_ALL "$TGT_UUID"
591 $LFS setstripe -c -1 -p $POOL $POOL_DIR
592 [[ $? -eq 0 ]] || error "$LFS setstripe -p $POOL failed."
593 check_dir_in_pool $POOL_DIR $POOL
595 # If an invalid pool name is specified, the command should fail
596 $LFS setstripe -c 2 -p $INVALID_POOL $POOL_DIR 2>/dev/null
597 [[ $? -ne 0 ]] || error "setstripe to invalid pool did not fail."
599 # lfs setstripe should work as before if a pool name is not specified.
600 $LFS setstripe -c -1 $POOL_DIR
601 [[ $? -eq 0 ]] || error "$LFS setstripe -c -1 $POOL_DIR failed."
602 $LFS setstripe -c -1 $POOL_FILE
603 [[ $? -eq 0 ]] || error "$LFS setstripe -c -1 $POOL_FILE failed."
605 # lfs setstripe should fail if a start index that is outside the
607 create_pool_nofail $POOL2
608 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
609 $LFS setstripe -i 1 -p $POOL2 $ROOT_POOL/$tfile 2>/dev/null
611 error "$LFS setstripe with start index outside the pool did not fail."
613 run_test 6 "getstripe/setstripe"
617 # Create a pool, stripe a directory and file with it
620 pool_add $pool || error "pool_add failed"
621 pool_add_targets $pool 0 1 || error "pool_add_targets failed"
623 $LFS setstripe -c 1 $DIR/$tdir/testfile1 --pool "$pool" ||
624 error "setstripe failed"
625 $LFS setstripe -c 1 $DIR/$tdir/testfile2 --pool "$FSNAME.$pool" ||
626 error "setstripe failed"
628 mkdir $DIR/$tdir/testdir
629 $LFS setstripe -c 1 $DIR/$tdir/testdir -p "$pool" ||
630 error "setstripe failed"
631 $LFS setstripe -c 1 $DIR/$tdir/testdir -p "$FSNAME.$pool" ||
632 error "setstripe failed"
634 rm -f $DIR/$tdir/testfile1
635 rm -f $DIR/$tdir/testfile2
636 rmdir $DIR/$tdir/testdir
638 destroy_pool_int $FSNAME.$pool
643 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
647 # Generate pool with random name from 1 to 15 characters
649 POOLNAME=$(echo $$$RANDOM$RANDOM |
650 tr -dc 'a-zA-Z0-9' | fold -w $i |
652 echo set poolname to $POOLNAME
653 helper_test_7a $POOLNAME
656 run_test 7a "create various pool name"
662 [ $? -ne 22 ] && error "can create a pool with no fsname"
666 [ $? -ne 22 ] && error "can create a pool with no name"
669 create_pool $FSNAME.0123456789^bdef
670 [ $? -ne 22 ] && error "can create a pool with an invalid name"
673 create_pool $FSNAME.0123456789abdefg
674 [ $? -ne 36 ] && error "can create a pool with a name too long"
678 run_test 7b "try to create pool name with invalid lengths or names"
682 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
686 # Create a pool with 15 letters
687 local pool=0123456789abcde
688 pool_add $pool || error "pool_add failed"
689 pool_add_targets $pool 0 1 || error "pool_add_targets failed"
691 # setstripe with the same pool name plus 1 letter
692 $LFS setstripe -c 1 $DIR/$tdir/testfile1 --pool "${pool}X" &&
693 error "setstripe succedeed"
695 rm -f $DIR/$tdir/testfile1
697 destroy_pool_int $FSNAME.$pool
699 run_test 7c "create a valid pool name and setstripe with a bad one"
702 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
704 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
706 create_pool_nofail $POOL
707 create_pool_nofail $POOL2
709 local start=$(printf %04x $((TGT_FIRST + 1)))
710 do_facet mgs lctl pool_add $FSNAME.$POOL2 \
711 $FSNAME-OST[$start-$TGT_MAX/2]
713 add_pool $POOL $TGT_HALF "$TGT_UUID2"
715 create_dir $POOL_ROOT/dir1 $POOL
716 create_dir $POOL_ROOT/dir2 $POOL2
719 createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
720 error "createmany $POOL_ROOT/dir1/$tfile failed!"
722 for file in $POOL_ROOT/dir1/*; do
723 check_file_in_pool $file $POOL
726 createmany -o $POOL_ROOT/dir2/$tfile $numfiles ||
727 error "createmany $POOL_ROOT/dir2/$tfile failed!"
728 for file in $POOL_ROOT/dir2/*; do
729 check_file_in_pool $file $POOL2
732 rm -rf $POOL_ROOT/dir?
736 run_test 11 "OSTs in overlapping/multiple pools"
739 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
741 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >=3 OSTs"
743 create_pool_nofail $POOL
744 create_pool_nofail $POOL2
746 local start=$(printf %04x $((TGT_FIRST + 1)))
747 do_facet mgs lctl pool_add $FSNAME.$POOL2 \
748 $FSNAME-OST[$start-$TGT_MAX/2]
750 add_pool $POOL $TGT_HALF "$TGT_UUID2"
752 echo creating some files in $POOL and $POOL2
754 create_dir $POOL_ROOT/dir1 $POOL
755 create_dir $POOL_ROOT/dir2 $POOL2
756 create_file $POOL_ROOT/file1 $POOL
757 create_file $POOL_ROOT/file2 $POOL2
759 echo Checking the files created
760 check_file_in_pool $POOL_ROOT/file1 $POOL
761 check_file_in_pool $POOL_ROOT/file2 $POOL2
763 echo Changing the pool membership
764 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST[$TGT_FIRST]
765 do_facet mgs lctl pool_list $FSNAME.$POOL
766 FIRST_UUID=$(echo $TGT_UUID | awk '{print $1}')
767 add_pool $POOL2 $FSNAME-OST[$TGT_FIRST] "$FIRST_UUID "
768 do_facet mgs lctl pool_list $FSNAME.$POOL2
770 echo Checking the files again
771 check_dir_in_pool $POOL_ROOT/dir1 $POOL
772 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
773 check_file_in_osts $POOL_ROOT/file1 "$TGT_LIST2"
774 check_file_in_osts $POOL_ROOT/file2 "$(seq 0x$start 2 0x$TGT_MAX)"
776 echo Creating some more files
777 create_dir $POOL_ROOT/dir3 $POOL
778 create_dir $POOL_ROOT/dir4 $POOL2
779 create_file $POOL_ROOT/file3 $POOL
780 create_file $POOL_ROOT/file4 $POOL2
782 echo Checking the new files
783 check_file_in_pool $POOL_ROOT/file3 $POOL
784 check_file_in_pool $POOL_ROOT/file4 $POOL2
788 run_test 12 "OST Pool Membership"
791 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >= 3 OSTs"
793 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
797 create_pool_nofail $POOL
798 add_pool $POOL $TGT_ALL "$TGT_UUID"
800 create_dir $POOL_ROOT/dir1 $POOL -1
801 createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
802 error "createmany $POOL_ROOT/dir1/$tfile failed!"
803 for file in $POOL_ROOT/dir1/*; do
804 check_file_in_pool $file $POOL $OSTCOUNT
807 create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
808 create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST + 1))
809 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST + 2))
810 check_file_in_osts $POOL_ROOT/dir1/file1 $((16#$TGT_FIRST))
811 check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST + 1))"
812 check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST + 2))"
814 create_dir $POOL_ROOT/dir2 $POOL $count
815 createmany -o $POOL_ROOT/dir2/$tfile- $numfiles ||
816 error "createmany $POOL_ROOT/dir2/$tfile- failed!"
817 for file in $POOL_ROOT/dir2/*; do
818 check_file_in_pool $file $POOL $count
821 create_dir $POOL_ROOT/dir3 $POOL $count $((TGT_FIRST + 1))
822 createmany -o $POOL_ROOT/dir3/$tfile- $numfiles ||
823 error "createmany $POOL_ROOT/dir3/$tfile- failed!"
824 for file in $POOL_ROOT/dir3/*; do
825 check_file_in_pool $file $POOL $count
828 create_dir $POOL_ROOT/dir4 $POOL 1
829 createmany -o $POOL_ROOT/dir4/$tfile- $numfiles ||
830 error "createmany $POOL_ROOT/dir4/$tfile- failed!"
831 for file in $POOL_ROOT/dir4/*; do
832 check_file_in_pool $file $POOL 1
835 create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST + 2))
836 createmany -o $POOL_ROOT/dir5/$tfile- $numfiles ||
837 error "createmany $POOL_ROOT/dir5/$tfile- failed!"
838 for file in $POOL_ROOT/dir5/*; do
839 check_file_in_pool $file $POOL 1
842 rm -rf $POOL_ROOT/dir[1-5]/
846 run_test 13 "Striping characteristics in a pool"
849 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >= 3 OSTs"
851 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
855 [ $OSTSIZE -gt $((MAXFREE / OSTCOUNT)) ] &&
856 skip_env "OST size $OSTSIZE is larger than $((MAXFREE / OSTCOUNT))"
858 create_pool_nofail $POOL
859 create_pool_nofail $POOL2
861 add_pool $POOL $TGT_HALF "$TGT_UUID2"
862 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
864 create_dir $POOL_ROOT/dir1 $POOL 1
865 create_file $POOL_ROOT/dir1/file $POOL 1
866 local ost=$($LFS getstripe -i $POOL_ROOT/dir1/file)
868 while [[ $i -lt $numfiles ]]; do
870 [[ $ost -gt $((16#$TGT_MAX)) ]] && ost=$TGT_FIRST
872 # echo "Iteration: $i OST: $ost"
873 create_file $POOL_ROOT/dir1/file${i} $POOL 1
874 check_file_in_pool $POOL_ROOT/dir1/file${i} $POOL
878 # Fill up OST0 until it is nearly full.
879 # Create 9 files of size OST0_SIZE/10 each.
880 create_dir $POOL_ROOT/dir2 $POOL2 1
881 $LFS df $POOL_ROOT/dir2
882 OST0_SIZE=$($LFS df $POOL_ROOT/dir2 | awk '/\[OST:0\]/ { print $4 }')
883 FILE_SIZE=$((OST0_SIZE/1024/10))
884 echo "Filling OST0 with 9 files of ${FILE_SIZE}MB in $POOL_ROOT/dir2"
886 while [[ $i -lt 10 ]]; do
887 dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1M count=$FILE_SIZE
890 sleep 1 # get new statfs info
891 $LFS df $POOL_ROOT/dir2
893 # OST $TGT_FIRST is no longer favored; but it may still be used.
894 create_dir $POOL_ROOT/dir3 $POOL 1
895 create_file $POOL_ROOT/dir3/file $POOL 1
896 createmany -o $POOL_ROOT/dir3/$tfile- $numfiles ||
897 error "createmany $POOL_ROOT/dir3/$tfile- failed!"
898 for file in $POOL_ROOT/dir3/*; do
899 check_file_in_pool $file $POOL
906 run_test 14 "Round robin and QOS striping within a pool"
909 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
913 while [[ $i -lt $OSTCOUNT ]]; do
914 create_pool_nofail $POOL${i}
916 local tgt=$(printf "$FSNAME-OST%04x_UUID " $i)
917 add_pool $POOL${i} "$FSNAME-OST[$(printf %04x $i)]" "$tgt"
918 create_dir $POOL_ROOT/dir${i} $POOL${i}
919 createmany -o $POOL_ROOT/dir$i/$tfile $numfiles ||
920 error "createmany $POOL_ROOT/dir$i/$tfile failed!"
922 for file in $POOL_ROOT/dir$i/*; do
923 check_file_in_osts $file $i
931 run_test 15 "One directory per OST/pool"
934 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
938 create_pool_nofail $POOL
940 add_pool $POOL $TGT_HALF "$TGT_UUID2"
942 local dir=$POOL_ROOT/$tdir
943 create_dir $dir $POOL
945 for i in $(seq 1 10); do
950 createmany -o $dir/$tfile $numfiles ||
951 error "createmany $dir/$tfile failed!"
953 for file in $dir/*; do
954 check_file_in_pool $file $POOL
957 rm -rf $POOL_ROOT/$tdir
961 run_test 16 "Inheritance of pool properties"
964 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
968 create_pool_nofail $POOL
970 add_pool $POOL $TGT_ALL "$TGT_UUID"
972 local dir=$POOL_ROOT/dir
973 create_dir $dir $POOL
975 createmany -o $dir/${tfile}1_ $numfiles ||
976 error "createmany $dir/${tfile}1_ failed!"
978 for file in $dir/*; do
979 check_file_in_pool $file $POOL
984 createmany -o $dir/${tfile}2_ $numfiles ||
985 error "createmany $dir/${tfile}2_ failed!"
990 run_test 17 "Referencing an empty pool"
999 wait_delete_completed >/dev/null # give pending IO chance to go to disk
1000 stat=$(createmany -o $cdir/${tfile} -t $numsec | tail -1)
1001 files=$(echo $stat | cut -f 2 -d ' ')
1003 unlinkmany $cdir/${tfile} $files > /dev/null
1010 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1013 local plaindir=$POOL_ROOT/plaindir
1014 local pooldir=$POOL_ROOT/pooldir
1020 for i in $(seq 1 $iter); do
1021 echo "Create performance, iteration $i, $numsec seconds x 3"
1023 local files1=$(create_perf $plaindir $numsec)
1024 [[ $files1 -eq 0 ]] && error "Zero files created without pool"
1026 echo "iter $i: $files1 creates without pool"
1028 create_pool_nofail $POOL > /dev/null
1029 add_pool $POOL $TGT_ALL "$TGT_UUID" > /dev/null
1030 create_dir $pooldir $POOL
1031 local files2=$(create_perf $pooldir $numsec)
1032 [[ $files2 -eq 0 ]] && error "Zero files created with pool"
1034 echo "iter $i: $files2 creates with pool"
1036 destroy_pool $POOL > /dev/null
1037 local files3=$(create_perf $pooldir $numsec)
1038 [[ $files3 -eq 0 ]] &&
1039 error "Zero files created with missing pool"
1041 echo "iter $i: $files3 creates with missing pool"
1046 echo Avg files created in $numsec seconds without pool: $((f1 / iter))
1047 echo Avg files created in $numsec seconds with pool: $((f2 / iter))
1048 echo Avg files created in $numsec seconds missing pool: $((f3 / iter))
1050 # Set this high until we establish a baseline for what the degradation
1054 diff=$((($f1 - $f2) * 100 / $f1))
1055 echo "No pool / wide pool: $diff %."
1056 [ $diff -gt $max ] &&
1057 error_ignore bz23408 "Degradation with wide pool is $diff% > $max%"
1060 diff=$((($f1 - $f3) * 100 / $f1))
1061 echo "No pool / missing pool: $diff %."
1062 [ $diff -gt $max ] &&
1063 error_ignore bz23408 "Degradation with wide pool is $diff% > $max%"
1067 run_test 18 "File create in a directory which references a deleted pool"
1070 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1072 local dir1=$POOL_ROOT/dir1
1073 local dir2=$POOL_ROOT/dir2
1076 create_pool_nofail $POOL
1078 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1080 create_dir $dir1 $POOL
1081 createmany -o $dir1/${tfile} $numfiles ||
1082 error "createmany $dir1/${tfile} failed!"
1083 for file in $dir1/*; do
1084 check_file_in_pool $file $POOL
1088 createmany -o $dir2/${tfile} $numfiles ||
1089 error "createmany $dir2/${tfile} failed!"
1090 for file in $dir2/*; do
1091 check_file_not_in_pool $file $POOL
1098 run_test 19 "Pools should not come into play when not specified"
1101 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
1103 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1105 local dir1=$POOL_ROOT/dir1
1106 local dir2=$dir1/dir2
1107 local dir3=$dir1/dir3
1111 create_pool_nofail $POOL
1112 create_pool_nofail $POOL2
1114 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1116 local start=$(printf %04x $((TGT_FIRST + 1)))
1117 TGT=$(for i in $(seq 0x$start 2 0x$TGT_MAX); do \
1118 printf "$FSNAME-OST%04x_UUID " $i; done)
1119 add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1121 create_dir $dir1 $POOL
1122 create_file $dir1/file1 $POOL2 # Should replace $dir1 pool with $POOL2
1123 create_dir $dir2 $POOL2
1124 touch $dir2/file2 # Should inherit $POOL2 from $dir2
1125 mkdir $dir3 # Should inherit $POOL from $dir1
1126 $LFS setstripe -c 1 $dir3 # Should remain existing $POOL
1127 touch $dir3/file3 # Should inherit $POOL from $dir3
1128 $LFS setstripe -c 1 $dir2/file4 # Should inherit $POOL2 from dir2
1129 $LFS setstripe -S 64K $dir1/file5 # Should inderit $POOL from $dir1
1131 check_file_in_pool $dir1/file1 $POOL2
1132 check_file_in_pool $dir2/file2 $POOL2
1133 check_dir_not_in_pool $dir3 $POOL2
1134 check_file_not_in_pool $dir3/file3 $POOL2
1135 check_file_not_in_pool $dir2/file4 $POOL
1136 check_file_not_in_pool $dir1/file5 $POOL2
1138 if [ "$MDS1_VERSION" -ge $(version_code 2.10.54) ]; then
1139 check_dir_in_pool $dir3 $POOL
1140 check_file_in_pool $dir3/file3 $POOL
1141 check_file_in_pool $dir2/file4 $POOL2
1142 check_file_in_pool $dir1/file5 $POOL
1149 run_test 20 "Different pools in a directory hierarchy."
1152 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1153 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1157 local dir=$POOL_ROOT/dir
1159 create_pool_nofail $POOL
1161 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1163 create_dir $dir $POOL $OSTCOUNT
1164 create_file $dir/file1 $POOL $OSTCOUNT
1165 $LFS getstripe -v $dir/file1
1166 check_file_in_pool $dir/file1 $POOL
1172 run_test 21 "OST pool with fewer OSTs than stripe count"
1180 for c in $(seq 1 10); do
1181 echo "Pool $pool, iteration $c"
1182 do_facet mgs lctl pool_add $FSNAME.$pool \
1183 OST[$TGT_FIRST-$TGT_MAX/$step] 2>/dev/null
1184 local TGT_SECOND=$(printf %04x $((TGT_FIRST + $step)))
1185 if [ $((16#$TGT_SECOND)) -le $((16#$TGT_MAX)) ]; then
1186 do_facet mgs lctl pool_remove $FSNAME.$pool \
1187 OST[$TGT_SECOND-$TGT_MAX/$step]
1190 echo loop for $pool complete
1194 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1195 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1199 create_pool_nofail $POOL
1200 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
1201 create_pool_nofail $POOL2
1202 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
1207 create_dir $POOL_ROOT $POOL
1208 createmany -o $POOL_ROOT/${tfile} $numfiles ||
1209 error "createmany $POOL_ROOT/${tfile} failed!"
1214 run_test 22 "Simultaneous manipulation of a pool"
1217 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1218 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1221 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS ||
1222 skip_env "User $RUNAS_ID does not exist - skipping"
1226 local BUNIT_SZ=1024 # min block quota unit(kB)
1227 local LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1)))
1228 local dir=$POOL_ROOT/dir
1229 local file="$dir/$tfile-quota"
1231 create_pool_nofail $POOL
1233 local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
1234 printf "$FSNAME-OST%04x_UUID " $i; done)
1235 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1236 create_dir $dir $POOL
1238 # XXX remove the interoperability code once we drop the old server
1239 # ( < 2.3.50) support.
1240 if [ "$MDS1_VERSION" -lt $(version_code 2.3.50) ]; then
1241 $LFS quotaoff -ug $MOUNT
1242 $LFS quotacheck -ug $MOUNT
1244 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1245 do_facet mgs $PERM_CMD \
1246 osd-*.$FSNAME-OST*.quota_slave.enabled=ug
1248 do_facet mgs $PERM_CMD $FSNAME.quota.ost=ug
1253 $LFS setquota -u $RUNAS_ID -b $LIMIT -B $LIMIT $dir
1255 $LFS quota -v -u $RUNAS_ID $dir
1257 $LFS setstripe -c 1 -p $POOL $file
1258 chown $RUNAS_ID.$RUNAS_GID $file
1261 # This does two "dd" runs to ensure that the quota failure is returned
1262 # to userspace when we check. The first "dd" might otherwise complete
1263 # without error if it is only writing into cache.
1264 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
1265 count=$((BUNIT_SZ*2)) 2>&1)
1266 echo $stat | grep "Disk quota exceeded" > /dev/null
1267 if [ $? -eq 0 ]; then
1268 $LFS quota -v -u $RUNAS_ID $dir
1269 cancel_lru_locks osc
1270 stack_trap "rm -f $file"
1271 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
1272 count=$BUNIT_SZ seek=$((BUNIT_SZ*2)) 2>&1)
1275 [[ $RC -eq 0 ]] && error "second dd did not fail."
1276 echo $stat | grep "Disk quota exceeded" > /dev/null
1277 [[ $? -eq 1 ]] && error "second dd did not fail with EDQUOT."
1279 log "first dd failed with EDQUOT."
1281 $LFS quota -v -u $RUNAS_ID $dir
1283 run_test 23a "OST pools and quota"
1286 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1287 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1290 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS || {
1291 skip_env "User $RUNAS_ID does not exist - skipping"
1296 local dir=$POOL_ROOT/dir
1297 local file="$dir/$tfile-quota"
1299 create_pool_nofail $POOL
1301 local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
1302 printf "$FSNAME-OST%04x_UUID " $i; done)
1303 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1304 create_dir $dir $POOL
1306 local maxfree=$((1024 * 1024 * 30)) # 30G
1307 local AVAIL=$(lfs_df -p $POOL $dir | awk '/summary/ { print $4 }')
1308 [ $AVAIL -gt $maxfree ] &&
1309 skip_env "Filesystem space $AVAIL is larger than " \
1312 echo "OSTCOUNT=$OSTCOUNT, OSTSIZE=$OSTSIZE, AVAIL=$AVAIL"
1313 echo "MAXFREE=$maxfree, SLOW=$SLOW"
1315 # XXX remove the interoperability code once we drop the old server
1316 # ( < 2.3.50) support.
1317 if [ "$MDS1_VERSION" -lt $(version_code 2.3.50) ]; then
1318 $LFS quotaoff -ug $MOUNT
1320 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1321 do_facet mgs $PERM_CMD \
1322 osd-*.$FSNAME-OST*.quota_slave.enabled=none
1324 do_facet mgs $PERM_CMD $FSNAME.quota.ost=none
1329 chown $RUNAS_ID.$RUNAS_ID $dir
1333 local stime=$(date +%s)
1337 local maxtime=300 # minimum speed: 5GB / 300sec ~= 17MB/s
1338 while [ $RC -eq 0 ]; do
1340 stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file}$i bs=1M \
1341 count=$((5 * 1024)) 2>&1)
1343 TOTAL=$((TOTAL + 1024 * 1024 * 5))
1344 echo "[$i iteration] $stat"
1345 echo "total written: $TOTAL"
1348 elapsed=$((etime - stime))
1349 echo "stime=$stime, etime=$etime, elapsed=$elapsed"
1351 if [ $RC -eq 1 ]; then
1352 echo $stat | grep -q "Disk quota exceeded"
1354 error "dd failed with EDQUOT with quota off"
1356 echo $stat | grep -q "No space left on device"
1358 error "dd did not fail with ENOSPC"
1359 elif [ $TOTAL -gt $AVAIL ]; then
1360 error "dd didn't fail with ENOSPC ($TOTAL > $AVAIL)"
1361 elif [ $i -eq 1 -a $elapsed -gt $maxtime ]; then
1362 log "The first 5G write used $elapsed (> $maxtime) " \
1363 "seconds, terminated"
1371 run_test 23b "OST pools and OOS"
1374 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1375 [[ "$MDS1_VERSION" -ge $(version_code 2.8.56) ]] ||
1376 skip "Need server version newer than 2.8.55"
1378 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1385 create_pool_nofail $POOL
1387 add_pool $POOL $TGT_ALL "$TGT_UUID"
1389 create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1391 mkdir $POOL_ROOT/dir2
1392 $LFS setstripe -p $POOL -S 65536 -i 0 -c 1 $POOL_ROOT/dir2 ||
1393 error "$LFS setstripe $POOL_ROOT/dir2 failed"
1395 mkdir $POOL_ROOT/dir3
1396 $LFS setstripe -S 65536 -i 0 -c 1 $POOL_ROOT/dir3 ||
1397 error "$LFS setstripe $POOL_ROOT/dir3 failed"
1399 mkdir $POOL_ROOT/dir4
1401 for i in 1 2 3 4; do
1402 dir=${POOL_ROOT}/dir${i}
1411 createmany -o $dir/${tfile} $numfiles ||
1412 error "createmany $dir/${tfile} failed!"
1413 pool=$($LFS getstripe --pool $dir)
1414 index=$($LFS getstripe -i $dir)
1415 size=$($LFS getstripe -S $dir)
1416 count=$($LFS getstripe -c $dir)
1418 for file in $dir/*; do
1419 if [ "$pool" != "" ]; then
1420 check_file_in_pool $file $pool
1422 pool1=$($LFS getstripe --pool $file)
1423 count1=$($LFS getstripe -c $file)
1424 size1=$($LFS getstripe -S $file)
1425 [[ "$pool" != "$pool1" ]] &&
1426 error "Pool '$pool' not on $file:$pool1"
1427 [[ "$count" != "$count1" ]] &&
1428 [[ "$count" != "-1" ]] &&
1429 error "Stripe count $count not on"\
1431 [[ "$count1" != "$OSTCOUNT" ]] &&
1432 [[ "$count" = "-1" ]] &&
1433 error "Stripe count $count1 not on"\
1435 [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] &&
1436 error "Stripe size $size not on $file:$size1"
1444 run_test 24 "Independence of pool from other setstripe parameters"
1447 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1449 mkdir_on_mdt0 $POOL_ROOT
1451 for i in $(seq 10); do
1452 create_pool_nofail $POOL$i
1453 do_facet mgs "lctl pool_add $FSNAME.$POOL$i OST0000; sync"
1454 wait_update $HOSTNAME "lctl get_param -n \
1455 lov.$FSNAME-*.pools.$POOL$i | sort -u |
1456 tr '\n' ' ' " "$FSNAME-OST0000_UUID " >/dev/null ||
1457 error "pool_add failed: $1; $2"
1459 facet_failover $SINGLEMDS ||
1460 error "failed to failover $SINGLEMDS"
1461 wait_osc_import_state $SINGLEMDS ost FULL
1465 # Veriy that the pool got created and is usable
1466 df $POOL_ROOT > /dev/null
1469 # Make sure OST0 can be striped on
1470 $LFS setstripe -i 0 -c 1 $POOL_ROOT/$tfile
1471 local STR=$($LFS getstripe -i $POOL_ROOT/$tfile)
1472 rm $POOL_ROOT/$tfile
1473 if [[ "$STR" == "0" ]]; then
1474 echo "Creating a file in pool$i"
1475 create_file $POOL_ROOT/file$i $POOL$i || break
1476 check_file_in_pool $POOL_ROOT/file$i $POOL$i || break
1478 echo "OST 0 seems to be unavailable. Try later."
1484 run_test 25 "Create new pool and restart MDS"
1487 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >= 3 OSTs"
1488 local dev=$(mdsdevname ${SINGLEMDS//mds/})
1489 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1493 create_pool_nofail $POOL2
1495 do_facet mgs "lctl pool_add $FSNAME.$POOL2 OST0000; sync"
1496 wait_update $HOSTNAME "lctl get_param -n \
1497 lov.$FSNAME-*.pools.$POOL2 | sort -u |
1498 grep $FSNAME-OST0000_UUID " "$FSNAME-OST0000_UUID" ||
1499 error "pool_add failed: $1; $2"
1501 do_facet mgs "lctl pool_add $FSNAME.$POOL2 OST0002; sync"
1502 wait_update $HOSTNAME "lctl get_param -n \
1503 lov.$FSNAME-*.pools.$POOL2 | sort -u |
1504 grep $FSNAME-OST0002_UUID" "$FSNAME-OST0002_UUID" ||
1505 error "pool_add failed: $1; $2"
1507 # Veriy that the pool got created and is usable
1509 echo "Creating files in $POOL2"
1511 for ((i = 0; i < 10; i++)); do
1512 #OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
1513 #Fail OST0000 to ensure objects create on
1514 #the other OST in the pool
1515 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
1516 do_facet $SINGLEMDS lctl set_param fail_val=0
1517 create_file $POOL_ROOT/file$i $POOL2 1 -1 || break
1518 do_facet $SINGLEMDS lctl set_param fail_loc=0
1519 check_file_in_pool $POOL_ROOT/file$i $POOL2 || break
1523 run_test 26 "Choose other OSTs in the pool first in the creation remedy"
1526 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs"
1530 local count=$OSTCOUNT
1532 create_pool_nofail $POOL
1533 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT_ALL
1534 wait_update_facet $SINGLEMDS \
1535 "lctl pool_list $FSNAME.$POOL | wc -l" "$((OSTCOUNT + 1))" ||
1536 error "MDS: pool_list $FSNAME.$POOL failed"
1537 osts=$(list_pool $FSNAME.$POOL)
1538 for ost in ${osts}; do
1540 if [[ $count -eq 0 ]]; then
1541 #define OBD_FAIL_OST_LIST_ASSERT 0x239
1542 do_facet $SINGLEMDS \
1543 $LCTL set_param fail_loc=0x239 fail_val=10
1544 list_pool $FSNAME.$POOL &
1547 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
1548 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $ost
1550 do_facet $SINGLEMDS $LCTL set_param fail_val=0
1552 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $ost
1557 run_test 27 "Race pool_list and pool_remove"
1560 create_pool_nofail $POOL
1561 create_pool_nofail $POOL2
1562 add_pool $POOL $TGT_ALL "$TGT_UUID"
1563 add_pool $POOL2 $TGT_ALL "$TGT_UUID"
1565 start_full_debug_logging
1566 #$LFS setstripe -E 4M -c 1 -p $POOL -E 16M -c 2 $DIR/$tfile
1567 $LFS setstripe -c 1 -p $POOL $DIR/$tfile
1568 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=1 seek=16
1569 local csum=$(cksum $DIR/$tfile)
1570 $LFS getstripe $DIR/$tfile
1571 local pool="$($LFS getstripe -p $DIR/$tfile)"
1572 [[ "$pool" == "$POOL" ]] ||
1573 error "$tfile is in '$pool', not created on $POOL"
1574 $LFS_MIGRATE -y -p $POOL2 $DIR/$tfile ||
1575 error "migrate $tfile to $POOL2 failed"
1576 $LFS getstripe $DIR/$tfile
1577 pool="$($LFS getstripe -p $DIR/$tfile)"
1578 [[ "$pool" == "$POOL2" ]] ||
1579 error "$tfile is in '$pool', not migrated to $POOL2"
1580 local csum2=$(cksum $DIR/$tfile)
1581 [[ "$csum" == "$csum2" ]] || error "checksum error after migration"
1582 stop_full_debug_logging
1584 run_test 28 "lfs_migrate with pool name"
1586 function fill_ost_pool() {
1589 local tmpfile=$DIR/$tdir/$tfile-$pool-filler
1592 lfs setstripe $tmpfile -p $pool -c -1
1594 local dfa=($(lfs_df -p $pool | grep _summary))
1595 local total=${dfa[1]}
1596 local used=${dfa[2]}
1597 local towrite=$(( (total * (threshold + 1) / 100) - used ))
1599 echo "total $total, used $used, towrite $towrite"
1600 (( towrite > 0 )) && {
1601 fallocate -l$((towrite * 1024)) $tmpfile ||
1602 error "can't fallocate"
1607 local pool1=${TESTNAME}-1
1608 local pool2=${TESTNAME}-2
1610 local prefix="lod.$FSNAME-MDT0000*.pool.$pool1"
1611 local cmd="$LCTL get_param -n $prefix"
1615 (( $MDS1_VERSION >= $(version_code 2.14.53) )) ||
1616 skip "Need MDS version at least 2.14.53"
1617 (( $OSTCOUNT >= 4 )) || skip "needs >= 4 OSTs"
1618 check_set_fallocate_or_skip
1620 mkdir_on_mdt0 $DIR/$tdir
1621 stack_trap "rm -rf $DIR/$tdir"
1623 pool_add $pool1 || error "Pool creation failed"
1624 pool_add_targets $pool1 0 1 || error "pool_add_targets failed"
1626 pool_add $pool2 || error "Pool creation failed"
1627 pool_add_targets $pool2 2 3 || error "pool_add_targets failed"
1629 do_facet mds1 $LCTL set_param $prefix.spill_target=$pool2
1630 do_facet mds1 $LCTL set_param $prefix.spill_threshold_pct=$threshold
1631 stack_trap "do_facet mds1 $LCTL set_param $prefix.spill_threshold_pct=0"
1633 [[ $(do_facet mds1 "$cmd.spill_target") == "$pool2" ]] ||
1634 error "spill target wasn't set"
1635 [[ $(do_facet mds1 "$cmd.spill_threshold_pct") == "$threshold" ]] ||
1636 error "spill threshold wasn't set"
1637 before=$(do_facet mds1 "$cmd.spill_hit")
1638 lfs_df -p $pool1 | grep summary
1639 fill_ost_pool $pool1 $threshold
1640 cancel_lru_locks osc
1641 local delay=$(do_facet mds1 lctl get_param -n lo[vd].*.qos_maxage |
1642 awk '{ print $1 * 2; exit; }')
1643 sleep $((delay + 1))
1644 lfs_df -p $pool1 | grep summary
1646 # in a directory with default striping
1647 $LFS setstripe -p $pool1 $DIR/$tdir || error "can't set default layout"
1648 touch $DIR/$tdir/$tfile-2
1649 [[ $($LFS getstripe -p $DIR/$tdir/$tfile-2) == "$pool2" ]] || {
1650 $LFS getstripe $DIR/$tdir/$tfile-2
1651 error "old pool on $tfile-2"
1653 after=$(do_facet mds1 "$cmd.spill_hit")
1654 (( after == before + 1 )) || error "after $after != before $before + 1"
1656 # when striping is specified explicitly
1657 $LFS setstripe -p $pool1 $DIR/$tdir/$tfile-3 || error "can't setstripe"
1658 touch $DIR/$tdir/$tfile-3
1659 [[ $($LFS getstripe -p $DIR/$tdir/$tfile-3) == "$pool2" ]] || {
1660 $LFS getstripe $DIR/$tdir/$tfile-3
1661 error "old pool on $tfile-3"
1663 after=$(do_facet mds1 "$cmd.spill_hit")
1664 (( after == before + 2 )) || error "after $after != before $before + 2"
1666 # spill is revalidated at object creation
1667 wait_update_facet mds1 "$cmd.spill_is_active" "1" ||
1668 error "spilling is still inactive"
1670 rm -f $DIR/$tdir/$tfile* || error "can't rm $DIR/$tfile*"
1671 wait_delete_completed
1675 touch $DIR/$tdir/$tfile-2
1676 [[ $($LFS getstripe -p $DIR/$tdir/$tfile-2) == "$pool1" ]] || {
1677 $LFS getstripe $DIR/$tdir/$tfile-2
1678 error "new pool != $pool1"
1680 # spill is revaluated at object creation
1681 wait_update_facet mds1 "$cmd.spill_is_active" "0" ||
1682 error "spilling is still active"
1684 do_facet mds1 "$LCTL set_param $prefix.spill_threshold_pct=0"
1685 [[ $(do_facet mds1 "$cmd.spill_threshold_pct") == "0" ]] ||
1686 error "spill threshold wasn't reset"
1688 run_test 29 "check OST pool spilling"
1691 local MDT_DEV=$(mdsdevname 1)
1692 local mdts=$(comma_list $(mdts_nodes))
1693 local pool1=${TESTNAME}-1
1694 local pool2=${TESTNAME}-2
1697 local prefix="lod.$FSNAME-MDT0000*.pool.$pool1"
1698 local cmd="$LCTL get_param -n $prefix"
1700 (( $MDS1_VERSION >= $(version_code 2.14.53) )) ||
1701 skip "Need MDS version at least 2.14.53"
1702 (( $OSTCOUNT >= 4 )) || skip "needs >= 4 OSTs"
1704 pool_add $pool1 || error "Pool creation failed"
1705 pool_add_targets $pool1 0 1 || error "pool_add_targets failed"
1707 pool_add $pool2 || error "Pool creation failed"
1708 pool_add_targets $pool2 2 3 || error "pool_add_targets failed"
1711 do_facet mds1 $LCTL set_param $prefix.spill_target="0123456789ABCDEF" &&
1713 do_facet mds1 $LCTL set_param $prefix.spill_target="$pool1-2" &&
1714 error "non-exising pool"
1715 do_facet mds1 $LCTL set_param $prefix.spill_target="$pool1" &&
1717 do_facet mds1 $LCTL set_param $prefix.spill_threshold_pct="101" &&
1719 do_facet mds1 $LCTL set_param $prefix.spill_threshold_pct="-1" &&
1722 # set persistent spilling
1723 do_facet mgs $LCTL set_param -P $prefix.spill_target="$pool2"
1724 do_facet mgs $LCTL set_param -P $prefix.spill_threshold_pct=$threshold
1725 wait_update_facet mds1 "$cmd.spill_target" "$pool2" ||
1726 error "spill target wasn't set"
1727 wait_update_facet mds1 "$cmd.spill_threshold_pct" $threshold ||
1728 error "spill target wasn't set"
1730 stop mds1 || error "Fail to stop MDT."
1731 start mds1 $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
1732 wait_update_facet mds1 "$cmd.spill_target" "$pool2" ||
1733 error "spill target wasn't set after restart"
1734 wait_update_facet mds1 "$cmd.spill_threshold_pct" $threshold ||
1735 error "spill target wasn't set after restart"
1737 # now reset spilling
1738 do_facet mgs $LCTL set_param -P $prefix.spill_threshold_pct=0
1739 wait_update_facet mds1 "$cmd.spill_threshold_pct" 0 ||
1740 error "spill target wasn't set"
1742 stop mds1 || error "Fail to stop MDT."
1743 start mds1 $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
1744 wait_update_facet mds1 "$cmd.spill_threshold_pct" 0 ||
1745 error "spill target wasn't set"
1747 run_test 30 "persistent OST pool spilling"
1750 local MDT_DEV=$(mdsdevname mds1)
1751 local mdts=$(comma_list $(mdts_nodes))
1752 local pool1=${TESTNAME}-1
1753 local pool2=${TESTNAME}-2
1754 local pool3=${TESTNAME}-3
1755 local pool4=${TESTNAME}-4
1759 (( $MDS1_VERSION >= $(version_code 2.14.53) )) ||
1760 skip "Need MDS version at least 2.14.53"
1761 (( $OSTCOUNT >= 4 )) || skip "needs >= 4 OSTs"
1762 check_set_fallocate_or_skip
1764 pool_add $pool1 || error "Pool creation failed"
1765 pool_add_targets $pool1 0 0 || error "pool_add_targets failed"
1767 pool_add $pool2 || error "Pool creation failed"
1768 pool_add_targets $pool2 1 1 || error "pool_add_targets failed"
1770 pool_add $pool3 || error "Pool creation failed"
1771 pool_add_targets $pool3 2 2 || error "pool_add_targets failed"
1773 pool_add $pool4 || error "Pool creation failed"
1774 pool_add_targets $pool4 3 3 || error "pool_add_targets failed"
1776 fill_ost_pool $pool1 $threshold
1777 fill_ost_pool $pool2 $threshold
1778 fill_ost_pool $pool3 $threshold
1779 cancel_lru_locks osc
1780 local delay=$(do_facet mds1 lctl get_param -n lo[vd].*.qos_maxage |
1781 awk '{ print $1 * 2; exit; }')
1782 sleep $((delay + 1))
1784 do_nodes $mdts $LCTL set_param lod.*.pool.$pool1.spill_target="$pool2"
1785 do_nodes $mdts $LCTL set_param lod.*.pool.$pool1.spill_threshold_pct="$threshold"
1787 do_nodes $mdts $LCTL set_param lod.*.pool.$pool2.spill_target="$pool3"
1788 do_nodes $mdts $LCTL set_param lod.*.pool.$pool2.spill_threshold_pct="$threshold"
1790 do_nodes $mdts $LCTL set_param lod.*.pool.$pool3.spill_target="$pool4"
1791 do_nodes $mdts $LCTL set_param lod.*.pool.$pool3.spill_threshold_pct="$threshold"
1793 do_nodes $mdts $LCTL get_param lod.*.pool.*.spill*
1795 $LFS setstripe -p $pool1 $DIR/$tdir || error "can't set default layout"
1796 local tmpfile=$DIR/$tdir/$tfile-2
1798 $LFS getstripe $tmpfile | grep -q pool.*$pool4 || {
1799 $LFS getstripe $tmpfile
1800 error "old pool is not $pool4"
1803 run_test 31 "OST pool spilling chained"
1808 destroy_test_pools $FSNAME
1809 if ! combined_mgs_mds; then
1810 zconf_umount $mgs_HOST $MOUNT
1811 do_facet mgs "rm -rf $MOUNT"
1813 check_and_cleanup_lustre