Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 9eae190

Browse files
josefbacikgregkh
authored andcommitted
nfsd: make svc_stat per-network namespace instead of global
[ Upstream commit 16fb980 ] 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 <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9ae63aa commit 9eae190

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
@@ -184,6 +185,9 @@ struct nfsd_net {
184185
/* Per-netns stats counters */
185186
struct percpu_counter counter[NFSD_STATS_COUNTERS_NUM];
186187

188+
/* sunrpc svc stats */
189+
struct svc_stat nfsd_svcstats;
190+
187191
/* longest hash chain seen */
188192
unsigned int longest_chain;
189193

fs/nfsd/nfsctl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,8 @@ static __net_init int nfsd_net_init(struct net *net)
15271527
retval = nfsd_stat_counters_init(nn);
15281528
if (retval)
15291529
goto out_repcache_error;
1530+
memset(&nn->nfsd_svcstats, 0, sizeof(nn->nfsd_svcstats));
1531+
nn->nfsd_svcstats.program = &nfsd_program;
15301532
nn->nfsd_versions = NULL;
15311533
nn->nfsd4_minorversions = NULL;
15321534
nfsd4_init_leases_net(nn);

fs/nfsd/nfssvc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ int nfsd_create_serv(struct net *net)
670670
if (nfsd_max_blksize == 0)
671671
nfsd_max_blksize = nfsd_get_default_max_blksize();
672672
nfsd_reset_versions(nn);
673-
serv = svc_create_pooled(&nfsd_program, &nfsd_svcstats,
673+
serv = svc_create_pooled(&nfsd_program, &nn->nfsd_svcstats,
674674
nfsd_max_blksize, nfsd);
675675
if (serv == NULL)
676676
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)