Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

block: Return effective IO priority from get_current_ioprio()

get_current_ioprio() is used to initialize IO priority of various
requests. As such it should be returning the effective IO priority of
the task (i.e., reflecting the fact that unset IO priority should get
set based on task's CPU priority) so that the conversion is concentrated
in one place.

Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Tested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20220623074840.5960-2-jack@suse.cz
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Jan Kara and committed by
Jens Axboe
f7eda402 e589f464

+9 -2
+9 -2
include/linux/ioprio.h
··· 53 53 static inline int get_current_ioprio(void) 54 54 { 55 55 struct io_context *ioc = current->io_context; 56 + int prio; 56 57 57 58 if (ioc) 58 - return ioc->ioprio; 59 - return IOPRIO_DEFAULT; 59 + prio = ioc->ioprio; 60 + else 61 + prio = IOPRIO_DEFAULT; 62 + 63 + if (IOPRIO_PRIO_CLASS(prio) == IOPRIO_CLASS_NONE) 64 + prio = IOPRIO_PRIO_VALUE(task_nice_ioclass(current), 65 + task_nice_ioprio(current)); 66 + return prio; 60 67 } 61 68 62 69 /*