summaryrefslogtreecommitdiff
path: root/fs/read_write.c
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2023-11-22 15:27:09 +0300
committerChristian Brauner <brauner@kernel.org>2023-11-24 12:09:51 +0300
commit269aed7014b3db9acdbc5a5e163d8a6c62e0e770 (patch)
tree1bf919e07ef620de322af867dc20b0fc671b33ac /fs/read_write.c
parente389b76a7ee1b62392ab52c22f9ba81f23145824 (diff)
downloadlinux-269aed7014b3db9acdbc5a5e163d8a6c62e0e770.tar.xz
fs: move file_start_write() into vfs_iter_write()
All the callers of vfs_iter_write() call file_start_write() just before calling vfs_iter_write() except for target_core_file's fd_do_rw(). Move file_start_write() from the callers into vfs_iter_write(). fd_do_rw() calls vfs_iter_write() with a non-regular file, so file_start_write() is a no-op. This is needed for fanotify "pre content" events. Suggested-by: Jan Kara <jack@suse.cz> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Amir Goldstein <amir73il@gmail.com> Link: https://lore.kernel.org/r/20231122122715.2561213-11-amir73il@gmail.com Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/read_write.c')
-rw-r--r--fs/read_write.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/fs/read_write.c b/fs/read_write.c
index 4771701c896b..3aa3bce18075 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -839,7 +839,7 @@ ssize_t vfs_iter_read(struct file *file, struct iov_iter *iter, loff_t *ppos,
EXPORT_SYMBOL(vfs_iter_read);
static ssize_t do_iter_write(struct file *file, struct iov_iter *iter,
- loff_t *pos, rwf_t flags)
+ loff_t *pos, rwf_t flags)
{
size_t tot_len;
ssize_t ret = 0;
@@ -894,11 +894,18 @@ ssize_t vfs_iocb_iter_write(struct file *file, struct kiocb *iocb,
EXPORT_SYMBOL(vfs_iocb_iter_write);
ssize_t vfs_iter_write(struct file *file, struct iov_iter *iter, loff_t *ppos,
- rwf_t flags)
+ rwf_t flags)
{
+ int ret;
+
if (!file->f_op->write_iter)
return -EINVAL;
- return do_iter_write(file, iter, ppos, flags);
+
+ file_start_write(file);
+ ret = do_iter_write(file, iter, ppos, flags);
+ file_end_write(file);
+
+ return ret;
}
EXPORT_SYMBOL(vfs_iter_write);