2023-03-11 20:52:10

by Luis Chamberlain

[permalink] [raw]
Subject: [PATCH v2 0/5] sunrpc: simplfy sysctl registrations

This is my v2 series to simplify sysctl registration for sunrpc. The
first series was posted just yesterday [0]. On this v2 I address the
only compilation issues found by 0day through my entire tree of
sysctl conversions.

Changes sincce v1:

o Fix compilation when CONFIG_SUNRPC_DEBUG is enabled, I forgot to move the
proc routines above, and so the 4th patch now does that too.

Feel free to take these patches or let me know and I'm happy to also
take these in through sysctl-next. Typically I use sysctl-next for
core sysctl changes or for kernel/sysctl.c cleanup to avoid conflicts.
All these syctls however are well contained to sunrpc so they can also
go in separately. Let me know how you'd like to go about these patches.

[0] https://lkml.kernel.org/r/[email protected]

Luis Chamberlain (5):
sunrpc: simplify two-level sysctl registration for tsvcrdma_parm_table
sunrpc: simplify one-level sysctl registration for xr_tunables_table
sunrpc: simplify one-level sysctl registration for xs_tunables_table
sunrpc: move sunrpc_table and proc routines above
sunrpc: simplify one-level sysctl registration for debug_table

net/sunrpc/sysctl.c | 44 ++++++++++++---------------------
net/sunrpc/xprtrdma/svc_rdma.c | 21 ++--------------
net/sunrpc/xprtrdma/transport.c | 11 +--------
net/sunrpc/xprtsock.c | 13 ++--------
4 files changed, 21 insertions(+), 68 deletions(-)

--
2.39.1



2023-03-11 20:52:12

by Luis Chamberlain

[permalink] [raw]
Subject: [PATCH v2 4/5] sunrpc: move sunrpc_table and proc routines above

No need to do a forward declaration for sunrpc_table, just move
the sysctls up as everyone else does it. This will make the next
change easier to read. This change produces no functional changes.

Signed-off-by: Luis Chamberlain <[email protected]>
---
net/sunrpc/sysctl.c | 38 ++++++++++++++++++--------------------
1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c
index 3aad6ef18504..a54438d68d1b 100644
--- a/net/sunrpc/sysctl.c
+++ b/net/sunrpc/sysctl.c
@@ -40,25 +40,6 @@ EXPORT_SYMBOL_GPL(nlm_debug);

#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)

-static struct ctl_table_header *sunrpc_table_header;
-static struct ctl_table sunrpc_table[];
-
-void
-rpc_register_sysctl(void)
-{
- if (!sunrpc_table_header)
- sunrpc_table_header = register_sysctl_table(sunrpc_table);
-}
-
-void
-rpc_unregister_sysctl(void)
-{
- if (sunrpc_table_header) {
- unregister_sysctl_table(sunrpc_table_header);
- sunrpc_table_header = NULL;
- }
-}
-
static int proc_do_xprt(struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
@@ -141,7 +122,9 @@ proc_dodebug(struct ctl_table *table, int write, void *buffer, size_t *lenp,
*ppos += *lenp;
return 0;
}
+#endif

+static struct ctl_table_header *sunrpc_table_header;

static struct ctl_table debug_table[] = {
{
@@ -190,4 +173,19 @@ static struct ctl_table sunrpc_table[] = {
{ }
};

-#endif
+
+void
+rpc_register_sysctl(void)
+{
+ if (!sunrpc_table_header)
+ sunrpc_table_header = register_sysctl_table(sunrpc_table);
+}
+
+void
+rpc_unregister_sysctl(void)
+{
+ if (sunrpc_table_header) {
+ unregister_sysctl_table(sunrpc_table_header);
+ sunrpc_table_header = NULL;
+ }
+}
--
2.39.1


2023-03-11 20:52:13

by Luis Chamberlain

[permalink] [raw]
Subject: [PATCH v2 3/5] sunrpc: simplify one-level sysctl registration for xs_tunables_table

There is no need to declare an extra tables to just create directory,
this can be easily be done with a prefix path with register_sysctl().

Simplify this registration.

Signed-off-by: Luis Chamberlain <[email protected]>
---
net/sunrpc/xprtsock.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index aaa5b2741b79..46bbd6230650 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -77,7 +77,7 @@ static unsigned int xs_tcp_fin_timeout __read_mostly = XS_TCP_LINGER_TO;

/*
* We can register our own files under /proc/sys/sunrpc by
- * calling register_sysctl_table() again. The files in that
+ * calling register_sysctl() again. The files in that
* directory become the union of all files registered there.
*
* We simply need to make sure that we don't collide with
@@ -157,15 +157,6 @@ static struct ctl_table xs_tunables_table[] = {
{ },
};

-static struct ctl_table sunrpc_table[] = {
- {
- .procname = "sunrpc",
- .mode = 0555,
- .child = xs_tunables_table
- },
- { },
-};
-
/*
* Wait duration for a reply from the RPC portmapper.
*/
@@ -3174,7 +3165,7 @@ static struct xprt_class xs_bc_tcp_transport = {
int init_socket_xprt(void)
{
if (!sunrpc_table_header)
- sunrpc_table_header = register_sysctl_table(sunrpc_table);
+ sunrpc_table_header = register_sysctl("sunrpc", xs_tunables_table);

xprt_register_transport(&xs_local_transport);
xprt_register_transport(&xs_udp_transport);
--
2.39.1