Commit 31754ea6 authored by Josef Bacik's avatar Josef Bacik Committed by Christian Brauner

iomap: add a private argument for iomap_file_buffered_write

In order to switch fuse over to using iomap for buffered writes we need
to be able to have the struct file for the original write, in case we
have to read in the page to make it uptodate.  Handle this by using the
existing private field in the iomap_iter, and add the argument to
iomap_file_buffered_write.  This will allow us to pass the file in
through the iomap buffered write path, and is flexible for any other
file systems needs.
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Link: https://lore.kernel.org/r/7f55c7c32275004ba00cddf862d970e6e633f750.1724755651.git.josef@toxicpanda.comReviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent d1dd75dc
...@@ -665,7 +665,7 @@ blkdev_direct_write(struct kiocb *iocb, struct iov_iter *from) ...@@ -665,7 +665,7 @@ blkdev_direct_write(struct kiocb *iocb, struct iov_iter *from)
static ssize_t blkdev_buffered_write(struct kiocb *iocb, struct iov_iter *from) static ssize_t blkdev_buffered_write(struct kiocb *iocb, struct iov_iter *from)
{ {
return iomap_file_buffered_write(iocb, from, &blkdev_iomap_ops); return iomap_file_buffered_write(iocb, from, &blkdev_iomap_ops, NULL);
} }
/* /*
......
...@@ -1057,7 +1057,7 @@ static ssize_t gfs2_file_buffered_write(struct kiocb *iocb, ...@@ -1057,7 +1057,7 @@ static ssize_t gfs2_file_buffered_write(struct kiocb *iocb,
} }
pagefault_disable(); pagefault_disable();
ret = iomap_file_buffered_write(iocb, from, &gfs2_iomap_ops); ret = iomap_file_buffered_write(iocb, from, &gfs2_iomap_ops, NULL);
pagefault_enable(); pagefault_enable();
if (ret > 0) if (ret > 0)
written += ret; written += ret;
......
...@@ -1022,13 +1022,14 @@ static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i) ...@@ -1022,13 +1022,14 @@ static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i)
ssize_t ssize_t
iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *i, iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *i,
const struct iomap_ops *ops) const struct iomap_ops *ops, void *private)
{ {
struct iomap_iter iter = { struct iomap_iter iter = {
.inode = iocb->ki_filp->f_mapping->host, .inode = iocb->ki_filp->f_mapping->host,
.pos = iocb->ki_pos, .pos = iocb->ki_pos,
.len = iov_iter_count(i), .len = iov_iter_count(i),
.flags = IOMAP_WRITE, .flags = IOMAP_WRITE,
.private = private,
}; };
ssize_t ret; ssize_t ret;
......
...@@ -760,7 +760,7 @@ xfs_file_buffered_write( ...@@ -760,7 +760,7 @@ xfs_file_buffered_write(
trace_xfs_file_buffered_write(iocb, from); trace_xfs_file_buffered_write(iocb, from);
ret = iomap_file_buffered_write(iocb, from, ret = iomap_file_buffered_write(iocb, from,
&xfs_buffered_write_iomap_ops); &xfs_buffered_write_iomap_ops, NULL);
/* /*
* If we hit a space limit, try to free up some lingering preallocated * If we hit a space limit, try to free up some lingering preallocated
......
...@@ -563,7 +563,7 @@ static ssize_t zonefs_file_buffered_write(struct kiocb *iocb, ...@@ -563,7 +563,7 @@ static ssize_t zonefs_file_buffered_write(struct kiocb *iocb,
if (ret <= 0) if (ret <= 0)
goto inode_unlock; goto inode_unlock;
ret = iomap_file_buffered_write(iocb, from, &zonefs_write_iomap_ops); ret = iomap_file_buffered_write(iocb, from, &zonefs_write_iomap_ops, NULL);
if (ret == -EIO) if (ret == -EIO)
zonefs_io_error(inode, true); zonefs_io_error(inode, true);
......
...@@ -257,7 +257,7 @@ static inline const struct iomap *iomap_iter_srcmap(const struct iomap_iter *i) ...@@ -257,7 +257,7 @@ static inline const struct iomap *iomap_iter_srcmap(const struct iomap_iter *i)
} }
ssize_t iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *from, ssize_t iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *from,
const struct iomap_ops *ops); const struct iomap_ops *ops, void *private);
int iomap_file_buffered_write_punch_delalloc(struct inode *inode, int iomap_file_buffered_write_punch_delalloc(struct inode *inode,
struct iomap *iomap, loff_t pos, loff_t length, ssize_t written, struct iomap *iomap, loff_t pos, loff_t length, ssize_t written,
int (*punch)(struct inode *inode, loff_t pos, loff_t length)); int (*punch)(struct inode *inode, loff_t pos, loff_t length));
......
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