[PATCH] Convert a few parametric options in smbd and a new one
Ralph Böhme
slow at samba.org
Wed Dec 5 10:18:16 UTC 2018
Hi,
attached is a patchset with two changes:
- convert three parametric options in hot code paths in smbd to normal options
- add a new option "smbd getinfo ask sharemode", counterpart to "smbd search ask
sharemode".
CI: https://gitlab.com/samba-team/devel/samba/pipelines/38774823
Please review&push if happy. Thanks!
-slow
--
Ralph Boehme, Samba Team https://samba.org/
Samba Developer, SerNet GmbH https://sernet.de/en/samba/
GPG-Fingerprint FAE2C6088A24252051C559E4AA1E9B7126399E46
-------------- next part --------------
From e95d3c0d16aea1d1d5032a1ecb6d960915756583 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Mon, 3 Dec 2018 14:59:55 +0100
Subject: [PATCH 01/11] tests:docs: reindent special_cases to one by line
Signed-off-by: Ralph Boehme <slow at samba.org>
---
python/samba/tests/docs.py | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/python/samba/tests/docs.py b/python/samba/tests/docs.py
index e11ebd1d26a..f25df436831 100644
--- a/python/samba/tests/docs.py
+++ b/python/samba/tests/docs.py
@@ -100,15 +100,32 @@ import xml.etree.ElementTree as ET
class SmbDotConfTests(TestCase):
# defines the cases where the defaults may differ from the documentation
- special_cases = set(['log level', 'path',
- 'panic action', 'homedir map', 'NIS homedir',
- 'server string', 'netbios name', 'socket options', 'use mmap',
- 'ctdbd socket', 'printing', 'printcap name', 'queueresume command',
- 'queuepause command', 'lpresume command', 'lppause command',
- 'lprm command', 'lpq command', 'print command', 'template homedir',
- 'max open files',
- 'include system krb5 conf', 'rpc server dynamic port range',
- 'mit kdc command'])
+ special_cases = set([
+ 'log level',
+ 'path',
+ 'panic action',
+ 'homedir map',
+ 'NIS homedir',
+ 'server string',
+ 'netbios name',
+ 'socket options',
+ 'use mmap',
+ 'ctdbd socket',
+ 'printing',
+ 'printcap name',
+ 'queueresume command',
+ 'queuepause command',
+ 'lpresume command',
+ 'lppause command',
+ 'lprm command',
+ 'lpq command',
+ 'print command',
+ 'template homedir',
+ 'max open files',
+ 'include system krb5 conf',
+ 'rpc server dynamic port range',
+ 'mit kdc command',
+ ])
def setUp(self):
super(SmbDotConfTests, self).setUp()
--
2.17.2
From 0aaf31eade97f7d9f3f4ed9e7c49b9328001f16c Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Mon, 3 Dec 2018 15:44:22 +0100
Subject: [PATCH 02/11] tests:docs: add a exceptions set
Signed-off-by: Ralph Boehme <slow at samba.org>
---
python/samba/tests/docs.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/python/samba/tests/docs.py b/python/samba/tests/docs.py
index f25df436831..b64f9726367 100644
--- a/python/samba/tests/docs.py
+++ b/python/samba/tests/docs.py
@@ -244,7 +244,12 @@ import xml.etree.ElementTree as ET
for tuples in self.defaults:
param, default, context, param_type = tuples
- if param in ['printing', 'rpc server dynamic port range']:
+ exceptions = set([
+ 'printing',
+ 'rpc server dynamic port range',
+ ])
+
+ if param in exceptions:
continue
section = None
--
2.17.2
From 34f89384e05cf88c67d2e391a62dc503ee5e4ed1 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Fri, 30 Nov 2018 20:24:10 +0100
Subject: [PATCH 03/11] docs-xml: add "smbd search ask sharemode"
Signed-off-by: Ralph Boehme <slow at samba.org>
---
docs-xml/smbdotconf/misc/smbdsearchasksharemode.xml | 13 +++++++++++++
lib/param/loadparm.c | 1 +
source3/param/loadparm.c | 1 +
3 files changed, 15 insertions(+)
create mode 100644 docs-xml/smbdotconf/misc/smbdsearchasksharemode.xml
diff --git a/docs-xml/smbdotconf/misc/smbdsearchasksharemode.xml b/docs-xml/smbdotconf/misc/smbdsearchasksharemode.xml
new file mode 100644
index 00000000000..de78818c5f8
--- /dev/null
+++ b/docs-xml/smbdotconf/misc/smbdsearchasksharemode.xml
@@ -0,0 +1,13 @@
+<samba:parameter name="smbd search ask sharemode"
+ context="S"
+ type="boolean"
+ xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+<description>
+ <para>
+ This parameter allows disabling fetching file write time from the open
+ file handle database locking.tdb. It's a performance optimisation at
+ the expense of protocol correctness.
+ </para>
+</description>
+<value type="default">yes</value>
+</samba:parameter>
diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c
index a7dbc6f8f0b..886f0b06b43 100644
--- a/lib/param/loadparm.c
+++ b/lib/param/loadparm.c
@@ -2592,6 +2592,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
lp_ctx->sDefault->force_directory_mode = 0000;
lp_ctx->sDefault->aio_read_size = 1;
lp_ctx->sDefault->aio_write_size = 1;
+ lp_ctx->sDefault->smbd_search_ask_sharemode = true;
DEBUG(3, ("Initialising global parameters\n"));
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index d8be520dc51..cdd06c0a2c7 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -246,6 +246,7 @@ static const struct loadparm_service _sDefault =
.durable_handles = true,
.check_parent_directory_delete_on_close = false,
.param_opt = NULL,
+ .smbd_search_ask_sharemode = true,
.dummy = ""
};
--
2.17.2
From 884afcd1cde61d2e1bfffd7fd62627fbebadc208 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sat, 1 Dec 2018 00:10:41 +0100
Subject: [PATCH 04/11] s3:smbd: use lp_smbd_search_ask_sharemode()
Parametric options have a performance impact, use the normal options
added in the previous commit.
Signed-off-by: Ralph Boehme <slow at samba.org>
---
source3/smbd/smb2_query_directory.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/source3/smbd/smb2_query_directory.c b/source3/smbd/smb2_query_directory.c
index fb77edca2bf..cbad1b7cc57 100644
--- a/source3/smbd/smb2_query_directory.c
+++ b/source3/smbd/smb2_query_directory.c
@@ -506,8 +506,7 @@ static struct tevent_req *smbd_smb2_query_directory_send(TALLOC_CTX *mem_ctx,
* handling in future.
*/
if (state->info_level != SMB_FIND_FILE_NAMES_INFO) {
- state->ask_sharemode = lp_parm_bool(
- SNUM(conn), "smbd", "search ask sharemode", true);
+ state->ask_sharemode = lp_smbd_search_ask_sharemode(SNUM(conn));
state->async_dosmode = lp_parm_bool(
SNUM(conn), "smbd", "async dosmode", false);
--
2.17.2
From 4fd0f8d98708c3055908ae3c1f4b602411e479f1 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sun, 2 Dec 2018 09:21:26 +0100
Subject: [PATCH 05/11] docs-xml: add "smbd async dosmode"
Signed-off-by: Ralph Boehme <slow at samba.org>
---
docs-xml/smbdotconf/misc/smbdasyncdosmode.xml | 13 +++++++++++++
1 file changed, 13 insertions(+)
create mode 100644 docs-xml/smbdotconf/misc/smbdasyncdosmode.xml
diff --git a/docs-xml/smbdotconf/misc/smbdasyncdosmode.xml b/docs-xml/smbdotconf/misc/smbdasyncdosmode.xml
new file mode 100644
index 00000000000..b76bd01ccfa
--- /dev/null
+++ b/docs-xml/smbdotconf/misc/smbdasyncdosmode.xml
@@ -0,0 +1,13 @@
+<samba:parameter name="smbd async dosmode"
+ context="S"
+ type="boolean"
+ xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+<description>
+ <para>
+ This parameter control whether the fileserver will use sync or async
+ methods for fetching the DOS mode. By default sync methods will be
+ used.
+ </para>
+</description>
+<value type="default">no</value>
+</samba:parameter>
--
2.17.2
From 41c144704c58dda57a50a350eb0a37608376e3d5 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sun, 2 Dec 2018 09:21:46 +0100
Subject: [PATCH 06/11] s3:smbd: use lp_smbd_async_dosmode()
Parametric options have a performance impact, use the normal options
added in the previous commit.
Signed-off-by: Ralph Boehme <slow at samba.org>
---
source3/smbd/smb2_query_directory.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/source3/smbd/smb2_query_directory.c b/source3/smbd/smb2_query_directory.c
index cbad1b7cc57..5d8af5531ce 100644
--- a/source3/smbd/smb2_query_directory.c
+++ b/source3/smbd/smb2_query_directory.c
@@ -508,8 +508,7 @@ static struct tevent_req *smbd_smb2_query_directory_send(TALLOC_CTX *mem_ctx,
if (state->info_level != SMB_FIND_FILE_NAMES_INFO) {
state->ask_sharemode = lp_smbd_search_ask_sharemode(SNUM(conn));
- state->async_dosmode = lp_parm_bool(
- SNUM(conn), "smbd", "async dosmode", false);
+ state->async_dosmode = lp_smbd_async_dosmode(SNUM(conn));
}
if (state->ask_sharemode && lp_clustering()) {
--
2.17.2
From 9d76c1204da7a62c5ad684b6e1db8538e7381855 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sun, 2 Dec 2018 09:22:56 +0100
Subject: [PATCH 07/11] docs-xml: add "smbd max async dosmode"
The parameter is added to the lists of ignored-paremteres in the
samba.docs tests, as the given default "aio max threads * 2" works only
as manpage string.
"aio max threads" can only be calculated at run time and requires a
handle to a pthreadpool_tevent which loadparm will never have.
Because of that lp_smbd_max_async_dosmode() will always return 0 as
default and it's up to the caller to calculate "aio max threads * 2" if
lp_smbd_max_async_dosmode() returns 0. Cf the next commit.
Signed-off-by: Ralph Boehme <slow at samba.org>
---
docs-xml/smbdotconf/misc/smbdmaxasyncdosmode.xml | 12 ++++++++++++
python/samba/tests/docs.py | 2 ++
2 files changed, 14 insertions(+)
create mode 100644 docs-xml/smbdotconf/misc/smbdmaxasyncdosmode.xml
diff --git a/docs-xml/smbdotconf/misc/smbdmaxasyncdosmode.xml b/docs-xml/smbdotconf/misc/smbdmaxasyncdosmode.xml
new file mode 100644
index 00000000000..b8a3425ece2
--- /dev/null
+++ b/docs-xml/smbdotconf/misc/smbdmaxasyncdosmode.xml
@@ -0,0 +1,12 @@
+<samba:parameter name="smbd max async dosmode"
+ context="S"
+ type="integer"
+ xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+<description>
+ <para>
+ This parameter controls how many async operations to fetch the DOS
+ mode the fileserver will queue.
+ </para>
+</description>
+<value type="default">aio max threads * 2</value>
+</samba:parameter>
diff --git a/python/samba/tests/docs.py b/python/samba/tests/docs.py
index b64f9726367..b6c15b7d8de 100644
--- a/python/samba/tests/docs.py
+++ b/python/samba/tests/docs.py
@@ -125,6 +125,7 @@ import xml.etree.ElementTree as ET
'include system krb5 conf',
'rpc server dynamic port range',
'mit kdc command',
+ 'smbd max async dosmode',
])
def setUp(self):
@@ -247,6 +248,7 @@ import xml.etree.ElementTree as ET
exceptions = set([
'printing',
'rpc server dynamic port range',
+ 'smbd max async dosmode',
])
if param in exceptions:
--
2.17.2
From c477006e9daa87f83beb2100ccd2b9ab249c9119 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sun, 2 Dec 2018 09:23:29 +0100
Subject: [PATCH 08/11] s3:smbd: use lp_smbd_max_async_dosmode()
Parametric options have a performance impact, use the normal options
added in the previous commit.
"aio max threads" can only be calculated at run time and requires a
handle to a pthreadpool_tevent which loadparm will never have.
Because of that lp_smbd_max_async_dosmode() will always return 0 as
default and it's up to us to calculate "aio max threads * 2" if
lp_smbd_max_async_dosmode() returns 0.
Signed-off-by: Ralph Boehme <slow at samba.org>
---
source3/smbd/smb2_query_directory.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/source3/smbd/smb2_query_directory.c b/source3/smbd/smb2_query_directory.c
index 5d8af5531ce..68c00241a51 100644
--- a/source3/smbd/smb2_query_directory.c
+++ b/source3/smbd/smb2_query_directory.c
@@ -521,12 +521,10 @@ static struct tevent_req *smbd_smb2_query_directory_send(TALLOC_CTX *mem_ctx,
max_threads = pthreadpool_tevent_max_threads(state->tp_chdir_safe);
- state->max_async_dosmode_active = lp_parm_ulong(
- SNUM(conn), "smbd", "max async dosmode",
- max_threads * 2);
-
+ state->max_async_dosmode_active = lp_smbd_max_async_dosmode(
+ SNUM(conn));
if (state->max_async_dosmode_active == 0) {
- state->max_async_dosmode_active = 1;
+ state->max_async_dosmode_active = max_threads * 2;
}
}
--
2.17.2
From 6c05561343fc92c8cc4af6b4ddce3e195f12143b Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sun, 2 Dec 2018 10:07:59 +0100
Subject: [PATCH 09/11] docs-xml: add "smbd getinfo ask sharemode"
Counterpart for "smbd search ask sharemode" for getinfo.
Signed-off-by: Ralph Boehme <slow at samba.org>
---
.../smbdotconf/misc/smbdgetinfoasksharemode.xml | 14 ++++++++++++++
lib/param/loadparm.c | 1 +
source3/param/loadparm.c | 1 +
3 files changed, 16 insertions(+)
create mode 100644 docs-xml/smbdotconf/misc/smbdgetinfoasksharemode.xml
diff --git a/docs-xml/smbdotconf/misc/smbdgetinfoasksharemode.xml b/docs-xml/smbdotconf/misc/smbdgetinfoasksharemode.xml
new file mode 100644
index 00000000000..1bef948ad2b
--- /dev/null
+++ b/docs-xml/smbdotconf/misc/smbdgetinfoasksharemode.xml
@@ -0,0 +1,14 @@
+<samba:parameter name="smbd getinfo ask sharemode"
+ context="S"
+ type="boolean"
+ xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+<description>
+ <para>
+ This parameter allows disabling fetching file write time from the open
+ file handle database locking.tdb when a client requests file or
+ directory metadata. It's a performance optimisation at the expense of
+ protocol correctness.
+ </para>
+</description>
+<value type="default">yes</value>
+</samba:parameter>
diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c
index 886f0b06b43..f31ef2319ac 100644
--- a/lib/param/loadparm.c
+++ b/lib/param/loadparm.c
@@ -2593,6 +2593,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
lp_ctx->sDefault->aio_read_size = 1;
lp_ctx->sDefault->aio_write_size = 1;
lp_ctx->sDefault->smbd_search_ask_sharemode = true;
+ lp_ctx->sDefault->smbd_getinfo_ask_sharemode = true;
DEBUG(3, ("Initialising global parameters\n"));
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index cdd06c0a2c7..29d9d59390b 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -247,6 +247,7 @@ static const struct loadparm_service _sDefault =
.check_parent_directory_delete_on_close = false,
.param_opt = NULL,
.smbd_search_ask_sharemode = true,
+ .smbd_getinfo_ask_sharemode = true,
.dummy = ""
};
--
2.17.2
From 086722feaafbe477ece8cee725f1521ee6d05408 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Mon, 3 Dec 2018 11:30:51 +0100
Subject: [PATCH 10/11] smbd: use lp_smbd_getinfo_ask_sharemode()
Counterpart for "smbd:search ask sharemode" for getinfo.
Pair-Programmed-With: Volker Lendecke <vl at samba.org>
Signed-off-by: Ralph Boehme <slow at samba.org>
---
source3/smbd/smb2_getinfo.c | 22 ++++++++++++++--------
source3/smbd/trans2.c | 26 ++++++++++++++++++++------
2 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/source3/smbd/smb2_getinfo.c b/source3/smbd/smb2_getinfo.c
index 7bded422520..314f44e858c 100644
--- a/source3/smbd/smb2_getinfo.c
+++ b/source3/smbd/smb2_getinfo.c
@@ -353,10 +353,13 @@ static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx,
return tevent_req_post(req, ev);
}
- fileid = vfs_file_id_from_sbuf(conn,
- &fsp->fsp_name->st);
- get_file_infos(fileid, fsp->name_hash,
- &delete_pending, &write_time_ts);
+ if (lp_smbd_getinfo_ask_sharemode(SNUM(conn))) {
+ fileid = vfs_file_id_from_sbuf(
+ conn, &fsp->fsp_name->st);
+ get_file_infos(fileid, fsp->name_hash,
+ &delete_pending,
+ &write_time_ts);
+ }
} else {
/*
* Original code - this is an open file.
@@ -370,10 +373,13 @@ static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx,
tevent_req_nterror(req, status);
return tevent_req_post(req, ev);
}
- fileid = vfs_file_id_from_sbuf(conn,
- &fsp->fsp_name->st);
- get_file_infos(fileid, fsp->name_hash,
- &delete_pending, &write_time_ts);
+ if (lp_smbd_getinfo_ask_sharemode(SNUM(conn))) {
+ fileid = vfs_file_id_from_sbuf(
+ conn, &fsp->fsp_name->st);
+ get_file_infos(fileid, fsp->name_hash,
+ &delete_pending,
+ &write_time_ts);
+ }
}
status = smbd_do_qfilepathinfo(conn, state,
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 306174e597d..d3497fed0b4 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -5785,8 +5785,13 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
return;
}
- fileid = vfs_file_id_from_sbuf(conn, &smb_fname->st);
- get_file_infos(fileid, fsp->name_hash, &delete_pending, &write_time_ts);
+ if (lp_smbd_getinfo_ask_sharemode(SNUM(conn))) {
+ fileid = vfs_file_id_from_sbuf(
+ conn, &smb_fname->st);
+ get_file_infos(fileid, fsp->name_hash,
+ &delete_pending,
+ &write_time_ts);
+ }
} else {
/*
* Original code - this is an open file.
@@ -5798,8 +5803,13 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
map_nt_error_from_unix(errno));
return;
}
- fileid = vfs_file_id_from_sbuf(conn, &smb_fname->st);
- get_file_infos(fileid, fsp->name_hash, &delete_pending, &write_time_ts);
+ if (lp_smbd_getinfo_ask_sharemode(SNUM(conn))) {
+ fileid = vfs_file_id_from_sbuf(
+ conn, &smb_fname->st);
+ get_file_infos(fileid, fsp->name_hash,
+ &delete_pending,
+ &write_time_ts);
+ }
}
} else {
@@ -5967,8 +5977,12 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
return;
}
- fileid = vfs_file_id_from_sbuf(conn, &smb_fname->st);
- get_file_infos(fileid, name_hash, &delete_pending, &write_time_ts);
+ if (lp_smbd_getinfo_ask_sharemode(SNUM(conn))) {
+ fileid = vfs_file_id_from_sbuf(conn, &smb_fname->st);
+ get_file_infos(fileid, name_hash, &delete_pending,
+ &write_time_ts);
+ }
+
if (delete_pending) {
reply_nterror(req, NT_STATUS_DELETE_PENDING);
return;
--
2.17.2
From a69bcdcc4cccdba841ef78c75e5c2744ced827bb Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Mon, 3 Dec 2018 11:23:28 +0100
Subject: [PATCH 11/11] WHATSNEW: document changes in SMB server parametric
options
Signed-off-by: Ralph Boehme <slow at samba.org>
---
WHATSNEW.txt | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 50543637c86..0d7aed0c27e 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -113,7 +113,14 @@ smb.conf changes
between attempts.
prefork maximum backoff Maximum delay for process between 120 (seconds)
process restart attempts
-
+ smbd search ask sharemode Name changed, old name was
+ "smbd:search ask sharemode"
+ smbd async dosmode Name changed, old name was
+ "smbd:async dosmode"
+ smbd max async dosmode Name changed, old name was
+ "smbd:max async dosmode"
+ smbd getinfo ask sharemode New: similar to "smbd search ask yes
+ sharemode" but for SMB getinfo
KNOWN ISSUES
============
--
2.17.2
More information about the samba-technical
mailing list