aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4state.c
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2019-04-09 15:56:57 -0400
committerJ. Bruce Fields <bfields@redhat.com>2019-07-03 17:52:50 -0400
commit97ad4031e29521894fc28765f14247e79b0ef263 (patch)
treedaec545c5697807abc3b7182f15b2c8086fd71a2 /fs/nfsd/nfs4state.c
parentnfsd: make client/ directory names small ints (diff)
downloadlinux-dev-97ad4031e29521894fc28765f14247e79b0ef263.tar.xz
linux-dev-97ad4031e29521894fc28765f14247e79b0ef263.zip
nfsd4: add a client info file
Add a new nfsd/clients/#/info file with some basic information about each NFSv4 client. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r--fs/nfsd/nfs4state.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 8f9747d84525..a6c722dc7e5e 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -2214,6 +2214,41 @@ find_stateid_by_type(struct nfs4_client *cl, stateid_t *t, char typemask)
return s;
}
+static int client_info_show(struct seq_file *m, void *v)
+{
+ struct inode *inode = m->private;
+ struct nfsdfs_client *nc;
+ struct nfs4_client *clp;
+ u64 clid;
+
+ nc = get_nfsdfs_client(inode);
+ if (!nc)
+ return -ENXIO;
+ clp = container_of(nc, struct nfs4_client, cl_nfsdfs);
+ memcpy(&clid, &clp->cl_clientid, sizeof(clid));
+ seq_printf(m, "clientid: 0x%llx\n", clid);
+ drop_client(clp);
+
+ return 0;
+}
+
+static int client_info_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, client_info_show, inode);
+}
+
+static const struct file_operations client_info_fops = {
+ .open = client_info_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+static const struct tree_descr client_files[] = {
+ [0] = {"info", &client_info_fops, S_IRUSR},
+ [1] = {""},
+};
+
static struct nfs4_client *create_client(struct xdr_netobj name,
struct svc_rqst *rqstp, nfs4_verifier *verf)
{
@@ -2242,7 +2277,8 @@ static struct nfs4_client *create_client(struct xdr_netobj name,
clp->cl_cb_session = NULL;
clp->net = net;
clp->cl_nfsd_dentry = nfsd_client_mkdir(nn, &clp->cl_nfsdfs,
- clp->cl_clientid.cl_id - nn->clientid_base);
+ clp->cl_clientid.cl_id - nn->clientid_base,
+ client_files);
if (!clp->cl_nfsd_dentry) {
free_client(clp);
return NULL;