Skip to content

Commit 5405fc4

Browse files
trondmypdamschuma-ntap
authored andcommitted
NFSv4.x: Add kernel parameter to control the callback server
Add support for the kernel parameter nfs.callback_nr_threads to set the number of threads that will be assigned to the callback channel. Add support for the kernel parameter nfs.nfs.max_session_cb_slots to set the maximum size of the callback channel slot table. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent bb6aeba commit 5405fc4

File tree

7 files changed

+33
-6
lines changed

7 files changed

+33
-6
lines changed

Documentation/kernel-parameters.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2420,6 +2420,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
24202420
nfsrootdebug [NFS] enable nfsroot debugging messages.
24212421
See Documentation/filesystems/nfs/nfsroot.txt.
24222422

2423+
nfs.callback_nr_threads=
2424+
[NFSv4] set the total number of threads that the
2425+
NFS client will assign to service NFSv4 callback
2426+
requests.
2427+
24232428
nfs.callback_tcpport=
24242429
[NFS] set the TCP port on which the NFSv4 callback
24252430
channel should listen.
@@ -2443,6 +2448,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
24432448
of returning the full 64-bit number.
24442449
The default is to return 64-bit inode numbers.
24452450

2451+
nfs.max_session_cb_slots=
2452+
[NFSv4.1] Sets the maximum number of session
2453+
slots the client will assign to the callback
2454+
channel. This determines the maximum number of
2455+
callbacks the client will process in parallel for
2456+
a particular server.
2457+
24462458
nfs.max_session_slots=
24472459
[NFSv4.1] Sets the maximum number of session slots
24482460
the client will attempt to negotiate with the server.

fs/nfs/callback.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,14 @@ static inline void nfs_callback_bc_serv(u32 minorversion, struct rpc_xprt *xprt,
148148
static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
149149
struct svc_serv *serv)
150150
{
151-
const int nrservs = NFS4_NR_CALLBACK_THREADS;
151+
int nrservs = nfs_callback_nr_threads;
152152
int ret;
153153

154154
nfs_callback_bc_serv(minorversion, xprt, serv);
155155

156+
if (nrservs < NFS4_MIN_NR_CALLBACK_THREADS)
157+
nrservs = NFS4_MIN_NR_CALLBACK_THREADS;
158+
156159
if (serv->sv_nrthreads-1 == nrservs)
157160
return 0;
158161

fs/nfs/callback.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,9 @@ extern void nfs_callback_down(int minorversion, struct net *net);
198198
#define NFS41_BC_MIN_CALLBACKS 1
199199
#define NFS41_BC_MAX_CALLBACKS 1
200200

201-
#define NFS4_NR_CALLBACK_THREADS 1
201+
#define NFS4_MIN_NR_CALLBACK_THREADS 1
202202

203203
extern unsigned int nfs_callback_set_tcpport;
204+
extern unsigned short nfs_callback_nr_threads;
204205

205206
#endif /* __LINUX_FS_NFS_CALLBACK_H */

fs/nfs/nfs4_fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ extern struct nfs_subversion nfs_v4;
471471
struct dentry *nfs4_try_mount(int, const char *, struct nfs_mount_info *, struct nfs_subversion *);
472472
extern bool nfs4_disable_idmapping;
473473
extern unsigned short max_session_slots;
474+
extern unsigned short max_session_cb_slots;
474475
extern unsigned short send_implementation_id;
475476
extern bool recover_lost_locks;
476477

fs/nfs/nfs4proc.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7463,7 +7463,7 @@ static void nfs4_init_channel_attrs(struct nfs41_create_session_args *args,
74637463
args->bc_attrs.max_resp_sz = max_bc_payload;
74647464
args->bc_attrs.max_resp_sz_cached = 0;
74657465
args->bc_attrs.max_ops = NFS4_MAX_BACK_CHANNEL_OPS;
7466-
args->bc_attrs.max_reqs = NFS41_BC_MAX_CALLBACKS;
7466+
args->bc_attrs.max_reqs = min_t(unsigned short, max_session_cb_slots, 1);
74677467

74687468
dprintk("%s: Back Channel : max_rqst_sz=%u max_resp_sz=%u "
74697469
"max_resp_sz_cached=%u max_ops=%u max_reqs=%u\n",
@@ -7510,10 +7510,9 @@ static int nfs4_verify_back_channel_attrs(struct nfs41_create_session_args *args
75107510
return -EINVAL;
75117511
if (rcvd->max_resp_sz_cached > sent->max_resp_sz_cached)
75127512
return -EINVAL;
7513-
/* These would render the backchannel useless: */
7514-
if (rcvd->max_ops != sent->max_ops)
7513+
if (rcvd->max_ops > sent->max_ops)
75157514
return -EINVAL;
7516-
if (rcvd->max_reqs != sent->max_reqs)
7515+
if (rcvd->max_reqs > sent->max_reqs)
75177516
return -EINVAL;
75187517
out:
75197518
return 0;

fs/nfs/nfs4session.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
/* maximum number of slots to use */
1111
#define NFS4_DEF_SLOT_TABLE_SIZE (64U)
12+
#define NFS4_DEF_CB_SLOT_TABLE_SIZE (1U)
1213
#define NFS4_MAX_SLOT_TABLE (1024U)
1314
#define NFS4_NO_SLOT ((u32)-1)
1415

fs/nfs/super.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2848,19 +2848,23 @@ static int nfs4_validate_mount_data(void *options,
28482848
* NFS client for backwards compatibility
28492849
*/
28502850
unsigned int nfs_callback_set_tcpport;
2851+
unsigned short nfs_callback_nr_threads;
28512852
/* Default cache timeout is 10 minutes */
28522853
unsigned int nfs_idmap_cache_timeout = 600;
28532854
/* Turn off NFSv4 uid/gid mapping when using AUTH_SYS */
28542855
bool nfs4_disable_idmapping = true;
28552856
unsigned short max_session_slots = NFS4_DEF_SLOT_TABLE_SIZE;
2857+
unsigned short max_session_cb_slots = NFS4_DEF_CB_SLOT_TABLE_SIZE;
28562858
unsigned short send_implementation_id = 1;
28572859
char nfs4_client_id_uniquifier[NFS4_CLIENT_ID_UNIQ_LEN] = "";
28582860
bool recover_lost_locks = false;
28592861

2862+
EXPORT_SYMBOL_GPL(nfs_callback_nr_threads);
28602863
EXPORT_SYMBOL_GPL(nfs_callback_set_tcpport);
28612864
EXPORT_SYMBOL_GPL(nfs_idmap_cache_timeout);
28622865
EXPORT_SYMBOL_GPL(nfs4_disable_idmapping);
28632866
EXPORT_SYMBOL_GPL(max_session_slots);
2867+
EXPORT_SYMBOL_GPL(max_session_cb_slots);
28642868
EXPORT_SYMBOL_GPL(send_implementation_id);
28652869
EXPORT_SYMBOL_GPL(nfs4_client_id_uniquifier);
28662870
EXPORT_SYMBOL_GPL(recover_lost_locks);
@@ -2887,6 +2891,9 @@ static const struct kernel_param_ops param_ops_portnr = {
28872891
#define param_check_portnr(name, p) __param_check(name, p, unsigned int);
28882892

28892893
module_param_named(callback_tcpport, nfs_callback_set_tcpport, portnr, 0644);
2894+
module_param_named(callback_nr_threads, nfs_callback_nr_threads, ushort, 0644);
2895+
MODULE_PARM_DESC(callback_nr_threads, "Number of threads that will be "
2896+
"assigned to the NFSv4 callback channels.");
28902897
module_param(nfs_idmap_cache_timeout, int, 0644);
28912898
module_param(nfs4_disable_idmapping, bool, 0644);
28922899
module_param_string(nfs4_unique_id, nfs4_client_id_uniquifier,
@@ -2896,6 +2903,9 @@ MODULE_PARM_DESC(nfs4_disable_idmapping,
28962903
module_param(max_session_slots, ushort, 0644);
28972904
MODULE_PARM_DESC(max_session_slots, "Maximum number of outstanding NFSv4.1 "
28982905
"requests the client will negotiate");
2906+
module_param(max_session_cb_slots, ushort, 0644);
2907+
MODULE_PARM_DESC(max_session_slots, "Maximum number of parallel NFSv4.1 "
2908+
"callbacks the client will process for a given server");
28992909
module_param(send_implementation_id, ushort, 0644);
29002910
MODULE_PARM_DESC(send_implementation_id,
29012911
"Send implementation ID with NFSv4.1 exchange_id");

0 commit comments

Comments
 (0)