aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAmir Goldstein2023-11-22 14:27:09 +0200
committerChristian Brauner2023-11-24 10:09:51 +0100
commit269aed7014b3db9acdbc5a5e163d8a6c62e0e770 (patch)
tree1bf919e07ef620de322af867dc20b0fc671b33ac /drivers
parente389b76a7ee1b62392ab52c22f9ba81f23145824 (diff)
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 'drivers')
-rw-r--r--drivers/block/loop.c2
-rw-r--r--drivers/target/target_core_file.c10
2 files changed, 3 insertions, 9 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 9f2d412fc560..8a8cd4fc9238 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -245,9 +245,7 @@ static int lo_write_bvec(struct file *file, struct bio_vec *bvec, loff_t *ppos)
iov_iter_bvec(&i, ITER_SOURCE, bvec, 1, bvec->bv_len);
- file_start_write(file);
bw = vfs_iter_write(file, &i, ppos, 0);
- file_end_write(file);
if (likely(bw == bvec->bv_len))
return 0;
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
index 4e4cf6c34a77..4d447520bab8 100644
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -332,13 +332,11 @@ static int fd_do_rw(struct se_cmd *cmd, struct file *fd,
}
iov_iter_bvec(&iter, is_write, bvec, sgl_nents, len);
- if (is_write) {
- file_start_write(fd);
+ if (is_write)
ret = vfs_iter_write(fd, &iter, &pos, 0);
- file_end_write(fd);
- } else {
+ else
ret = vfs_iter_read(fd, &iter, &pos, 0);
- }
+
if (is_write) {
if (ret < 0 || ret != data_length) {
pr_err("%s() write returned %d\n", __func__, ret);
@@ -469,9 +467,7 @@ fd_execute_write_same(struct se_cmd *cmd)
}
iov_iter_bvec(&iter, ITER_SOURCE, bvec, nolb, len);
- file_start_write(fd_dev->fd_file);
ret = vfs_iter_write(fd_dev->fd_file, &iter, &pos, 0);
- file_end_write(fd_dev->fd_file);
kfree(bvec);
if (ret < 0 || ret != len) {