nfs: make the rpc_stat per net namespace

Now that we're exposing the rpc stats on a per-network namespace basis,
move this struct into struct nfs_net and use that to make sure only the
per-network namespace stats are exposed.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
This commit is contained in:
Josef Bacik 2024-02-15 14:57:32 -05:00 committed by Trond Myklebust
parent d47151b79e
commit 1548036ef1
4 changed files with 9 additions and 4 deletions

View file

@ -73,7 +73,6 @@ const struct rpc_program nfs_program = {
.number = NFS_PROGRAM, .number = NFS_PROGRAM,
.nrvers = ARRAY_SIZE(nfs_version), .nrvers = ARRAY_SIZE(nfs_version),
.version = nfs_version, .version = nfs_version,
.stats = &nfs_rpcstat,
.pipe_dir_name = NFS_PIPE_DIRNAME, .pipe_dir_name = NFS_PIPE_DIRNAME,
}; };
@ -502,6 +501,7 @@ int nfs_create_rpc_client(struct nfs_client *clp,
const struct nfs_client_initdata *cl_init, const struct nfs_client_initdata *cl_init,
rpc_authflavor_t flavor) rpc_authflavor_t flavor)
{ {
struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
struct rpc_clnt *clnt = NULL; struct rpc_clnt *clnt = NULL;
struct rpc_create_args args = { struct rpc_create_args args = {
.net = clp->cl_net, .net = clp->cl_net,
@ -513,6 +513,7 @@ int nfs_create_rpc_client(struct nfs_client *clp,
.servername = clp->cl_hostname, .servername = clp->cl_hostname,
.nodename = cl_init->nodename, .nodename = cl_init->nodename,
.program = &nfs_program, .program = &nfs_program,
.stats = &nn->rpcstats,
.version = clp->rpc_ops->version, .version = clp->rpc_ops->version,
.authflavor = flavor, .authflavor = flavor,
.cred = cl_init->cred, .cred = cl_init->cred,
@ -1182,6 +1183,8 @@ void nfs_clients_init(struct net *net)
#endif #endif
spin_lock_init(&nn->nfs_client_lock); spin_lock_init(&nn->nfs_client_lock);
nn->boot_time = ktime_get_real(); nn->boot_time = ktime_get_real();
memset(&nn->rpcstats, 0, sizeof(nn->rpcstats));
nn->rpcstats.program = &nfs_program;
nfs_netns_sysfs_setup(nn, net); nfs_netns_sysfs_setup(nn, net);
} }

View file

@ -2426,8 +2426,10 @@ EXPORT_SYMBOL_GPL(nfs_net_id);
static int nfs_net_init(struct net *net) static int nfs_net_init(struct net *net)
{ {
struct nfs_net *nn = net_generic(net, nfs_net_id);
nfs_clients_init(net); nfs_clients_init(net);
rpc_proc_register(net, &nfs_rpcstat); rpc_proc_register(net, &nn->rpcstats);
return nfs_fs_proc_net_init(net); return nfs_fs_proc_net_init(net);
} }

View file

@ -449,8 +449,6 @@ int nfs_try_get_tree(struct fs_context *);
int nfs_get_tree_common(struct fs_context *); int nfs_get_tree_common(struct fs_context *);
void nfs_kill_super(struct super_block *); void nfs_kill_super(struct super_block *);
extern struct rpc_stat nfs_rpcstat;
extern int __init register_nfs_fs(void); extern int __init register_nfs_fs(void);
extern void __exit unregister_nfs_fs(void); extern void __exit unregister_nfs_fs(void);
extern bool nfs_sb_active(struct super_block *sb); extern bool nfs_sb_active(struct super_block *sb);

View file

@ -9,6 +9,7 @@
#include <linux/nfs4.h> #include <linux/nfs4.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
#include <net/netns/generic.h> #include <net/netns/generic.h>
#include <linux/sunrpc/stats.h>
struct bl_dev_msg { struct bl_dev_msg {
int32_t status; int32_t status;
@ -34,6 +35,7 @@ struct nfs_net {
struct nfs_netns_client *nfs_client; struct nfs_netns_client *nfs_client;
spinlock_t nfs_client_lock; spinlock_t nfs_client_lock;
ktime_t boot_time; ktime_t boot_time;
struct rpc_stat rpcstats;
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_nfsfs; struct proc_dir_entry *proc_nfsfs;
#endif #endif