Skip to content

Commit 0db1d53

Browse files
amir73ilbrauner
authored andcommitted
scsi: target: core: add missing file_{start,end}_write()
The callers of vfs_iter_write() are required to hold file_start_write(). file_start_write() is a no-op for the S_ISBLK() case, but it is really needed when the backing file is a regular file. We are going to move file_{start,end}_write() into vfs_iter_write(), but we need to fix this first, so that the fix could be backported to stable kernels. Suggested-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected]/ Cc: <[email protected]> Signed-off-by: Amir Goldstein <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: Martin K. Petersen <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Jens Axboe <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent b85ea95 commit 0db1d53

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/target/target_core_file.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,13 @@ static int fd_do_rw(struct se_cmd *cmd, struct file *fd,
332332
}
333333

334334
iov_iter_bvec(&iter, is_write, bvec, sgl_nents, len);
335-
if (is_write)
335+
if (is_write) {
336+
file_start_write(fd);
336337
ret = vfs_iter_write(fd, &iter, &pos, 0);
337-
else
338+
file_end_write(fd);
339+
} else {
338340
ret = vfs_iter_read(fd, &iter, &pos, 0);
339-
341+
}
340342
if (is_write) {
341343
if (ret < 0 || ret != data_length) {
342344
pr_err("%s() write returned %d\n", __func__, ret);
@@ -467,7 +469,9 @@ fd_execute_write_same(struct se_cmd *cmd)
467469
}
468470

469471
iov_iter_bvec(&iter, ITER_SOURCE, bvec, nolb, len);
472+
file_start_write(fd_dev->fd_file);
470473
ret = vfs_iter_write(fd_dev->fd_file, &iter, &pos, 0);
474+
file_end_write(fd_dev->fd_file);
471475

472476
kfree(bvec);
473477
if (ret < 0 || ret != len) {

0 commit comments

Comments
 (0)