[PATCH] copy_chunk buffer size
Ralph Böhme
rb at sernet.de
Wed Jul 1 18:26:53 CEST 2015
Hi!
Attached is a patch that changes copy_chunk to use a larger, talloced
buffer instead of a fixed size, small 64 KB buffer.
Please review&push if ok. Thanks!
-Ralph
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de,mailto:kontakt@sernet.de
-------------- next part --------------
From 5d9b4e29f3884a8032dc61e9685f6c59af22313d Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Wed, 1 Jul 2015 17:57:36 +0200
Subject: [PATCH] s3:vfs: copy_chunk buffer size
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 at samba.org>
---
source3/modules/vfs_default.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 9b434a0..6982634 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -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) {
--
2.1.0
More information about the samba-technical
mailing list