Merge tag 'nfsd-6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux
[sfrench/cifs-2.6.git] / fs / nfsd / stats.c
index 12d79f5d4eb1acafd5ea50c0f39b3d605dcc8339..be52fb1e928ed62d4ccfd680f19149faa62f0880 100644 (file)
 
 #include "nfsd.h"
 
-struct nfsd_stats      nfsdstats;
-struct svc_stat                nfsd_svcstats = {
-       .program        = &nfsd_program,
-};
-
 static int nfsd_show(struct seq_file *seq, void *v)
 {
+       struct net *net = pde_data(file_inode(seq->file));
+       struct nfsd_net *nn = net_generic(net, nfsd_net_id);
        int i;
 
        seq_printf(seq, "rc %lld %lld %lld\nfh %lld 0 0 0 0\nio %lld %lld\n",
-                  percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_RC_HITS]),
-                  percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_RC_MISSES]),
-                  percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_RC_NOCACHE]),
-                  percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_FH_STALE]),
-                  percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_IO_READ]),
-                  percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_IO_WRITE]));
+                  percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_HITS]),
+                  percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_MISSES]),
+                  percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_NOCACHE]),
+                  percpu_counter_sum_positive(&nn->counter[NFSD_STATS_FH_STALE]),
+                  percpu_counter_sum_positive(&nn->counter[NFSD_STATS_IO_READ]),
+                  percpu_counter_sum_positive(&nn->counter[NFSD_STATS_IO_WRITE]));
 
        /* thread usage: */
-       seq_printf(seq, "th %u 0", atomic_read(&nfsdstats.th_cnt));
+       seq_printf(seq, "th %u 0", atomic_read(&nfsd_th_cnt));
 
        /* deprecated thread usage histogram stats */
        for (i = 0; i < 10; i++)
@@ -55,7 +52,7 @@ static int nfsd_show(struct seq_file *seq, void *v)
        seq_puts(seq, "\nra 0 0 0 0 0 0 0 0 0 0 0 0\n");
 
        /* show my rpc info */
-       svc_seq_show(seq, &nfsd_svcstats);
+       svc_seq_show(seq, &nn->nfsd_svcstats);
 
 #ifdef CONFIG_NFSD_V4
        /* Show count for individual nfsv4 operations */
@@ -63,10 +60,10 @@ static int nfsd_show(struct seq_file *seq, void *v)
        seq_printf(seq, "proc4ops %u", LAST_NFS4_OP + 1);
        for (i = 0; i <= LAST_NFS4_OP; i++) {
                seq_printf(seq, " %lld",
-                          percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_NFS4_OP(i)]));
+                          percpu_counter_sum_positive(&nn->counter[NFSD_STATS_NFS4_OP(i)]));
        }
        seq_printf(seq, "\nwdeleg_getattr %lld",
-               percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_WDELEG_GETATTR]));
+               percpu_counter_sum_positive(&nn->counter[NFSD_STATS_WDELEG_GETATTR]));
 
        seq_putc(seq, '\n');
 #endif
@@ -108,31 +105,24 @@ void nfsd_percpu_counters_destroy(struct percpu_counter counters[], int num)
                percpu_counter_destroy(&counters[i]);
 }
 
-static int nfsd_stat_counters_init(void)
+int nfsd_stat_counters_init(struct nfsd_net *nn)
 {
-       return nfsd_percpu_counters_init(nfsdstats.counter, NFSD_STATS_COUNTERS_NUM);
+       return nfsd_percpu_counters_init(nn->counter, NFSD_STATS_COUNTERS_NUM);
 }
 
-static void nfsd_stat_counters_destroy(void)
+void nfsd_stat_counters_destroy(struct nfsd_net *nn)
 {
-       nfsd_percpu_counters_destroy(nfsdstats.counter, NFSD_STATS_COUNTERS_NUM);
+       nfsd_percpu_counters_destroy(nn->counter, NFSD_STATS_COUNTERS_NUM);
 }
 
-int nfsd_stat_init(void)
+void nfsd_proc_stat_init(struct net *net)
 {
-       int err;
-
-       err = nfsd_stat_counters_init();
-       if (err)
-               return err;
+       struct nfsd_net *nn = net_generic(net, nfsd_net_id);
 
-       svc_proc_register(&init_net, &nfsd_svcstats, &nfsd_proc_ops);
-
-       return 0;
+       svc_proc_register(net, &nn->nfsd_svcstats, &nfsd_proc_ops);
 }
 
-void nfsd_stat_shutdown(void)
+void nfsd_proc_stat_shutdown(struct net *net)
 {
-       nfsd_stat_counters_destroy();
-       svc_proc_unregister(&init_net, "nfsd");
+       svc_proc_unregister(net, "nfsd");
 }