Commit 71fc3f5e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block: don't try to poll multi-bio I/Os in __blkdev_direct_IO

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: default avatarChristoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20211012111226.760968-3-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 94c2ed58
...@@ -197,7 +197,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, ...@@ -197,7 +197,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
struct blk_plug plug; struct blk_plug plug;
struct blkdev_dio *dio; struct blkdev_dio *dio;
struct bio *bio; 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; bool is_read = (iov_iter_rw(iter) == READ), is_sync;
loff_t pos = iocb->ki_pos; loff_t pos = iocb->ki_pos;
blk_qc_t qc = BLK_QC_T_NONE; 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, ...@@ -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 * Don't plug for HIPRI/polled IO, as those should go straight
* to issue * to issue
*/ */
if (!is_poll) if (!(iocb->ki_flags & IOCB_HIPRI))
blk_start_plug(&plug); blk_start_plug(&plug);
for (;;) { for (;;) {
...@@ -260,20 +260,13 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, ...@@ -260,20 +260,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); nr_pages = bio_iov_vecs_to_alloc(iter, BIO_MAX_VECS);
if (!nr_pages) { if (!nr_pages) {
bool polled = false; if (do_poll)
if (iocb->ki_flags & IOCB_HIPRI) {
bio_set_polled(bio, iocb); bio_set_polled(bio, iocb);
polled = true;
}
qc = submit_bio(bio); qc = submit_bio(bio);
if (do_poll)
if (polled)
WRITE_ONCE(iocb->ki_cookie, qc); WRITE_ONCE(iocb->ki_cookie, qc);
break; break;
} }
if (!dio->multi_bio) { if (!dio->multi_bio) {
/* /*
* AIO needs an extra reference to ensure the dio * AIO needs an extra reference to ensure the dio
...@@ -284,6 +277,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, ...@@ -284,6 +277,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
bio_get(bio); bio_get(bio);
dio->multi_bio = true; dio->multi_bio = true;
atomic_set(&dio->ref, 2); atomic_set(&dio->ref, 2);
do_poll = false;
} else { } else {
atomic_inc(&dio->ref); atomic_inc(&dio->ref);
} }
...@@ -292,7 +286,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, ...@@ -292,7 +286,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
bio = bio_alloc(GFP_KERNEL, nr_pages); bio = bio_alloc(GFP_KERNEL, nr_pages);
} }
if (!is_poll) if (!(iocb->ki_flags & IOCB_HIPRI))
blk_finish_plug(&plug); blk_finish_plug(&plug);
if (!is_sync) if (!is_sync)
...@@ -303,8 +297,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, ...@@ -303,8 +297,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
if (!READ_ONCE(dio->waiter)) if (!READ_ONCE(dio->waiter))
break; break;
if (!(iocb->ki_flags & IOCB_HIPRI) || if (!do_poll || !blk_poll(bdev_get_queue(bdev), qc, true))
!blk_poll(bdev_get_queue(bdev), qc, true))
blk_io_schedule(); blk_io_schedule();
} }
__set_current_state(TASK_RUNNING); __set_current_state(TASK_RUNNING);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment