Skip to content

Commit fbf7668

Browse files
chuckleverTrond Myklebust
authored andcommitted
SUNRPC: relocate the creation of socket-specific tunables
Clean-up: The RPC client currently creates some sysctls that are specific to the socket transport. Move those entirely into xprtsock.c. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1 parent 282b32e commit fbf7668

2 files changed

Lines changed: 104 additions & 53 deletions

File tree

‎net/sunrpc/sysctl.c‎

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <linux/sunrpc/types.h>
1919
#include <linux/sunrpc/sched.h>
2020
#include <linux/sunrpc/stats.h>
21-
#include <linux/sunrpc/xprt.h>
2221

2322
/*
2423
* Declare the debug flags here
@@ -119,11 +118,6 @@ proc_dodebug(ctl_table *table, int write, struct file *file,
119118
}
120119

121120

122-
static unsigned int min_slot_table_size = RPC_MIN_SLOT_TABLE;
123-
static unsigned int max_slot_table_size = RPC_MAX_SLOT_TABLE;
124-
static unsigned int xprt_min_resvport_limit = RPC_MIN_RESVPORT;
125-
static unsigned int xprt_max_resvport_limit = RPC_MAX_RESVPORT;
126-
127121
static ctl_table debug_table[] = {
128122
{
129123
.ctl_name = CTL_RPCDEBUG,
@@ -157,50 +151,6 @@ static ctl_table debug_table[] = {
157151
.mode = 0644,
158152
.proc_handler = &proc_dodebug
159153
},
160-
{
161-
.ctl_name = CTL_SLOTTABLE_UDP,
162-
.procname = "udp_slot_table_entries",
163-
.data = &xprt_udp_slot_table_entries,
164-
.maxlen = sizeof(unsigned int),
165-
.mode = 0644,
166-
.proc_handler = &proc_dointvec_minmax,
167-
.strategy = &sysctl_intvec,
168-
.extra1 = &min_slot_table_size,
169-
.extra2 = &max_slot_table_size
170-
},
171-
{
172-
.ctl_name = CTL_SLOTTABLE_TCP,
173-
.procname = "tcp_slot_table_entries",
174-
.data = &xprt_tcp_slot_table_entries,
175-
.maxlen = sizeof(unsigned int),
176-
.mode = 0644,
177-
.proc_handler = &proc_dointvec_minmax,
178-
.strategy = &sysctl_intvec,
179-
.extra1 = &min_slot_table_size,
180-
.extra2 = &max_slot_table_size
181-
},
182-
{
183-
.ctl_name = CTL_MIN_RESVPORT,
184-
.procname = "min_resvport",
185-
.data = &xprt_min_resvport,
186-
.maxlen = sizeof(unsigned int),
187-
.mode = 0644,
188-
.proc_handler = &proc_dointvec_minmax,
189-
.strategy = &sysctl_intvec,
190-
.extra1 = &xprt_min_resvport_limit,
191-
.extra2 = &xprt_max_resvport_limit
192-
},
193-
{
194-
.ctl_name = CTL_MAX_RESVPORT,
195-
.procname = "max_resvport",
196-
.data = &xprt_max_resvport,
197-
.maxlen = sizeof(unsigned int),
198-
.mode = 0644,
199-
.proc_handler = &proc_dointvec_minmax,
200-
.strategy = &sysctl_intvec,
201-
.extra1 = &xprt_min_resvport_limit,
202-
.extra2 = &xprt_max_resvport_limit
203-
},
204154
{ .ctl_name = 0 }
205155
};
206156

‎net/sunrpc/xprtsock.c‎

Lines changed: 104 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,92 @@ unsigned int xprt_tcp_slot_table_entries = RPC_DEF_SLOT_TABLE;
4545
unsigned int xprt_min_resvport = RPC_DEF_MIN_RESVPORT;
4646
unsigned int xprt_max_resvport = RPC_DEF_MAX_RESVPORT;
4747

48+
/*
49+
* We can register our own files under /proc/sys/sunrpc by
50+
* calling register_sysctl_table() again. The files in that
51+
* directory become the union of all files registered there.
52+
*
53+
* We simply need to make sure that we don't collide with
54+
* someone else's file names!
55+
*/
56+
57+
#ifdef RPC_DEBUG
58+
59+
static unsigned int min_slot_table_size = RPC_MIN_SLOT_TABLE;
60+
static unsigned int max_slot_table_size = RPC_MAX_SLOT_TABLE;
61+
static unsigned int xprt_min_resvport_limit = RPC_MIN_RESVPORT;
62+
static unsigned int xprt_max_resvport_limit = RPC_MAX_RESVPORT;
63+
64+
static struct ctl_table_header *sunrpc_table_header;
65+
66+
/*
67+
* FIXME: changing the UDP slot table size should also resize the UDP
68+
* socket buffers for existing UDP transports
69+
*/
70+
static ctl_table xs_tunables_table[] = {
71+
{
72+
.ctl_name = CTL_SLOTTABLE_UDP,
73+
.procname = "udp_slot_table_entries",
74+
.data = &xprt_udp_slot_table_entries,
75+
.maxlen = sizeof(unsigned int),
76+
.mode = 0644,
77+
.proc_handler = &proc_dointvec_minmax,
78+
.strategy = &sysctl_intvec,
79+
.extra1 = &min_slot_table_size,
80+
.extra2 = &max_slot_table_size
81+
},
82+
{
83+
.ctl_name = CTL_SLOTTABLE_TCP,
84+
.procname = "tcp_slot_table_entries",
85+
.data = &xprt_tcp_slot_table_entries,
86+
.maxlen = sizeof(unsigned int),
87+
.mode = 0644,
88+
.proc_handler = &proc_dointvec_minmax,
89+
.strategy = &sysctl_intvec,
90+
.extra1 = &min_slot_table_size,
91+
.extra2 = &max_slot_table_size
92+
},
93+
{
94+
.ctl_name = CTL_MIN_RESVPORT,
95+
.procname = "min_resvport",
96+
.data = &xprt_min_resvport,
97+
.maxlen = sizeof(unsigned int),
98+
.mode = 0644,
99+
.proc_handler = &proc_dointvec_minmax,
100+
.strategy = &sysctl_intvec,
101+
.extra1 = &xprt_min_resvport_limit,
102+
.extra2 = &xprt_max_resvport_limit
103+
},
104+
{
105+
.ctl_name = CTL_MAX_RESVPORT,
106+
.procname = "max_resvport",
107+
.data = &xprt_max_resvport,
108+
.maxlen = sizeof(unsigned int),
109+
.mode = 0644,
110+
.proc_handler = &proc_dointvec_minmax,
111+
.strategy = &sysctl_intvec,
112+
.extra1 = &xprt_min_resvport_limit,
113+
.extra2 = &xprt_max_resvport_limit
114+
},
115+
{
116+
.ctl_name = 0,
117+
},
118+
};
119+
120+
static ctl_table sunrpc_table[] = {
121+
{
122+
.ctl_name = CTL_SUNRPC,
123+
.procname = "sunrpc",
124+
.mode = 0555,
125+
.child = xs_tunables_table
126+
},
127+
{
128+
.ctl_name = 0,
129+
},
130+
};
131+
132+
#endif
133+
48134
/*
49135
* How many times to try sending a request on a socket before waiting
50136
* for the socket buffer to clear.
@@ -1504,19 +1590,34 @@ struct rpc_xprt *xs_setup_tcp(struct sockaddr *addr, size_t addrlen, struct rpc_
15041590
}
15051591

15061592
/**
1507-
* init_socket_xprt - stub
1593+
* init_socket_xprt - set up xprtsock's sysctls
15081594
*
15091595
*/
15101596
int init_socket_xprt(void)
15111597
{
1598+
#ifdef RPC_DEBUG
1599+
if (!sunrpc_table_header) {
1600+
sunrpc_table_header = register_sysctl_table(sunrpc_table, 1);
1601+
#ifdef CONFIG_PROC_FS
1602+
if (sunrpc_table[0].de)
1603+
sunrpc_table[0].de->owner = THIS_MODULE;
1604+
#endif
1605+
}
1606+
#endif
1607+
15121608
return 0;
15131609
}
15141610

15151611
/**
1516-
* cleanup_socket_xprt - stub
1612+
* cleanup_socket_xprt - remove xprtsock's sysctls
15171613
*
15181614
*/
15191615
void cleanup_socket_xprt(void)
15201616
{
1521-
return;
1617+
#ifdef RPC_DEBUG
1618+
if (sunrpc_table_header) {
1619+
unregister_sysctl_table(sunrpc_table_header);
1620+
sunrpc_table_header = NULL;
1621+
}
1622+
#endif
15221623
}

0 commit comments

Comments
 (0)