]> git.itanic.dy.fi Git - linux-stable/commitdiff
block: make __get_task_ioprio() easier to read
authorJens Axboe <axboe@kernel.dk>
Mon, 8 Jan 2024 18:51:57 +0000 (11:51 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 8 Jan 2024 19:27:46 +0000 (12:27 -0700)
We don't need to do any gymnastics if we don't have an io_context
assigned at all, so just return early with our default priority.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/ioprio.h

index d6a9b5b7ed1671dbb13bed816610505edb85b1b0..db1249cd9692080f495c8986826d96eaf56b7995 100644 (file)
@@ -59,13 +59,13 @@ static inline int __get_task_ioprio(struct task_struct *p)
        struct io_context *ioc = p->io_context;
        int prio;
 
+       if (!ioc)
+               return IOPRIO_DEFAULT;
+
        if (p != current)
                lockdep_assert_held(&p->alloc_lock);
-       if (ioc)
-               prio = ioc->ioprio;
-       else
-               prio = IOPRIO_DEFAULT;
 
+       prio = ioc->ioprio;
        if (IOPRIO_PRIO_CLASS(prio) == IOPRIO_CLASS_NONE)
                prio = IOPRIO_PRIO_VALUE(task_nice_ioclass(p),
                                         task_nice_ioprio(p));