diff options
author | Jan Kara <jack@suse.cz> | 2014-10-30 15:43:38 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2014-10-31 10:30:43 -0400 |
commit | ece9c72accdc45c3a9484dacb1125ce572647288 (patch) | |
tree | 9951eb6b877628b60562f4cc5ee80099f501d736 /block | |
parent | 3a2f22b7d0cc64482a91529e23c2570aa0602fa6 (diff) |
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: d58cdfb89ce0c6bd5f81ae931a984ef298dbda20
CC: stable@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/ioprio.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/block/ioprio.c b/block/ioprio.c index e50170ca7c33..31666c92b46a 100644 --- a/block/ioprio.c +++ b/block/ioprio.c | |||
@@ -157,14 +157,16 @@ out: | |||
157 | 157 | ||
158 | int ioprio_best(unsigned short aprio, unsigned short bprio) | 158 | int ioprio_best(unsigned short aprio, unsigned short bprio) |
159 | { | 159 | { |
160 | unsigned short aclass = IOPRIO_PRIO_CLASS(aprio); | 160 | unsigned short aclass; |
161 | unsigned short bclass = IOPRIO_PRIO_CLASS(bprio); | 161 | unsigned short bclass; |
162 | 162 | ||
163 | if (aclass == IOPRIO_CLASS_NONE) | 163 | if (!ioprio_valid(aprio)) |
164 | aclass = IOPRIO_CLASS_BE; | 164 | aprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM); |
165 | if (bclass == IOPRIO_CLASS_NONE) | 165 | if (!ioprio_valid(bprio)) |
166 | bclass = IOPRIO_CLASS_BE; | 166 | bprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM); |
167 | 167 | ||
168 | aclass = IOPRIO_PRIO_CLASS(aprio); | ||
169 | bclass = IOPRIO_PRIO_CLASS(bprio); | ||
168 | if (aclass == bclass) | 170 | if (aclass == bclass) |
169 | return min(aprio, bprio); | 171 | return min(aprio, bprio); |
170 | if (aclass > bclass) | 172 | if (aclass > bclass) |