Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Josef Bacik <josef@toxicpanda.com>
Link: https://lore.kernel.org/r/7f55c7c32275004ba00cddf862d970e6e633f750.1724755651.git.josef@toxicpanda.com
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Josef Bacik and committed by
Christian Brauner
31754ea6 d1dd75dc

+7 -6
+1 -1
block/fops.c
··· 665 665 666 666 static ssize_t blkdev_buffered_write(struct kiocb *iocb, struct iov_iter *from) 667 667 { 668 - return iomap_file_buffered_write(iocb, from, &blkdev_iomap_ops); 668 + return iomap_file_buffered_write(iocb, from, &blkdev_iomap_ops, NULL); 669 669 } 670 670 671 671 /*
+1 -1
fs/gfs2/file.c
··· 1057 1057 } 1058 1058 1059 1059 pagefault_disable(); 1060 - ret = iomap_file_buffered_write(iocb, from, &gfs2_iomap_ops); 1060 + ret = iomap_file_buffered_write(iocb, from, &gfs2_iomap_ops, NULL); 1061 1061 pagefault_enable(); 1062 1062 if (ret > 0) 1063 1063 written += ret;
+2 -1
fs/iomap/buffered-io.c
··· 1022 1022 1023 1023 ssize_t 1024 1024 iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *i, 1025 - const struct iomap_ops *ops) 1025 + const struct iomap_ops *ops, void *private) 1026 1026 { 1027 1027 struct iomap_iter iter = { 1028 1028 .inode = iocb->ki_filp->f_mapping->host, 1029 1029 .pos = iocb->ki_pos, 1030 1030 .len = iov_iter_count(i), 1031 1031 .flags = IOMAP_WRITE, 1032 + .private = private, 1032 1033 }; 1033 1034 ssize_t ret; 1034 1035
+1 -1
fs/xfs/xfs_file.c
··· 760 760 761 761 trace_xfs_file_buffered_write(iocb, from); 762 762 ret = iomap_file_buffered_write(iocb, from, 763 - &xfs_buffered_write_iomap_ops); 763 + &xfs_buffered_write_iomap_ops, NULL); 764 764 765 765 /* 766 766 * If we hit a space limit, try to free up some lingering preallocated
+1 -1
fs/zonefs/file.c
··· 563 563 if (ret <= 0) 564 564 goto inode_unlock; 565 565 566 - ret = iomap_file_buffered_write(iocb, from, &zonefs_write_iomap_ops); 566 + ret = iomap_file_buffered_write(iocb, from, &zonefs_write_iomap_ops, NULL); 567 567 if (ret == -EIO) 568 568 zonefs_io_error(inode, true); 569 569
+1 -1
include/linux/iomap.h
··· 257 257 } 258 258 259 259 ssize_t iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *from, 260 - const struct iomap_ops *ops); 260 + const struct iomap_ops *ops, void *private); 261 261 int iomap_file_buffered_write_punch_delalloc(struct inode *inode, 262 262 struct iomap *iomap, loff_t pos, loff_t length, ssize_t written, 263 263 int (*punch)(struct inode *inode, loff_t pos, loff_t length));