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
536 wait_update_facet $SINGLEMDS "lctl pool_list $FSNAME.$POOL |
537 wc -l" "$((OSTCOUNT + 1))" ||
538 error "MDS: pool_list $FSNAME.$POOL failed"
540 $LCMD pool_list $FSNAME.$POOL
541 [[ $? -eq 0 ]] || error "pool_list $FSNAME.$POOL failed."
543 $LCMD pool_list ${NON_EXISTANT_FS} 2>/dev/null
545 error "pool_list did not fail for fsname $NON_EXISTANT_FS"
547 $LCMD pool_list ${FSNAME}.$NON_EXISTANT_POOL 2>/dev/null
549 error "pool_list did not fail for pool $NON_EXISTANT_POOL"
551 if [[ ! $(grep $SINGLEMDS <<< $LCMD) ]]; then
552 echo $LCMD pool_list $DIR
554 [[ $? -eq 0 ]] || error "pool_list failed for $DIR"
557 $LCMD pool_list ${DIR}/d1
558 [[ $? -eq 0 ]] || error "pool_list failed for ${DIR}/d1"
561 rm -rf ${DIR}nonexistant
562 $LCMD pool_list ${DIR}nonexistant 2>/dev/null
564 error "pool_list did not fail for invalid mountpoint ${DIR}nonexistant"
571 # Issue commands from client
574 run_test 5a "lfs pool_list from client"
577 sub_test_5 "do_facet $SINGLEMDS lctl"
579 run_test 5b "lctl pool_list from MDS"
582 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
583 local POOL_DIR=$POOL_ROOT/dir_tst
584 local POOL_FILE=$POOL_ROOT/file_tst
586 create_pool_nofail $POOL
588 do_facet $SINGLEMDS lctl pool_list $FSNAME
589 [[ $? -eq 0 ]] || error "pool_list $FSNAME failed."
591 add_pool $POOL $TGT_ALL "$TGT_UUID"
594 $LFS setstripe -c -1 -p $POOL $POOL_DIR
595 [[ $? -eq 0 ]] || error "$LFS setstripe -p $POOL failed."
596 check_dir_in_pool $POOL_DIR $POOL
598 # If an invalid pool name is specified, the command should fail
599 $LFS setstripe -c 2 -p $INVALID_POOL $POOL_DIR 2>/dev/null
600 [[ $? -ne 0 ]] || error "setstripe to invalid pool did not fail."
602 # 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 rm -f $DIR/$tdir/testfile1
700 destroy_pool_int $FSNAME.$pool
702 run_test 7c "create a valid pool name and setstripe with a bad one"
705 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
707 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
709 create_pool_nofail $POOL
710 create_pool_nofail $POOL2
712 local start=$(printf %04x $((TGT_FIRST + 1)))
713 do_facet mgs lctl pool_add $FSNAME.$POOL2 \
714 $FSNAME-OST[$start-$TGT_MAX/2]
716 add_pool $POOL $TGT_HALF "$TGT_UUID2"
718 create_dir $POOL_ROOT/dir1 $POOL
719 create_dir $POOL_ROOT/dir2 $POOL2
722 createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
723 error "createmany $POOL_ROOT/dir1/$tfile failed!"
725 for file in $POOL_ROOT/dir1/*; do
726 check_file_in_pool $file $POOL
729 createmany -o $POOL_ROOT/dir2/$tfile $numfiles ||
730 error "createmany $POOL_ROOT/dir2/$tfile failed!"
731 for file in $POOL_ROOT/dir2/*; do
732 check_file_in_pool $file $POOL2
735 rm -rf $POOL_ROOT/dir?
739 run_test 11 "OSTs in overlapping/multiple pools"
742 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
744 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >=3 OSTs"
746 create_pool_nofail $POOL
747 create_pool_nofail $POOL2
749 local start=$(printf %04x $((TGT_FIRST + 1)))
750 do_facet mgs lctl pool_add $FSNAME.$POOL2 \
751 $FSNAME-OST[$start-$TGT_MAX/2]
753 add_pool $POOL $TGT_HALF "$TGT_UUID2"
755 echo creating some files in $POOL and $POOL2
757 create_dir $POOL_ROOT/dir1 $POOL
758 create_dir $POOL_ROOT/dir2 $POOL2
759 create_file $POOL_ROOT/file1 $POOL
760 create_file $POOL_ROOT/file2 $POOL2
762 echo Checking the files created
763 check_file_in_pool $POOL_ROOT/file1 $POOL
764 check_file_in_pool $POOL_ROOT/file2 $POOL2
766 echo Changing the pool membership
767 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST[$TGT_FIRST]
768 do_facet mgs lctl pool_list $FSNAME.$POOL
769 FIRST_UUID=$(echo $TGT_UUID | awk '{print $1}')
770 add_pool $POOL2 $FSNAME-OST[$TGT_FIRST] "$FIRST_UUID "
771 do_facet mgs lctl pool_list $FSNAME.$POOL2
773 echo Checking the files again
774 check_dir_in_pool $POOL_ROOT/dir1 $POOL
775 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
776 check_file_in_osts $POOL_ROOT/file1 "$TGT_LIST2"
777 check_file_in_osts $POOL_ROOT/file2 "$(seq 0x$start 2 0x$TGT_MAX)"
779 echo Creating some more files
780 create_dir $POOL_ROOT/dir3 $POOL
781 create_dir $POOL_ROOT/dir4 $POOL2
782 create_file $POOL_ROOT/file3 $POOL
783 create_file $POOL_ROOT/file4 $POOL2
785 echo Checking the new files
786 check_file_in_pool $POOL_ROOT/file3 $POOL
787 check_file_in_pool $POOL_ROOT/file4 $POOL2
791 run_test 12 "OST Pool Membership"
794 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >= 3 OSTs"
796 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
800 create_pool_nofail $POOL
801 add_pool $POOL $TGT_ALL "$TGT_UUID"
803 create_dir $POOL_ROOT/dir1 $POOL -1
804 createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
805 error "createmany $POOL_ROOT/dir1/$tfile failed!"
806 for file in $POOL_ROOT/dir1/*; do
807 check_file_in_pool $file $POOL $OSTCOUNT
810 create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
811 create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST + 1))
812 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST + 2))
813 check_file_in_osts $POOL_ROOT/dir1/file1 $((16#$TGT_FIRST))
814 check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST + 1))"
815 check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST + 2))"
817 create_dir $POOL_ROOT/dir2 $POOL $count
818 createmany -o $POOL_ROOT/dir2/$tfile- $numfiles ||
819 error "createmany $POOL_ROOT/dir2/$tfile- failed!"
820 for file in $POOL_ROOT/dir2/*; do
821 check_file_in_pool $file $POOL $count
824 create_dir $POOL_ROOT/dir3 $POOL $count $((TGT_FIRST + 1))
825 createmany -o $POOL_ROOT/dir3/$tfile- $numfiles ||
826 error "createmany $POOL_ROOT/dir3/$tfile- failed!"
827 for file in $POOL_ROOT/dir3/*; do
828 check_file_in_pool $file $POOL $count
831 create_dir $POOL_ROOT/dir4 $POOL 1
832 createmany -o $POOL_ROOT/dir4/$tfile- $numfiles ||
833 error "createmany $POOL_ROOT/dir4/$tfile- failed!"
834 for file in $POOL_ROOT/dir4/*; do
835 check_file_in_pool $file $POOL 1
838 create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST + 2))
839 createmany -o $POOL_ROOT/dir5/$tfile- $numfiles ||
840 error "createmany $POOL_ROOT/dir5/$tfile- failed!"
841 for file in $POOL_ROOT/dir5/*; do
842 check_file_in_pool $file $POOL 1
845 rm -rf $POOL_ROOT/dir[1-5]/
849 run_test 13 "Striping characteristics in a pool"
852 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >= 3 OSTs"
854 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
858 [ $OSTSIZE -gt $((MAXFREE / OSTCOUNT)) ] &&
859 skip_env "OST size $OSTSIZE is larger than $((MAXFREE / OSTCOUNT))"
861 create_pool_nofail $POOL
862 create_pool_nofail $POOL2
864 add_pool $POOL $TGT_HALF "$TGT_UUID2"
865 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
867 create_dir $POOL_ROOT/dir1 $POOL 1
868 create_file $POOL_ROOT/dir1/file $POOL 1
869 local ost=$($LFS getstripe -i $POOL_ROOT/dir1/file)
871 while [[ $i -lt $numfiles ]]; do
873 [[ $ost -gt $((16#$TGT_MAX)) ]] && ost=$TGT_FIRST
875 # echo "Iteration: $i OST: $ost"
876 create_file $POOL_ROOT/dir1/file${i} $POOL 1
877 check_file_in_pool $POOL_ROOT/dir1/file${i} $POOL
881 # Fill up OST0 until it is nearly full.
882 # Create 9 files of size OST0_SIZE/10 each.
883 create_dir $POOL_ROOT/dir2 $POOL2 1
884 $LFS df $POOL_ROOT/dir2
885 OST0_SIZE=$($LFS df $POOL_ROOT/dir2 | awk '/\[OST:0\]/ { print $4 }')
886 FILE_SIZE=$((OST0_SIZE/1024/10))
887 echo "Filling OST0 with 9 files of ${FILE_SIZE}MB in $POOL_ROOT/dir2"
889 while [[ $i -lt 10 ]]; do
890 dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1M count=$FILE_SIZE
893 sleep 1 # get new statfs info
894 $LFS df $POOL_ROOT/dir2
896 # OST $TGT_FIRST is no longer favored; but it may still be used.
897 create_dir $POOL_ROOT/dir3 $POOL 1
898 create_file $POOL_ROOT/dir3/file $POOL 1
899 createmany -o $POOL_ROOT/dir3/$tfile- $numfiles ||
900 error "createmany $POOL_ROOT/dir3/$tfile- failed!"
901 for file in $POOL_ROOT/dir3/*; do
902 check_file_in_pool $file $POOL
909 run_test 14 "Round robin and QOS striping within a pool"
912 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
916 while [[ $i -lt $OSTCOUNT ]]; do
917 create_pool_nofail $POOL${i}
919 local tgt=$(printf "$FSNAME-OST%04x_UUID " $i)
920 add_pool $POOL${i} "$FSNAME-OST[$(printf %04x $i)]" "$tgt"
921 create_dir $POOL_ROOT/dir${i} $POOL${i}
922 createmany -o $POOL_ROOT/dir$i/$tfile $numfiles ||
923 error "createmany $POOL_ROOT/dir$i/$tfile failed!"
925 for file in $POOL_ROOT/dir$i/*; do
926 check_file_in_osts $file $i
934 run_test 15 "One directory per OST/pool"
937 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
941 create_pool_nofail $POOL
943 add_pool $POOL $TGT_HALF "$TGT_UUID2"
945 local dir=$POOL_ROOT/$tdir
946 create_dir $dir $POOL
948 for i in $(seq 1 10); do
953 createmany -o $dir/$tfile $numfiles ||
954 error "createmany $dir/$tfile failed!"
956 for file in $dir/*; do
957 check_file_in_pool $file $POOL
960 rm -rf $POOL_ROOT/$tdir
964 run_test 16 "Inheritance of pool properties"
967 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
971 create_pool_nofail $POOL
973 add_pool $POOL $TGT_ALL "$TGT_UUID"
975 local dir=$POOL_ROOT/dir
976 create_dir $dir $POOL
978 createmany -o $dir/${tfile}1_ $numfiles ||
979 error "createmany $dir/${tfile}1_ failed!"
981 for file in $dir/*; do
982 check_file_in_pool $file $POOL
987 createmany -o $dir/${tfile}2_ $numfiles ||
988 error "createmany $dir/${tfile}2_ failed!"
993 run_test 17 "Referencing an empty pool"
1002 wait_delete_completed >/dev/null # give pending IO chance to go to disk
1003 stat=$(createmany -o $cdir/${tfile} -t $numsec | tail -1)
1004 files=$(echo $stat | cut -f 2 -d ' ')
1006 unlinkmany $cdir/${tfile} $files > /dev/null
1013 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1016 local plaindir=$POOL_ROOT/plaindir
1017 local pooldir=$POOL_ROOT/pooldir
1023 for i in $(seq 1 $iter); do
1024 echo "Create performance, iteration $i, $numsec seconds x 3"
1026 local files1=$(create_perf $plaindir $numsec)
1027 [[ $files1 -eq 0 ]] && error "Zero files created without pool"
1029 echo "iter $i: $files1 creates without pool"
1031 create_pool_nofail $POOL > /dev/null
1032 add_pool $POOL $TGT_ALL "$TGT_UUID" > /dev/null
1033 create_dir $pooldir $POOL
1034 local files2=$(create_perf $pooldir $numsec)
1035 [[ $files2 -eq 0 ]] && error "Zero files created with pool"
1037 echo "iter $i: $files2 creates with pool"
1039 destroy_pool $POOL > /dev/null
1040 local files3=$(create_perf $pooldir $numsec)
1041 [[ $files3 -eq 0 ]] &&
1042 error "Zero files created with missing pool"
1044 echo "iter $i: $files3 creates with missing pool"
1049 echo Avg files created in $numsec seconds without pool: $((f1 / iter))
1050 echo Avg files created in $numsec seconds with pool: $((f2 / iter))
1051 echo Avg files created in $numsec seconds missing pool: $((f3 / iter))
1053 # Set this high until we establish a baseline for what the degradation
1057 diff=$((($f1 - $f2) * 100 / $f1))
1058 echo "No pool / wide pool: $diff %."
1059 [ $diff -gt $max ] &&
1060 error_ignore bz23408 "Degradation with wide pool is $diff% > $max%"
1063 diff=$((($f1 - $f3) * 100 / $f1))
1064 echo "No pool / missing pool: $diff %."
1065 [ $diff -gt $max ] &&
1066 error_ignore bz23408 "Degradation with wide pool is $diff% > $max%"
1070 run_test 18 "File create in a directory which references a deleted pool"
1073 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1075 local dir1=$POOL_ROOT/dir1
1076 local dir2=$POOL_ROOT/dir2
1079 create_pool_nofail $POOL
1081 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1083 create_dir $dir1 $POOL
1084 createmany -o $dir1/${tfile} $numfiles ||
1085 error "createmany $dir1/${tfile} failed!"
1086 for file in $dir1/*; do
1087 check_file_in_pool $file $POOL
1091 createmany -o $dir2/${tfile} $numfiles ||
1092 error "createmany $dir2/${tfile} failed!"
1093 for file in $dir2/*; do
1094 check_file_not_in_pool $file $POOL
1101 run_test 19 "Pools should not come into play when not specified"
1104 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
1106 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1108 local dir1=$POOL_ROOT/dir1
1109 local dir2=$dir1/dir2
1110 local dir3=$dir1/dir3
1114 create_pool_nofail $POOL
1115 create_pool_nofail $POOL2
1117 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1119 local start=$(printf %04x $((TGT_FIRST + 1)))
1120 TGT=$(for i in $(seq 0x$start 2 0x$TGT_MAX); do \
1121 printf "$FSNAME-OST%04x_UUID " $i; done)
1122 add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1124 create_dir $dir1 $POOL
1125 create_file $dir1/file1 $POOL2 # Should replace $dir1 pool with $POOL2
1126 create_dir $dir2 $POOL2
1127 touch $dir2/file2 # Should inherit $POOL2 from $dir2
1128 mkdir $dir3 # Should inherit $POOL from $dir1
1129 $LFS setstripe -c 1 $dir3 # Should remain existing $POOL
1130 touch $dir3/file3 # Should inherit $POOL from $dir3
1131 $LFS setstripe -c 1 $dir2/file4 # Should inherit $POOL2 from dir2
1132 $LFS setstripe -S 64K $dir1/file5 # Should inderit $POOL from $dir1
1134 check_file_in_pool $dir1/file1 $POOL2
1135 check_file_in_pool $dir2/file2 $POOL2
1136 check_dir_not_in_pool $dir3 $POOL2
1137 check_file_not_in_pool $dir3/file3 $POOL2
1138 check_file_not_in_pool $dir2/file4 $POOL
1139 check_file_not_in_pool $dir1/file5 $POOL2
1141 if [ "$MDS1_VERSION" -ge $(version_code 2.10.54) ]; then
1142 check_dir_in_pool $dir3 $POOL
1143 check_file_in_pool $dir3/file3 $POOL
1144 check_file_in_pool $dir2/file4 $POOL2
1145 check_file_in_pool $dir1/file5 $POOL
1152 run_test 20 "Different pools in a directory hierarchy."
1155 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1156 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1160 local dir=$POOL_ROOT/dir
1162 create_pool_nofail $POOL
1164 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1166 create_dir $dir $POOL $OSTCOUNT
1167 create_file $dir/file1 $POOL $OSTCOUNT
1168 $LFS getstripe -v $dir/file1
1169 check_file_in_pool $dir/file1 $POOL
1175 run_test 21 "OST pool with fewer OSTs than stripe count"
1183 for c in $(seq 1 10); do
1184 echo "Pool $pool, iteration $c"
1185 do_facet mgs lctl pool_add $FSNAME.$pool \
1186 OST[$TGT_FIRST-$TGT_MAX/$step] 2>/dev/null
1187 local TGT_SECOND=$(printf %04x $((TGT_FIRST + $step)))
1188 if [ $((16#$TGT_SECOND)) -le $((16#$TGT_MAX)) ]; then
1189 do_facet mgs lctl pool_remove $FSNAME.$pool \
1190 OST[$TGT_SECOND-$TGT_MAX/$step]
1193 echo loop for $pool complete
1197 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1198 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1202 create_pool_nofail $POOL
1203 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
1204 create_pool_nofail $POOL2
1205 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
1210 create_dir $POOL_ROOT $POOL
1211 createmany -o $POOL_ROOT/${tfile} $numfiles ||
1212 error "createmany $POOL_ROOT/${tfile} failed!"
1217 run_test 22 "Simultaneous manipulation of a pool"
1220 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1221 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1224 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS ||
1225 skip_env "User $RUNAS_ID does not exist - skipping"
1229 local BUNIT_SZ=1024 # min block quota unit(kB)
1230 local LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1)))
1231 local dir=$POOL_ROOT/dir
1232 local file="$dir/$tfile-quota"
1234 create_pool_nofail $POOL
1236 local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
1237 printf "$FSNAME-OST%04x_UUID " $i; done)
1238 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1239 create_dir $dir $POOL
1241 # XXX remove the interoperability code once we drop the old server
1242 # ( < 2.3.50) support.
1243 if [ "$MDS1_VERSION" -lt $(version_code 2.3.50) ]; then
1244 $LFS quotaoff -ug $MOUNT
1245 $LFS quotacheck -ug $MOUNT
1247 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1248 do_facet mgs $PERM_CMD \
1249 osd-*.$FSNAME-OST*.quota_slave.enabled=ug
1251 do_facet mgs $PERM_CMD $FSNAME.quota.ost=ug
1256 $LFS setquota -u $RUNAS_ID -b $LIMIT -B $LIMIT $dir
1258 $LFS quota -v -u $RUNAS_ID $dir
1260 $LFS setstripe -c 1 -p $POOL $file
1261 chown $RUNAS_ID.$RUNAS_GID $file
1264 # This does two "dd" runs to ensure that the quota failure is returned
1265 # to userspace when we check. The first "dd" might otherwise complete
1266 # without error if it is only writing into cache.
1267 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
1268 count=$((BUNIT_SZ*2)) 2>&1)
1269 echo $stat | grep "Disk quota exceeded" > /dev/null
1270 if [ $? -eq 0 ]; then
1271 $LFS quota -v -u $RUNAS_ID $dir
1272 cancel_lru_locks osc
1273 stack_trap "rm -f $file"
1274 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
1275 count=$BUNIT_SZ seek=$((BUNIT_SZ*2)) 2>&1)
1278 [[ $RC -eq 0 ]] && error "second dd did not fail."
1279 echo $stat | grep "Disk quota exceeded" > /dev/null
1280 [[ $? -eq 1 ]] && error "second dd did not fail with EDQUOT."
1282 log "first dd failed with EDQUOT."
1284 $LFS quota -v -u $RUNAS_ID $dir
1286 run_test 23a "OST pools and quota"
1289 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1290 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1293 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS || {
1294 skip_env "User $RUNAS_ID does not exist - skipping"
1299 local dir=$POOL_ROOT/dir
1300 local file="$dir/$tfile-quota"
1302 create_pool_nofail $POOL
1304 local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
1305 printf "$FSNAME-OST%04x_UUID " $i; done)
1306 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1307 create_dir $dir $POOL
1309 local maxfree=$((1024 * 1024 * 30)) # 30G
1310 local AVAIL=$(lfs_df -p $POOL $dir | awk '/summary/ { print $4 }')
1311 [ $AVAIL -gt $maxfree ] &&
1312 skip_env "Filesystem space $AVAIL is larger than " \
1315 echo "OSTCOUNT=$OSTCOUNT, OSTSIZE=$OSTSIZE, AVAIL=$AVAIL"
1316 echo "MAXFREE=$maxfree, SLOW=$SLOW"
1318 # XXX remove the interoperability code once we drop the old server
1319 # ( < 2.3.50) support.
1320 if [ "$MDS1_VERSION" -lt $(version_code 2.3.50) ]; then
1321 $LFS quotaoff -ug $MOUNT
1323 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1324 do_facet mgs $PERM_CMD \
1325 osd-*.$FSNAME-OST*.quota_slave.enabled=none
1327 do_facet mgs $PERM_CMD $FSNAME.quota.ost=none
1332 chown $RUNAS_ID.$RUNAS_ID $dir
1336 local stime=$(date +%s)
1340 local maxtime=300 # minimum speed: 5GB / 300sec ~= 17MB/s
1341 while [ $RC -eq 0 ]; do
1343 stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file}$i bs=1M \
1344 count=$((5 * 1024)) 2>&1)
1346 TOTAL=$((TOTAL + 1024 * 1024 * 5))
1347 echo "[$i iteration] $stat"
1348 echo "total written: $TOTAL"
1351 elapsed=$((etime - stime))
1352 echo "stime=$stime, etime=$etime, elapsed=$elapsed"
1354 if [ $RC -eq 1 ]; then
1355 echo $stat | grep -q "Disk quota exceeded"
1357 error "dd failed with EDQUOT with quota off"
1359 echo $stat | grep -q "No space left on device"
1361 error "dd did not fail with ENOSPC"
1362 elif [ $TOTAL -gt $AVAIL ]; then
1363 error "dd didn't fail with ENOSPC ($TOTAL > $AVAIL)"
1364 elif [ $i -eq 1 -a $elapsed -gt $maxtime ]; then
1365 log "The first 5G write used $elapsed (> $maxtime) " \
1366 "seconds, terminated"
1374 run_test 23b "OST pools and OOS"
1377 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1378 [[ "$MDS1_VERSION" -ge $(version_code 2.8.56) ]] ||
1379 skip "Need server version newer than 2.8.55"
1381 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1388 create_pool_nofail $POOL
1390 add_pool $POOL $TGT_ALL "$TGT_UUID"
1392 create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1394 mkdir $POOL_ROOT/dir2
1395 $LFS setstripe -p $POOL -S 65536 -i 0 -c 1 $POOL_ROOT/dir2 ||
1396 error "$LFS setstripe $POOL_ROOT/dir2 failed"
1398 mkdir $POOL_ROOT/dir3
1399 $LFS setstripe -S 65536 -i 0 -c 1 $POOL_ROOT/dir3 ||
1400 error "$LFS setstripe $POOL_ROOT/dir3 failed"
1402 mkdir $POOL_ROOT/dir4
1404 for i in 1 2 3 4; do
1405 dir=${POOL_ROOT}/dir${i}
1414 createmany -o $dir/${tfile} $numfiles ||
1415 error "createmany $dir/${tfile} failed!"
1416 pool=$($LFS getstripe --pool $dir)
1417 index=$($LFS getstripe -i $dir)
1418 size=$($LFS getstripe -S $dir)
1419 count=$($LFS getstripe -c $dir)
1421 for file in $dir/*; do
1422 if [ "$pool" != "" ]; then
1423 check_file_in_pool $file $pool
1425 pool1=$($LFS getstripe --pool $file)
1426 count1=$($LFS getstripe -c $file)
1427 size1=$($LFS getstripe -S $file)
1428 [[ "$pool" != "$pool1" ]] &&
1429 error "Pool '$pool' not on $file:$pool1"
1430 [[ "$count" != "$count1" ]] &&
1431 [[ "$count" != "-1" ]] &&
1432 error "Stripe count $count not on"\
1434 [[ "$count1" != "$OSTCOUNT" ]] &&
1435 [[ "$count" = "-1" ]] &&
1436 error "Stripe count $count1 not on"\
1438 [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] &&
1439 error "Stripe size $size not on $file:$size1"
1447 run_test 24 "Independence of pool from other setstripe parameters"
1450 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1452 mkdir_on_mdt0 $POOL_ROOT
1454 for i in $(seq 10); do
1455 create_pool_nofail $POOL$i
1456 do_facet mgs "lctl pool_add $FSNAME.$POOL$i OST0000; sync"
1457 wait_update $HOSTNAME "lctl get_param -n \
1458 lov.$FSNAME-*.pools.$POOL$i | sort -u |
1459 tr '\n' ' ' " "$FSNAME-OST0000_UUID " >/dev/null ||
1460 error "pool_add failed: $1; $2"
1462 facet_failover $SINGLEMDS ||
1463 error "failed to failover $SINGLEMDS"
1464 wait_osc_import_state $SINGLEMDS ost FULL
1468 # Veriy that the pool got created and is usable
1469 df $POOL_ROOT > /dev/null
1472 # Make sure OST0 can be striped on
1473 $LFS setstripe -i 0 -c 1 $POOL_ROOT/$tfile
1474 local STR=$($LFS getstripe -i $POOL_ROOT/$tfile)
1475 rm $POOL_ROOT/$tfile
1476 if [[ "$STR" == "0" ]]; then
1477 echo "Creating a file in pool$i"
1478 create_file $POOL_ROOT/file$i $POOL$i || break
1479 check_file_in_pool $POOL_ROOT/file$i $POOL$i || break
1481 echo "OST 0 seems to be unavailable. Try later."
1487 run_test 25 "Create new pool and restart MDS"
1490 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >= 3 OSTs"
1491 local dev=$(mdsdevname ${SINGLEMDS//mds/})
1492 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1496 create_pool_nofail $POOL2
1498 do_facet mgs "lctl pool_add $FSNAME.$POOL2 OST0000; sync"
1499 wait_update $HOSTNAME "lctl get_param -n \
1500 lov.$FSNAME-*.pools.$POOL2 | sort -u |
1501 grep $FSNAME-OST0000_UUID " "$FSNAME-OST0000_UUID" ||
1502 error "pool_add failed: $1; $2"
1504 do_facet mgs "lctl pool_add $FSNAME.$POOL2 OST0002; sync"
1505 wait_update $HOSTNAME "lctl get_param -n \
1506 lov.$FSNAME-*.pools.$POOL2 | sort -u |
1507 grep $FSNAME-OST0002_UUID" "$FSNAME-OST0002_UUID" ||
1508 error "pool_add failed: $1; $2"
1510 # Veriy that the pool got created and is usable
1512 echo "Creating files in $POOL2"
1514 for ((i = 0; i < 10; i++)); do
1515 #OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
1516 #Fail OST0000 to ensure objects create on
1517 #the other OST in the pool
1518 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
1519 do_facet $SINGLEMDS lctl set_param fail_val=0
1520 create_file $POOL_ROOT/file$i $POOL2 1 -1 || break
1521 do_facet $SINGLEMDS lctl set_param fail_loc=0
1522 check_file_in_pool $POOL_ROOT/file$i $POOL2 || break
1526 run_test 26 "Choose other OSTs in the pool first in the creation remedy"
1529 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs"
1533 local count=$OSTCOUNT
1535 create_pool_nofail $POOL
1536 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT_ALL
1537 wait_update_facet $SINGLEMDS \
1538 "lctl pool_list $FSNAME.$POOL | wc -l" "$((OSTCOUNT + 1))" ||
1539 error "MDS: pool_list $FSNAME.$POOL failed"
1540 osts=$(list_pool $FSNAME.$POOL)
1541 for ost in ${osts}; do
1543 if [[ $count -eq 0 ]]; then
1544 #define OBD_FAIL_OST_LIST_ASSERT 0x239
1545 do_facet $SINGLEMDS \
1546 $LCTL set_param fail_loc=0x239 fail_val=10
1547 list_pool $FSNAME.$POOL &
1550 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
1551 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $ost
1553 do_facet $SINGLEMDS $LCTL set_param fail_val=0
1555 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $ost
1560 run_test 27 "Race pool_list and pool_remove"
1563 create_pool_nofail $POOL
1564 create_pool_nofail $POOL2
1565 add_pool $POOL $TGT_ALL "$TGT_UUID"
1566 add_pool $POOL2 $TGT_ALL "$TGT_UUID"
1568 start_full_debug_logging
1569 #$LFS setstripe -E 4M -c 1 -p $POOL -E 16M -c 2 $DIR/$tfile
1570 $LFS setstripe -c 1 -p $POOL $DIR/$tfile
1571 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=1 seek=16
1572 local csum=$(cksum $DIR/$tfile)
1573 $LFS getstripe $DIR/$tfile
1574 local pool="$($LFS getstripe -p $DIR/$tfile)"
1575 [[ "$pool" == "$POOL" ]] ||
1576 error "$tfile is in '$pool', not created on $POOL"
1577 $LFS_MIGRATE -y -p $POOL2 $DIR/$tfile ||
1578 error "migrate $tfile to $POOL2 failed"
1579 $LFS getstripe $DIR/$tfile
1580 pool="$($LFS getstripe -p $DIR/$tfile)"
1581 [[ "$pool" == "$POOL2" ]] ||
1582 error "$tfile is in '$pool', not migrated to $POOL2"
1583 local csum2=$(cksum $DIR/$tfile)
1584 [[ "$csum" == "$csum2" ]] || error "checksum error after migration"
1585 stop_full_debug_logging
1587 run_test 28 "lfs_migrate with pool name"
1591 function fill_ost_pool() {
1594 local tmpfile=$DIR/$tdir/$tfile-$pool-filler-$fill_ost_pool_cnt
1597 lfs setstripe $tmpfile -p $pool -c -1
1599 local dfa=($(lfs_df -p $pool | grep _summary))
1600 local total=${dfa[1]}
1601 local used=${dfa[2]}
1602 local towrite=$(( (total * (threshold + 1) / 100) - used ))
1604 echo "total $total, used $used, towrite $towrite"
1605 (( towrite > 0 )) && {
1606 fallocate -l$((towrite * 1024)) $tmpfile ||
1607 error "can't fallocate"
1609 echo ">> filled to $threshold"
1610 ((fill_ost_pool_cnt++))
1614 local pool1=${TESTNAME}-1
1615 local pool2=${TESTNAME}-2
1616 local mdts=$(comma_list $(mdts_nodes))
1618 local prefix="lod.$FSNAME-MDT0000-mdtlov.pool.$pool1"
1619 local cmd="$LCTL get_param -n $prefix"
1623 (( $MDS1_VERSION >= $(version_code 2.14.53) )) ||
1624 skip "Need MDS version at least 2.14.53"
1625 (( $OSTCOUNT >= 4 )) || skip "needs >= 4 OSTs"
1626 check_set_fallocate_or_skip
1628 mkdir_on_mdt0 $DIR/$tdir
1629 stack_trap "rm -rf $DIR/$tdir"
1630 local delay=$(do_facet mds1 lctl get_param -n lo[vd].*.qos_maxage |
1631 awk '{ print $1 * 2; exit; }')
1633 pool_add $pool1 || error "Pool creation failed"
1634 pool_add_targets $pool1 0 1 || error "pool_add_targets failed"
1636 pool_add $pool2 || error "Pool creation failed"
1637 pool_add_targets $pool2 2 3 || error "pool_add_targets failed"
1639 do_facet mds1 $LCTL set_param $prefix.spill_target=$pool2
1640 do_facet mds1 $LCTL set_param $prefix.spill_threshold_pct=$threshold
1641 stack_trap "do_facet mds1 $LCTL set_param $prefix.spill_threshold_pct=0"
1643 [[ $(do_facet mds1 "$cmd.spill_target" | uniq) == "$pool2" ]] ||
1644 error "spill target wasn't set to $pool2"
1645 [[ $(do_facet mds1 "$cmd.spill_threshold_pct" | uniq) == "$threshold" ]] ||
1646 error "spill threshold wasn't set"
1647 before=$(do_facet mds1 "$cmd.spill_hit")
1648 lfs_df -p $pool1 | grep summary
1651 stack_trap "rm -rf $DIR/$tdir"
1652 $LFS setstripe -p $pool1 $DIR/$tdir || error "can't set default layout"
1654 echo "check status with empty $pool1"
1655 sleep $((delay + 1))
1656 [[ $(do_nodes $mdts $cmd.spill_is_active | uniq) == "0" ]] || {
1657 do_nodes $mdts $cmd.spill_is_active
1658 error "spilling on $pool1 is on"
1660 touch $DIR/$tdir/$tfile-5
1661 [[ $($LFS getstripe -p $DIR/$tdir/$tfile-5) == "$pool1" ]] || {
1662 $LFS getstripe $DIR/$tdir/$tfile-5
1663 error "not old pool on $tfile-5"
1666 echo "check with non-empty $pool1"
1667 fill_ost_pool $pool1 $((threshold / 2))
1668 cancel_lru_locks osc
1669 sleep $((delay + 1))
1670 lfs_df -p $pool1 | grep summary
1671 [[ $(do_nodes $mdts $cmd.spill_is_active | uniq) == "0" ]] || {
1672 do_nodes $mdts $cmd.spill_is_active
1673 error "spilling on $pool1 is on"
1675 touch $DIR/$tdir/$tfile-4
1676 [[ $($LFS getstripe -p $DIR/$tdir/$tfile-4) == "$pool1" ]] || {
1677 $LFS getstripe $DIR/$tdir/$tfile-4
1678 error "new pool on $tfile-4"
1681 fill_ost_pool $pool1 $threshold
1682 cancel_lru_locks osc
1683 sleep $((delay + 1))
1684 lfs_df -p $pool1 | grep summary
1685 [[ $(do_nodes $mdts $cmd.spill_is_active | uniq) == "1" ]] || {
1686 do_nodes $mdts $cmd.spill_is_active
1687 error "spilling on $pool1 is off"
1690 # in a directory with default striping
1691 $LFS setstripe -p $pool1 $DIR/$tdir || error "can't set default layout"
1692 touch $DIR/$tdir/$tfile-2
1693 [[ $($LFS getstripe -p $DIR/$tdir/$tfile-2) == "$pool2" ]] || {
1694 $LFS getstripe $DIR/$tdir/$tfile-2
1695 error "old pool on $tfile-2"
1697 after=$(do_facet mds1 "$cmd.spill_hit")
1698 (( after == before + 1 )) || error "after $after != before $before + 1"
1700 # when striping is specified explicitly
1701 $LFS setstripe -p $pool1 $DIR/$tdir/$tfile-3 || error "can't setstripe"
1702 touch $DIR/$tdir/$tfile-3
1703 [[ $($LFS getstripe -p $DIR/$tdir/$tfile-3) == "$pool2" ]] || {
1704 $LFS getstripe $DIR/$tdir/$tfile-3
1705 error "old pool on $tfile-3"
1707 after=$(do_facet mds1 "$cmd.spill_hit")
1708 (( after == before + 2 )) || error "after $after != before $before + 2"
1710 # spill is revalidated at object creation
1711 wait_update_facet mds1 "$cmd.spill_is_active" "1" ||
1712 error "spilling is still inactive"
1714 rm -f $DIR/$tdir/$tfile* || error "can't rm $DIR/$tfile*"
1715 wait_delete_completed
1719 touch $DIR/$tdir/$tfile-2
1720 [[ $($LFS getstripe -p $DIR/$tdir/$tfile-2) == "$pool1" ]] || {
1721 $LFS getstripe $DIR/$tdir/$tfile-2
1722 error "new pool != $pool1"
1724 # spill is revaluated at object creation
1725 wait_update_facet mds1 "$cmd.spill_is_active" "0" ||
1726 error "spilling is still active"
1728 do_facet mds1 "$LCTL set_param $prefix.spill_threshold_pct=0"
1729 [[ $(do_facet mds1 "$cmd.spill_threshold_pct") == "0" ]] ||
1730 error "spill threshold wasn't reset"
1732 run_test 29 "check OST pool spilling"
1735 local MDT_DEV=$(mdsdevname 1)
1736 local mdts=$(comma_list $(mdts_nodes))
1737 local pool1=${TESTNAME}-1
1738 local pool2=${TESTNAME}-2
1741 local prefix="lod.$FSNAME-MDT0000*.pool.$pool1"
1742 local cmd="$LCTL get_param -n $prefix"
1744 (( $MDS1_VERSION >= $(version_code 2.14.53) )) ||
1745 skip "Need MDS version at least 2.14.53"
1746 (( $OSTCOUNT >= 4 )) || skip "needs >= 4 OSTs"
1748 pool_add $pool1 || error "Pool creation failed"
1749 pool_add_targets $pool1 0 1 || error "pool_add_targets failed"
1751 pool_add $pool2 || error "Pool creation failed"
1752 pool_add_targets $pool2 2 3 || error "pool_add_targets failed"
1755 do_facet mds1 $LCTL set_param $prefix.spill_target="0123456789ABCDEF" &&
1757 do_facet mds1 $LCTL set_param $prefix.spill_target="$pool1-2" &&
1758 error "non-exising pool"
1759 do_facet mds1 $LCTL set_param $prefix.spill_target="$pool1" &&
1761 do_facet mds1 $LCTL set_param $prefix.spill_threshold_pct="101" &&
1763 do_facet mds1 $LCTL set_param $prefix.spill_threshold_pct="-1" &&
1766 # set persistent spilling
1767 do_facet mgs $LCTL set_param -P $prefix.spill_target="$pool2"
1768 do_facet mgs $LCTL set_param -P $prefix.spill_threshold_pct=$threshold
1769 wait_update_facet mds1 "$cmd.spill_target" "$pool2" ||
1770 error "spill target wasn't set"
1771 wait_update_facet mds1 "$cmd.spill_threshold_pct" $threshold ||
1772 error "spill target wasn't set"
1774 stop mds1 || error "Fail to stop MDT."
1775 start mds1 $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
1776 wait_update_facet mds1 "$cmd.spill_target" "$pool2" ||
1777 error "spill target wasn't set after restart"
1778 wait_update_facet mds1 "$cmd.spill_threshold_pct" $threshold ||
1779 error "spill target wasn't set after restart"
1781 # now reset spilling
1782 do_facet mgs $LCTL set_param -P $prefix.spill_threshold_pct=0
1783 wait_update_facet mds1 "$cmd.spill_threshold_pct" 0 ||
1784 error "spill target wasn't set"
1786 stop mds1 || error "Fail to stop MDT."
1787 start mds1 $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
1788 wait_update_facet mds1 "$cmd.spill_threshold_pct" 0 ||
1789 error "spill target wasn't set"
1791 run_test 30 "persistent OST pool spilling"
1794 local prefix="lod.$FSNAME-*.pool."
1795 local MDT_DEV=$(mdsdevname mds1)
1796 local mdts=$(comma_list $(mdts_nodes))
1797 local do_mdts="do_nodes $mdts $LCTL"
1798 local pool1=${TESTNAME}-1
1799 local pool2=${TESTNAME}-2
1800 local pool3=${TESTNAME}-3
1801 local pool4=${TESTNAME}-4
1805 (( $MDS1_VERSION >= $(version_code 2.14.53) )) ||
1806 skip "Need MDS version at least 2.14.53"
1807 (( $OSTCOUNT >= 4 )) || skip "needs >= 4 OSTs"
1808 check_set_fallocate_or_skip
1810 pool_add $pool1 || error "Pool creation failed"
1811 pool_add_targets $pool1 0 0 || error "pool_add_targets failed"
1813 pool_add $pool2 || error "Pool creation failed"
1814 pool_add_targets $pool2 1 1 || error "pool_add_targets failed"
1816 pool_add $pool3 || error "Pool creation failed"
1817 pool_add_targets $pool3 2 2 || error "pool_add_targets failed"
1819 pool_add $pool4 || error "Pool creation failed"
1820 pool_add_targets $pool4 3 3 || error "pool_add_targets failed"
1822 fill_ost_pool $pool1 $threshold
1823 fill_ost_pool $pool2 $threshold
1824 fill_ost_pool $pool3 $threshold
1825 cancel_lru_locks osc
1826 local delay=$(do_facet mds1 lctl get_param -n lo[vd].*.qos_maxage |
1827 awk '{ print $1 * 2; exit; }')
1828 sleep $((delay + 1))
1830 stack_trap "$do_mdts set_param lod.*.pool.*.spill_threshold_pct=0"
1832 $do_mdts set_param lod.*.pool.$pool1.spill_target="$pool2"
1833 $do_mdts set_param lod.*.pool.$pool1.spill_threshold_pct="$threshold"
1835 $do_mdts set_param lod.*.pool.$pool2.spill_target="$pool3"
1836 $do_mdts set_param lod.*.pool.$pool2.spill_threshold_pct="$threshold"
1838 $do_mdts set_param lod.*.pool.$pool3.spill_target="$pool4"
1839 $do_mdts set_param lod.*.pool.$pool3.spill_threshold_pct="$threshold"
1841 $do_mdts get_param lod.*.pool.*.spill*
1843 $LFS setstripe -p $pool1 $DIR/$tdir || error "can't set default layout"
1844 local tmpfile=$DIR/$tdir/$tfile-2
1846 $LFS getstripe $tmpfile | grep -q pool.*$pool4 || {
1847 $LFS getstripe $tmpfile
1848 error "old pool is not $pool4"
1853 # reset all loop spilling
1854 $do_mdts set_param lod.*.pool.*.spill_threshold_pct="0"
1856 # pool1->pool2->pool3, then pool4->pool1 fails
1857 $do_mdts set_param lod.*.pool.$pool1.spill_target="$pool2" ||
1858 error "can't set spill target for $pool1"
1859 $do_mdts set_param lod.*.pool.$pool2.spill_target="$pool3" ||
1860 error "can't set spill target for $pool1"
1861 $do_mdts set_param lod.*.pool.$pool3.spill_target="$pool4" ||
1862 error "can't set spill target for $pool1"
1863 $do_mdts set_param lod.*.pool.$pool4.spill_target="$pool1" &&
1864 error "loop succeed"
1866 # reset all loop spilling
1867 $do_mdts set_param lod.*.pool.*.spill_threshold_pct="0"
1869 # pool1->pool2,pool4->pool1, then pool3->pool4 fails
1870 $do_mdts set_param lod.*.pool.$pool1.spill_target="$pool2" ||
1871 error "can't set spill target for $pool1"
1872 $do_mdts set_param lod.*.pool.$pool2.spill_target="$pool3" ||
1873 error "can't set spill target for $pool1"
1874 $do_mdts set_param lod.*.pool.$pool4.spill_target="$pool1" ||
1875 error "can't set spill target for $pool4"
1876 $do_mdts set_param lod.*.pool.$pool3.spill_target="$pool4" &&
1877 error "loop succeed"
1881 run_test 31 "OST pool spilling chained"
1883 test_32() { # LU-15707
1884 (( OSTCOUNT >= 2 )) || skip "Need at least 2 OST"
1886 local pool=$TESTNAME
1887 pool_add $pool || error "add $pool failed"
1888 pool_add_targets $pool 0 ||
1889 error "add targets to $pool failed"
1891 test_mkdir $DIR/$tdir
1892 $LFS setstripe -p $pool $DIR/$tdir ||
1893 error "setstripe fail on $DIR/$tdir"
1895 ( $LFS getstripe -p $DIR/$tdir | grep -q $pool ) ||
1896 error "fail to set pool on $DIR/$tdir"
1898 $LFS setstripe -p ignore $DIR/$tdir/$tfile ||
1899 error "setstripe fail on $DIR/$tdir/$tfile"
1901 ! ( $LFS getstripe -p $DIR/$tdir/$tfile | egrep -q "[^ ]+" ) ||
1902 error "fail to create $DIR/$tdir/$tfile without pool"
1904 # Test with start index
1906 for ((idx = 0; idx < OSTCOUNT; idx++)); do
1907 $LFS setstripe -p ignore -i $idx $DIR/$tdir/$tfile.$idx ||
1908 error "setstripe -i fail on $DIR/$tdir/$tfile.$idx"
1910 got=$($LFS getstripe -i $DIR/$tdir/$tfile.$idx)
1912 error "file $tfile.$idx on OST $got != $idx"
1915 # Test with ost list
1916 $LFS setstripe -p ignore -o 1,0 $DIR/$tdir/$tfile.1_0 ||
1917 error "setstripe --ost fail on $DIR/$tdir/$tfile.1_0"
1919 got=$($LFS getstripe -i $DIR/$tdir/$tfile.1_0)
1921 error "file $tfile.1_0 (ostlist) start on OST $got != 1"
1923 got=$($LFS getstripe -c $DIR/$tdir/$tfile.1_0)
1925 error "file $tfile.1_0 (ostlist) has stripe count $got != 2"
1927 run_test 32 "force to create a file without pool (no inheritance)"
1932 destroy_test_pools $FSNAME
1933 if ! combined_mgs_mds; then
1934 zconf_umount $mgs_HOST $MOUNT
1935 do_facet mgs "rm -rf $MOUNT"
1937 check_and_cleanup_lustre