From: Daniel Wagner <dwagner@suse.de>
To: Christoph Hellwig <hch@infradead.org>,
Stephen Zhang <starzhangzsd@gmail.com>,
Kent Overstreet <kent.overstreet@linux.dev>,
Coly Li <colyli@fnnas.com>,
Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
Johannes Thumshirn <Johannes.Thumshirn@wdc.com>,
linux-block@vger.kernel.org, linux-bcache@vger.kernel.org,
Daniel Wagner <dwagner@suse.de>
Subject: [PATCH blktests v3 2/3] bcache: add bcache/002
Date: Thu, 22 Jan 2026 10:57:13 +0100 [thread overview]
Message-ID: <20260122-bcache-v3-2-2c02d15a4503@suse.de> (raw)
In-Reply-To: <20260122-bcache-v3-0-2c02d15a4503@suse.de>
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 <dwagner@suse.de>
---
tests/bcache/002 | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/bcache/002.out | 2 ++
2 files changed, 65 insertions(+)
diff --git a/tests/bcache/002 b/tests/bcache/002
new file mode 100644
index 000000000000..04892667ad1b
--- /dev/null
+++ b/tests/bcache/002
@@ -0,0 +1,63 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2026 Daniel Wagner, SUSE Labs
+#
+# Test based on Stephen Zhang <starzhangzsd@gmail.com> test case
+# https://lore.kernel.org/linux-bcache/CANubcdX7eNbH_bo4-f94DUbdiEbt04Vxy1MPyhm+CZyXB01FuQ@mail.gmail.com/#t
+#
+# Test bcache for bio leaks in clone
+
+. tests/bcache/rc
+
+DESCRIPTION="test bcache for bio leaks in clone"
+
+requires() {
+ _bcache_requires
+ _have_fio
+ _have_program iostat
+}
+
+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
+
+ 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
+ echo "ERROR: Accounting leak detected!"
+ fi
+
+ { pkill -f "fio.*${bcache_dev}"; wait "${fio_pid}"; } &> /dev/null
+
+ _remove_bcache --bcache "${bcache_nodes[@]}" \
+ --cache "${TEST_DEV_ARRAY[0]##*/}" \
+ --bdev "${TEST_DEV_ARRAY[1]##*/}"
+}
diff --git a/tests/bcache/002.out b/tests/bcache/002.out
new file mode 100644
index 000000000000..529c1a90b135
--- /dev/null
+++ b/tests/bcache/002.out
@@ -0,0 +1,2 @@
+Running bcache/002
+Device state: no cache
--
2.52.0
next prev parent reply other threads:[~2026-01-22 9:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-22 9:57 [PATCH blktests v3 0/3] bcache: add initial test cases Daniel Wagner
2026-01-22 9:57 ` [PATCH blktests v3 1/3] bcache: add bcache/001 Daniel Wagner
2026-01-22 9:57 ` Daniel Wagner [this message]
2026-01-22 9:57 ` [PATCH blktests v3 3/3] doc: document how to configure bcache tests Daniel Wagner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260122-bcache-v3-2-2c02d15a4503@suse.de \
--to=dwagner@suse.de \
--cc=Johannes.Thumshirn@wdc.com \
--cc=colyli@fnnas.com \
--cc=hch@infradead.org \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=shinichiro.kawasaki@wdc.com \
--cc=starzhangzsd@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox