sunrpc: move pc_count out of struct svc_procinfo
authorChristoph Hellwig <hch@lst.de>
Mon, 8 May 2017 21:40:27 +0000 (23:40 +0200)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Thu, 13 Jul 2017 19:58:02 +0000 (15:58 -0400)
pc_count is the only writeable memeber of struct svc_procinfo, which is
a good candidate to be const-ified as it contains function pointers.

This patch moves it into out out struct svc_procinfo, and into a
separate writable array that is pointed to by struct svc_version.

Signed-off-by: Christoph Hellwig <hch@lst.de>
fs/lockd/svc.c
fs/nfs/callback_xdr.c
fs/nfsd/nfs2acl.c
fs/nfsd/nfs3acl.c
fs/nfsd/nfs3proc.c
fs/nfsd/nfs4proc.c
fs/nfsd/nfsproc.c
include/linux/sunrpc/svc.h
net/sunrpc/stats.c
net/sunrpc/svc.c

index 5d481e8a1b5d0c732207c4a583027ec084d7a0db..cc6abe6280bce7479a144f8619a1489d98d881be 100644 (file)
@@ -739,23 +739,29 @@ module_exit(exit_nlm);
 /*
  * Define NLM program and procedures
  */
+static unsigned int nlmsvc_version1_count[17];
 static struct svc_version      nlmsvc_version1 = {
                .vs_vers        = 1,
                .vs_nproc       = 17,
                .vs_proc        = nlmsvc_procedures,
+               .vs_count       = nlmsvc_version1_count,
                .vs_xdrsize     = NLMSVC_XDRSIZE,
 };
+static unsigned int nlmsvc_version3_count[24];
 static struct svc_version      nlmsvc_version3 = {
                .vs_vers        = 3,
                .vs_nproc       = 24,
                .vs_proc        = nlmsvc_procedures,
+               .vs_count       = nlmsvc_version3_count,
                .vs_xdrsize     = NLMSVC_XDRSIZE,
 };
 #ifdef CONFIG_LOCKD_V4
+static unsigned int nlmsvc_version4_count[24];
 static struct svc_version      nlmsvc_version4 = {
                .vs_vers        = 4,
                .vs_nproc       = 24,
                .vs_proc        = nlmsvc_procedures4,
+               .vs_count       = nlmsvc_version4_count,
                .vs_xdrsize     = NLMSVC_XDRSIZE,
 };
 #endif
index acf75dc63e14e786795892003b8995e0a5549fd7..ecd46b8c098517a83aace2d3556f59477d280af6 100644 (file)
@@ -1011,20 +1011,24 @@ static struct svc_procedure nfs4_callback_procedures1[] = {
        }
 };
 
+static unsigned int nfs4_callback_count1[ARRAY_SIZE(nfs4_callback_procedures1)];
 struct svc_version nfs4_callback_version1 = {
        .vs_vers = 1,
        .vs_nproc = ARRAY_SIZE(nfs4_callback_procedures1),
        .vs_proc = nfs4_callback_procedures1,
+       .vs_count = nfs4_callback_count1,
        .vs_xdrsize = NFS4_CALLBACK_XDRSIZE,
        .vs_dispatch = NULL,
        .vs_hidden = true,
        .vs_need_cong_ctrl = true,
 };
 
+static unsigned int nfs4_callback_count4[ARRAY_SIZE(nfs4_callback_procedures1)];
 struct svc_version nfs4_callback_version4 = {
        .vs_vers = 4,
        .vs_nproc = ARRAY_SIZE(nfs4_callback_procedures1),
        .vs_proc = nfs4_callback_procedures1,
+       .vs_count = nfs4_callback_count4,
        .vs_xdrsize = NFS4_CALLBACK_XDRSIZE,
        .vs_dispatch = NULL,
        .vs_hidden = true,
index fc6b179c8fff787217a8823db4716f79d99d5e5d..026edfe73fd5b132aff70279e89858f4e340c67e 100644 (file)
@@ -378,10 +378,12 @@ static struct svc_procedure               nfsd_acl_procedures2[] = {
   PROC(access, access,         access,         access,   RC_NOCACHE, ST+AT+1),
 };
 
+static unsigned int nfsd_acl_count2[ARRAY_SIZE(nfsd_acl_procedures2)];
 struct svc_version     nfsd_acl_version2 = {
                .vs_vers        = 2,
                .vs_nproc       = 5,
                .vs_proc        = nfsd_acl_procedures2,
+               .vs_count       = nfsd_acl_count2,
                .vs_dispatch    = nfsd_dispatch,
                .vs_xdrsize     = NFS3_SVC_XDRSIZE,
 };
index 9437b758cbfdbb93fa34ad3f0251b727aba7b8b6..73c0970ccefb458d6250054634545924cd86f166 100644 (file)
@@ -263,10 +263,12 @@ static struct svc_procedure               nfsd_acl_procedures3[] = {
   PROC(setacl, setacl,         setacl,         fhandle,  RC_NOCACHE, ST+pAT),
 };
 
+static unsigned int nfsd_acl_count3[ARRAY_SIZE(nfsd_acl_procedures3)];
 struct svc_version     nfsd_acl_version3 = {
                .vs_vers        = 3,
                .vs_nproc       = 3,
                .vs_proc        = nfsd_acl_procedures3,
+               .vs_count       = nfsd_acl_count3,
                .vs_dispatch    = nfsd_dispatch,
                .vs_xdrsize     = NFS3_SVC_XDRSIZE,
 };
index 17c90c41a3a6824ee46b64193c050a84d5fc2ee5..b5823802e2785fa2605fe43cc7b9540a81743cfd 100644 (file)
@@ -890,10 +890,12 @@ static struct svc_procedure               nfsd_procedures3[22] = {
        },
 };
 
+static unsigned int nfsd_count3[ARRAY_SIZE(nfsd_procedures3)];
 struct svc_version     nfsd_version3 = {
                .vs_vers        = 3,
                .vs_nproc       = 22,
                .vs_proc        = nfsd_procedures3,
+               .vs_count       = nfsd_count3,
                .vs_dispatch    = nfsd_dispatch,
                .vs_xdrsize     = NFS3_SVC_XDRSIZE,
 };
index 403c1d14d99af274a8a206cd76416c2b1242e63c..4de6a995072264bab23477d741f750b7edfcef28 100644 (file)
@@ -2553,10 +2553,12 @@ static struct svc_procedure             nfsd_procedures4[2] = {
        },
 };
 
+static unsigned int nfsd_count3[ARRAY_SIZE(nfsd_procedures4)];
 struct svc_version     nfsd_version4 = {
        .vs_vers                = 4,
        .vs_nproc               = 2,
        .vs_proc                = nfsd_procedures4,
+       .vs_count               = nfsd_count3,
        .vs_dispatch            = nfsd_dispatch,
        .vs_xdrsize             = NFS4_SVC_XDRSIZE,
        .vs_rpcb_optnl          = true,
index 0ef88d0e67d9d34c798de8248654439a12515e29..44b157553733754264c1f481b19a2977ef5a8e7a 100644 (file)
@@ -743,10 +743,12 @@ static struct svc_procedure               nfsd_procedures2[18] = {
 };
 
 
+static unsigned int nfsd_count2[ARRAY_SIZE(nfsd_procedures2)];
 struct svc_version     nfsd_version2 = {
                .vs_vers        = 2,
                .vs_nproc       = 18,
                .vs_proc        = nfsd_procedures2,
+               .vs_count       = nfsd_count2,
                .vs_dispatch    = nfsd_dispatch,
                .vs_xdrsize     = NFS2_SVC_XDRSIZE,
 };
index bd9e313c444aff746af7908a03fec3f3ee3b2798..bcd114f038ef185bb62bfa62763020828a74059e 100644 (file)
@@ -398,6 +398,7 @@ struct svc_version {
        u32                     vs_vers;        /* version number */
        u32                     vs_nproc;       /* number of procedures */
        struct svc_procedure *  vs_proc;        /* per-procedure info */
+       unsigned int            *vs_count;      /* call counts */
        u32                     vs_xdrsize;     /* xdrsize needed for this version */
 
        /* Don't register with rpcbind */
@@ -430,7 +431,6 @@ struct svc_procedure {
        void                    (*pc_release)(struct svc_rqst *);
        unsigned int            pc_argsize;     /* argument struct size */
        unsigned int            pc_ressize;     /* result struct size */
-       unsigned int            pc_count;       /* call count */
        unsigned int            pc_cachetype;   /* cache info (NFS) */
        unsigned int            pc_xdrressize;  /* maximum size of XDR reply */
 };
index 8b6c35ae1d571f6f6bf4434f46c3c0f31b6ccce1..1e671333c3d5b5a61be412860a4cfe85db7b66eb 100644 (file)
@@ -77,9 +77,9 @@ static const struct file_operations rpc_proc_fops = {
 /*
  * Get RPC server stats
  */
-void svc_seq_show(struct seq_file *seq, const struct svc_stat *statp) {
+void svc_seq_show(struct seq_file *seq, const struct svc_stat *statp)
+{
        const struct svc_program *prog = statp->program;
-       const struct svc_procedure *proc;
        const struct svc_version *vers;
        unsigned int i, j;
 
@@ -98,11 +98,12 @@ void svc_seq_show(struct seq_file *seq, const struct svc_stat *statp) {
                        statp->rpcbadclnt);
 
        for (i = 0; i < prog->pg_nvers; i++) {
-               if (!(vers = prog->pg_vers[i]) || !(proc = vers->vs_proc))
+               vers = prog->pg_vers[i];
+               if (!vers)
                        continue;
                seq_printf(seq, "proc%d %u", i, vers->vs_nproc);
-               for (j = 0; j < vers->vs_nproc; j++, proc++)
-                       seq_printf(seq, " %u", proc->pc_count);
+               for (j = 0; j < vers->vs_nproc; j++)
+                       seq_printf(seq, " %u", vers->vs_count[j]);
                seq_putc(seq, '\n');
        }
 }
index aa643a29fdc6f3738da98948464ee5d3605d272d..6452592194ac05654b4d78de9e8c5553f47c07e4 100644 (file)
@@ -1261,7 +1261,7 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
        svc_putnl(resv, RPC_SUCCESS);
 
        /* Bump per-procedure stats counter */
-       procp->pc_count++;
+       versp->vs_count[proc]++;
 
        /* Initialize storage for argp and resp */
        memset(rqstp->rq_argp, 0, procp->pc_argsize);