]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
block: Fix default IO priority if there is no IO context
authorGuenter Roeck <linux@roeck-us.net>
Thu, 31 Jul 2025 04:49:53 +0000 (21:49 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 31 Jul 2025 21:00:41 +0000 (15:00 -0600)
Upstream commit 53889bcaf536 ("block: make __get_task_ioprio() easier to
read") changes the IO priority returned to the caller if no IO context
is defined for the task. Prior to this commit, the returned IO priority
was determined by task_nice_ioclass() and task_nice_ioprio(). Now it is
always IOPRIO_DEFAULT, which translates to IOPRIO_CLASS_NONE with priority
0. However, task_nice_ioclass() returns IOPRIO_CLASS_IDLE, IOPRIO_CLASS_RT,
or IOPRIO_CLASS_BE depending on the task scheduling policy, and
task_nice_ioprio() returns a value determined by task_nice(). This causes
regressions in test code checking the IO priority and class of IO
operations on tasks with no IO context.

Fix the problem by returning the IO priority calculated from
task_nice_ioclass() and task_nice_ioprio() if no IO context is defined
to match earlier behavior.

Fixes: 53889bcaf536 ("block: make __get_task_ioprio() easier to read")
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Link: https://lore.kernel.org/r/20250731044953.1852690-1-linux@roeck-us.net
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/ioprio.h

index b25377b6ea98dd6a0446ac71a71ae969d526d540..5210e8371238f1fef4efe7c2806d831bb06bab7e 100644 (file)
@@ -60,7 +60,8 @@ static inline int __get_task_ioprio(struct task_struct *p)
        int prio;
 
        if (!ioc)
-               return IOPRIO_DEFAULT;
+               return IOPRIO_PRIO_VALUE(task_nice_ioclass(p),
+                                        task_nice_ioprio(p));
 
        if (p != current)
                lockdep_assert_held(&p->alloc_lock);