fs: Pass an iocb to generic_perform_write()

We can extract both the file pointer and the pos from the iocb.
This simplifies each caller as well as allowing generic_perform_write()
to see more of the iocb contents in the future.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Reviewed-by: Al Viro <viro@zeniv.linux.org.uk>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Matthew Wilcox (Oracle) 2022-02-19 23:19:49 -05:00
parent b2403a6130
commit 800ba29547
6 changed files with 11 additions and 9 deletions

View File

@ -1869,7 +1869,7 @@ retry_snap:
* are pending vmtruncate. So write and vmtruncate * are pending vmtruncate. So write and vmtruncate
* can not run at the same time * can not run at the same time
*/ */
written = generic_perform_write(file, from, pos); written = generic_perform_write(iocb, from);
if (likely(written >= 0)) if (likely(written >= 0))
iocb->ki_pos = pos + written; iocb->ki_pos = pos + written;
ceph_end_io_write(inode); ceph_end_io_write(inode);

View File

@ -267,7 +267,7 @@ static ssize_t ext4_buffered_write_iter(struct kiocb *iocb,
goto out; goto out;
current->backing_dev_info = inode_to_bdi(inode); current->backing_dev_info = inode_to_bdi(inode);
ret = generic_perform_write(iocb->ki_filp, from, iocb->ki_pos); ret = generic_perform_write(iocb, from);
current->backing_dev_info = NULL; current->backing_dev_info = NULL;
out: out:

View File

@ -4448,7 +4448,7 @@ static ssize_t f2fs_buffered_write_iter(struct kiocb *iocb,
return -EOPNOTSUPP; return -EOPNOTSUPP;
current->backing_dev_info = inode_to_bdi(inode); current->backing_dev_info = inode_to_bdi(inode);
ret = generic_perform_write(file, from, iocb->ki_pos); ret = generic_perform_write(iocb, from);
current->backing_dev_info = NULL; current->backing_dev_info = NULL;
if (ret > 0) { if (ret > 0) {

View File

@ -646,7 +646,7 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)
result = generic_write_checks(iocb, from); result = generic_write_checks(iocb, from);
if (result > 0) { if (result > 0) {
current->backing_dev_info = inode_to_bdi(inode); current->backing_dev_info = inode_to_bdi(inode);
result = generic_perform_write(file, from, iocb->ki_pos); result = generic_perform_write(iocb, from);
current->backing_dev_info = NULL; current->backing_dev_info = NULL;
} }
nfs_end_io_write(inode); nfs_end_io_write(inode);

View File

@ -2999,7 +2999,7 @@ extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *);
extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *); extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *);
extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *); extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *);
extern ssize_t generic_file_direct_write(struct kiocb *, struct iov_iter *); extern ssize_t generic_file_direct_write(struct kiocb *, struct iov_iter *);
extern ssize_t generic_perform_write(struct file *, struct iov_iter *, loff_t); ssize_t generic_perform_write(struct kiocb *, struct iov_iter *);
ssize_t vfs_iter_read(struct file *file, struct iov_iter *iter, loff_t *ppos, ssize_t vfs_iter_read(struct file *file, struct iov_iter *iter, loff_t *ppos,
rwf_t flags); rwf_t flags);

View File

@ -3752,9 +3752,10 @@ out:
} }
EXPORT_SYMBOL(generic_file_direct_write); EXPORT_SYMBOL(generic_file_direct_write);
ssize_t generic_perform_write(struct file *file, ssize_t generic_perform_write(struct kiocb *iocb, struct iov_iter *i)
struct iov_iter *i, loff_t pos)
{ {
struct file *file = iocb->ki_filp;
loff_t pos = iocb->ki_pos;
struct address_space *mapping = file->f_mapping; struct address_space *mapping = file->f_mapping;
const struct address_space_operations *a_ops = mapping->a_ops; const struct address_space_operations *a_ops = mapping->a_ops;
long status = 0; long status = 0;
@ -3884,7 +3885,8 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
if (written < 0 || !iov_iter_count(from) || IS_DAX(inode)) if (written < 0 || !iov_iter_count(from) || IS_DAX(inode))
goto out; goto out;
status = generic_perform_write(file, from, pos = iocb->ki_pos); pos = iocb->ki_pos;
status = generic_perform_write(iocb, from);
/* /*
* If generic_perform_write() returned a synchronous error * If generic_perform_write() returned a synchronous error
* then we want to return the number of bytes which were * then we want to return the number of bytes which were
@ -3916,7 +3918,7 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
*/ */
} }
} else { } else {
written = generic_perform_write(file, from, iocb->ki_pos); written = generic_perform_write(iocb, from);
if (likely(written > 0)) if (likely(written > 0))
iocb->ki_pos += written; iocb->ki_pos += written;
} }