Skip to content

Commit 16fb980

Browse files
josefbacikchucklever
authored andcommitted
nfsd: make svc_stat per-network namespace instead of global
The final bit of stats that is global is the rpc svc_stat. Move this into the nfsd_net struct and use that everywhere instead of the global struct. Remove the unused global struct. Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent e41ee44 commit 16fb980

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

fs/nfsd/netns.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/nfs4.h>
1515
#include <linux/percpu_counter.h>
1616
#include <linux/siphash.h>
17+
#include <linux/sunrpc/stats.h>
1718

1819
/* Hash tables for nfs4_clientid state */
1920
#define CLIENT_HASH_BITS 4
@@ -179,6 +180,9 @@ struct nfsd_net {
179180
/* Per-netns stats counters */
180181
struct percpu_counter counter[NFSD_STATS_COUNTERS_NUM];
181182

183+
/* sunrpc svc stats */
184+
struct svc_stat nfsd_svcstats;
185+
182186
/* longest hash chain seen */
183187
unsigned int longest_chain;
184188

fs/nfsd/nfsctl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,6 +1674,8 @@ static __net_init int nfsd_net_init(struct net *net)
16741674
retval = nfsd_stat_counters_init(nn);
16751675
if (retval)
16761676
goto out_repcache_error;
1677+
memset(&nn->nfsd_svcstats, 0, sizeof(nn->nfsd_svcstats));
1678+
nn->nfsd_svcstats.program = &nfsd_program;
16771679
nn->nfsd_versions = NULL;
16781680
nn->nfsd4_minorversions = NULL;
16791681
nfsd4_init_leases_net(nn);

fs/nfsd/nfssvc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ int nfsd_create_serv(struct net *net)
661661
if (nfsd_max_blksize == 0)
662662
nfsd_max_blksize = nfsd_get_default_max_blksize();
663663
nfsd_reset_versions(nn);
664-
serv = svc_create_pooled(&nfsd_program, &nfsd_svcstats,
664+
serv = svc_create_pooled(&nfsd_program, &nn->nfsd_svcstats,
665665
nfsd_max_blksize, nfsd);
666666
if (serv == NULL)
667667
return -ENOMEM;

fs/nfsd/stats.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
2727

2828
#include "nfsd.h"
2929

30-
struct svc_stat nfsd_svcstats = {
31-
.program = &nfsd_program,
32-
};
33-
3430
static int nfsd_show(struct seq_file *seq, void *v)
3531
{
3632
struct net *net = pde_data(file_inode(seq->file));
@@ -56,7 +52,7 @@ static int nfsd_show(struct seq_file *seq, void *v)
5652
seq_puts(seq, "\nra 0 0 0 0 0 0 0 0 0 0 0 0\n");
5753

5854
/* show my rpc info */
59-
svc_seq_show(seq, &nfsd_svcstats);
55+
svc_seq_show(seq, &nn->nfsd_svcstats);
6056

6157
#ifdef CONFIG_NFSD_V4
6258
/* Show count for individual nfsv4 operations */
@@ -121,7 +117,9 @@ void nfsd_stat_counters_destroy(struct nfsd_net *nn)
121117

122118
void nfsd_proc_stat_init(struct net *net)
123119
{
124-
svc_proc_register(net, &nfsd_svcstats, &nfsd_proc_ops);
120+
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
121+
122+
svc_proc_register(net, &nn->nfsd_svcstats, &nfsd_proc_ops);
125123
}
126124

127125
void nfsd_proc_stat_shutdown(struct net *net)

fs/nfsd/stats.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#include <uapi/linux/nfsd/stats.h>
1111
#include <linux/percpu_counter.h>
1212

13-
extern struct svc_stat nfsd_svcstats;
14-
1513
int nfsd_percpu_counters_init(struct percpu_counter *counters, int num);
1614
void nfsd_percpu_counters_reset(struct percpu_counter *counters, int num);
1715
void nfsd_percpu_counters_destroy(struct percpu_counter *counters, int num);

0 commit comments

Comments
 (0)