s3:vfs: copy_chunk buffer size
authorRalph Boehme <slow@samba.org>
Wed, 1 Jul 2015 15:57:36 +0000 (17:57 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 1 Jul 2015 21:05:55 +0000 (23:05 +0200)
Use a dynamically allocated copy_chunk buffer size with an upper bound
of 8 MB for now.

The previous size of 64 KB has proven to really hurt performance,
especially with "strict locking = yes".

The SMB2 protocol level maximum allowed copy_chunk size is 1 MB, that's
what will be used as buffer size in the typical case.

With the AAPL copyfile extension the requested copy_chunk size is the
size whole file, which would then make use of a larger buffer up to the
limit of 8 MB.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_default.c

index 9b434a0dfd59f79f16299c4ed4c12216f0236692..69826348d5c92b82d4157970fc87b4bf3b58352d 100644 (file)
@@ -1395,7 +1395,7 @@ static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct *handle,
 
 struct vfs_cc_state {
        off_t copied;
-       uint8_t buf[65536];
+       uint8_t *buf;
 };
 
 static struct tevent_req *vfswrap_copy_chunk_send(struct vfs_handle_struct *handle,
@@ -1419,6 +1419,12 @@ static struct tevent_req *vfswrap_copy_chunk_send(struct vfs_handle_struct *hand
                return NULL;
        }
 
+       vfs_cc_state->buf = talloc_array(vfs_cc_state, uint8_t,
+                                        MIN(num, 8*1024*1024));
+       if (tevent_req_nomem(vfs_cc_state->buf, req)) {
+               return tevent_req_post(req, ev);
+       }
+
        status = vfs_stat_fsp(src_fsp);
        if (tevent_req_nterror(req, status)) {
                return tevent_req_post(req, ev);
@@ -1444,7 +1450,7 @@ static struct tevent_req *vfswrap_copy_chunk_send(struct vfs_handle_struct *hand
                struct lock_struct lck;
                int saved_errno;
 
-               off_t this_num = MIN(sizeof(vfs_cc_state->buf),
+               off_t this_num = MIN(talloc_array_length(vfs_cc_state->buf),
                                     num - vfs_cc_state->copied);
 
                if (src_fsp->op == NULL) {