diff --git a/docs-xml/smbdotconf/tuning/aiomaxthreads.xml b/docs-xml/smbdotconf/tuning/aiomaxthreads.xml new file mode 100644 index 00000000000..3afe989f5ce --- /dev/null +++ b/docs-xml/smbdotconf/tuning/aiomaxthreads.xml @@ -0,0 +1,19 @@ + + + + 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. + + + aio read size + aio write size + + +100 + diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c index 871d2d90ebc..640c60230e7 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/source3/modules/vfs_aio_fork.c b/source3/modules/vfs_aio_fork.c index 25a72c62f5f..472ef0cdad1 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 599272e3861..4f6230a2fdf 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_pthread.c b/source3/modules/vfs_aio_pthread.c index 72c812f14e0..10a3a23100b 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; } - ret = pthreadpool_init(get_aio_pending_size(), pp_pool); + ret = pthreadpool_init(lp_aio_max_threads(), pp_pool); if (ret) { errno = ret; return false; @@ -69,7 +69,7 @@ static bool init_aio_threadpool(struct tevent_context *ev_ctx, } DEBUG(10,("init_aio_threadpool: initialized with up to %d threads\n", - get_aio_pending_size())); + (int)lp_aio_max_threads())); return true; } diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index f3ebb897580..819a1a1ca6f 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -716,7 +716,7 @@ static bool vfswrap_init_asys_ctx(struct smbd_server_connection *conn) return true; } - ret = asys_context_init(&ctx, get_aio_pending_size()); + ret = asys_context_init(&ctx, lp_aio_max_threads()); if (ret != 0) { DEBUG(1, ("asys_context_init failed: %s\n", strerror(ret))); return false; diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index b24d198a1d9..9f40e65f33f 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -917,6 +917,8 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals) Globals.web_port = 901; + Globals.aio_max_threads = 100; + /* Now put back the settings that were set with lp_set_cmdline() */ apply_lp_set_cmdline(); } diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c index 3923eacdf64..32a1ce0e4a0 100644 --- a/source3/smbd/aio.c +++ b/source3/smbd/aio.c @@ -29,19 +29,8 @@ Statics plus accessor functions. *****************************************************************************/ -static int aio_pending_size = 100; /* Current max threads. */ static int outstanding_aio_calls; -int get_aio_pending_size(void) -{ - return aio_pending_size; -} - -void set_aio_pending_size(int newsize) -{ - aio_pending_size = newsize; -} - int get_outstanding_aio_calls(void) { return outstanding_aio_calls; diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 95414e638b0..7926dd6d16d 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -66,8 +66,6 @@ void srv_set_signing(struct smbXsrv_connection *conn, /* The following definitions come from smbd/aio.c */ -int get_aio_pending_size(void); -void set_aio_pending_size(int newsize); int get_outstanding_aio_calls(void); void increment_outstanding_aio_calls(void); void decrement_outstanding_aio_calls(void);