[LTP] [PATCH] sys_block_queue01: Accept plain "none" in queue/scheduler
Cyril Hrubis
chrubis@suse.cz
Thu Nov 19 12:24:10 CET 2026
Hi!
> 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).
> + */
The description in the top level comment is enough, I wouldn't add this
comment here.
> + if (!strcmp(sched, "none")) {
> + tst_res(TPASS, PATH_SYS_BLOCK "/%s/queue/scheduler = 'none'", dev);
> + return;
> + }
If this happens only in older kernels the check should be done only on
older kernels too. So we need tst_kvercmp() in the test setup that would
set allow_plain_none flag.
> + 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
>
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list