summaryrefslogtreecommitdiff
path: root/fs/nfsd/nfs4state.c
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2019-04-09 22:56:57 +0300
committerJ. Bruce Fields <bfields@redhat.com>2019-07-04 00:52:50 +0300
commit97ad4031e29521894fc28765f14247e79b0ef263 (patch)
treedaec545c5697807abc3b7182f15b2c8086fd71a2 /fs/nfsd/nfs4state.c
parentbf5ed3e3bb84c39d70ad10b2f8e47ec62f4c63b1 (diff)
downloadlinux-97ad4031e29521894fc28765f14247e79b0ef263.tar.xz
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;