* [PATCH] block: Fix computation of merged request priority
@ 2014-10-30 19:43 Jan Kara
2014-10-31 14:27 ` Jeff Moyer
2014-10-31 14:31 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Jan Kara @ 2014-10-30 19:43 UTC (permalink / raw)
To: axboe; +Cc: LKML, Jan Kara, stable
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: d58cdfb89ce0c6bd5f81ae931a984ef298dbda20
CC: stable@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
---
block/ioprio.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/block/ioprio.c b/block/ioprio.c
index e50170ca7c33..3a71df7f38cb 100644
--- a/block/ioprio.c
+++ b/block/ioprio.c
@@ -157,14 +157,16 @@ out:
int ioprio_best(unsigned short aprio, unsigned short bprio)
{
- unsigned short aclass = IOPRIO_PRIO_CLASS(aprio);
- unsigned short bclass = IOPRIO_PRIO_CLASS(bprio);
+ unsigned short aclass;
+ unsigned short bclass;
- if (aclass == IOPRIO_CLASS_NONE)
- aclass = IOPRIO_CLASS_BE;
- if (bclass == IOPRIO_CLASS_NONE)
- bclass = IOPRIO_CLASS_BE;
+ if (!ioprio_valid(aprio))
+ aprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM);
+ if (!ioprio_valid(bprio))
+ bprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM);
+ aclass = IOPRIO_PRIO_CLASS(aprio);
+ bclass = IOPRIO_PRIO_CLASS(bprio);
if (aclass == bclass)
return min(aprio, bprio);
if (aclass > bclass)
--
1.8.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] block: Fix computation of merged request priority
2014-10-30 19:43 [PATCH] block: Fix computation of merged request priority Jan Kara
@ 2014-10-31 14:27 ` Jeff Moyer
2014-10-31 14:31 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Moyer @ 2014-10-31 14:27 UTC (permalink / raw)
To: Jan Kara; +Cc: axboe, LKML, stable
Jan Kara <jack@suse.cz> writes:
> 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.
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] block: Fix computation of merged request priority
2014-10-30 19:43 [PATCH] block: Fix computation of merged request priority Jan Kara
2014-10-31 14:27 ` Jeff Moyer
@ 2014-10-31 14:31 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2014-10-31 14:31 UTC (permalink / raw)
To: Jan Kara; +Cc: LKML, stable
On 2014-10-30 13:43, Jan Kara wrote:
> 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.
Thanks Jan, applied. I fixed up a indentation issue, jfyi.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-10-31 14:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-30 19:43 [PATCH] block: Fix computation of merged request priority Jan Kara
2014-10-31 14:27 ` Jeff Moyer
2014-10-31 14:31 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).