summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2024-01-08 11:51:57 -0700
committerJens Axboe <axboe@kernel.dk>2024-01-08 12:27:46 -0700
commit53889bcaf536b3abedeaf104019877cee37dd08b (patch)
treea60aa7d8c61d9e626c4e0f6f6ab06dd680679d86
parent3b7cb745473aec7255d66e3854abaa9c3f46f952 (diff)
downloadlinux-53889bcaf536b3abedeaf104019877cee37dd08b.tar.gz
linux-53889bcaf536b3abedeaf104019877cee37dd08b.tar.bz2
linux-53889bcaf536b3abedeaf104019877cee37dd08b.zip
block: make __get_task_ioprio() easier to read
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>
-rw-r--r--include/linux/ioprio.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h
index d6a9b5b7ed16..db1249cd9692 100644
--- a/include/linux/ioprio.h
+++ b/include/linux/ioprio.h
@@ -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));