block layer: ioprio_best function fix
PATCH 1/1 block layer: ioprio_best function fix
Currently ioprio_best function first checks wethere aioprio or bioprio equals IOPRIO_CLASS_NONE (ioprio_valid() macros does that) and if it is so it returns bioprio/aioprio appropriately. Thus the next four lines, that set aclass/bclass to IOPRIO_CLASS_BE, if aclass/bclass == IOPRIO_CLASS_NONE, are never executed.
The second problem: if aioprio from class IOPRIO_CLASS_NONE and bioprio from class IOPRIO_CLASS_IDLE are passed to ioprio_best function, it will return IOPRIO_CLASS_IDLE. It means that during __make_request we can merge two requests and set the priority of merged request to IDLE, while one of the initial requests originates from a process with NONE (default) priority. So we can get a situation when a process with default ioprio will experience IO starvation, while there is no process from real-time class in the system.
Just removing ioprio_valid check should correct situation.
--
fs/ioprio.c renamed from fs/ioprio.c.orig +0 -5
@@ -145,11 +145,6 @@ int ioprio_best(unsigned short aprio, ununsigned short aclass =IOPRIO_PRIO_CLASS (aprio);unsigned short bclass =IOPRIO_PRIO_CLASS (bprio); -if (!ioprio_valid (aprio)) -return bprio; -if (!ioprio_valid (bprio)) -return aprio; -if (aclass ==IOPRIO_CLASS_NONE ) aclass =IOPRIO_CLASS_BE ;if (bclass ==IOPRIO_CLASS_NONE )
Quoted 13 lines · Vasily Tarasov
Currently
ioprio_bestfunction first checks wethere aioprio or bioprio equalsIOPRIO_CLASS_NONE(ioprio_valid()macros does that) and if it is so it returns bioprio/aioprio appropriately. Thus the next four lines, that set aclass/bclass toIOPRIO_CLASS_BE, if aclass/bclass ==IOPRIO_CLASS_NONE, are never executed.The second problem: if aioprio from class
IOPRIO_CLASS_NONEand bioprio from classIOPRIO_CLASS_IDLEare passed toioprio_bestfunction, it will returnIOPRIO_CLASS_IDLE. It means that during__make_requestwe can merge two requests and set the priority of merged request to IDLE, while one of the initial requests originates from a process with NONE (default) priority. So we can get a situation when a process with default ioprio will experience IO starvation, while there is no process from real-time class in the system.
Quoted 1 line
Just removing
ioprio_validcheck should correct situation.
Analysis looks correct, thanks.
Signature · 1 line
Jens Axboe