Skip to content

Commit 39d432f

Browse files
committed
NFSD: trace nfsctl operations
Add trace log eye-catchers that record the arguments used to configure NFSD. This helps when troubleshooting the NFSD administrative interfaces. These tracepoints can capture NFSD start-up and shutdown times and parameters, changes in lease time and thread count, and a request to end the namespace's NFSv4 grace period, in addition to the set of NFS versions that are enabled. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 3434d7a commit 39d432f

File tree

2 files changed

+284
-8
lines changed

2 files changed

+284
-8
lines changed

fs/nfsd/nfsctl.c

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "netns.h"
2626
#include "pnfs.h"
2727
#include "filecache.h"
28+
#include "trace.h"
2829

2930
/*
3031
* We have a single directory with several nodes in it.
@@ -230,6 +231,7 @@ static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size)
230231
if (rpc_pton(net, fo_path, size, sap, salen) == 0)
231232
return -EINVAL;
232233

234+
trace_nfsd_ctl_unlock_ip(net, buf);
233235
return nlmsvc_unlock_all_by_ip(sap);
234236
}
235237

@@ -263,7 +265,7 @@ static ssize_t write_unlock_fs(struct file *file, char *buf, size_t size)
263265
fo_path = buf;
264266
if (qword_get(&buf, fo_path, size) < 0)
265267
return -EINVAL;
266-
268+
trace_nfsd_ctl_unlock_fs(netns(file), fo_path);
267269
error = kern_path(fo_path, 0, &path);
268270
if (error)
269271
return error;
@@ -341,6 +343,8 @@ static ssize_t write_filehandle(struct file *file, char *buf, size_t size)
341343
if (qword_get(&mesg, mesg, size) > 0)
342344
return -EINVAL;
343345

346+
trace_nfsd_ctl_filehandle(netns(file), dname, path, maxsize);
347+
344348
/* we have all the words, they are in buf.. */
345349
dom = unix_domain_find(dname);
346350
if (!dom)
@@ -399,6 +403,7 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size)
399403
return rv;
400404
if (newthreads < 0)
401405
return -EINVAL;
406+
trace_nfsd_ctl_threads(net, newthreads);
402407
rv = nfsd_svc(newthreads, net, file->f_cred);
403408
if (rv < 0)
404409
return rv;
@@ -471,6 +476,7 @@ static ssize_t write_pool_threads(struct file *file, char *buf, size_t size)
471476
rv = -EINVAL;
472477
if (nthreads[i] < 0)
473478
goto out_free;
479+
trace_nfsd_ctl_pool_threads(net, i, nthreads[i]);
474480
}
475481
rv = nfsd_set_nrthreads(i, nthreads, net);
476482
if (rv)
@@ -536,6 +542,7 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size)
536542
if (buf[size-1] != '\n')
537543
return -EINVAL;
538544
buf[size-1] = 0;
545+
trace_nfsd_ctl_version(netns(file), buf);
539546

540547
vers = mesg;
541548
len = qword_get(&mesg, vers, size);
@@ -689,6 +696,7 @@ static ssize_t __write_ports_addfd(char *buf, struct net *net, const struct cred
689696
err = get_int(&mesg, &fd);
690697
if (err != 0 || fd < 0)
691698
return -EINVAL;
699+
trace_nfsd_ctl_ports_addfd(net, fd);
692700

693701
err = nfsd_create_serv(net);
694702
if (err != 0)
@@ -720,6 +728,7 @@ static ssize_t __write_ports_addxprt(char *buf, struct net *net, const struct cr
720728

721729
if (port < 1 || port > USHRT_MAX)
722730
return -EINVAL;
731+
trace_nfsd_ctl_ports_addxprt(net, transport, port);
723732

724733
err = nfsd_create_serv(net);
725734
if (err != 0)
@@ -853,6 +862,8 @@ static ssize_t write_maxblksize(struct file *file, char *buf, size_t size)
853862
int rv = get_int(&mesg, &bsize);
854863
if (rv)
855864
return rv;
865+
trace_nfsd_ctl_maxblksize(netns(file), bsize);
866+
856867
/* force bsize into allowed range and
857868
* required alignment.
858869
*/
@@ -903,6 +914,7 @@ static ssize_t write_maxconn(struct file *file, char *buf, size_t size)
903914

904915
if (rv)
905916
return rv;
917+
trace_nfsd_ctl_maxconn(netns(file), maxconn);
906918
nn->max_connections = maxconn;
907919
}
908920

@@ -913,6 +925,7 @@ static ssize_t write_maxconn(struct file *file, char *buf, size_t size)
913925
static ssize_t __nfsd4_write_time(struct file *file, char *buf, size_t size,
914926
time64_t *time, struct nfsd_net *nn)
915927
{
928+
struct dentry *dentry = file_dentry(file);
916929
char *mesg = buf;
917930
int rv, i;
918931

@@ -922,6 +935,9 @@ static ssize_t __nfsd4_write_time(struct file *file, char *buf, size_t size,
922935
rv = get_int(&mesg, &i);
923936
if (rv)
924937
return rv;
938+
trace_nfsd_ctl_time(netns(file), dentry->d_name.name,
939+
dentry->d_name.len, i);
940+
925941
/*
926942
* Some sanity checking. We don't have a reason for
927943
* these particular numbers, but problems with the
@@ -1014,6 +1030,7 @@ static ssize_t __write_recoverydir(struct file *file, char *buf, size_t size,
10141030
len = qword_get(&mesg, recdir, size);
10151031
if (len <= 0)
10161032
return -EINVAL;
1033+
trace_nfsd_ctl_recoverydir(netns(file), recdir);
10171034

10181035
status = nfs4_reset_recoverydir(recdir);
10191036
if (status)
@@ -1087,7 +1104,7 @@ static ssize_t write_v4_end_grace(struct file *file, char *buf, size_t size)
10871104
case '1':
10881105
if (!nn->nfsd_serv)
10891106
return -EBUSY;
1090-
nfsd4_end_grace(nn);
1107+
trace_nfsd_end_grace(netns(file));
10911108
break;
10921109
default:
10931110
return -EINVAL;
@@ -1192,8 +1209,8 @@ static int __nfsd_symlink(struct inode *dir, struct dentry *dentry,
11921209
* @content is assumed to be a NUL-terminated string that lives
11931210
* longer than the symlink itself.
11941211
*/
1195-
static void nfsd_symlink(struct dentry *parent, const char *name,
1196-
const char *content)
1212+
static void _nfsd_symlink(struct dentry *parent, const char *name,
1213+
const char *content)
11971214
{
11981215
struct inode *dir = parent->d_inode;
11991216
struct dentry *dentry;
@@ -1210,8 +1227,8 @@ static void nfsd_symlink(struct dentry *parent, const char *name,
12101227
inode_unlock(dir);
12111228
}
12121229
#else
1213-
static inline void nfsd_symlink(struct dentry *parent, const char *name,
1214-
const char *content)
1230+
static inline void _nfsd_symlink(struct dentry *parent, const char *name,
1231+
const char *content)
12151232
{
12161233
}
12171234

@@ -1389,8 +1406,8 @@ static int nfsd_fill_super(struct super_block *sb, struct fs_context *fc)
13891406
ret = simple_fill_super(sb, 0x6e667364, nfsd_files);
13901407
if (ret)
13911408
return ret;
1392-
nfsd_symlink(sb->s_root, "supported_krb5_enctypes",
1393-
"/proc/net/rpc/gss_krb5_enctypes");
1409+
_nfsd_symlink(sb->s_root, "supported_krb5_enctypes",
1410+
"/proc/net/rpc/gss_krb5_enctypes");
13941411
dentry = nfsd_mkdir(sb->s_root, NULL, "clients");
13951412
if (IS_ERR(dentry))
13961413
return PTR_ERR(dentry);

0 commit comments

Comments
 (0)