block: Fix handling of tasks without ioprio in ioprio_get(2)
authorJan Kara <jack@suse.cz>
Thu, 23 Jun 2022 07:48:30 +0000 (09:48 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 27 Jun 2022 12:29:12 +0000 (06:29 -0600)
commit4b838d9ee950b37bee624e301bd8e923165b1cf3
tree6c6bbd6120095074bc73b0fafe0de664a51e8da8
parentfc25545e17bd74befe0b8ab2c65ac84936be5066
block: Fix handling of tasks without ioprio in ioprio_get(2)

ioprio_get(2) can be asked to return the best IO priority from several
tasks (IOPRIO_WHO_PGRP, IOPRIO_WHO_USER). Currently the call treats
tasks without set IO priority as having priority
IOPRIO_CLASS_BE/IOPRIO_BE_NORM however this does not really reflect the
IO priority the task will get (which depends on task's nice value).

Fix the code to use the real IO priority task's IO will use. We have to
modify code for ioprio_get(IOPRIO_WHO_PROCESS) to keep returning
IOPRIO_CLASS_NONE priority for tasks without set IO priority as a
special case to maintain userspace visible API.

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>
Link: https://lore.kernel.org/r/20220623074840.5960-5-jack@suse.cz
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/ioprio.c