From: Ralph Boehme Date: Fri, 25 Jun 2021 13:47:38 +0000 (+0200) Subject: vfs_default: properly track written bytes for copy-chunk X-Git-Tag: tevent-0.11.0~111 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2d524d4baee193b0d03df3e7edda48b3cb4bddf;p=thirdparty%2Fsamba.git vfs_default: properly track written bytes for copy-chunk No change in behavour, this just makes the logic slightly more understandable. In theory it would also allow the logic to be adjusted for allowing short reads which is not quite clear from MS-SMB2 if we should allow it. The file could be truncated while we're reading it. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12033 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 648950bf730..b4791285d3f 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -2030,6 +2030,7 @@ struct vfswrap_offload_write_state { off_t dst_off; off_t to_copy; off_t remaining; + off_t copied; size_t next_io_size; }; @@ -2340,6 +2341,7 @@ static void vfswrap_offload_write_write_done(struct tevent_req *subreq) tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR); return; } + state->copied += nwritten; state->remaining -= nwritten; if (state->remaining == 0) { tevent_req_done(req); @@ -2376,7 +2378,7 @@ static NTSTATUS vfswrap_offload_write_recv(struct vfs_handle_struct *handle, return status; } - *copied = state->to_copy; + *copied = state->copied; DBG_DEBUG("copy chunk copied %lu\n", (unsigned long)*copied); tevent_req_received(req);