Commit ece9c72a authored by Jan Kara's avatar Jan Kara Committed by Jens Axboe

block: Fix computation of merged request priority

Priority of a merged request is computed by ioprio_best(). If one of the
requests has undefined priority (IOPRIO_CLASS_NONE) and another request
has priority from IOPRIO_CLASS_BE, the function will return the
undefined priority which is wrong. Fix the function to properly return
priority of a request with the defined priority.

Fixes: d58cdfb8
CC: stable@vger.kernel.org
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Reviewed-by: default avatarJeff Moyer <jmoyer@redhat.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 3a2f22b7
...@@ -157,14 +157,16 @@ static int get_task_ioprio(struct task_struct *p) ...@@ -157,14 +157,16 @@ static int get_task_ioprio(struct task_struct *p)
int ioprio_best(unsigned short aprio, unsigned short bprio) int ioprio_best(unsigned short aprio, unsigned short bprio)
{ {
unsigned short aclass = IOPRIO_PRIO_CLASS(aprio); unsigned short aclass;
unsigned short bclass = IOPRIO_PRIO_CLASS(bprio); unsigned short bclass;
if (aclass == IOPRIO_CLASS_NONE) if (!ioprio_valid(aprio))
aclass = IOPRIO_CLASS_BE; aprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM);
if (bclass == IOPRIO_CLASS_NONE) if (!ioprio_valid(bprio))
bclass = IOPRIO_CLASS_BE; bprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM);
aclass = IOPRIO_PRIO_CLASS(aprio);
bclass = IOPRIO_PRIO_CLASS(bprio);
if (aclass == bclass) if (aclass == bclass)
return min(aprio, bprio); return min(aprio, bprio);
if (aclass > bclass) if (aclass > bclass)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment