diff --git a/tests/throtl/008 b/tests/throtl/008 index 0570fc0..b1bcf84 100755 --- a/tests/throtl/008 +++ b/tests/throtl/008 @@ -4,76 +4,36 @@ # # Test cgroup iocost IOPS limiting. -. tests/block/rc -. common/null_blk -. common/cgroup +. tests/throtl/rc . common/fio DESCRIPTION="test cgroup iocost controller limits" requires() { - _have_cgroup2_controller io - _have_null_blk _have_fio - _have_program bc if [[ ! -e "$(_cgroup2_base_dir)/io.cost.qos" ]]; then SKIP_REASONS+=("iocost controller not supported (CONFIG_BLK_CGROUP_IOCOST)") return 1 fi } +set_conditions() { + _set_throtl_blkdev_type "$@" +} + test() { echo "Running ${TEST_NAME}" - # Create a null_blk instance - local null_blk_params=( - blocksize=4096 - completion_nsec=0 - memory_backed=0 - size=1024 # MB - submit_queues=1 - power=1 - ) - _init_null_blk nr_devices=0 queue_mode=2 && - if ! _configure_null_blk nullb0 "${null_blk_params[@]}"; then - echo "Configuring null_blk failed" + # Set up throtl device and cgroup + if ! _set_up_throtl; then return 1 fi local dev_t - dev_t=$( "$(_cgroup2_base_dir)/cgroup.subtree_control"; then - echo "Failed to enable io controller on cgroup root" - _exit_cgroup2 - _exit_null_blk - return 1 - fi - deactivate_io_ctrlr=true - fi - - if ! echo "+io" > "$CGROUP2_DIR/cgroup.subtree_control"; then - echo "Failed to enable io controller on $CGROUP2_DIR" - if [[ $deactivate_io_ctrlr == true ]]; then - echo "-io" > "$(_cgroup2_base_dir)/cgroup.subtree_control" - fi - _exit_cgroup2 - _exit_null_blk + echo "Failed to get major:minor for $THROTL_DEV" + _clean_up_throtl return 1 fi @@ -81,11 +41,7 @@ test() { # min=100.00 max=100.00 forces vrate to be fixed at 100% if ! echo "$dev_t enable=1 min=100.00 max=100.00" > "$(_cgroup2_base_dir)/io.cost.qos"; then echo "Failed to configure io.cost.qos" - if [[ $deactivate_io_ctrlr == true ]]; then - echo "-io" > "$(_cgroup2_base_dir)/cgroup.subtree_control" - fi - _exit_cgroup2 - _exit_null_blk + _clean_up_throtl return 1 fi @@ -94,25 +50,21 @@ test() { if ! echo "$dev_t ctrl=user model=linear rbps=0 rseqiops=100 rrandiops=100 wbps=0 wseqiops=10 wrandiops=10" > "$(_cgroup2_base_dir)/io.cost.model"; then echo "Failed to configure io.cost.model" echo "$dev_t enable=0" > "$(_cgroup2_base_dir)/io.cost.qos" - if [[ $deactivate_io_ctrlr == true ]]; then - echo "-io" > "$(_cgroup2_base_dir)/cgroup.subtree_control" - fi - _exit_cgroup2 - _exit_null_blk + _clean_up_throtl return 1 fi # Create a child cgroup for test local cg_name="testgrp" - local cg_path="$CGROUP2_DIR/$cg_name" + local cg_path="$CGROUP2_DIR/$THROTL_DIR/$cg_name" mkdir "$cg_path" # 1. Run FIO read test local -a FIO_PERF_FIELDS FIO_PERF_FIELDS=("read iops") - if ! _fio_perf --bs=4k --rw=randread --name=read-test --filename=/dev/nullb0 \ + if ! _fio_perf --bs=4k --rw=randread --name=read-test --filename=/dev/"$THROTL_DEV" \ --ioengine=libaio --direct=1 --iodepth=64 --time_based --runtime=10 \ - --cgroup="blktests/$cg_name" > /dev/null 2>&1; then + --cgroup="blktests/$THROTL_DIR/$cg_name" > /dev/null 2>&1; then echo "FIO read test failed" else local read_iops=${TEST_RUN["read iops"]} @@ -125,9 +77,9 @@ test() { # 2. Run FIO write test FIO_PERF_FIELDS=("write iops") - if ! _fio_perf --bs=4k --rw=randwrite --name=write-test --filename=/dev/nullb0 \ + if ! _fio_perf --bs=4k --rw=randwrite --name=write-test --filename=/dev/"$THROTL_DEV" \ --ioengine=libaio --direct=1 --iodepth=64 --time_based --runtime=10 \ - --cgroup="blktests/$cg_name" > /dev/null 2>&1; then + --cgroup="blktests/$THROTL_DIR/$cg_name" > /dev/null 2>&1; then echo "FIO write test failed" else local write_iops=${TEST_RUN["write iops"]} @@ -140,13 +92,7 @@ test() { # Clean up cgroups rmdir "$cg_path" - if [[ $deactivate_io_ctrlr == true ]]; then - { echo "-io" > "$(_cgroup2_base_dir)/cgroup.subtree_control"; } &> "${FULL}" - fi - _exit_cgroup2 - - # Clean up null_blk - _exit_null_blk + _clean_up_throtl echo "Test complete" }