Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Benjamin Coddington and committed by
Trond Myklebust
e13b5493 1c725118

+35 -8
+5
fs/nfs/client.c
··· 628 628 if (server->flags & NFS_MOUNT_SOFT) 629 629 server->client->cl_softrtry = 1; 630 630 631 + nfs_sysfs_link_rpc_client(server, server->client, NULL); 631 632 return 0; 632 633 } 633 634 EXPORT_SYMBOL_GPL(nfs_init_server_rpcclient); ··· 700 699 701 700 server->nfs_client = clp; 702 701 nfs_sysfs_add_server(server); 702 + nfs_sysfs_link_rpc_client(server, clp->cl_rpcclient, "_state"); 703 703 704 704 /* Initialise the client representation from the mount data */ 705 705 server->flags = ctx->flags; ··· 1126 1124 server->fsid = fattr->fsid; 1127 1125 1128 1126 nfs_sysfs_add_server(server); 1127 + 1128 + nfs_sysfs_link_rpc_client(server, 1129 + server->nfs_client->cl_rpcclient, "_state"); 1129 1130 1130 1131 error = nfs_init_server_rpcclient(server, 1131 1132 source->client->cl_timeout,
+1
fs/nfs/nfs4client.c
··· 954 954 955 955 server->nfs_client = clp; 956 956 nfs_sysfs_add_server(server); 957 + nfs_sysfs_link_rpc_client(server, clp->cl_rpcclient, "_state"); 957 958 958 959 return 0; 959 960 }
+20
fs/nfs/sysfs.c
··· 216 216 } 217 217 } 218 218 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 + 219 239 static void nfs_sysfs_sb_release(struct kobject *kobj) 220 240 { 221 241 /* no-op: why? see lib/kobject.c kobject_cleanup() */
+2
fs/nfs/sysfs.h
··· 23 23 void nfs_netns_sysfs_setup(struct nfs_net *netns, struct net *net); 24 24 void nfs_netns_sysfs_destroy(struct nfs_net *netns); 25 25 26 + void nfs_sysfs_link_rpc_client(struct nfs_server *server, 27 + struct rpc_clnt *clnt, const char *sysfs_prefix); 26 28 void nfs_sysfs_add_server(struct nfs_server *s); 27 29 void nfs_sysfs_move_server_to_sb(struct super_block *s); 28 30 void nfs_sysfs_move_sb_to_server(struct nfs_server *s);
+7 -1
include/linux/sunrpc/clnt.h
··· 30 30 #include <linux/sunrpc/xprtmultipath.h> 31 31 32 32 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 + 34 40 35 41 /* 36 42 * The high-level client handle
-7
net/sunrpc/sysfs.h
··· 5 5 #ifndef __SUNRPC_SYSFS_H 6 6 #define __SUNRPC_SYSFS_H 7 7 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 - 15 8 struct rpc_sysfs_xprt_switch { 16 9 struct kobject kobject; 17 10 struct net *net;