From: Damien Le Moal <dlemoal@kernel.org>
To: Aaron Lu <ziqianlu@bytedance.com>, Jens Axboe <axboe@kernel.dk>
Cc: Kexin Wei <ys.weikexin@h3c.com>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] block: remove test of io priority level
Date: Tue, 29 Apr 2025 19:50:11 +0900 [thread overview]
Message-ID: <adca39d3-04fc-45f5-8e34-0d06714f0ff9@kernel.org> (raw)
In-Reply-To: <20250429082934.GA3896701@bytedance>
On 4/29/25 17:29, Aaron Lu wrote:
> Ever since commit eca2040972b4("scsi: block: ioprio: Clean up interface
> definition"), the io priority level is masked and can no longer be larger
> than IOPRIO_NR_LEVELS so remove this now useless test.
>
> The actual test of io prio level is done in ioprio_value() where any
> invalid input of class/level/hint will result in an invalid class being
> passed to the syscall, this is introduced in commit 01584c1e2337("scsi:
> block: Improve ioprio value validity checks").
>
> Reported-by: Kexin Wei <ys.weikexin@h3c.com>
> Cc: Damien Le Moal <dlemoal@kernel.org>
> Signed-off-by: Aaron Lu <ziqianlu@bytedance.com>
> ---
> Kexin reported a LTP/ioprio_set03 case failure, where the test would
> pass IOPRIO_CLASS_BE with priority level 8 and see if kernel would
> return error. Turned out she is using an old kernel header where the
> change introduced in commit 01584c1e2337("scsi: block: Improve ioprio
> value validity checks") isn't available. During troubleshooting, I find
> this priority level test confusing and misleading so I think it should
> be removed.
What is confusing and misleading about the fact that we support only 8 priority
levels (0 to 7) and should check for it ?
With that said, the test is indeed redundant for the BE and RT class because we
have:
int ioprio_check_cap(int ioprio)
{
int class = IOPRIO_PRIO_CLASS(ioprio);
int level = IOPRIO_PRIO_LEVEL(ioprio);
And the macro IOPRIO_PRIO_LEVEL() will mask the level value to something between
0 and 7, always. So necessarily, level will always be lower than
IOPRIO_NR_LEVELS. So please reword your commit message to explain that rather
than describe what a user may or may not use when setting an ioprio field.
And also simplify the patch:
diff --git a/block/ioprio.c b/block/ioprio.c
index 73301a261429..f0ee2798539c 100644
--- a/block/ioprio.c
+++ b/block/ioprio.c
@@ -46,12 +46,8 @@ int ioprio_check_cap(int ioprio)
*/
if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_NICE))
return -EPERM;
- fallthrough;
- /* rt has prio field too */
- case IOPRIO_CLASS_BE:
- if (level >= IOPRIO_NR_LEVELS)
- return -EINVAL;
break;
+ case IOPRIO_CLASS_BE:
case IOPRIO_CLASS_IDLE:
break;
case IOPRIO_CLASS_NONE:
> block/ioprio.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/block/ioprio.c b/block/ioprio.c
> index 73301a261429f..60364d3faf800 100644
> --- a/block/ioprio.c
> +++ b/block/ioprio.c
> @@ -46,11 +46,8 @@ int ioprio_check_cap(int ioprio)
> */
> if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_NICE))
> return -EPERM;
> - fallthrough;
> - /* rt has prio field too */
> + break;
> case IOPRIO_CLASS_BE:
> - if (level >= IOPRIO_NR_LEVELS)
> - return -EINVAL;
> break;
> case IOPRIO_CLASS_IDLE:
> break;
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2025-04-29 10:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-29 8:29 [PATCH] block: remove test of io priority level Aaron Lu
2025-04-29 10:50 ` Damien Le Moal [this message]
2025-04-29 11:44 ` [External] " Aaron Lu
2025-04-29 12:24 ` Damien Le Moal
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=adca39d3-04fc-45f5-8e34-0d06714f0ff9@kernel.org \
--to=dlemoal@kernel.org \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ys.weikexin@h3c.com \
--cc=ziqianlu@bytedance.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