iomap: only set iocb->private for polled bio
authorJens Axboe <axboe@kernel.dk>
Thu, 20 Jul 2023 17:47:56 +0000 (11:47 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 1 Aug 2023 23:32:38 +0000 (17:32 -0600)
iocb->private is only used for polled IO, where the completer will
find the bio to poll through that field.

Assign it when we're submitting a polled bio, and get rid of the
dio->poll_bio indirection.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/iomap/direct-io.c

index 6b690fc..e4b9d91 100644 (file)
@@ -41,7 +41,6 @@ struct iomap_dio {
                struct {
                        struct iov_iter         *iter;
                        struct task_struct      *waiter;
-                       struct bio              *poll_bio;
                } submit;
 
                /* used for aio completion: */
@@ -63,12 +62,14 @@ static struct bio *iomap_dio_alloc_bio(const struct iomap_iter *iter,
 static void iomap_dio_submit_bio(const struct iomap_iter *iter,
                struct iomap_dio *dio, struct bio *bio, loff_t pos)
 {
+       struct kiocb *iocb = dio->iocb;
+
        atomic_inc(&dio->ref);
 
        /* Sync dio can't be polled reliably */
-       if ((dio->iocb->ki_flags & IOCB_HIPRI) && !is_sync_kiocb(dio->iocb)) {
-               bio_set_polled(bio, dio->iocb);
-               dio->submit.poll_bio = bio;
+       if ((iocb->ki_flags & IOCB_HIPRI) && !is_sync_kiocb(iocb)) {
+               bio_set_polled(bio, iocb);
+               WRITE_ONCE(iocb->private, bio);
        }
 
        if (dio->dops && dio->dops->submit_io)
@@ -184,7 +185,6 @@ void iomap_dio_bio_end_io(struct bio *bio)
         * more IO to be issued to finalise filesystem metadata changes or
         * guarantee data integrity.
         */
-       WRITE_ONCE(iocb->private, NULL);
        INIT_WORK(&dio->aio.work, iomap_dio_complete_work);
        queue_work(file_inode(iocb->ki_filp)->i_sb->s_dio_done_wq,
                        &dio->aio.work);
@@ -523,7 +523,6 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
 
        dio->submit.iter = iter;
        dio->submit.waiter = current;
-       dio->submit.poll_bio = NULL;
 
        if (iocb->ki_flags & IOCB_NOWAIT)
                iomi.flags |= IOMAP_NOWAIT;
@@ -633,8 +632,6 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
        if (dio->flags & IOMAP_DIO_WRITE_THROUGH)
                dio->flags &= ~IOMAP_DIO_NEED_SYNC;
 
-       WRITE_ONCE(iocb->private, dio->submit.poll_bio);
-
        /*
         * We are about to drop our additional submission reference, which
         * might be the last reference to the dio.  There are three different