Skip to content

Commit

Permalink
block: provide bio_clear_hipri() helper
Browse files Browse the repository at this point in the history
Any case that turns off REQ_HIPRI must also clear BIO_PERCPU_CACHE,
as non-polled IO may complete through hard/soft IRQ and hence isn't
safe for our polled bio alloc cache.

Provide a helper that does just that, and use it in the merging code as
well if we split a bio and turn off polling.

Fixes: be863b9 ("block: clear BIO_PERCPU_CACHE flag if polling isn't supported")
Reported-by: Keith Busch <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Aug 23, 2021
1 parent 01cfa28 commit 270a1c9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
7 changes: 2 additions & 5 deletions block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -832,11 +832,8 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio)
}
}

if (!test_bit(QUEUE_FLAG_POLL, &q->queue_flags)) {
/* can't support alloc cache if we turn off polling */
bio_clear_flag(bio, BIO_PERCPU_CACHE);
bio->bi_opf &= ~REQ_HIPRI;
}
if (!test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
bio_clear_hipri(bio);

switch (bio_op(bio)) {
case REQ_OP_DISCARD:
Expand Down
2 changes: 1 addition & 1 deletion block/blk-merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
* iopoll in direct IO routine. Given performance gain of iopoll for
* big IO can be trival, disable iopoll when split needed.
*/
bio->bi_opf &= ~REQ_HIPRI;
bio_clear_hipri(bio);

return bio_split(bio, sectors, GFP_NOIO, bs);
}
Expand Down
7 changes: 7 additions & 0 deletions block/blk.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,4 +364,11 @@ extern struct device_attribute dev_attr_events;
extern struct device_attribute dev_attr_events_async;
extern struct device_attribute dev_attr_events_poll_msecs;

static inline void bio_clear_hipri(struct bio *bio)
{
/* can't support alloc cache if we turn off polling */
bio_clear_flag(bio, BIO_PERCPU_CACHE);
bio->bi_opf &= ~REQ_HIPRI;
}

#endif /* BLK_INTERNAL_H */

0 comments on commit 270a1c9

Please sign in to comment.