Skip to content

Commit

Permalink
bio: safeguard REQ_ALLOC_CACHE bio put
Browse files Browse the repository at this point in the history
[ Upstream commit d4347d5 ]

bio_put() with REQ_ALLOC_CACHE assumes that it's executed not from
an irq context. Let's add a warning if the invariant is not respected,
especially since there is a couple of places removing REQ_POLLED by hand
without also clearing REQ_ALLOC_CACHE.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/558d78313476c4e9c233902efa0092644c3d420a.1666122465.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
isilence authored and gregkh committed Nov 10, 2022
1 parent bbc48d3 commit 48629bf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion block/bio.c
Expand Up @@ -741,7 +741,7 @@ void bio_put(struct bio *bio)
return;
}

if (bio->bi_opf & REQ_ALLOC_CACHE) {
if ((bio->bi_opf & REQ_ALLOC_CACHE) && !WARN_ON_ONCE(in_interrupt())) {
struct bio_alloc_cache *cache;

bio_uninit(bio);
Expand Down

0 comments on commit 48629bf

Please sign in to comment.