Skip to content

Commit 1548036

Browse files
josefbacikTrond Myklebust
authored and
Trond Myklebust
committed
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>
1 parent d47151b commit 1548036

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

fs/nfs/client.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ const struct rpc_program nfs_program = {
7373
.number = NFS_PROGRAM,
7474
.nrvers = ARRAY_SIZE(nfs_version),
7575
.version = nfs_version,
76-
.stats = &nfs_rpcstat,
7776
.pipe_dir_name = NFS_PIPE_DIRNAME,
7877
};
7978

@@ -502,6 +501,7 @@ int nfs_create_rpc_client(struct nfs_client *clp,
502501
const struct nfs_client_initdata *cl_init,
503502
rpc_authflavor_t flavor)
504503
{
504+
struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
505505
struct rpc_clnt *clnt = NULL;
506506
struct rpc_create_args args = {
507507
.net = clp->cl_net,
@@ -513,6 +513,7 @@ int nfs_create_rpc_client(struct nfs_client *clp,
513513
.servername = clp->cl_hostname,
514514
.nodename = cl_init->nodename,
515515
.program = &nfs_program,
516+
.stats = &nn->rpcstats,
516517
.version = clp->rpc_ops->version,
517518
.authflavor = flavor,
518519
.cred = cl_init->cred,
@@ -1182,6 +1183,8 @@ void nfs_clients_init(struct net *net)
11821183
#endif
11831184
spin_lock_init(&nn->nfs_client_lock);
11841185
nn->boot_time = ktime_get_real();
1186+
memset(&nn->rpcstats, 0, sizeof(nn->rpcstats));
1187+
nn->rpcstats.program = &nfs_program;
11851188

11861189
nfs_netns_sysfs_setup(nn, net);
11871190
}

fs/nfs/inode.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2426,8 +2426,10 @@ EXPORT_SYMBOL_GPL(nfs_net_id);
24262426

24272427
static int nfs_net_init(struct net *net)
24282428
{
2429+
struct nfs_net *nn = net_generic(net, nfs_net_id);
2430+
24292431
nfs_clients_init(net);
2430-
rpc_proc_register(net, &nfs_rpcstat);
2432+
rpc_proc_register(net, &nn->rpcstats);
24312433
return nfs_fs_proc_net_init(net);
24322434
}
24332435

fs/nfs/internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,6 @@ int nfs_try_get_tree(struct fs_context *);
449449
int nfs_get_tree_common(struct fs_context *);
450450
void nfs_kill_super(struct super_block *);
451451

452-
extern struct rpc_stat nfs_rpcstat;
453-
454452
extern int __init register_nfs_fs(void);
455453
extern void __exit unregister_nfs_fs(void);
456454
extern bool nfs_sb_active(struct super_block *sb);

fs/nfs/netns.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/nfs4.h>
1010
#include <net/net_namespace.h>
1111
#include <net/netns/generic.h>
12+
#include <linux/sunrpc/stats.h>
1213

1314
struct bl_dev_msg {
1415
int32_t status;
@@ -34,6 +35,7 @@ struct nfs_net {
3435
struct nfs_netns_client *nfs_client;
3536
spinlock_t nfs_client_lock;
3637
ktime_t boot_time;
38+
struct rpc_stat rpcstats;
3739
#ifdef CONFIG_PROC_FS
3840
struct proc_dir_entry *proc_nfsfs;
3941
#endif

0 commit comments

Comments
 (0)