]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_default: properly track written bytes for copy-chunk
authorRalph Boehme <slow@samba.org>
Fri, 25 Jun 2021 13:47:38 +0000 (15:47 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 30 Jun 2021 16:51:29 +0000 (16:51 +0000)
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 <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_default.c

index 648950bf73099aad55e2b03bdcb4aaab6ee44080..b4791285d3ff7384cb0005d107173cd0872aa5d3 100644 (file)
@@ -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);