]> git.baikalelectronics.ru Git - kernel.git/commitdiff
btrfs: add a btrfs_dio_rw wrapper
authorChristoph Hellwig <hch@lst.de>
Thu, 5 May 2022 20:11:09 +0000 (15:11 -0500)
committerDavid Sterba <dsterba@suse.com>
Mon, 16 May 2022 15:17:32 +0000 (17:17 +0200)
Add a wrapper around iomap_dio_rw that keeps the direct I/O internals
isolated in inode.c.

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/ctree.h
fs/btrfs/file.c
fs/btrfs/inode.c

index 0d1d43f171cc69060562fe7010110ca53a755ada..47e1e79e8bfff007a85330baa8317aab1a32a90f 100644 (file)
@@ -3359,9 +3359,9 @@ ssize_t btrfs_encoded_read(struct kiocb *iocb, struct iov_iter *iter,
 ssize_t btrfs_do_encoded_write(struct kiocb *iocb, struct iov_iter *from,
                             const struct btrfs_ioctl_encoded_io_args *encoded);
 
+ssize_t btrfs_dio_rw(struct kiocb *iocb, struct iov_iter *iter, size_t done_before);
+
 extern const struct dentry_operations btrfs_dentry_operations;
-extern const struct iomap_ops btrfs_dio_iomap_ops;
-extern const struct iomap_dio_ops btrfs_dio_ops;
 
 /* Inode locking type flags, by default the exclusive lock is taken */
 #define BTRFS_ILOCK_SHARED     (1U << 0)
index b64fb93d904697cb9638abdefd453caa21baa96e..46c2baa8fdf54079d1c6080a27b5f26622654765 100644 (file)
@@ -1929,8 +1929,7 @@ relock:
         */
 again:
        from->nofault = true;
-       err = iomap_dio_rw(iocb, from, &btrfs_dio_iomap_ops, &btrfs_dio_ops,
-                          IOMAP_DIO_PARTIAL, written);
+       err = btrfs_dio_rw(iocb, from, written);
        from->nofault = false;
 
        /* No increment (+=) because iomap returns a cumulative value. */
@@ -3693,8 +3692,7 @@ again:
         */
        pagefault_disable();
        to->nofault = true;
-       ret = iomap_dio_rw(iocb, to, &btrfs_dio_iomap_ops, &btrfs_dio_ops,
-                          IOMAP_DIO_PARTIAL, read);
+       ret = btrfs_dio_rw(iocb, to, read);
        to->nofault = false;
        pagefault_enable();
 
index 63f71b3097d8cfde19e62738f9688b1fcfeac367..eb951ac52d22c563fe61891e7a1d107fb006531e 100644 (file)
@@ -8155,15 +8155,21 @@ out_err:
        btrfs_dio_private_put(dip);
 }
 
-const struct iomap_ops btrfs_dio_iomap_ops = {
+static const struct iomap_ops btrfs_dio_iomap_ops = {
        .iomap_begin            = btrfs_dio_iomap_begin,
        .iomap_end              = btrfs_dio_iomap_end,
 };
 
-const struct iomap_dio_ops btrfs_dio_ops = {
+static const struct iomap_dio_ops btrfs_dio_ops = {
        .submit_io              = btrfs_submit_direct,
 };
 
+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);
+}
+
 static int btrfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
                        u64 start, u64 len)
 {