From 3f773a8594ac6020d586bb4596c0c2ea393e1068 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 31 Jan 2024 17:13:39 -0800 Subject: [PATCH] Fix uninit written in scoutfs_file_write_iter scoutfs_file_write_iter tried to track written bytes and return those unless there was an error. But written was uninitialized if we got errors in any of the calls leading up to performing the write. The bytes written were also not being passed to the generic_write_sync helper. This fixes up all those inconsistencies and makes it look like the write_iter path in other filesystems. Signed-off-by: Zach Brown --- kmod/src/file.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/kmod/src/file.c b/kmod/src/file.c index cac72245..55c8b230 100644 --- a/kmod/src/file.c +++ b/kmod/src/file.c @@ -203,8 +203,7 @@ ssize_t scoutfs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) struct scoutfs_lock *scoutfs_inode_lock = NULL; SCOUTFS_DECLARE_PER_TASK_ENTRY(pt_ent); DECLARE_DATA_WAIT(dw); - int ret; - int written; + ssize_t ret; retry: inode_lock(inode); @@ -231,7 +230,7 @@ retry: /* XXX: remove SUID bit */ - written = __generic_file_write_iter(iocb, from); + ret = __generic_file_write_iter(iocb, from); out: scoutfs_per_task_del(&si->pt_data_lock, &pt_ent); @@ -244,10 +243,10 @@ out: goto retry; } - if (ret > 0 || ret == -EIOCBQUEUED) - ret = generic_write_sync(iocb, written); + if (ret > 0) + ret = generic_write_sync(iocb, ret); - return written ? written : ret; + return ret; } #endif