Re: [PATCH blktests v4 2/3] bcache: add bcache/002

Shinichiro Kawasaki <[email protected]> Tue, 17 Feb 2026 07:50:04 +0000
Newsgroups org.kernel.vger.linux-bcache,org.kernel.vger.linux-block
Message-ID <aZQcH-d-ZcgtMoJb@shinmob>
On Feb 12, 2026 / 16:23, Daniel Wagner wrote:
> Add test case from Stephen Zhang [1].
> 
> [1] https://lore.kernel.org/linux-bcache/CANubcdX7eNbH_bo4-f94DUbdiEbt04Vxy1MPyhm+CZyXB01FuQ@mail.gmail.com/
> 
> Signed-off-by: Daniel Wagner <[email protected]>

Thank you for adding this patch. When I ran this test case in my test
environment using the kernel v6.19, it failed:

    runtime  7.536s  ...  7.214s
    --- tests/bcache/002.out    2026-02-14 21:16:20.918000000 +0900
    +++ /home/shin/Blktests/blktests/results/nvme0n1_nvme2n1_nvme3n1_nvme4n1/bcache/002.out.bad 2026-02-16 14:29:25.596000000 +0900
    @@ -1,2 +1,3 @@
     Running bcache/002
     Device state: no cache
    +ERROR: Accounting leak detected!

Is this failure expected?

And let me leave a few nit comments in line.

> ---
>  tests/bcache/002     | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/bcache/002.out |  2 ++
>  2 files changed, 64 insertions(+)
> 
> diff --git a/tests/bcache/002 b/tests/bcache/002
> new file mode 100755
> index 000000000000..c27178a90c2d
> --- /dev/null
> +++ b/tests/bcache/002
[...]
> +test_device_array() {
> +	echo "Running ${TEST_NAME}"
> +
> +	if [[ ${#TEST_DEV_ARRAY[@]} -lt 2 ]]; then
> +		SKIP_REASONS+=("requires at least 2 devices")
> +		return 1
> +	fi
> +
> +	_setup_bcache "${TEST_DEV_ARRAY[@]}"
> +
> +	local bcache_nodes bcache_dev bdev_name fio_pid

Nit: I think bcache_nodes should be declared as an array, with -a option.
     Also, 'state' can be added to this local var list.

> +
> +	mapfile -t bcache_nodes < <(_create_bcache \
> +				--cache "${TEST_DEV_ARRAY[0]##*/}" \
> +				--bdev "${TEST_DEV_ARRAY[1]##*/}" \
> +				--writeback)
> +
> +	bcache_dev="${bcache_nodes[0]}"
> +	bdev_name="$(basename "${bcache_dev}")"
> +	echo 1 > /sys/block/"${bdev_name}"/bcache/detach
> +
> +	state="$(cat /sys/block/"${bdev_name}"/bcache/state)"
> +	echo "Device state: ${state}"
> +
> +	_run_fio_rand_io --filename="${bcache_dev}" --time_base \
> +			--runtime=30 >> "$FULL" 2>&1 &
> +	fio_pid=$!
> +
> +	sleep 5
> +
> +	local stats_line util
> +	stats_line=$(iostat -x 1 2 "${bdev_name}" | grep -w "${bdev_name}" | tail -n 1)
> +	util="$(echo "${stats_line}" | awk '{print $NF}')"
> +
> +	if (( $(echo "${util} > 1.0" | bc -l) )); then

Nit: bc -l option can be --mathlib for readability.

> +		echo "ERROR: Accounting leak detected!"
> +	fi
> +
> +	{ pkill -f "fio.*${bcache_dev}"; wait "${fio_pid}"; } &> /dev/null

Nit: pkill -f option can be --full for readability.

> +
> +	_remove_bcache --bcache "${bcache_nodes[@]}" \
> +			--cache "${TEST_DEV_ARRAY[0]##*/}" \
> +			--bdev "${TEST_DEV_ARRAY[1]##*/}"
> +}