[LTP] [PATCH] sys_block_queue01: Accept plain "none" in queue/scheduler
Darren Chang
chihsheng@google.com
Wed Nov 18 07:34:45 CET 2026
On kernels older than 6.5, bio-based block devices (such as dm, ram,
zram, and pmem) expose queue/scheduler with plain "none" (without
brackets). Kernels before 6.14 also output plain "none" for blk-mq
devices with BLK_MQ_F_NO_SCHED.
These cases were removed in kernel 6.5 (commit 6d85ebf95c44) and
kernel 6.14 (commit e7602bb4f3a1), but older kernels still fail the
test because TST_SYSFS_ASSERT_CHOICE() expects one bracketed token:
TFAIL: /sys/block/dm-87/queue/scheduler has 0 selected tokens, expected exactly 1
Read queue/scheduler first and pass if the value is exact "none".
Keep TCONF when the file is missing, and use TST_SYSFS_ASSERT_CHOICE()
for all other values.
Fixes: f35242c9cc22 ("testcases: sysfs: Add sys_block_queue01")
Signed-off-by: Darren Chang <chihsheng@google.com>
---
.../kernel/sysfs/block/sys_block_queue01.c | 38 ++++++++++++++++---
1 file changed, 33 insertions(+), 5 deletions(-)
diff --git a/testcases/kernel/sysfs/block/sys_block_queue01.c b/testcases/kernel/sysfs/block/sys_block_queue01.c
index 38564139a..ce1f945fd 100644
--- a/testcases/kernel/sysfs/block/sys_block_queue01.c
+++ b/testcases/kernel/sysfs/block/sys_block_queue01.c
@@ -16,7 +16,13 @@
* - read_ahead_kb, nr_requests and discard_max_bytes are non-negative
* - nr_requests is greater than zero
* - rotational, add_random, iostats are boolean (0 or 1)
- * - scheduler is a valid bracketed-choice file with exactly one active scheduler
+ * - scheduler is a valid bracketed-choice file with exactly one active
+ * scheduler, or plain ``none`` without brackets for devices that do not
+ * support I/O schedulers (bio-based devices such as dm, ram, zram, pmem on
+ * kernels prior to 6.5 before commit 6d85ebf95c44 "blk-sysfs: add a new
+ * attr_group for blk_mq", and blk-mq queues with BLK_MQ_F_NO_SCHED prior to
+ * 6.14 before commit e7602bb4f3a1 "block: remove BLK_MQ_F_NO_SCHED", where
+ * elv_iosched_show() emits "none\n")
*
* All checks skip gracefully with TCONF when a particular attribute is not
* present, since the set of exported queue attributes differs between kernel
@@ -36,6 +42,31 @@ static const char *const sched_allowed[] = {
"kyber", "bfq", "anticipatory", NULL
};
+static void check_scheduler(const char *dev)
+{
+ char sched[64];
+
+ if (!TST_SYSFS_READ_STR(sched, sizeof(sched),
+ PATH_SYS_BLOCK "/%s/queue/scheduler", dev)) {
+ tst_res(TCONF, PATH_SYS_BLOCK "/%s/queue/scheduler does not exist",
+ dev);
+ return;
+ }
+
+ /*
+ * elv_iosched_show() emits plain "none\n" without brackets for queues
+ * that do not support I/O schedulers (bio-based devices prior to 6.5,
+ * and BLK_MQ_F_NO_SCHED devices prior to 6.14).
+ */
+ if (!strcmp(sched, "none")) {
+ tst_res(TPASS, PATH_SYS_BLOCK "/%s/queue/scheduler = 'none'", dev);
+ return;
+ }
+
+ TST_SYSFS_ASSERT_CHOICE(sched_allowed, NULL, 0,
+ PATH_SYS_BLOCK "/%s/queue/scheduler", dev);
+}
+
static void check_cross(const char *dev)
{
TST_SYSFS_ASSERT_LE_SUFFIX("logical_block_size", "physical_block_size",
@@ -50,8 +81,6 @@ static void check_cross(const char *dev)
static void check_device(const char *dev)
{
- char sched[64];
-
tst_res(TINFO, "Checking block device '%s'", dev);
TST_SYSFS_ASSERT_POW2(PATH_SYS_BLOCK "/%s/queue/logical_block_size", dev);
@@ -68,8 +97,7 @@ static void check_device(const char *dev)
TST_SYSFS_ASSERT_BOOL(PATH_SYS_BLOCK "/%s/queue/add_random", dev);
TST_SYSFS_ASSERT_BOOL(PATH_SYS_BLOCK "/%s/queue/iostats", dev);
- TST_SYSFS_ASSERT_CHOICE(sched_allowed, sched, sizeof(sched),
- PATH_SYS_BLOCK "/%s/queue/scheduler", dev);
+ check_scheduler(dev);
check_cross(dev);
}
--
2.56.1.703.gf848ed807c-goog
More information about the ltp
mailing list