]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
block: provide bio_clear_hipri() helper
authorJens Axboe <axboe@kernel.dk>
Thu, 12 Aug 2021 17:42:53 +0000 (11:42 -0600)
committerJens Axboe <axboe@kernel.dk>
Mon, 23 Aug 2021 19:45:15 +0000 (13:45 -0600)
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: be863b9e4348 ("block: clear BIO_PERCPU_CACHE flag if polling isn't supported")
Reported-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-core.c
block/blk-merge.c
block/blk.h

index 0d4d6b1e5d2554ff2d5661a208a7e4d4fd5a6258..f35d401e65f8dce889d081271aa8e84af5f9a9f0 100644 (file)
@@ -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:
index a11b3b53717efe7433d449b089b982c5956edb47..bc25ad409fc1adb3ded4e73ddbfe5e0399dc8021 100644 (file)
@@ -285,7 +285,7 @@ split:
         * 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);
 }
index cb01429c162c6f950a3edc3b4274f282f2e648b4..5a4652a109319ac0583a000c39fc878ed6dff32c 100644 (file)
@@ -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 */