[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Fri Nov 13 23:40:05 UTC 2015


The branch, master has been updated
       via  eee4af5 WHATSNEW: Add async SMB2 flush and new aio parameter
       via  90469a3 docs: Update doc for 'strict sync' parameter for async SMB2 flush
       via  c4be0b7 s3: smbd: Change aio_pending_size static variable to a new "aio max threads" smb.conf parameter.
       via  c83ecbb s3: smbd: Remove checks causing fallback to sync on pread/pwrite/fsync.
       via  5327c60 s3: smbd: Remove --with-aio-support. We no longer would ever prefer POSIX-RT aio, use pthread_aio instead.
      from  e05d69f docs: correct the name of the idmap config group of parameters

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit eee4af5c76be9b8ab0cee4e0721eeb438d0a8f5d
Author: Christof Schmitt <cs at samba.org>
Date:   Fri Nov 13 11:47:32 2015 -0700

    WHATSNEW: Add async SMB2 flush and new aio parameter
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Sat Nov 14 00:39:17 CET 2015 on sn-devel-104

commit 90469a3d214b1ee0990fb2f7efb7d4d21ef28e4a
Author: Christof Schmitt <cs at samba.org>
Date:   Fri Nov 13 11:46:33 2015 -0700

    docs: Update doc for 'strict sync' parameter for async SMB2 flush
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c4be0b7ff4f1d2a3e5c1664e4735f35381f78a5e
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Nov 12 13:23:30 2015 -0800

    s3: smbd: Change aio_pending_size static variable to a new "aio max threads" smb.conf parameter.
    
    Removes accessor functions as now this parameter is set
    under user control in smb.conf. Default is 100.
    
    Note that this doesn't limit the number of outstanding
    aio requests, it just causes them to go onto the
    pthreadpool queue.
    
    Now we need to prioritize pthreadpool pipe replies
    ahead of incoming SMB2 requests, but that's a patch
    for another day.
    
    Based on ideas from Volker.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit c83ecbb51bddb1642eb4ee10c24f6b721af66c45
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Nov 12 13:07:21 2015 -0800

    s3: smbd: Remove checks causing fallback to sync on pread/pwrite/fsync.
    
    Rely on pthreadpool queueing instead of falling back.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 5327c6004997e6b3cf235a1a292cc8f2ea1ff698
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Nov 12 12:44:50 2015 -0800

    s3: smbd: Remove --with-aio-support. We no longer would ever prefer POSIX-RT aio, use pthread_aio instead.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 WHATSNEW.txt                                 |   6 +
 docs-xml/smbdotconf/tuning/aiomaxthreads.xml |  19 ++
 docs-xml/smbdotconf/tuning/strictsync.xml    |   6 +-
 lib/param/loadparm.c                         |   2 +
 packaging/RHEL-CTDB/configure.rpm            |   1 -
 packaging/RHEL-CTDB/samba.spec.tmpl          |   2 -
 source3/modules/vfs_aio_fork.c               |  11 -
 source3/modules/vfs_aio_linux.c              |  22 +-
 source3/modules/vfs_aio_posix.c              | 301 ---------------------------
 source3/modules/vfs_aio_pthread.c            |   4 +-
 source3/modules/vfs_default.c                |   2 +-
 source3/modules/wscript_build                |   8 -
 source3/param/loadparm.c                     |   2 +
 source3/smbd/aio.c                           |  45 ----
 source3/smbd/proto.h                         |   2 -
 source3/smbd/smb2_flush.c                    |  14 --
 source3/wscript                              |  25 ---
 17 files changed, 39 insertions(+), 433 deletions(-)
 create mode 100644 docs-xml/smbdotconf/tuning/aiomaxthreads.xml
 delete mode 100644 source3/modules/vfs_aio_posix.c


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index d76d8fc..f1a1c07 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -17,6 +17,11 @@ Nothing special.
 NEW FEATURES
 ============
 
+Flush requests from SMB2/3 clients are handled asynchronously and do
+not block the processing of other requests. Note that 'strict sync'
+has to be set to 'yes' for Samba to honor flush requests from SMB
+clients.
+
 WINS nsswitch module
 ====================
 
@@ -34,6 +39,7 @@ smb.conf changes
 
   Parameter Name		Description		Default
   --------------		-----------		-------
+  aio max threads               New                     100
 
 KNOWN ISSUES
 ============
diff --git a/docs-xml/smbdotconf/tuning/aiomaxthreads.xml b/docs-xml/smbdotconf/tuning/aiomaxthreads.xml
new file mode 100644
index 0000000..3afe989
--- /dev/null
+++ b/docs-xml/smbdotconf/tuning/aiomaxthreads.xml
@@ -0,0 +1,19 @@
+<samba:parameter name="aio max threads"
+                 type="integer"
+                 context="G"
+                 xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+<description>
+  <para>
+    The integer parameter specifies the maximum number of
+    threads each smbd process will create when doing parallel asynchronous IO
+    calls. If the number of outstanding calls is greater than this
+    number the requests will not be refused but go onto a queue
+    and will be scheduled in turn as outstanding requests complete.
+  </para>
+
+  <related>aio read size</related>
+  <related>aio write size</related>
+</description>
+
+<value type="default">100</value>
+</samba:parameter>
diff --git a/docs-xml/smbdotconf/tuning/strictsync.xml b/docs-xml/smbdotconf/tuning/strictsync.xml
index 0d33845..5cfd388 100644
--- a/docs-xml/smbdotconf/tuning/strictsync.xml
+++ b/docs-xml/smbdotconf/tuning/strictsync.xml
@@ -5,7 +5,7 @@
  <description>
     <para>Many Windows applications (including the Windows 98 explorer
     shell) seem to confuse flushing buffer contents to disk with doing
-    a sync to disk. Under UNIX, a sync call forces the process to be
+    a sync to disk. Under UNIX, a sync call forces the thread to be
     suspended until the kernel has ensured that all outstanding data in
     kernel disk buffers has been safely stored onto stable storage.
     This is very slow and should only be done rarely. Setting this
@@ -17,6 +17,10 @@
     on crashes, so there is little danger in this default setting. In
     addition, this fixes many performance problems that people have
     reported with the new Windows98 explorer shell file copies.</para>
+    <para>The flush request from SMB2/3 clients is handled
+    asynchronously, so for these clients setting the parameter
+    to <constant>yes</constant> does not block the processing of other
+    requests in the smbd process.</para>
 </description>
 
 <related>sync always</related>
diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c
index 871d2d9..640c602 100644
--- a/lib/param/loadparm.c
+++ b/lib/param/loadparm.c
@@ -2809,6 +2809,8 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
 
 	lpcfg_do_global_parameter(lp_ctx, "printjob username", "%U");
 
+	lpcfg_do_global_parameter(lp_ctx, "aio max threads", "100");
+
 	/* Allow modules to adjust defaults */
 	for (defaults_hook = defaults_hooks; defaults_hook;
 		 defaults_hook = defaults_hook->next) {
diff --git a/packaging/RHEL-CTDB/configure.rpm b/packaging/RHEL-CTDB/configure.rpm
index c36d4bd..a2d35ea 100755
--- a/packaging/RHEL-CTDB/configure.rpm
+++ b/packaging/RHEL-CTDB/configure.rpm
@@ -62,7 +62,6 @@ CC="$CC" CFLAGS="-Wall -g -D_GNU_SOURCE -O3" ./configure -C \
 	--with-ctdb=/usr/include \
 	--without-ldb \
 	--without-dnsupdate \
-	--with-aio-support \
 	--disable-external-libtalloc \
 	--disable-external-libtdb \
 	$*
diff --git a/packaging/RHEL-CTDB/samba.spec.tmpl b/packaging/RHEL-CTDB/samba.spec.tmpl
index 0d8b5a6..6380158 100644
--- a/packaging/RHEL-CTDB/samba.spec.tmpl
+++ b/packaging/RHEL-CTDB/samba.spec.tmpl
@@ -180,7 +180,6 @@ CFLAGS="$RPM_OPT_FLAGS $EXTRA -D_GNU_SOURCE" ./configure \
 	--with-ctdb=/usr/include \
 	--without-ldb \
 	--without-dnsupdate \
-	--with-aio-support \
 	--disable-external-libtalloc \
 	--disable-external-libtdb
 
@@ -428,7 +427,6 @@ exit 0
 %{_libarchdir}/samba/vfs/tsmsm.so
 %endif
 %{_libarchdir}/samba/vfs/xattr_tdb.so
-%{_libarchdir}/samba/vfs/aio_posix.so
 %{_libarchdir}/samba/vfs/aio_pthread.so
 %{_libarchdir}/samba/vfs/media_harmony.so
 
diff --git a/source3/modules/vfs_aio_fork.c b/source3/modules/vfs_aio_fork.c
index 25a72c6..472ef0c 100644
--- a/source3/modules/vfs_aio_fork.c
+++ b/source3/modules/vfs_aio_fork.c
@@ -899,17 +899,6 @@ static int aio_fork_connect(vfs_handle_struct *handle, const char *service,
 				NULL, struct aio_fork_config,
 				return -1);
 
-	/*********************************************************************
-	 * How many threads to initialize ?
-	 * 100 per process seems insane as a default until you realize that
-	 * (a) Threads terminate after 1 second when idle.
-	 * (b) Throttling is done in SMB2 via the crediting algorithm.
-	 * (c) SMB1 clients are limited to max_mux (50) outstanding
-	 *     requests and Windows clients don't use this anyway.
-	 * Essentially we want this to be unlimited unless smb.conf
-	 * says different.
-	 *********************************************************************/
-	set_aio_pending_size(100);
 	return 0;
 }
 
diff --git a/source3/modules/vfs_aio_linux.c b/source3/modules/vfs_aio_linux.c
index 599272e..4f6230a 100644
--- a/source3/modules/vfs_aio_linux.c
+++ b/source3/modules/vfs_aio_linux.c
@@ -113,12 +113,12 @@ static bool init_aio_linux(struct vfs_handle_struct *handle)
 		goto fail;
 	}
 
-	if (io_queue_init(get_aio_pending_size(), &io_ctx)) {
+	if (io_queue_init(lp_aio_max_threads(), &io_ctx)) {
 		goto fail;
 	}
 
 	DEBUG(10,("init_aio_linux: initialized with up to %d events\n",
-		  get_aio_pending_size()));
+		  (int)lp_aio_max_threads()));
 
 	return true;
 
@@ -321,25 +321,7 @@ static int aio_linux_int_recv(struct tevent_req *req, int *err)
 	return aio_linux_recv(req, err);
 }
 
-static int aio_linux_connect(vfs_handle_struct *handle, const char *service,
-			       const char *user)
-{
-	/*********************************************************************
-	 * How many io_events to initialize ?
-	 * 128 per process seems insane as a default until you realize that
-	 * (a) Throttling is done in SMB2 via the crediting algorithm.
-	 * (b) SMB1 clients are limited to max_mux (50) outstanding
-	 *     requests and Windows clients don't use this anyway.
-	 * Essentially we want this to be unlimited unless smb.conf
-	 * says different.
-	 *********************************************************************/
-	set_aio_pending_size(lp_parm_int(
-		SNUM(handle->conn), "aio_linux", "aio num events", 128));
-	return SMB_VFS_NEXT_CONNECT(handle, service, user);
-}
-
 static struct vfs_fn_pointers vfs_aio_linux_fns = {
-	.connect_fn = aio_linux_connect,
 	.pread_send_fn = aio_linux_pread_send,
 	.pread_recv_fn = aio_linux_recv,
 	.pwrite_send_fn = aio_linux_pwrite_send,
diff --git a/source3/modules/vfs_aio_posix.c b/source3/modules/vfs_aio_posix.c
deleted file mode 100644
index bca69b4..0000000
--- a/source3/modules/vfs_aio_posix.c
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- * Simulate pread_send/recv and pwrite_send/recv using posix aio
- *
- * Copyright (C) Volker Lendecke 2012
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "includes.h"
-#include "system/filesys.h"
-#include "system/shmem.h"
-#include "smbd/smbd.h"
-#include "smbd/globals.h"
-#include "lib/util/tevent_unix.h"
-#include "lib/util/sys_rw.h"
-#include <aio.h>
-
-/* The signal we'll use to signify aio done. */
-#ifndef RT_SIGNAL_AIO
-#define RT_SIGNAL_AIO	(SIGRTMIN+3)
-#endif
-
-#ifndef HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR
-#ifdef HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR
-#define sival_int	sigval_int
-#define sival_ptr	sigval_ptr
-#endif
-#endif
-
-static struct tevent_signal *aio_signal_event = NULL;
-
-struct aio_posix_state {
-	struct aiocb acb;
-	ssize_t ret;
-	int err;
-};
-
-static int aio_posix_state_destructor(struct aio_posix_state *s)
-{
-	int ret;
-
-	/*
-	 * We could do better here. This destructor is run when a
-	 * request is prematurely cancelled. We wait for the aio to
-	 * complete, so that we do not have to maintain aiocb structs
-	 * beyond the life of an aio_posix_state. Possible, but not
-	 * sure the effort is worth it right now.
-	 */
-
-	do {
-		const struct aiocb *a = &s->acb;
-		ret = aio_suspend(&a, 1, NULL);
-	} while ((ret == -1) && (errno == EINTR));
-
-	return 0;
-}
-
-static struct tevent_req *aio_posix_pread_send(
-	struct vfs_handle_struct *handle,
-	TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-	struct files_struct *fsp, void *data, size_t n, off_t offset)
-{
-	struct tevent_req *req;
-	struct aio_posix_state *state;
-	struct aiocb *a;
-	int ret;
-
-	req = tevent_req_create(mem_ctx, &state, struct aio_posix_state);
-	if (req == NULL) {
-		return NULL;
-	}
-
-	a = &state->acb;
-
-	a->aio_fildes = fsp->fh->fd;
-	a->aio_buf = data;
-	a->aio_nbytes = n;
-	a->aio_offset = offset;
-	a->aio_sigevent.sigev_notify = SIGEV_SIGNAL;
-	a->aio_sigevent.sigev_signo  = RT_SIGNAL_AIO;
-	a->aio_sigevent.sigev_value.sival_ptr = req;
-
-	ret = aio_read(a);
-	if (ret == 0) {
-		talloc_set_destructor(state, aio_posix_state_destructor);
-		return req;
-	}
-
-	if (errno == EAGAIN) {
-		/*
-		 * aio overloaded, do the sync fallback
-		 */
-		state->ret = sys_pread(fsp->fh->fd, data, n, offset);
-		if (state->ret == -1) {
-			state->err = errno;
-		}
-		tevent_req_done(req);
-		return tevent_req_post(req, ev);
-	}
-
-	tevent_req_error(req, errno);
-	return tevent_req_post(req, ev);
-}
-
-static struct tevent_req *aio_posix_pwrite_send(
-	struct vfs_handle_struct *handle,
-	TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-	struct files_struct *fsp, const void *data, size_t n, off_t offset)
-{
-	struct tevent_req *req;
-	struct aio_posix_state *state;
-	struct aiocb *a;
-	int ret;
-
-	req = tevent_req_create(mem_ctx, &state, struct aio_posix_state);
-	if (req == NULL) {
-		return NULL;
-	}
-
-	a = &state->acb;
-
-	a->aio_fildes = fsp->fh->fd;
-	a->aio_buf = discard_const(data);
-	a->aio_nbytes = n;
-	a->aio_offset = offset;
-	a->aio_sigevent.sigev_notify = SIGEV_SIGNAL;
-	a->aio_sigevent.sigev_signo  = RT_SIGNAL_AIO;
-	a->aio_sigevent.sigev_value.sival_ptr = req;
-
-	ret = aio_write(a);
-	if (ret == 0) {
-		talloc_set_destructor(state, aio_posix_state_destructor);
-		return req;
-	}
-
-	if (errno == EAGAIN) {
-		/*
-		 * aio overloaded, do the sync fallback
-		 */
-		state->ret = sys_pwrite(fsp->fh->fd, data, n, offset);
-		if (state->ret == -1) {
-			state->err = errno;
-		}
-		tevent_req_done(req);
-		return tevent_req_post(req, ev);
-	}
-
-	tevent_req_error(req, errno);
-	return tevent_req_post(req, ev);
-}
-
-static void aio_posix_signal_handler(struct tevent_context *ev,
-				     struct tevent_signal *se,
-				     int signum, int count,
-				     void *_info, void *private_data)
-{
-	siginfo_t *info;
-	struct tevent_req *req;
-	struct aio_posix_state *state;
-	int err;
-
-	info = (siginfo_t *)_info;
-	req = talloc_get_type_abort(info->si_value.sival_ptr,
-				    struct tevent_req);
-	state = tevent_req_data(req, struct aio_posix_state);
-
-	err = aio_error(&state->acb);
-	if (err == EINPROGRESS) {
-		DEBUG(10, ("aio_posix_signal_handler: operation req %p "
-			   "still in progress\n", req));
-		return;
-	}
-	if (err == ECANCELED) {
-		DEBUG(10, ("aio_posix_signal_handler: operation req %p "
-			   "canceled\n", req));
-		return;
-	}
-
-	/*
-	 * No need to suspend for this in the destructor anymore
-	 */
-	talloc_set_destructor(state, NULL);
-
-	state->ret = aio_return(&state->acb);
-	state->err = err;
-	tevent_req_done(req);
-}
-
-static ssize_t aio_posix_recv(struct tevent_req *req, int *err)
-{
-	struct aio_posix_state *state = tevent_req_data(
-		req, struct aio_posix_state);
-
-	if (tevent_req_is_unix_error(req, err)) {
-		return -1;
-	}
-	*err = state->err;
-	return state->ret;
-}
-
-static struct tevent_req *aio_posix_fsync_send(
-	struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
-	struct tevent_context *ev, struct files_struct *fsp)
-{
-	struct tevent_req *req;
-	struct aio_posix_state *state;
-	struct aiocb *a;
-	int ret;
-
-	req = tevent_req_create(mem_ctx, &state, struct aio_posix_state);
-	if (req == NULL) {
-		return NULL;
-	}
-
-	a = &state->acb;
-
-	a->aio_fildes = fsp->fh->fd;
-	a->aio_sigevent.sigev_notify = SIGEV_SIGNAL;
-	a->aio_sigevent.sigev_signo  = RT_SIGNAL_AIO;
-	a->aio_sigevent.sigev_value.sival_ptr = req;
-
-	ret = aio_fsync(O_SYNC, a);
-	if (ret == 0) {
-		talloc_set_destructor(state, aio_posix_state_destructor);
-		return req;
-	}
-
-	if (errno == EAGAIN) {
-		/*
-		 * aio overloaded, do the sync fallback
-		 */
-		state->ret = fsync(fsp->fh->fd);
-		if (state->ret == -1) {
-			state->err = errno;
-		}
-		tevent_req_done(req);
-		return tevent_req_post(req, ev);
-	}
-
-	tevent_req_error(req, errno);
-	return tevent_req_post(req, ev);
-}
-
-static int aio_posix_int_recv(struct tevent_req *req, int *err)
-{
-	struct aio_posix_state *state = tevent_req_data(
-		req, struct aio_posix_state);
-
-	if (tevent_req_is_unix_error(req, err)) {
-		return -1;
-	}
-	*err = state->err;
-	return state->ret;
-}
-
-static int aio_posix_connect(vfs_handle_struct *handle, const char *service,
-			     const char *user)
-{
-	if (aio_signal_event == NULL) {
-		struct tevent_context *ev = handle->conn->sconn->ev_ctx;
-
-		aio_signal_event = tevent_add_signal(
-			ev, ev, RT_SIGNAL_AIO, SA_SIGINFO,
-			aio_posix_signal_handler, NULL);
-
-		if (aio_signal_event == NULL) {
-			DEBUG(1, ("tevent_add_signal failed\n"));
-			return -1;
-		}
-	}
-	return SMB_VFS_NEXT_CONNECT(handle, service, user);
-}
-
-static struct vfs_fn_pointers vfs_aio_posix_fns = {
-	.connect_fn = aio_posix_connect,
-	.pread_send_fn = aio_posix_pread_send,
-	.pread_recv_fn = aio_posix_recv,
-	.pwrite_send_fn = aio_posix_pwrite_send,
-	.pwrite_recv_fn = aio_posix_recv,
-	.fsync_send_fn = aio_posix_fsync_send,
-	.fsync_recv_fn = aio_posix_int_recv,
-};
-
-NTSTATUS vfs_aio_posix_init(void);
-NTSTATUS vfs_aio_posix_init(void)
-{
-	return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
-				"aio_posix", &vfs_aio_posix_fns);
-}
diff --git a/source3/modules/vfs_aio_pthread.c b/source3/modules/vfs_aio_pthread.c
index 72c812f..10a3a23 100644
--- a/source3/modules/vfs_aio_pthread.c
+++ b/source3/modules/vfs_aio_pthread.c
@@ -51,7 +51,7 @@ static bool init_aio_threadpool(struct tevent_context *ev_ctx,
 		return true;
 	}
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list