Skip to content

Commit aa185f7

Browse files
josefbaciksmb49
authored andcommitted
nfs: make the rpc_stat per net namespace
BugLink: https://bugs.launchpad.net/bugs/2070028 [ Upstream commit 1548036 ] 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> Stable-dep-of: 24457f1 ("nfs: Handle error of rpc_proc_register() in nfs_net_init().") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent b6d60ba commit aa185f7

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

@@ -500,6 +499,7 @@ int nfs_create_rpc_client(struct nfs_client *clp,
500499
const struct nfs_client_initdata *cl_init,
501500
rpc_authflavor_t flavor)
502501
{
502+
struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
503503
struct rpc_clnt *clnt = NULL;
504504
struct rpc_create_args args = {
505505
.net = clp->cl_net,
@@ -511,6 +511,7 @@ int nfs_create_rpc_client(struct nfs_client *clp,
511511
.servername = clp->cl_hostname,
512512
.nodename = cl_init->nodename,
513513
.program = &nfs_program,
514+
.stats = &nn->rpcstats,
514515
.version = clp->rpc_ops->version,
515516
.authflavor = flavor,
516517
.cred = cl_init->cred,
@@ -1129,6 +1130,8 @@ void nfs_clients_init(struct net *net)
11291130
#endif
11301131
spin_lock_init(&nn->nfs_client_lock);
11311132
nn->boot_time = ktime_get_real();
1133+
memset(&nn->rpcstats, 0, sizeof(nn->rpcstats));
1134+
nn->rpcstats.program = &nfs_program;
11321135

11331136
nfs_netns_sysfs_setup(nn, net);
11341137
}

fs/nfs/inode.c

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

23612361
static int nfs_net_init(struct net *net)
23622362
{
2363+
struct nfs_net *nn = net_generic(net, nfs_net_id);
2364+
23632365
nfs_clients_init(net);
2364-
rpc_proc_register(net, &nfs_rpcstat);
2366+
rpc_proc_register(net, &nn->rpcstats);
23652367
return nfs_fs_proc_net_init(net);
23662368
}
23672369

fs/nfs/internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,6 @@ int nfs_try_get_tree(struct fs_context *);
428428
int nfs_get_tree_common(struct fs_context *);
429429
void nfs_kill_super(struct super_block *);
430430

431-
extern struct rpc_stat nfs_rpcstat;
432-
433431
extern int __init register_nfs_fs(void);
434432
extern void __exit unregister_nfs_fs(void);
435433
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)