summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2022-06-23 09:48:27 +0200
committerJens Axboe <axboe@kernel.dk>2022-06-27 06:29:12 -0600
commitf7eda402878b12bc0884c5bc1192a9e76ad121fb (patch)
tree93dd7989700fd8bd18b9dc98f79ffc1026d6ea55
parente589f46445960c274cc813a1cc8e2fc73b2a1849 (diff)
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>
-rw-r--r--include/linux/ioprio.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h
index 3d088a88f832..61ed6bb4998e 100644
--- a/include/linux/ioprio.h
+++ b/include/linux/ioprio.h
@@ -53,10 +53,17 @@ static inline int task_nice_ioclass(struct task_struct *task)
static inline int get_current_ioprio(void)
{
struct io_context *ioc = current->io_context;
+ int prio;
if (ioc)
- return ioc->ioprio;
- return IOPRIO_DEFAULT;
+ prio = ioc->ioprio;
+ else
+ prio = IOPRIO_DEFAULT;
+
+ if (IOPRIO_PRIO_CLASS(prio) == IOPRIO_CLASS_NONE)
+ prio = IOPRIO_PRIO_VALUE(task_nice_ioclass(current),
+ task_nice_ioprio(current));
+ return prio;
}
/*