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 local mgc_timeout_path=/sys/module/mgc/parameters/mgc_requeue_timeout_min
438 local tgt="$FSNAME-OST0000_UUID"
441 (( MGS_VERSION >= $(version_code 2.15.60) )) ||
442 skip "Need MGS version at least 2.15.60"
444 mgc_timeout=$(cat $mgc_timeout_path)
445 echo 5 > $mgc_timeout_path
446 stack_trap "echo $mgc_timeout > $mgc_timeout_path"
448 do_facet mgs timeout 4 $LCTL pool_new -n $FSNAME.$POOL || rc=$?
449 ((rc != 124)) || error "lctl pool_new -n $FSNAME.$POOL timeout"
450 ((rc == 0)) || error "lctl pool_new -n $FSNAME.$POOL failed"
452 do_facet mgs timeout 4 $LCTL pool_add -n $FSNAME.$POOL $tgt || rc=$?
453 ((rc != 124)) || error "lctl pool_new -n $FSNAME.$POOL timeout"
454 ((rc == 0)) || error "lctl pool_new -n $FSNAME.$POOL failed"
456 wait_update_facet mds1 \
457 "lctl pool_list $FSNAME.$POOL 2> /dev/null | sed '1d'" "$tgt" ||
458 error "Add $tgt to $FSNAME.$POOL failed"
460 do_facet mgs timeout 4 $LCTL pool_remove -n $FSNAME.$POOL $tgt || rc=$?
461 ((rc != 124)) || error "lctl pool_remove -n $FSNAME.$POOL timeout"
462 ((rc == 0)) || error "lctl pool_remove -n $FSNAME.$POOL failed"
464 do_facet mgs timeout 4 $LCTL pool_destroy -n $FSNAME.$POOL || rc=$?
465 ((rc != 124)) || error "lctl pool_destroy -n $FSNAME.$POOL timeout"
466 ((rc == 0)) || error "lctl pool_destroy -n $FSNAME.$POOL failed"
468 wait_update_facet mds1 \
469 "lctl pool_list $FSNAME.$POOL &> /dev/null || echo destroy" "destroy" ||
470 error "destroy $FSNAME.$POOL failed"
472 run_test 2f "check -n|--nowait option"
475 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
476 [[ $? -ne 0 ]] || destroy_pool $POOL
479 lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000 2>/dev/null
481 error "pool_remove did not fail even though pool did not exist."
483 run_test 3a "pool_remove: non-existant pool"
487 lctl pool_remove ${NON_EXISTANT_FS}.$POOL OST0000 2>/dev/null
489 error "pool_remove did not fail even though fsname did not exist."
491 run_test 3b "pool_remove: non-existant fsname"
494 do_facet mgs lctl pool_remove $FSNAME.p1234567891234567890 \
495 $FSNAME-OST0000 2>/dev/null
497 error "pool_remove did not fail even though pool name was invalid."
499 run_test 3c "pool_remove: Invalid pool name"
501 # Testing various combinations of OST name list
503 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
504 [[ $? -ne 0 ]] || destroy_pool $POOL
506 create_pool_nofail $POOL
507 do_facet mgs lctl pool_add $FSNAME.$POOL OST0000
508 do_facet mgs lctl pool_remove $FSNAME.$POOL OST0000
509 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL OST0000"
512 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000
513 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000
514 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000"
517 do_facet mgs lctl pool_add $FSNAME.$POOL $FSNAME-OST0000_UUID
518 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST0000_UUID
520 error "pool_remove failed. $FSNAME $POOL $FSNAME-OST0000_UUID"
523 add_pool $POOL $TGT_ALL "$TGT_UUID"
524 do_facet mgs lctl pool_remove $FSNAME.$POOL $TGT_ALL
525 [[ $? -eq 0 ]] || error "pool_remove failed. $FSNAME $POOL" $TGT_ALL
530 run_test 3d "pool_remove: OST index combinations"
533 lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null
534 [[ $? -ne 0 ]] || destroy_pool $POOL
536 do_facet mgs lctl pool_destroy $FSNAME.$POOL 2>/dev/null
538 error "pool_destroy did not fail even though pool did not exist."
540 run_test 4a "pool_destroy: non-existant pool"
543 do_facet mgs lctl pool_destroy ${NON_EXISTANT_FS}.$POOL 2>/dev/null
545 error "pool_destroy did not fail even though filesystem did not exist."
547 run_test 4b "pool_destroy: non-existant fs-name"
550 create_pool_nofail $POOL
551 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
553 do_facet mgs lctl pool_destroy ${FSNAME}.$POOL
554 [[ $? -ne 0 ]] || error "pool_destroy succeeded with a non-empty pool."
557 run_test 4c "pool_destroy: non-empty pool"
562 $LCMD pool_list 2>/dev/null
564 error "pool_list did not fail even though fsname missing."
566 destroy_pool $POOL 2>/dev/null
567 destroy_pool $POOL2 2>/dev/null
569 create_pool_nofail $POOL
570 create_pool_nofail $POOL2
571 $LCMD pool_list $FSNAME
572 [[ $? -eq 0 ]] || error "pool_list $FSNAME failed."
574 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT_ALL
575 wait_update_facet $SINGLEMDS "lctl pool_list $FSNAME.$POOL |
576 wc -l" "$((OSTCOUNT + 1))" ||
577 error "MDS: pool_list $FSNAME.$POOL failed"
579 $LCMD pool_list $FSNAME.$POOL
580 [[ $? -eq 0 ]] || error "pool_list $FSNAME.$POOL failed."
582 $LCMD pool_list ${NON_EXISTANT_FS} 2>/dev/null
584 error "pool_list did not fail for fsname $NON_EXISTANT_FS"
586 $LCMD pool_list ${FSNAME}.$NON_EXISTANT_POOL 2>/dev/null
588 error "pool_list did not fail for pool $NON_EXISTANT_POOL"
590 if [[ ! $(grep $SINGLEMDS <<< $LCMD) ]]; then
591 echo $LCMD pool_list $DIR
593 [[ $? -eq 0 ]] || error "pool_list failed for $DIR"
596 $LCMD pool_list ${DIR}/d1
597 [[ $? -eq 0 ]] || error "pool_list failed for ${DIR}/d1"
600 rm -rf ${DIR}nonexistant
601 $LCMD pool_list ${DIR}nonexistant 2>/dev/null
603 error "pool_list did not fail for invalid mountpoint ${DIR}nonexistant"
610 # Issue commands from client
613 run_test 5a "lfs pool_list from client"
616 sub_test_5 "do_facet $SINGLEMDS lctl"
618 run_test 5b "lctl pool_list from MDS"
621 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
622 local POOL_DIR=$POOL_ROOT/dir_tst
623 local POOL_FILE=$POOL_ROOT/file_tst
625 create_pool_nofail $POOL
627 do_facet $SINGLEMDS lctl pool_list $FSNAME
628 [[ $? -eq 0 ]] || error "pool_list $FSNAME failed."
630 add_pool $POOL $TGT_ALL "$TGT_UUID"
633 $LFS setstripe -c -1 -p $POOL $POOL_DIR
634 [[ $? -eq 0 ]] || error "$LFS setstripe -p $POOL failed."
635 check_dir_in_pool $POOL_DIR $POOL
637 # If an invalid pool name is specified, the command should fail
638 $LFS setstripe -c 2 -p $INVALID_POOL $POOL_DIR 2>/dev/null
639 [[ $? -ne 0 ]] || error "setstripe to invalid pool did not fail."
641 # lfs setstripe should work as before if a pool name is not specified.
642 $LFS setstripe -c -1 $POOL_DIR
643 [[ $? -eq 0 ]] || error "$LFS setstripe -c -1 $POOL_DIR failed."
644 $LFS setstripe -c -1 $POOL_FILE
645 [[ $? -eq 0 ]] || error "$LFS setstripe -c -1 $POOL_FILE failed."
647 # lfs setstripe should fail if a start index that is outside the
649 create_pool_nofail $POOL2
650 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
651 $LFS setstripe -i 1 -p $POOL2 $ROOT_POOL/$tfile 2>/dev/null
653 error "$LFS setstripe with start index outside the pool did not fail."
655 run_test 6 "getstripe/setstripe"
659 # Create a pool, stripe a directory and file with it
662 pool_add $pool || error "pool_add failed"
663 pool_add_targets $pool 0 1 || error "pool_add_targets failed"
665 $LFS setstripe -c 1 $DIR/$tdir/testfile1 --pool "$pool" ||
666 error "setstripe failed"
667 $LFS setstripe -c 1 $DIR/$tdir/testfile2 --pool "$FSNAME.$pool" ||
668 error "setstripe failed"
670 mkdir $DIR/$tdir/testdir
671 $LFS setstripe -c 1 $DIR/$tdir/testdir -p "$pool" ||
672 error "setstripe failed"
673 $LFS setstripe -c 1 $DIR/$tdir/testdir -p "$FSNAME.$pool" ||
674 error "setstripe failed"
676 rm -f $DIR/$tdir/testfile1
677 rm -f $DIR/$tdir/testfile2
678 rmdir $DIR/$tdir/testdir
680 destroy_pool_int $FSNAME.$pool
685 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
689 # Generate pool with random name from 1 to 15 characters
691 POOLNAME=$(echo $$$RANDOM$RANDOM |
692 tr -dc 'a-zA-Z0-9' | fold -w $i |
694 echo set poolname to $POOLNAME
695 helper_test_7a $POOLNAME
698 run_test 7a "create various pool name"
704 [ $? -ne 22 ] && error "can create a pool with no fsname"
708 [ $? -ne 22 ] && error "can create a pool with no name"
711 create_pool $FSNAME.0123456789^bdef
712 [ $? -ne 22 ] && error "can create a pool with an invalid name"
715 create_pool $FSNAME.0123456789abdefg
716 [ $? -ne 36 ] && error "can create a pool with a name too long"
720 run_test 7b "try to create pool name with invalid lengths or names"
724 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
728 # Create a pool with 15 letters
729 local pool=0123456789abcde
730 pool_add $pool || error "pool_add failed"
731 pool_add_targets $pool 0 1 || error "pool_add_targets failed"
733 # setstripe with the same pool name plus 1 letter
734 $LFS setstripe -c 1 $DIR/$tdir/testfile1 --pool "${pool}X" &&
735 error "setstripe succeeded"
737 rm -f $DIR/$tdir/testfile1
739 destroy_pool_int $FSNAME.$pool
741 run_test 7c "create a valid pool name and setstripe with a bad one"
744 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
746 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
748 create_pool_nofail $POOL
749 create_pool_nofail $POOL2
751 local start=$(printf %04x $((TGT_FIRST + 1)))
752 do_facet mgs lctl pool_add $FSNAME.$POOL2 \
753 $FSNAME-OST[$start-$TGT_MAX/2]
755 add_pool $POOL $TGT_HALF "$TGT_UUID2"
757 create_dir $POOL_ROOT/dir1 $POOL
758 create_dir $POOL_ROOT/dir2 $POOL2
761 createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
762 error "createmany $POOL_ROOT/dir1/$tfile failed!"
764 for file in $POOL_ROOT/dir1/*; do
765 check_file_in_pool $file $POOL
768 createmany -o $POOL_ROOT/dir2/$tfile $numfiles ||
769 error "createmany $POOL_ROOT/dir2/$tfile failed!"
770 for file in $POOL_ROOT/dir2/*; do
771 check_file_in_pool $file $POOL2
774 rm -rf $POOL_ROOT/dir?
778 run_test 11 "OSTs in overlapping/multiple pools"
781 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
783 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >=3 OSTs"
785 create_pool_nofail $POOL
786 create_pool_nofail $POOL2
788 local start=$(printf %04x $((TGT_FIRST + 1)))
789 do_facet mgs lctl pool_add $FSNAME.$POOL2 \
790 $FSNAME-OST[$start-$TGT_MAX/2]
792 add_pool $POOL $TGT_HALF "$TGT_UUID2"
794 echo creating some files in $POOL and $POOL2
796 create_dir $POOL_ROOT/dir1 $POOL
797 create_dir $POOL_ROOT/dir2 $POOL2
798 create_file $POOL_ROOT/file1 $POOL
799 create_file $POOL_ROOT/file2 $POOL2
801 echo Checking the files created
802 check_file_in_pool $POOL_ROOT/file1 $POOL
803 check_file_in_pool $POOL_ROOT/file2 $POOL2
805 echo Changing the pool membership
806 do_facet mgs lctl pool_remove $FSNAME.$POOL $FSNAME-OST[$TGT_FIRST]
807 do_facet mgs lctl pool_list $FSNAME.$POOL
808 FIRST_UUID=$(echo $TGT_UUID | awk '{print $1}')
809 add_pool $POOL2 $FSNAME-OST[$TGT_FIRST] "$FIRST_UUID "
810 do_facet mgs lctl pool_list $FSNAME.$POOL2
812 echo Checking the files again
813 check_dir_in_pool $POOL_ROOT/dir1 $POOL
814 check_dir_in_pool $POOL_ROOT/dir2 $POOL2
815 check_file_in_osts $POOL_ROOT/file1 "$TGT_LIST2"
816 check_file_in_osts $POOL_ROOT/file2 "$(seq 0x$start 2 0x$TGT_MAX)"
818 echo Creating some more files
819 create_dir $POOL_ROOT/dir3 $POOL
820 create_dir $POOL_ROOT/dir4 $POOL2
821 create_file $POOL_ROOT/file3 $POOL
822 create_file $POOL_ROOT/file4 $POOL2
824 echo Checking the new files
825 check_file_in_pool $POOL_ROOT/file3 $POOL
826 check_file_in_pool $POOL_ROOT/file4 $POOL2
830 run_test 12 "OST Pool Membership"
833 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >= 3 OSTs"
835 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
839 create_pool_nofail $POOL
840 add_pool $POOL $TGT_ALL "$TGT_UUID"
842 create_dir $POOL_ROOT/dir1 $POOL -1
843 createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
844 error "createmany $POOL_ROOT/dir1/$tfile failed!"
845 for file in $POOL_ROOT/dir1/*; do
846 check_file_in_pool $file $POOL $OSTCOUNT
849 create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
850 create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST + 1))
851 create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST + 2))
852 check_file_in_osts $POOL_ROOT/dir1/file1 $((16#$TGT_FIRST))
853 check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST + 1))"
854 check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST + 2))"
856 create_dir $POOL_ROOT/dir2 $POOL $count
857 createmany -o $POOL_ROOT/dir2/$tfile- $numfiles ||
858 error "createmany $POOL_ROOT/dir2/$tfile- failed!"
859 for file in $POOL_ROOT/dir2/*; do
860 check_file_in_pool $file $POOL $count
863 create_dir $POOL_ROOT/dir3 $POOL $count $((TGT_FIRST + 1))
864 createmany -o $POOL_ROOT/dir3/$tfile- $numfiles ||
865 error "createmany $POOL_ROOT/dir3/$tfile- failed!"
866 for file in $POOL_ROOT/dir3/*; do
867 check_file_in_pool $file $POOL $count
870 create_dir $POOL_ROOT/dir4 $POOL 1
871 createmany -o $POOL_ROOT/dir4/$tfile- $numfiles ||
872 error "createmany $POOL_ROOT/dir4/$tfile- failed!"
873 for file in $POOL_ROOT/dir4/*; do
874 check_file_in_pool $file $POOL 1
877 create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST + 2))
878 createmany -o $POOL_ROOT/dir5/$tfile- $numfiles ||
879 error "createmany $POOL_ROOT/dir5/$tfile- failed!"
880 for file in $POOL_ROOT/dir5/*; do
881 check_file_in_pool $file $POOL 1
884 rm -rf $POOL_ROOT/dir[1-5]/
888 run_test 13 "Striping characteristics in a pool"
891 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >= 3 OSTs"
893 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
897 [ $OSTSIZE -gt $((MAXFREE / OSTCOUNT)) ] &&
898 skip_env "OST size $OSTSIZE is larger than $((MAXFREE / OSTCOUNT))"
900 create_pool_nofail $POOL
901 create_pool_nofail $POOL2
903 add_pool $POOL $TGT_HALF "$TGT_UUID2"
904 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
906 create_dir $POOL_ROOT/dir1 $POOL 1
907 create_file $POOL_ROOT/dir1/file $POOL 1
908 local ost=$($LFS getstripe -i $POOL_ROOT/dir1/file)
910 while [[ $i -lt $numfiles ]]; do
912 [[ $ost -gt $((16#$TGT_MAX)) ]] && ost=$TGT_FIRST
914 # echo "Iteration: $i OST: $ost"
915 create_file $POOL_ROOT/dir1/file${i} $POOL 1
916 check_file_in_pool $POOL_ROOT/dir1/file${i} $POOL
920 # Fill up OST0 until it is nearly full.
921 # Create 9 files of size OST0_SIZE/10 each.
922 create_dir $POOL_ROOT/dir2 $POOL2 1
923 $LFS df $POOL_ROOT/dir2
924 OST0_SIZE=$($LFS df $POOL_ROOT/dir2 | awk '/\[OST:0\]/ { print $4 }')
925 FILE_SIZE=$((OST0_SIZE/1024/10))
926 echo "Filling OST0 with 9 files of ${FILE_SIZE}MB in $POOL_ROOT/dir2"
928 while [[ $i -lt 10 ]]; do
929 dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1M count=$FILE_SIZE
932 sleep 1 # get new statfs info
933 $LFS df $POOL_ROOT/dir2
935 # OST $TGT_FIRST is no longer favored; but it may still be used.
936 create_dir $POOL_ROOT/dir3 $POOL 1
937 create_file $POOL_ROOT/dir3/file $POOL 1
938 createmany -o $POOL_ROOT/dir3/$tfile- $numfiles ||
939 error "createmany $POOL_ROOT/dir3/$tfile- failed!"
940 for file in $POOL_ROOT/dir3/*; do
941 check_file_in_pool $file $POOL
948 run_test 14 "Round robin and QOS striping within a pool"
951 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
955 while [[ $i -lt $OSTCOUNT ]]; do
956 create_pool_nofail $POOL${i}
958 local tgt=$(printf "$FSNAME-OST%04x_UUID " $i)
959 add_pool $POOL${i} "$FSNAME-OST[$(printf %04x $i)]" "$tgt"
960 create_dir $POOL_ROOT/dir${i} $POOL${i}
961 createmany -o $POOL_ROOT/dir$i/$tfile $numfiles ||
962 error "createmany $POOL_ROOT/dir$i/$tfile failed!"
964 for file in $POOL_ROOT/dir$i/*; do
965 check_file_in_osts $file $i
973 run_test 15 "One directory per OST/pool"
976 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
980 create_pool_nofail $POOL
982 add_pool $POOL $TGT_HALF "$TGT_UUID2"
984 local dir=$POOL_ROOT/$tdir
985 create_dir $dir $POOL
987 for i in $(seq 1 10); do
992 createmany -o $dir/$tfile $numfiles ||
993 error "createmany $dir/$tfile failed!"
995 for file in $dir/*; do
996 check_file_in_pool $file $POOL
999 rm -rf $POOL_ROOT/$tdir
1003 run_test 16 "Inheritance of pool properties"
1006 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1010 create_pool_nofail $POOL
1012 add_pool $POOL $TGT_ALL "$TGT_UUID"
1014 local dir=$POOL_ROOT/dir
1015 create_dir $dir $POOL
1017 createmany -o $dir/${tfile}1_ $numfiles ||
1018 error "createmany $dir/${tfile}1_ failed!"
1020 for file in $dir/*; do
1021 check_file_in_pool $file $POOL
1026 createmany -o $dir/${tfile}2_ $numfiles ||
1027 error "createmany $dir/${tfile}2_ failed!"
1032 run_test 17 "Referencing an empty pool"
1040 wait_delete_completed >/dev/null # give pending IO chance to go to disk
1041 stat=$(createmany -o $cdir/${tfile} -t $numsec | tail -1)
1042 files=$(echo $stat | cut -f 2 -d ' ')
1044 unlinkmany $cdir/${tfile} $files > /dev/null
1051 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1054 local plaindir=$POOL_ROOT/plaindir
1055 local pooldir=$POOL_ROOT/pooldir
1061 for i in $(seq 1 $iter); do
1062 echo "Create performance, iteration $i, $numsec seconds x 3"
1064 local files1=$(create_perf $plaindir $numsec)
1065 [[ $files1 -eq 0 ]] && error "Zero files created without pool"
1067 echo "iter $i: $files1 creates without pool"
1069 create_pool_nofail $POOL > /dev/null
1070 add_pool $POOL $TGT_ALL "$TGT_UUID" > /dev/null
1071 create_dir $pooldir $POOL
1072 local files2=$(create_perf $pooldir $numsec)
1073 [[ $files2 -eq 0 ]] && error "Zero files created with pool"
1075 echo "iter $i: $files2 creates with pool"
1077 destroy_pool $POOL > /dev/null
1078 local files3=$(create_perf $pooldir $numsec)
1079 [[ $files3 -eq 0 ]] &&
1080 error "Zero files created with missing pool"
1082 echo "iter $i: $files3 creates with missing pool"
1087 echo Avg files created in $numsec seconds without pool: $((f1 / iter))
1088 echo Avg files created in $numsec seconds with pool: $((f2 / iter))
1089 echo Avg files created in $numsec seconds missing pool: $((f3 / iter))
1091 # Set this high until we establish a baseline for what the degradation
1095 diff=$((($f1 - $f2) * 100 / $f1))
1096 echo "No pool / wide pool: $diff %."
1097 [ $diff -gt $max ] &&
1098 error_ignore bz23408 "Degradation with wide pool is $diff% > $max%"
1101 diff=$((($f1 - $f3) * 100 / $f1))
1102 echo "No pool / missing pool: $diff %."
1103 [ $diff -gt $max ] &&
1104 error_ignore bz23408 "Degradation with wide pool is $diff% > $max%"
1108 run_test 18 "File create in a directory which references a deleted pool"
1111 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1113 local dir1=$POOL_ROOT/dir1
1114 local dir2=$POOL_ROOT/dir2
1117 create_pool_nofail $POOL
1119 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1121 create_dir $dir1 $POOL
1122 createmany -o $dir1/${tfile} $numfiles ||
1123 error "createmany $dir1/${tfile} failed!"
1124 for file in $dir1/*; do
1125 check_file_in_pool $file $POOL
1129 createmany -o $dir2/${tfile} $numfiles ||
1130 error "createmany $dir2/${tfile} failed!"
1131 for file in $dir2/*; do
1132 check_file_not_in_pool $file $POOL
1139 run_test 19 "Pools should not come into play when not specified"
1142 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
1144 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1146 local dir1=$POOL_ROOT/dir1
1147 local dir2=$dir1/dir2
1148 local dir3=$dir1/dir3
1152 create_pool_nofail $POOL
1153 create_pool_nofail $POOL2
1155 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1157 local start=$(printf %04x $((TGT_FIRST + 1)))
1158 TGT=$(for i in $(seq 0x$start 2 0x$TGT_MAX); do \
1159 printf "$FSNAME-OST%04x_UUID " $i; done)
1160 add_pool $POOL2 "$FSNAME-OST[$start-$TGT_MAX/2]" "$TGT"
1162 create_dir $dir1 $POOL
1163 create_file $dir1/file1 $POOL2 # Should replace $dir1 pool with $POOL2
1164 create_dir $dir2 $POOL2
1165 touch $dir2/file2 # Should inherit $POOL2 from $dir2
1166 mkdir $dir3 # Should inherit $POOL from $dir1
1167 $LFS setstripe -c 1 $dir3 # Should remain existing $POOL
1168 touch $dir3/file3 # Should inherit $POOL from $dir3
1169 $LFS setstripe -c 1 $dir2/file4 # Should inherit $POOL2 from dir2
1170 $LFS setstripe -S 64K $dir1/file5 # Should inderit $POOL from $dir1
1172 check_file_in_pool $dir1/file1 $POOL2
1173 check_file_in_pool $dir2/file2 $POOL2
1174 check_dir_not_in_pool $dir3 $POOL2
1175 check_file_not_in_pool $dir3/file3 $POOL2
1176 check_file_not_in_pool $dir2/file4 $POOL
1177 check_file_not_in_pool $dir1/file5 $POOL2
1179 if [ "$MDS1_VERSION" -ge $(version_code 2.10.54) ]; then
1180 check_dir_in_pool $dir3 $POOL
1181 check_file_in_pool $dir3/file3 $POOL
1182 check_file_in_pool $dir2/file4 $POOL2
1183 check_file_in_pool $dir1/file5 $POOL
1190 run_test 20 "Different pools in a directory hierarchy."
1193 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1194 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1198 local dir=$POOL_ROOT/dir
1200 create_pool_nofail $POOL
1202 add_pool $POOL $TGT_HALF "$TGT_UUID2"
1204 create_dir $dir $POOL $OSTCOUNT
1205 create_file $dir/file1 $POOL $OSTCOUNT
1206 $LFS getstripe -v $dir/file1
1207 check_file_in_pool $dir/file1 $POOL
1213 run_test 21 "OST pool with fewer OSTs than stripe count"
1221 for c in $(seq 1 10); do
1222 echo "Pool $pool, iteration $c"
1223 do_facet mgs lctl pool_add $FSNAME.$pool \
1224 OST[$TGT_FIRST-$TGT_MAX/$step] 2>/dev/null
1225 local TGT_SECOND=$(printf %04x $((TGT_FIRST + $step)))
1226 if [ $((16#$TGT_SECOND)) -le $((16#$TGT_MAX)) ]; then
1227 do_facet mgs lctl pool_remove $FSNAME.$pool \
1228 OST[$TGT_SECOND-$TGT_MAX/$step]
1231 echo loop for $pool complete
1235 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1236 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1240 create_pool_nofail $POOL
1241 add_pool $POOL "OST0000" "$FSNAME-OST0000_UUID "
1242 create_pool_nofail $POOL2
1243 add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
1248 create_dir $POOL_ROOT $POOL
1249 createmany -o $POOL_ROOT/${tfile} $numfiles ||
1250 error "createmany $POOL_ROOT/${tfile} failed!"
1255 run_test 22 "Simultaneous manipulation of a pool"
1258 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1259 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1262 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS ||
1263 skip_env "User $RUNAS_ID does not exist - skipping"
1267 local BUNIT_SZ=1024 # min block quota unit(kB)
1268 local LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1)))
1269 local dir=$POOL_ROOT/dir
1270 local file="$dir/$tfile-quota"
1272 create_pool_nofail $POOL
1274 local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
1275 printf "$FSNAME-OST%04x_UUID " $i; done)
1276 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1277 create_dir $dir $POOL
1279 # XXX remove the interoperability code once we drop the old server
1280 # ( < 2.3.50) support.
1281 if [ "$MDS1_VERSION" -lt $(version_code 2.3.50) ]; then
1282 $LFS quotaoff -ug $MOUNT
1283 $LFS quotacheck -ug $MOUNT
1285 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1286 do_facet mgs $PERM_CMD \
1287 osd-*.$FSNAME-OST*.quota_slave.enabled=ug
1289 do_facet mgs $PERM_CMD $FSNAME.quota.ost=ug
1294 $LFS setquota -u $RUNAS_ID -b $LIMIT -B $LIMIT $dir
1296 $LFS quota -v -u $RUNAS_ID $dir
1298 $LFS setstripe -c 1 -p $POOL $file
1299 chown $RUNAS_ID.$RUNAS_GID $file
1302 # This does two "dd" runs to ensure that the quota failure is returned
1303 # to userspace when we check. The first "dd" might otherwise complete
1304 # without error if it is only writing into cache.
1305 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
1306 count=$((BUNIT_SZ*2)) 2>&1)
1307 echo $stat | grep "Disk quota exceeded" > /dev/null
1308 if [ $? -eq 0 ]; then
1309 $LFS quota -v -u $RUNAS_ID $dir
1310 cancel_lru_locks osc
1311 stack_trap "rm -f $file"
1312 stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
1313 count=$BUNIT_SZ seek=$((BUNIT_SZ*2)) 2>&1)
1316 [[ $RC -eq 0 ]] && error "second dd did not fail."
1317 echo $stat | grep "Disk quota exceeded" > /dev/null
1318 [[ $? -eq 1 ]] && error "second dd did not fail with EDQUOT."
1320 log "first dd failed with EDQUOT."
1322 $LFS quota -v -u $RUNAS_ID $dir
1324 run_test 23a "OST pools and quota"
1327 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1328 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1331 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS || {
1332 skip_env "User $RUNAS_ID does not exist - skipping"
1337 local dir=$POOL_ROOT/dir
1338 local file="$dir/$tfile-quota"
1340 create_pool_nofail $POOL
1342 local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
1343 printf "$FSNAME-OST%04x_UUID " $i; done)
1344 add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
1345 create_dir $dir $POOL
1347 local maxfree=$((1024 * 1024 * 30)) # 30G
1348 local AVAIL=$(lfs_df -p $POOL $dir | awk '/summary/ { print $4 }')
1349 [ $AVAIL -gt $maxfree ] &&
1350 skip_env "Filesystem space $AVAIL is larger than " \
1353 echo "OSTCOUNT=$OSTCOUNT, OSTSIZE=$OSTSIZE, AVAIL=$AVAIL"
1354 echo "MAXFREE=$maxfree, SLOW=$SLOW"
1356 # XXX remove the interoperability code once we drop the old server
1357 # ( < 2.3.50) support.
1358 if [ "$MDS1_VERSION" -lt $(version_code 2.3.50) ]; then
1359 $LFS quotaoff -ug $MOUNT
1361 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1362 do_facet mgs $PERM_CMD \
1363 osd-*.$FSNAME-OST*.quota_slave.enabled=none
1365 do_facet mgs $PERM_CMD $FSNAME.quota.ost=none
1370 chown $RUNAS_ID.$RUNAS_ID $dir
1374 local stime=$(date +%s)
1378 local maxtime=300 # minimum speed: 5GB / 300sec ~= 17MB/s
1379 while [ $RC -eq 0 ]; do
1381 stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file}$i bs=1M \
1382 count=$((5 * 1024)) 2>&1)
1384 TOTAL=$((TOTAL + 1024 * 1024 * 5))
1385 echo "[$i iteration] $stat"
1386 echo "total written: $TOTAL"
1389 elapsed=$((etime - stime))
1390 echo "stime=$stime, etime=$etime, elapsed=$elapsed"
1392 if [ $RC -eq 1 ]; then
1393 echo $stat | grep -q "Disk quota exceeded"
1395 error "dd failed with EDQUOT with quota off"
1397 echo $stat | grep -q "No space left on device"
1399 error "dd did not fail with ENOSPC"
1400 elif [ $TOTAL -gt $AVAIL ]; then
1401 error "dd didn't fail with ENOSPC ($TOTAL > $AVAIL)"
1402 elif [ $i -eq 1 -a $elapsed -gt $maxtime ]; then
1403 log "The first 5G write used $elapsed (> $maxtime) " \
1404 "seconds, terminated"
1412 run_test 23b "OST pools and OOS"
1415 [[ $OSTCOUNT -le 1 ]] && skip_env "needs >= 2 OSTs"
1416 [[ "$MDS1_VERSION" -ge $(version_code 2.8.56) ]] ||
1417 skip "Need server version newer than 2.8.55"
1419 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1426 create_pool_nofail $POOL
1428 add_pool $POOL $TGT_ALL "$TGT_UUID"
1430 create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
1432 mkdir $POOL_ROOT/dir2
1433 $LFS setstripe -p $POOL -S 65536 -i 0 -c 1 $POOL_ROOT/dir2 ||
1434 error "$LFS setstripe $POOL_ROOT/dir2 failed"
1436 mkdir $POOL_ROOT/dir3
1437 $LFS setstripe -S 65536 -i 0 -c 1 $POOL_ROOT/dir3 ||
1438 error "$LFS setstripe $POOL_ROOT/dir3 failed"
1440 mkdir $POOL_ROOT/dir4
1442 for i in 1 2 3 4; do
1443 dir=${POOL_ROOT}/dir${i}
1452 createmany -o $dir/${tfile} $numfiles ||
1453 error "createmany $dir/${tfile} failed!"
1454 pool=$($LFS getstripe --pool $dir)
1455 index=$($LFS getstripe -i $dir)
1456 size=$($LFS getstripe -S $dir)
1457 count=$($LFS getstripe -c $dir)
1459 for file in $dir/*; do
1460 if [ "$pool" != "" ]; then
1461 check_file_in_pool $file $pool
1463 pool1=$($LFS getstripe --pool $file)
1464 count1=$($LFS getstripe -c $file)
1465 size1=$($LFS getstripe -S $file)
1466 [[ "$pool" != "$pool1" ]] &&
1467 error "Pool '$pool' not on $file:$pool1"
1468 [[ "$count" != "$count1" ]] &&
1469 [[ "$count" != "-1" ]] &&
1470 error "Stripe count $count not on"\
1472 [[ "$count1" != "$OSTCOUNT" ]] &&
1473 [[ "$count" = "-1" ]] &&
1474 error "Stripe count $count1 not on"\
1476 [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] &&
1477 error "Stripe size $size not on $file:$size1"
1485 run_test 24 "Independence of pool from other setstripe parameters"
1488 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1490 mkdir_on_mdt0 $POOL_ROOT
1492 for i in $(seq 10); do
1493 create_pool_nofail $POOL$i
1494 do_facet mgs "lctl pool_add $FSNAME.$POOL$i OST0000; sync"
1495 wait_update $HOSTNAME "lctl get_param -n \
1496 lov.$FSNAME-*.pools.$POOL$i | sort -u |
1497 tr '\n' ' ' " "$FSNAME-OST0000_UUID " >/dev/null ||
1498 error "pool_add failed: $1; $2"
1500 facet_failover $SINGLEMDS ||
1501 error "failed to failover $SINGLEMDS"
1502 wait_osc_import_state $SINGLEMDS ost FULL
1506 # Veriy that the pool got created and is usable
1507 df $POOL_ROOT > /dev/null
1510 # Make sure OST0 can be striped on
1511 $LFS setstripe -i 0 -c 1 $POOL_ROOT/$tfile
1512 local STR=$($LFS getstripe -i $POOL_ROOT/$tfile)
1513 rm $POOL_ROOT/$tfile
1514 if [[ "$STR" == "0" ]]; then
1515 echo "Creating a file in pool$i"
1516 create_file $POOL_ROOT/file$i $POOL$i || break
1517 check_file_in_pool $POOL_ROOT/file$i $POOL$i || break
1519 echo "OST 0 seems to be unavailable. Try later."
1525 run_test 25 "Create new pool and restart MDS"
1528 [[ $OSTCOUNT -le 2 ]] && skip_env "needs >= 3 OSTs"
1529 local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
1533 create_pool_nofail $POOL2
1535 do_facet mgs "lctl pool_add $FSNAME.$POOL2 OST0000; sync"
1536 wait_update $HOSTNAME "lctl get_param -n \
1537 lov.$FSNAME-*.pools.$POOL2 | sort -u |
1538 grep $FSNAME-OST0000_UUID " "$FSNAME-OST0000_UUID" ||
1539 error "pool_add failed: $1; $2"
1541 do_facet mgs "lctl pool_add $FSNAME.$POOL2 OST0002; sync"
1542 wait_update $HOSTNAME "lctl get_param -n \
1543 lov.$FSNAME-*.pools.$POOL2 | sort -u |
1544 grep $FSNAME-OST0002_UUID" "$FSNAME-OST0002_UUID" ||
1545 error "pool_add failed: $1; $2"
1547 # Veriy that the pool got created and is usable
1549 echo "Creating files in $POOL2"
1551 for ((i = 0; i < 10; i++)); do
1552 #OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
1553 #Fail OST0000 to ensure objects create on
1554 #the other OST in the pool
1555 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
1556 do_facet $SINGLEMDS lctl set_param fail_val=0
1557 create_file $POOL_ROOT/file$i $POOL2 1 -1 || break
1558 do_facet $SINGLEMDS lctl set_param fail_loc=0
1559 check_file_in_pool $POOL_ROOT/file$i $POOL2 || break
1563 run_test 26 "Choose other OSTs in the pool first in the creation remedy"
1566 [[ $OSTCOUNT -le 1 ]] && skip_env "Need at least 2 OSTs"
1570 local count=$OSTCOUNT
1572 create_pool_nofail $POOL
1573 do_facet mgs lctl pool_add $FSNAME.$POOL $TGT_ALL
1574 wait_update_facet $SINGLEMDS \
1575 "lctl pool_list $FSNAME.$POOL | wc -l" "$((OSTCOUNT + 1))" ||
1576 error "MDS: pool_list $FSNAME.$POOL failed"
1577 osts=$(list_pool $FSNAME.$POOL)
1578 for ost in ${osts}; do
1580 if [[ $count -eq 0 ]]; then
1581 #define OBD_FAIL_OST_LIST_ASSERT 0x239
1582 do_facet $SINGLEMDS \
1583 $LCTL set_param fail_loc=0x239 fail_val=10
1584 list_pool $FSNAME.$POOL &
1587 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
1588 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $ost
1590 do_facet $SINGLEMDS $LCTL set_param fail_val=0
1592 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $ost
1597 run_test 27 "Race pool_list and pool_remove"
1600 create_pool_nofail $POOL
1601 create_pool_nofail $POOL2
1602 add_pool $POOL $TGT_ALL "$TGT_UUID"
1603 add_pool $POOL2 $TGT_ALL "$TGT_UUID"
1605 start_full_debug_logging
1606 #$LFS setstripe -E 4M -c 1 -p $POOL -E 16M -c 2 $DIR/$tfile
1607 $LFS setstripe -c 1 -p $POOL $DIR/$tfile
1608 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=1 seek=16
1609 local csum=$(cksum $DIR/$tfile)
1610 $LFS getstripe $DIR/$tfile
1611 local pool="$($LFS getstripe -p $DIR/$tfile)"
1612 [[ "$pool" == "$POOL" ]] ||
1613 error "$tfile is in '$pool', not created on $POOL"
1614 $LFS_MIGRATE -y -p $POOL2 $DIR/$tfile ||
1615 error "migrate $tfile to $POOL2 failed"
1616 $LFS getstripe $DIR/$tfile
1617 pool="$($LFS getstripe -p $DIR/$tfile)"
1618 [[ "$pool" == "$POOL2" ]] ||
1619 error "$tfile is in '$pool', not migrated to $POOL2"
1620 local csum2=$(cksum $DIR/$tfile)
1621 [[ "$csum" == "$csum2" ]] || error "checksum error after migration"
1622 stop_full_debug_logging
1624 run_test 28 "lfs_migrate with pool name"
1628 function fill_ost_pool() {
1631 local tmpfile=$DIR/$tdir/$tfile-$pool-filler-$fill_ost_pool_cnt
1634 lfs setstripe $tmpfile -p $pool -c -1
1636 local dfa=($(lfs_df -p $pool | grep _summary))
1637 local total=${dfa[1]}
1638 local used=${dfa[2]}
1639 local towrite=$(( (total * (threshold + 1) / 100) - used ))
1641 echo "total $total, used $used, towrite $towrite"
1642 (( towrite > 0 )) && {
1643 fallocate -l$((towrite * 1024)) $tmpfile ||
1644 error "can't fallocate"
1646 echo ">> filled to $threshold"
1647 ((fill_ost_pool_cnt++))
1651 local pool1=${TESTNAME}-1
1652 local pool2=${TESTNAME}-2
1653 local mdts=$(comma_list $(mdts_nodes))
1655 local prefix="lod.$FSNAME-MDT0000-mdtlov.pool.$pool1"
1656 local cmd="$LCTL get_param -n $prefix"
1660 (( $MDS1_VERSION >= $(version_code 2.14.53) )) ||
1661 skip "Need MDS version at least 2.14.53"
1662 (( $OSTCOUNT >= 4 )) || skip "needs >= 4 OSTs"
1663 check_set_fallocate_or_skip
1665 mkdir_on_mdt0 $DIR/$tdir
1666 stack_trap "rm -rf $DIR/$tdir"
1667 local delay=$(do_facet mds1 lctl get_param -n lo[vd].*.qos_maxage |
1668 awk '{ print $1 * 2; exit; }')
1670 pool_add $pool1 || error "Pool creation failed"
1671 pool_add_targets $pool1 0 1 || error "pool_add_targets failed"
1673 pool_add $pool2 || error "Pool creation failed"
1674 pool_add_targets $pool2 2 3 || error "pool_add_targets failed"
1676 do_facet mds1 $LCTL set_param $prefix.spill_target=$pool2
1677 do_facet mds1 $LCTL set_param $prefix.spill_threshold_pct=$threshold
1678 stack_trap "do_facet mds1 $LCTL set_param $prefix.spill_threshold_pct=0"
1680 [[ $(do_facet mds1 "$cmd.spill_target" | uniq) == "$pool2" ]] ||
1681 error "spill target wasn't set to $pool2"
1682 [[ $(do_facet mds1 "$cmd.spill_threshold_pct" | uniq) == "$threshold" ]] ||
1683 error "spill threshold wasn't set"
1684 before=$(do_facet mds1 "$cmd.spill_hit")
1685 lfs_df -p $pool1 | grep summary
1688 stack_trap "rm -rf $DIR/$tdir"
1689 $LFS setstripe -p $pool1 $DIR/$tdir || error "can't set default layout"
1691 echo "check status with empty $pool1"
1692 sleep $((delay + 1))
1693 [[ $(do_nodes $mdts $cmd.spill_is_active | uniq) == "0" ]] || {
1694 do_nodes $mdts $cmd.spill_is_active
1695 error "spilling on $pool1 is on"
1697 touch $DIR/$tdir/$tfile-5
1698 [[ $($LFS getstripe -p $DIR/$tdir/$tfile-5) == "$pool1" ]] || {
1699 $LFS getstripe $DIR/$tdir/$tfile-5
1700 error "not old pool on $tfile-5"
1703 echo "check with non-empty $pool1"
1704 fill_ost_pool $pool1 $((threshold / 2))
1705 cancel_lru_locks osc
1706 sleep $((delay + 1))
1707 lfs_df -p $pool1 | grep summary
1708 [[ $(do_nodes $mdts $cmd.spill_is_active | uniq) == "0" ]] || {
1709 do_nodes $mdts $cmd.spill_is_active
1710 error "spilling on $pool1 is on"
1712 touch $DIR/$tdir/$tfile-4
1713 [[ $($LFS getstripe -p $DIR/$tdir/$tfile-4) == "$pool1" ]] || {
1714 $LFS getstripe $DIR/$tdir/$tfile-4
1715 error "new pool on $tfile-4"
1718 fill_ost_pool $pool1 $threshold
1719 cancel_lru_locks osc
1720 sleep $((delay + 1))
1721 lfs_df -p $pool1 | grep summary
1722 [[ $(do_nodes $mdts $cmd.spill_is_active | uniq) == "1" ]] || {
1723 do_nodes $mdts $cmd.spill_is_active
1724 error "spilling on $pool1 is off"
1727 # in a directory with default striping
1728 $LFS setstripe -p $pool1 $DIR/$tdir || error "can't set default layout"
1729 touch $DIR/$tdir/$tfile-2
1730 [[ $($LFS getstripe -p $DIR/$tdir/$tfile-2) == "$pool2" ]] || {
1731 $LFS getstripe $DIR/$tdir/$tfile-2
1732 error "old pool on $tfile-2"
1734 after=$(do_facet mds1 "$cmd.spill_hit")
1735 (( after == before + 1 )) || error "after $after != before $before + 1"
1737 # when striping is specified explicitly
1738 $LFS setstripe -p $pool1 $DIR/$tdir/$tfile-3 || error "can't setstripe"
1739 touch $DIR/$tdir/$tfile-3
1740 [[ $($LFS getstripe -p $DIR/$tdir/$tfile-3) == "$pool2" ]] || {
1741 $LFS getstripe $DIR/$tdir/$tfile-3
1742 error "old pool on $tfile-3"
1744 after=$(do_facet mds1 "$cmd.spill_hit")
1745 (( after == before + 2 )) || error "after $after != before $before + 2"
1747 # spill is revalidated at object creation
1748 wait_update_facet mds1 "$cmd.spill_is_active" "1" ||
1749 error "spilling is still inactive"
1751 rm -f $DIR/$tdir/$tfile* || error "can't rm $DIR/$tfile*"
1752 wait_delete_completed
1756 touch $DIR/$tdir/$tfile-2
1757 [[ $($LFS getstripe -p $DIR/$tdir/$tfile-2) == "$pool1" ]] || {
1758 $LFS getstripe $DIR/$tdir/$tfile-2
1759 error "new pool != $pool1"
1761 # spill is revaluated at object creation
1762 wait_update_facet mds1 "$cmd.spill_is_active" "0" ||
1763 error "spilling is still active"
1765 do_facet mds1 "$LCTL set_param $prefix.spill_threshold_pct=0"
1766 [[ $(do_facet mds1 "$cmd.spill_threshold_pct") == "0" ]] ||
1767 error "spill threshold wasn't reset"
1769 run_test 29 "check OST pool spilling"
1772 local MDT_DEV=$(mdsdevname 1)
1773 local mdts=$(comma_list $(mdts_nodes))
1774 local pool1=${TESTNAME}-1
1775 local pool2=${TESTNAME}-2
1777 local prefix="lod.$FSNAME-MDT0000*.pool.$pool1"
1778 local cmd="$LCTL get_param -n $prefix"
1780 (( $MDS1_VERSION >= $(version_code 2.14.53) )) ||
1781 skip "Need MDS version at least 2.14.53"
1782 (( $OSTCOUNT >= 4 )) || skip "needs >= 4 OSTs"
1784 pool_add $pool1 || error "Pool creation failed"
1785 pool_add_targets $pool1 0 1 || error "pool_add_targets failed"
1787 pool_add $pool2 || error "Pool creation failed"
1788 pool_add_targets $pool2 2 3 || error "pool_add_targets failed"
1791 do_facet mds1 $LCTL set_param $prefix.spill_target="0123456789ABCDEF" &&
1793 do_facet mds1 $LCTL set_param $prefix.spill_target="$pool1-2" &&
1794 error "non-exising pool"
1795 do_facet mds1 $LCTL set_param $prefix.spill_target="$pool1" &&
1797 do_facet mds1 $LCTL set_param $prefix.spill_threshold_pct="101" &&
1799 do_facet mds1 $LCTL set_param $prefix.spill_threshold_pct="-1" &&
1802 # set persistent spilling
1803 do_facet mgs $LCTL set_param -P $prefix.spill_target="$pool2"
1804 do_facet mgs $LCTL set_param -P $prefix.spill_threshold_pct=$threshold
1805 wait_update_facet mds1 "$cmd.spill_target" "$pool2" ||
1806 error "spill target wasn't set"
1807 wait_update_facet mds1 "$cmd.spill_threshold_pct" $threshold ||
1808 error "spill target wasn't set"
1810 stop mds1 || error "Fail to stop MDT."
1811 start mds1 $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
1812 wait_update_facet mds1 "$cmd.spill_target" "$pool2" ||
1813 error "spill target wasn't set after restart"
1814 wait_update_facet mds1 "$cmd.spill_threshold_pct" $threshold ||
1815 error "spill target wasn't set after restart"
1817 # now reset spilling
1818 do_facet mgs $LCTL set_param -P $prefix.spill_threshold_pct=0
1819 wait_update_facet mds1 "$cmd.spill_threshold_pct" 0 ||
1820 error "spill target wasn't set"
1822 stop mds1 || error "Fail to stop MDT."
1823 start mds1 $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
1824 wait_update_facet mds1 "$cmd.spill_threshold_pct" 0 ||
1825 error "spill target wasn't set"
1827 run_test 30 "persistent OST pool spilling"
1830 local prefix="lod.$FSNAME-*.pool."
1831 local MDT_DEV=$(mdsdevname mds1)
1832 local mdts=$(comma_list $(mdts_nodes))
1833 local do_mdts="do_nodes $mdts $LCTL"
1834 local pool1=${TESTNAME}-1
1835 local pool2=${TESTNAME}-2
1836 local pool3=${TESTNAME}-3
1837 local pool4=${TESTNAME}-4
1840 (( $MDS1_VERSION >= $(version_code 2.14.53) )) ||
1841 skip "Need MDS version at least 2.14.53"
1842 (( $OSTCOUNT >= 4 )) || skip "needs >= 4 OSTs"
1843 check_set_fallocate_or_skip
1845 pool_add $pool1 || error "Pool creation failed"
1846 pool_add_targets $pool1 0 0 || error "pool_add_targets failed"
1848 pool_add $pool2 || error "Pool creation failed"
1849 pool_add_targets $pool2 1 1 || error "pool_add_targets failed"
1851 pool_add $pool3 || error "Pool creation failed"
1852 pool_add_targets $pool3 2 2 || error "pool_add_targets failed"
1854 pool_add $pool4 || error "Pool creation failed"
1855 pool_add_targets $pool4 3 3 || error "pool_add_targets failed"
1857 fill_ost_pool $pool1 $threshold
1858 fill_ost_pool $pool2 $threshold
1859 fill_ost_pool $pool3 $threshold
1860 cancel_lru_locks osc
1861 local delay=$(do_facet mds1 lctl get_param -n lo[vd].*.qos_maxage |
1862 awk '{ print $1 * 2; exit; }')
1863 sleep $((delay + 1))
1865 stack_trap "$do_mdts set_param lod.*.pool.*.spill_threshold_pct=0"
1867 $do_mdts set_param lod.*.pool.$pool1.spill_target="$pool2"
1868 $do_mdts set_param lod.*.pool.$pool1.spill_threshold_pct="$threshold"
1870 $do_mdts set_param lod.*.pool.$pool2.spill_target="$pool3"
1871 $do_mdts set_param lod.*.pool.$pool2.spill_threshold_pct="$threshold"
1873 $do_mdts set_param lod.*.pool.$pool3.spill_target="$pool4"
1874 $do_mdts set_param lod.*.pool.$pool3.spill_threshold_pct="$threshold"
1876 $do_mdts get_param lod.*.pool.*.spill*
1878 $LFS setstripe -p $pool1 $DIR/$tdir || error "can't set default layout"
1879 local tmpfile=$DIR/$tdir/$tfile-2
1881 $LFS getstripe $tmpfile | grep -q pool.*$pool4 || {
1882 $LFS getstripe $tmpfile
1883 error "old pool is not $pool4"
1888 # reset all loop spilling
1889 $do_mdts set_param lod.*.pool.*.spill_threshold_pct="0"
1891 # pool1->pool2->pool3, then pool4->pool1 fails
1892 $do_mdts set_param lod.*.pool.$pool1.spill_target="$pool2" ||
1893 error "can't set spill target for $pool1"
1894 $do_mdts set_param lod.*.pool.$pool2.spill_target="$pool3" ||
1895 error "can't set spill target for $pool1"
1896 $do_mdts set_param lod.*.pool.$pool3.spill_target="$pool4" ||
1897 error "can't set spill target for $pool1"
1898 $do_mdts set_param lod.*.pool.$pool4.spill_target="$pool1" &&
1899 error "loop succeed"
1901 # reset all loop spilling
1902 $do_mdts set_param lod.*.pool.*.spill_threshold_pct="0"
1904 # pool1->pool2,pool4->pool1, then pool3->pool4 fails
1905 $do_mdts set_param lod.*.pool.$pool1.spill_target="$pool2" ||
1906 error "can't set spill target for $pool1"
1907 $do_mdts set_param lod.*.pool.$pool2.spill_target="$pool3" ||
1908 error "can't set spill target for $pool1"
1909 $do_mdts set_param lod.*.pool.$pool4.spill_target="$pool1" ||
1910 error "can't set spill target for $pool4"
1911 $do_mdts set_param lod.*.pool.$pool3.spill_target="$pool4" &&
1912 error "loop succeed"
1916 run_test 31 "OST pool spilling chained"
1918 test_32() { # LU-15707
1919 (( OSTCOUNT >= 2 )) || skip "Need at least 2 OST"
1921 local pool=$TESTNAME
1922 pool_add $pool || error "add $pool failed"
1923 pool_add_targets $pool 0 ||
1924 error "add targets to $pool failed"
1926 test_mkdir $DIR/$tdir
1927 $LFS setstripe -p $pool $DIR/$tdir ||
1928 error "setstripe fail on $DIR/$tdir"
1930 ( $LFS getstripe -p $DIR/$tdir | grep -q $pool ) ||
1931 error "fail to set pool on $DIR/$tdir"
1933 $LFS setstripe -p ignore $DIR/$tdir/$tfile ||
1934 error "setstripe fail on $DIR/$tdir/$tfile"
1936 ! ( $LFS getstripe -p $DIR/$tdir/$tfile | egrep -q "[^ ]+" ) ||
1937 error "fail to create $DIR/$tdir/$tfile without pool"
1939 # Test with start index
1941 for ((idx = 0; idx < OSTCOUNT; idx++)); do
1942 $LFS setstripe -p ignore -i $idx $DIR/$tdir/$tfile.$idx ||
1943 error "setstripe -i fail on $DIR/$tdir/$tfile.$idx"
1945 got=$($LFS getstripe -i $DIR/$tdir/$tfile.$idx)
1947 error "file $tfile.$idx on OST $got != $idx"
1950 # Test with ost list
1951 $LFS setstripe -p ignore -o 1,0 $DIR/$tdir/$tfile.1_0 ||
1952 error "setstripe --ost fail on $DIR/$tdir/$tfile.1_0"
1954 got=$($LFS getstripe -i $DIR/$tdir/$tfile.1_0)
1956 error "file $tfile.1_0 (ostlist) start on OST $got != 1"
1958 got=$($LFS getstripe -c $DIR/$tdir/$tfile.1_0)
1960 error "file $tfile.1_0 (ostlist) has stripe count $got != 2"
1962 run_test 32 "force to create a file without pool (no inheritance)"
1966 complete_test $SECONDS
1967 destroy_test_pools $FSNAME
1968 if ! combined_mgs_mds; then
1969 zconf_umount $mgs_HOST $MOUNT
1970 do_facet mgs "rm -rf $MOUNT"
1972 check_and_cleanup_lustre