Skip to content

Commit e13b549

Browse files
bcodding-rhTrond Myklebust
authored andcommitted
NFS: Add sysfs links to sunrpc clients for nfs_clients
For the general and state management nfs_client under each mount, create symlinks to their respective rpc_client sysfs entries. Signed-off-by: Benjamin Coddington <bcodding@redhat.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent 1c72511 commit e13b549

File tree

6 files changed

+35
-8
lines changed

6 files changed

+35
-8
lines changed

fs/nfs/client.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ int nfs_init_server_rpcclient(struct nfs_server *server,
628628
if (server->flags & NFS_MOUNT_SOFT)
629629
server->client->cl_softrtry = 1;
630630

631+
nfs_sysfs_link_rpc_client(server, server->client, NULL);
631632
return 0;
632633
}
633634
EXPORT_SYMBOL_GPL(nfs_init_server_rpcclient);
@@ -699,6 +700,7 @@ static int nfs_init_server(struct nfs_server *server,
699700

700701
server->nfs_client = clp;
701702
nfs_sysfs_add_server(server);
703+
nfs_sysfs_link_rpc_client(server, clp->cl_rpcclient, "_state");
702704

703705
/* Initialise the client representation from the mount data */
704706
server->flags = ctx->flags;
@@ -1125,6 +1127,9 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source,
11251127

11261128
nfs_sysfs_add_server(server);
11271129

1130+
nfs_sysfs_link_rpc_client(server,
1131+
server->nfs_client->cl_rpcclient, "_state");
1132+
11281133
error = nfs_init_server_rpcclient(server,
11291134
source->client->cl_timeout,
11301135
flavor);

fs/nfs/nfs4client.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,7 @@ static int nfs4_set_client(struct nfs_server *server,
954954

955955
server->nfs_client = clp;
956956
nfs_sysfs_add_server(server);
957+
nfs_sysfs_link_rpc_client(server, clp->cl_rpcclient, "_state");
957958

958959
return 0;
959960
}

fs/nfs/sysfs.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,26 @@ void nfs_netns_sysfs_destroy(struct nfs_net *netns)
216216
}
217217
}
218218

219+
#define RPC_CLIENT_NAME_SIZE 64
220+
221+
void nfs_sysfs_link_rpc_client(struct nfs_server *server,
222+
struct rpc_clnt *clnt, const char *uniq)
223+
{
224+
char name[RPC_CLIENT_NAME_SIZE];
225+
int ret;
226+
227+
strcpy(name, clnt->cl_program->name);
228+
strcat(name, uniq ? uniq : "");
229+
strcat(name, "_client");
230+
231+
ret = sysfs_create_link_nowarn(&server->kobj,
232+
&clnt->cl_sysfs->kobject, name);
233+
if (ret < 0)
234+
pr_warn("NFS: can't create link to %s in sysfs (%d)\n",
235+
name, ret);
236+
}
237+
EXPORT_SYMBOL_GPL(nfs_sysfs_link_rpc_client);
238+
219239
static void nfs_sysfs_sb_release(struct kobject *kobj)
220240
{
221241
/* no-op: why? see lib/kobject.c kobject_cleanup() */

fs/nfs/sysfs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ extern void nfs_sysfs_exit(void);
2323
void nfs_netns_sysfs_setup(struct nfs_net *netns, struct net *net);
2424
void nfs_netns_sysfs_destroy(struct nfs_net *netns);
2525

26+
void nfs_sysfs_link_rpc_client(struct nfs_server *server,
27+
struct rpc_clnt *clnt, const char *sysfs_prefix);
2628
void nfs_sysfs_add_server(struct nfs_server *s);
2729
void nfs_sysfs_move_server_to_sb(struct super_block *s);
2830
void nfs_sysfs_move_sb_to_server(struct nfs_server *s);

include/linux/sunrpc/clnt.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@
3030
#include <linux/sunrpc/xprtmultipath.h>
3131

3232
struct rpc_inode;
33-
struct rpc_sysfs_client;
33+
struct rpc_sysfs_client {
34+
struct kobject kobject;
35+
struct net *net;
36+
struct rpc_clnt *clnt;
37+
struct rpc_xprt_switch *xprt_switch;
38+
};
39+
3440

3541
/*
3642
* The high-level client handle

net/sunrpc/sysfs.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55
#ifndef __SUNRPC_SYSFS_H
66
#define __SUNRPC_SYSFS_H
77

8-
struct rpc_sysfs_client {
9-
struct kobject kobject;
10-
struct net *net;
11-
struct rpc_clnt *clnt;
12-
struct rpc_xprt_switch *xprt_switch;
13-
};
14-
158
struct rpc_sysfs_xprt_switch {
169
struct kobject kobject;
1710
struct net *net;

0 commit comments

Comments
 (0)