]> git.baikalelectronics.ru Git - kernel.git/commitdiff
iomap: add per-iomap_iter private data
authorChristoph Hellwig <hch@lst.de>
Thu, 5 May 2022 20:11:11 +0000 (15:11 -0500)
committerDavid Sterba <dsterba@suse.com>
Mon, 16 May 2022 15:17:32 +0000 (17:17 +0200)
Allow the file system to keep state for all iterations.  For now only
wire it up for direct I/O as there is an immediate need for it there.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c
fs/erofs/data.c
fs/ext4/file.c
fs/f2fs/file.c
fs/gfs2/file.c
fs/iomap/direct-io.c
fs/xfs/xfs_file.c
fs/zonefs/super.c
include/linux/iomap.h

index eb951ac52d22c563fe61891e7a1d107fb006531e..954e91b74d21ff26c98c81118c7ee2d23dfbc8c5 100644 (file)
@@ -8167,7 +8167,7 @@ static const struct iomap_dio_ops btrfs_dio_ops = {
 ssize_t btrfs_dio_rw(struct kiocb *iocb, struct iov_iter *iter, size_t done_before)
 {
        return iomap_dio_rw(iocb, iter, &btrfs_dio_iomap_ops, &btrfs_dio_ops,
-                           IOMAP_DIO_PARTIAL, done_before);
+                           IOMAP_DIO_PARTIAL, NULL, done_before);
 }
 
 static int btrfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
index 780db1e5f4b7235c4ed6c1fa19e57656b62f3648..91c11d5bb9990d83d1b5f5022292feae8d7e7ce0 100644 (file)
@@ -385,7 +385,7 @@ static ssize_t erofs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
 
                if (!err)
                        return iomap_dio_rw(iocb, to, &erofs_iomap_ops,
-                                           NULL, 0, 0);
+                                           NULL, 0, NULL, 0);
                if (err < 0)
                        return err;
        }
index 6feb07e3e1eb595b9cc3feb14a182994c82a4cd1..109d07629f81fb9e1d255f95a4965b7b0caf266d 100644 (file)
@@ -76,7 +76,7 @@ static ssize_t ext4_dio_read_iter(struct kiocb *iocb, struct iov_iter *to)
                return generic_file_read_iter(iocb, to);
        }
 
-       ret = iomap_dio_rw(iocb, to, &ext4_iomap_ops, NULL, 0, 0);
+       ret = iomap_dio_rw(iocb, to, &ext4_iomap_ops, NULL, 0, NULL, 0);
        inode_unlock_shared(inode);
 
        file_accessed(iocb->ki_filp);
@@ -565,7 +565,7 @@ static ssize_t ext4_dio_write_iter(struct kiocb *iocb, struct iov_iter *from)
                iomap_ops = &ext4_iomap_overwrite_ops;
        ret = iomap_dio_rw(iocb, from, iomap_ops, &ext4_dio_write_ops,
                           (unaligned_io || extend) ? IOMAP_DIO_FORCE_WAIT : 0,
-                          0);
+                          NULL, 0);
        if (ret == -ENOTBLK)
                ret = 0;
 
index 5b89af0f27f053265672a30e595ad4db26a2905c..04bc8709314bf22ecbdfc54f0529ac9a60873262 100644 (file)
@@ -4309,7 +4309,7 @@ static ssize_t f2fs_dio_read_iter(struct kiocb *iocb, struct iov_iter *to)
         */
        inc_page_count(sbi, F2FS_DIO_READ);
        dio = __iomap_dio_rw(iocb, to, &f2fs_iomap_ops,
-                            &f2fs_iomap_dio_read_ops, 0, 0);
+                            &f2fs_iomap_dio_read_ops, 0, NULL, 0);
        if (IS_ERR_OR_NULL(dio)) {
                ret = PTR_ERR_OR_ZERO(dio);
                if (ret != -EIOCBQUEUED)
@@ -4527,7 +4527,7 @@ static ssize_t f2fs_dio_write_iter(struct kiocb *iocb, struct iov_iter *from,
        if (pos + count > inode->i_size)
                dio_flags |= IOMAP_DIO_FORCE_WAIT;
        dio = __iomap_dio_rw(iocb, from, &f2fs_iomap_ops,
-                            &f2fs_iomap_dio_write_ops, dio_flags, 0);
+                            &f2fs_iomap_dio_write_ops, dio_flags, NULL, 0);
        if (IS_ERR_OR_NULL(dio)) {
                ret = PTR_ERR_OR_ZERO(dio);
                if (ret == -ENOTBLK)
index 2556ae1f92ea2d9e27d0fefe9c60c09543c6c563..0b07d5a7bb8155f1ec0caf4b5a0e7270ed5108f9 100644 (file)
@@ -835,7 +835,7 @@ retry:
        pagefault_disable();
        to->nofault = true;
        ret = iomap_dio_rw(iocb, to, &gfs2_iomap_ops, NULL,
-                          IOMAP_DIO_PARTIAL, read);
+                          IOMAP_DIO_PARTIAL, NULL, read);
        to->nofault = false;
        pagefault_enable();
        if (ret <= 0 && ret != -EFAULT)
@@ -898,7 +898,7 @@ retry:
 
        from->nofault = true;
        ret = iomap_dio_rw(iocb, from, &gfs2_iomap_ops, NULL,
-                          IOMAP_DIO_PARTIAL, written);
+                          IOMAP_DIO_PARTIAL, NULL, written);
        from->nofault = false;
        if (ret <= 0) {
                if (ret == -ENOTBLK)
index 314d8235f4ab545cb85ce87f0ee4f2e5f258197a..cf224a8bb31150b9b5a1e37d51f4bcbc4f3859a0 100644 (file)
@@ -483,7 +483,7 @@ static loff_t iomap_dio_iter(const struct iomap_iter *iter,
 struct iomap_dio *
 __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
                const struct iomap_ops *ops, const struct iomap_dio_ops *dops,
-               unsigned int dio_flags, size_t done_before)
+               unsigned int dio_flags, void *private, size_t done_before)
 {
        struct address_space *mapping = iocb->ki_filp->f_mapping;
        struct inode *inode = file_inode(iocb->ki_filp);
@@ -492,6 +492,7 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
                .pos            = iocb->ki_pos,
                .len            = iov_iter_count(iter),
                .flags          = IOMAP_DIRECT,
+               .private        = private,
        };
        loff_t end = iomi.pos + iomi.len - 1, ret = 0;
        bool wait_for_completion =
@@ -683,11 +684,12 @@ EXPORT_SYMBOL_GPL(__iomap_dio_rw);
 ssize_t
 iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
                const struct iomap_ops *ops, const struct iomap_dio_ops *dops,
-               unsigned int dio_flags, size_t done_before)
+               unsigned int dio_flags, void *private, size_t done_before)
 {
        struct iomap_dio *dio;
 
-       dio = __iomap_dio_rw(iocb, iter, ops, dops, dio_flags, done_before);
+       dio = __iomap_dio_rw(iocb, iter, ops, dops, dio_flags, private,
+                            done_before);
        if (IS_ERR_OR_NULL(dio))
                return PTR_ERR_OR_ZERO(dio);
        return iomap_dio_complete(dio);
index 5bddb1e9e0b3eea622efa37e58d15cd69f515bc2..85c412107a100fe011fcfeaa38db8977d552e650 100644 (file)
@@ -225,7 +225,7 @@ xfs_file_dio_read(
        ret = xfs_ilock_iocb(iocb, XFS_IOLOCK_SHARED);
        if (ret)
                return ret;
-       ret = iomap_dio_rw(iocb, to, &xfs_read_iomap_ops, NULL, 0, 0);
+       ret = iomap_dio_rw(iocb, to, &xfs_read_iomap_ops, NULL, 0, NULL, 0);
        xfs_iunlock(ip, XFS_IOLOCK_SHARED);
 
        return ret;
@@ -534,7 +534,7 @@ xfs_file_dio_write_aligned(
        }
        trace_xfs_file_direct_write(iocb, from);
        ret = iomap_dio_rw(iocb, from, &xfs_direct_write_iomap_ops,
-                          &xfs_dio_write_ops, 0, 0);
+                          &xfs_dio_write_ops, 0, NULL, 0);
 out_unlock:
        if (iolock)
                xfs_iunlock(ip, iolock);
@@ -612,7 +612,7 @@ retry_exclusive:
 
        trace_xfs_file_direct_write(iocb, from);
        ret = iomap_dio_rw(iocb, from, &xfs_direct_write_iomap_ops,
-                          &xfs_dio_write_ops, flags, 0);
+                          &xfs_dio_write_ops, flags, NULL, 0);
 
        /*
         * Retry unaligned I/O with exclusive blocking semantics if the DIO
index e20e7c8414896c0fde07647c5065799a927ab03c..777fe626c2b38efe7d698bab01adc4c18e3b0fa7 100644 (file)
@@ -861,7 +861,7 @@ static ssize_t zonefs_file_dio_write(struct kiocb *iocb, struct iov_iter *from)
                ret = zonefs_file_dio_append(iocb, from);
        else
                ret = iomap_dio_rw(iocb, from, &zonefs_iomap_ops,
-                                  &zonefs_write_dio_ops, 0, 0);
+                                  &zonefs_write_dio_ops, 0, NULL, 0);
        if (zi->i_ztype == ZONEFS_ZTYPE_SEQ &&
            (ret > 0 || ret == -EIOCBQUEUED)) {
                if (ret > 0)
@@ -996,7 +996,7 @@ static ssize_t zonefs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
                }
                file_accessed(iocb->ki_filp);
                ret = iomap_dio_rw(iocb, to, &zonefs_iomap_ops,
-                                  &zonefs_read_dio_ops, 0, 0);
+                                  &zonefs_read_dio_ops, 0, NULL, 0);
        } else {
                ret = generic_file_read_iter(iocb, to);
                if (ret == -EIO)
index cf903f1a230f319865feca283bebefdf657c4582..5b6f64f4d771f36527076b8c89c34f21604561c2 100644 (file)
@@ -188,6 +188,7 @@ struct iomap_iter {
        unsigned flags;
        struct iomap iomap;
        struct iomap srcmap;
+       void *private;
 };
 
 int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops);
@@ -354,10 +355,10 @@ struct iomap_dio_ops {
 
 ssize_t iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
                const struct iomap_ops *ops, const struct iomap_dio_ops *dops,
-               unsigned int dio_flags, size_t done_before);
+               unsigned int dio_flags, void *private, size_t done_before);
 struct iomap_dio *__iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
                const struct iomap_ops *ops, const struct iomap_dio_ops *dops,
-               unsigned int dio_flags, size_t done_before);
+               unsigned int dio_flags, void *private, size_t done_before);
 ssize_t iomap_dio_complete(struct iomap_dio *dio);
 void iomap_dio_bio_end_io(struct bio *bio);