Commit 36e8c622 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba

btrfs: add a btrfs_dio_rw wrapper

Add a wrapper around iomap_dio_rw that keeps the direct I/O internals
isolated in inode.c.
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 74e91b12
...@@ -3359,9 +3359,9 @@ ssize_t btrfs_encoded_read(struct kiocb *iocb, struct iov_iter *iter, ...@@ -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, ssize_t btrfs_do_encoded_write(struct kiocb *iocb, struct iov_iter *from,
const struct btrfs_ioctl_encoded_io_args *encoded); 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 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 */ /* Inode locking type flags, by default the exclusive lock is taken */
#define BTRFS_ILOCK_SHARED (1U << 0) #define BTRFS_ILOCK_SHARED (1U << 0)
......
...@@ -1929,8 +1929,7 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from) ...@@ -1929,8 +1929,7 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
*/ */
again: again:
from->nofault = true; from->nofault = true;
err = iomap_dio_rw(iocb, from, &btrfs_dio_iomap_ops, &btrfs_dio_ops, err = btrfs_dio_rw(iocb, from, written);
IOMAP_DIO_PARTIAL, written);
from->nofault = false; from->nofault = false;
/* No increment (+=) because iomap returns a cumulative value. */ /* No increment (+=) because iomap returns a cumulative value. */
...@@ -3693,8 +3692,7 @@ static ssize_t btrfs_direct_read(struct kiocb *iocb, struct iov_iter *to) ...@@ -3693,8 +3692,7 @@ static ssize_t btrfs_direct_read(struct kiocb *iocb, struct iov_iter *to)
*/ */
pagefault_disable(); pagefault_disable();
to->nofault = true; to->nofault = true;
ret = iomap_dio_rw(iocb, to, &btrfs_dio_iomap_ops, &btrfs_dio_ops, ret = btrfs_dio_rw(iocb, to, read);
IOMAP_DIO_PARTIAL, read);
to->nofault = false; to->nofault = false;
pagefault_enable(); pagefault_enable();
......
...@@ -8155,15 +8155,21 @@ static void btrfs_submit_direct(const struct iomap_iter *iter, ...@@ -8155,15 +8155,21 @@ static void btrfs_submit_direct(const struct iomap_iter *iter,
btrfs_dio_private_put(dip); 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_begin = btrfs_dio_iomap_begin,
.iomap_end = btrfs_dio_iomap_end, .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, .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, static int btrfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
u64 start, u64 len) u64 start, u64 len)
{ {
......
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