From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.15.y 1/6] block: don't try to poll multi-bio I/Os in __blkdev_direct_IO
Date: Fri, 4 Sep 2026 11:53:31 -0400 [thread overview]
Message-ID: <20260904155336.1042108-1-sashal@kernel.org> (raw)
In-Reply-To: <2026090333-willfully-art-ea0b@gregkh>
From: Christoph Hellwig <hch@lst.de>
[ Upstream commit 71fc3f5e2c00c966e6a2ffebadfbcc6914249d32 ]
If an iocb is split into multiple bios we can't poll for both. So don't
even bother to try to poll in that case.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20211012111226.760968-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Stable-dep-of: e78dcb1f7ec2 ("usb: gadget: f_fs: Fix Use-After-Free in AIO error path")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
block/fops.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/block/fops.c b/block/fops.c
index 72da501542f14..c23529d08929d 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -197,7 +197,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
struct blk_plug plug;
struct blkdev_dio *dio;
struct bio *bio;
- bool is_poll = (iocb->ki_flags & IOCB_HIPRI) != 0;
+ bool do_poll = (iocb->ki_flags & IOCB_HIPRI);
bool is_read = (iov_iter_rw(iter) == READ), is_sync;
loff_t pos = iocb->ki_pos;
blk_qc_t qc = BLK_QC_T_NONE;
@@ -226,7 +226,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
* Don't plug for HIPRI/polled IO, as those should go straight
* to issue
*/
- if (!is_poll)
+ if (!(iocb->ki_flags & IOCB_HIPRI))
blk_start_plug(&plug);
for (;;) {
@@ -278,20 +278,13 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
nr_pages = bio_iov_vecs_to_alloc(iter, BIO_MAX_VECS);
if (!nr_pages) {
- bool polled = false;
-
- if (iocb->ki_flags & IOCB_HIPRI) {
+ if (do_poll)
bio_set_polled(bio, iocb);
- polled = true;
- }
-
qc = submit_bio(bio);
-
- if (polled)
+ if (do_poll)
WRITE_ONCE(iocb->ki_cookie, qc);
break;
}
-
if (!dio->multi_bio) {
/*
* AIO needs an extra reference to ensure the dio
@@ -302,6 +295,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
bio_get(bio);
dio->multi_bio = true;
atomic_set(&dio->ref, 2);
+ do_poll = false;
} else {
atomic_inc(&dio->ref);
}
@@ -310,7 +304,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
bio = bio_alloc(GFP_KERNEL, nr_pages);
}
- if (!is_poll)
+ if (!(iocb->ki_flags & IOCB_HIPRI))
blk_finish_plug(&plug);
if (!is_sync)
@@ -321,8 +315,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
if (!READ_ONCE(dio->waiter))
break;
- if (!(iocb->ki_flags & IOCB_HIPRI) ||
- !blk_poll(bdev_get_queue(bdev), qc, true))
+ if (!do_poll || !blk_poll(bdev_get_queue(bdev), qc, true))
blk_io_schedule();
}
__set_current_state(TASK_RUNNING);
--
2.53.0
next prev parent reply other threads:[~2026-09-04 15:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 12:41 FAILED: patch "[PATCH] usb: gadget: f_fs: Fix Use-After-Free in AIO error path" failed to apply to 5.15-stable tree gregkh
2026-09-04 15:53 ` Sasha Levin [this message]
2026-09-04 15:53 ` [PATCH 5.15.y 2/6] block: use flags instead of bit fields for blkdev_dio Sasha Levin
2026-09-04 15:53 ` [PATCH 5.15.y 3/6] usb: remove res2 argument from gadget code completions Sasha Levin
2026-09-04 15:53 ` [PATCH 5.15.y 4/6] fs: get rid of the res2 iocb->ki_complete argument Sasha Levin
2026-09-04 15:53 ` [PATCH 5.15.y 5/6] USB: gadget: ffs: fix mm lifetime handling Sasha Levin
2026-09-04 15:53 ` [PATCH 5.15.y 6/6] usb: gadget: f_fs: Fix Use-After-Free in AIO error path Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260904155336.1042108-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.