nfs: make the rpc_stat per net namespace
authorJosef Bacik <josef@toxicpanda.com>
Thu, 15 Feb 2024 19:57:32 +0000 (14:57 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 May 2024 09:50:46 +0000 (11:50 +0200)
[ Upstream commit 1548036ef1204df65ca5a16e8b199c858cb80075 ]

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: 24457f1be29f ("nfs: Handle error of rpc_proc_register() in nfs_net_init().")
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nfs/client.c
fs/nfs/inode.c
fs/nfs/internal.h
fs/nfs/netns.h

index 090b16890e3d627cdd51b09b1ad8070abc0b0f2f..9e3a3570efc0f2e0fed53333d60e573db1c187ca 100644 (file)
@@ -73,7 +73,6 @@ const struct rpc_program nfs_program = {
        .number                 = NFS_PROGRAM,
        .nrvers                 = ARRAY_SIZE(nfs_version),
        .version                = nfs_version,
-       .stats                  = &nfs_rpcstat,
        .pipe_dir_name          = NFS_PIPE_DIRNAME,
 };
 
@@ -500,6 +499,7 @@ int nfs_create_rpc_client(struct nfs_client *clp,
                          const struct nfs_client_initdata *cl_init,
                          rpc_authflavor_t flavor)
 {
+       struct nfs_net          *nn = net_generic(clp->cl_net, nfs_net_id);
        struct rpc_clnt         *clnt = NULL;
        struct rpc_create_args args = {
                .net            = clp->cl_net,
@@ -511,6 +511,7 @@ int nfs_create_rpc_client(struct nfs_client *clp,
                .servername     = clp->cl_hostname,
                .nodename       = cl_init->nodename,
                .program        = &nfs_program,
+               .stats          = &nn->rpcstats,
                .version        = clp->rpc_ops->version,
                .authflavor     = flavor,
                .cred           = cl_init->cred,
@@ -1129,6 +1130,8 @@ void nfs_clients_init(struct net *net)
 #endif
        spin_lock_init(&nn->nfs_client_lock);
        nn->boot_time = ktime_get_real();
+       memset(&nn->rpcstats, 0, sizeof(nn->rpcstats));
+       nn->rpcstats.program = &nfs_program;
 
        nfs_netns_sysfs_setup(nn, net);
 }
index f5942b81213d6ab0dd75fdc898cfe4b90769f01f..c3d961f9b4e15a0f0ef177a8e1b8b4f9ae249bd1 100644 (file)
@@ -2360,8 +2360,10 @@ EXPORT_SYMBOL_GPL(nfs_net_id);
 
 static int nfs_net_init(struct net *net)
 {
+       struct nfs_net *nn = net_generic(net, nfs_net_id);
+
        nfs_clients_init(net);
-       rpc_proc_register(net, &nfs_rpcstat);
+       rpc_proc_register(net, &nn->rpcstats);
        return nfs_fs_proc_net_init(net);
 }
 
index 2ceb4b98ec15fb2db1599da6fcf51457b76b3503..d0965b4676a5b751a9f2f5391b4af92eee27a15b 100644 (file)
@@ -428,8 +428,6 @@ int nfs_try_get_tree(struct fs_context *);
 int nfs_get_tree_common(struct fs_context *);
 void nfs_kill_super(struct super_block *);
 
-extern struct rpc_stat nfs_rpcstat;
-
 extern int __init register_nfs_fs(void);
 extern void __exit unregister_nfs_fs(void);
 extern bool nfs_sb_active(struct super_block *sb);
index c8374f74dce1142289ed717c5281b4600a2a44e5..a68b21603ea9a867ba513e2a667b08fbc6d80dd8 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/nfs4.h>
 #include <net/net_namespace.h>
 #include <net/netns/generic.h>
+#include <linux/sunrpc/stats.h>
 
 struct bl_dev_msg {
        int32_t status;
@@ -34,6 +35,7 @@ struct nfs_net {
        struct nfs_netns_client *nfs_client;
        spinlock_t nfs_client_lock;
        ktime_t boot_time;
+       struct rpc_stat rpcstats;
 #ifdef CONFIG_PROC_FS
        struct proc_dir_entry *proc_nfsfs;
 #endif