diff mbox series

[RFC] iomap: add a private argument for iomap_file_buffered_write

Message ID 7f55c7c32275004ba00cddf862d970e6e633f750.1724755651.git.josef@toxicpanda.com (mailing list archive)
State New
Headers show
Series [RFC] iomap: add a private argument for iomap_file_buffered_write | expand

Commit Message

Josef Bacik Aug. 27, 2024, 10:51 a.m. UTC
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: Josef Bacik <josef@toxicpanda.com>
---
Alternatively we could just stuff the iocb in the iter, or the file, or any
other such changes to give us access to the file for the original operation.  I
don't have a strong opinion here, I just want to be able to take advantage of
iomap for FUSE, so whatever the prevailing opinion is here I'll happily do it
differently.

 block/fops.c           | 2 +-
 fs/gfs2/file.c         | 2 +-
 fs/iomap/buffered-io.c | 3 ++-
 fs/xfs/xfs_file.c      | 2 +-
 fs/zonefs/file.c       | 2 +-
 include/linux/iomap.h  | 2 +-
 6 files changed, 7 insertions(+), 6 deletions(-)

Comments

Christoph Hellwig Aug. 27, 2024, 10:55 a.m. UTC | #1
On Tue, Aug 27, 2024 at 06:51:36AM -0400, Josef Bacik wrote:
> 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.

No, we need my version of this :)

http://git.infradead.org/?p=users/hch/xfs.git;a=commitdiff;h=84e044c2d18b2ba8ca6b8001d7cec54d3c972e89

Looks fine:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Josef Bacik Aug. 27, 2024, 11:03 a.m. UTC | #2
On Tue, Aug 27, 2024 at 03:55:19AM -0700, Christoph Hellwig wrote:
> On Tue, Aug 27, 2024 at 06:51:36AM -0400, Josef Bacik wrote:
> > 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.
> 
> No, we need my version of this :)
> 
> http://git.infradead.org/?p=users/hch/xfs.git;a=commitdiff;h=84e044c2d18b2ba8ca6b8001d7cec54d3c972e89
> 

Hooray I'm not an idiot!  Thanks,

Josef
Christian Brauner Aug. 27, 2024, 11:07 a.m. UTC | #3
On Tue, 27 Aug 2024 06:51:36 -0400, Josef Bacik wrote:
> 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.
> 
> [...]

It's in vfs.blocksize because there's other work that touches iomap in there.
But I'll likely rename the branch to something that's more generic such as
vfs.iomap at some point soon now that we have other stuff coming in.

---

Applied to the vfs.blocksize branch of the vfs/vfs.git tree.
Patches in the vfs.blocksize branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.blocksize

[1/1] iomap: add a private argument for iomap_file_buffered_write
      https://git.kernel.org/vfs/vfs/c/f143d1a48d6e
diff mbox series

Patch

diff --git a/block/fops.c b/block/fops.c
index 9825c1713a49..d16a6dddb12a 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -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)
 {
-	return iomap_file_buffered_write(iocb, from, &blkdev_iomap_ops);
+	return iomap_file_buffered_write(iocb, from, &blkdev_iomap_ops, NULL);
 }
 
 /*
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 08982937b5df..f7dd64856c9b 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -1057,7 +1057,7 @@  static ssize_t gfs2_file_buffered_write(struct kiocb *iocb,
 	}
 
 	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();
 	if (ret > 0)
 		written += ret;
diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index f420c53d86ac..a047a11541e6 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -1022,13 +1022,14 @@  static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i)
 
 ssize_t
 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 = {
 		.inode		= iocb->ki_filp->f_mapping->host,
 		.pos		= iocb->ki_pos,
 		.len		= iov_iter_count(i),
 		.flags		= IOMAP_WRITE,
+		.private	= private,
 	};
 	ssize_t ret;
 
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 4cdc54dc9686..e9c693bb20bc 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -760,7 +760,7 @@  xfs_file_buffered_write(
 
 	trace_xfs_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
diff --git a/fs/zonefs/file.c b/fs/zonefs/file.c
index 3b103715acc9..35166c92420c 100644
--- a/fs/zonefs/file.c
+++ b/fs/zonefs/file.c
@@ -563,7 +563,7 @@  static ssize_t zonefs_file_buffered_write(struct kiocb *iocb,
 	if (ret <= 0)
 		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)
 		zonefs_io_error(inode, true);
 
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index 6fc1c858013d..f792b37f7627 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -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,
-		const struct iomap_ops *ops);
+		const struct iomap_ops *ops, void *private);
 int iomap_file_buffered_write_punch_delalloc(struct inode *inode,
 		struct iomap *iomap, loff_t pos, loff_t length, ssize_t written,
 		int (*punch)(struct inode *inode, loff_t pos, loff_t length));