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

This patch moves it into out out struct rpc_procinfo, and into a
separate writable array that is pointed to by struct rpc_version and
indexed by p_statidx.

Signed-off-by: Christoph Hellwig <hch@lst.de>
13 files changed:
fs/lockd/clnt4xdr.c
fs/lockd/clntxdr.c
fs/lockd/mon.c
fs/nfs/mount_clnt.c
fs/nfs/nfs2xdr.c
fs/nfs/nfs3xdr.c
fs/nfs/nfs4xdr.c
fs/nfsd/nfs4callback.c
include/linux/sunrpc/clnt.h
net/sunrpc/auth_gss/gss_rpc_upcall.c
net/sunrpc/clnt.c
net/sunrpc/rpcb_clnt.c
net/sunrpc/stats.c

index f0ab7a99dd236b862b9aafedbc570f04aebacdb1..7c255d1d7c644da918fa8adc442273203d8c34da 100644 (file)
@@ -602,8 +602,10 @@ static struct rpc_procinfo nlm4_procedures[] = {
        PROC(GRANTED_RES,       res,            norep),
 };
 
+static unsigned int nlm_version4_counts[ARRAY_SIZE(nlm4_procedures)];
 const struct rpc_version nlm_version4 = {
        .number         = 4,
        .nrprocs        = ARRAY_SIZE(nlm4_procedures),
        .procs          = nlm4_procedures,
+       .counts         = nlm_version4_counts,
 };
index bd8a976785aead9708d785501bd4e88f2f410936..39500c5743a56ce10bee2627db2dcb8497e048de 100644 (file)
@@ -600,16 +600,20 @@ static struct rpc_procinfo        nlm_procedures[] = {
        PROC(GRANTED_RES,       res,            norep),
 };
 
+static unsigned int nlm_version1_counts[ARRAY_SIZE(nlm_procedures)];
 static const struct rpc_version        nlm_version1 = {
        .number         = 1,
        .nrprocs        = ARRAY_SIZE(nlm_procedures),
        .procs          = nlm_procedures,
+       .counts         = nlm_version1_counts,
 };
 
+static unsigned int nlm_version3_counts[ARRAY_SIZE(nlm_procedures)];
 static const struct rpc_version        nlm_version3 = {
        .number         = 3,
        .nrprocs        = ARRAY_SIZE(nlm_procedures),
        .procs          = nlm_procedures,
+       .counts         = nlm_version3_counts,
 };
 
 static const struct rpc_version        *nlm_versions[] = {
index 62424e929a7fd37e6666b1629d3199141f5f8647..fe4ec82764fe1f7d2fb2169cca220683b0ac4a59 100644 (file)
@@ -552,10 +552,12 @@ static struct rpc_procinfo        nsm_procedures[] = {
        },
 };
 
+static unsigned int nsm_version1_counts[ARRAY_SIZE(nsm_procedures)];
 static const struct rpc_version nsm_version1 = {
        .number         = 1,
        .nrprocs        = ARRAY_SIZE(nsm_procedures),
-       .procs          = nsm_procedures
+       .procs          = nsm_procedures,
+       .counts         = nsm_version1_counts,
 };
 
 static const struct rpc_version *nsm_version[] = {
index 806657d650745ebbb5c2af6877c7318489c2458f..d25914aa8bf9171f5e777207e3f3ca3bec9ee3d2 100644 (file)
@@ -504,17 +504,20 @@ static struct rpc_procinfo mnt3_procedures[] = {
        },
 };
 
-
+static unsigned int mnt_counts[ARRAY_SIZE(mnt_procedures)];
 static const struct rpc_version mnt_version1 = {
        .number         = 1,
        .nrprocs        = ARRAY_SIZE(mnt_procedures),
        .procs          = mnt_procedures,
+       .counts         = mnt_counts,
 };
 
+static unsigned int mnt3_counts[ARRAY_SIZE(mnt_procedures)];
 static const struct rpc_version mnt_version3 = {
        .number         = 3,
        .nrprocs        = ARRAY_SIZE(mnt3_procedures),
        .procs          = mnt3_procedures,
+       .counts         = mnt3_counts,
 };
 
 static const struct rpc_version *mnt_version[] = {
index a299648ea3215286183a517ea800a08a5a9f02da..16b4526299c11405f1c18967580a4bd4afd94899 100644 (file)
@@ -1170,8 +1170,10 @@ struct rpc_procinfo      nfs_procedures[] = {
        PROC(STATFS,    fhandle,        statfsres,      0),
 };
 
+static unsigned int nfs_version2_counts[ARRAY_SIZE(nfs_procedures)];
 const struct rpc_version nfs_version2 = {
        .number                 = 2,
        .nrprocs                = ARRAY_SIZE(nfs_procedures),
-       .procs                  = nfs_procedures
+       .procs                  = nfs_procedures,
+       .counts                 = nfs_version2_counts,
 };
index cc272eb8be3e05cfe0ed15cf5e6de462d8011b5f..a017ec5c7a9d6f3b85cdc53992050d13eadc262b 100644 (file)
@@ -2578,10 +2578,12 @@ struct rpc_procinfo     nfs3_procedures[] = {
        PROC(COMMIT,            commit,         commit,         5),
 };
 
+static unsigned int nfs_version3_counts[ARRAY_SIZE(nfs3_procedures)];
 const struct rpc_version nfs_version3 = {
        .number                 = 3,
        .nrprocs                = ARRAY_SIZE(nfs3_procedures),
-       .procs                  = nfs3_procedures
+       .procs                  = nfs3_procedures,
+       .counts                 = nfs_version3_counts,
 };
 
 #ifdef CONFIG_NFS_V3_ACL
@@ -2606,10 +2608,12 @@ static struct rpc_procinfo      nfs3_acl_procedures[] = {
        },
 };
 
+static unsigned int nfs3_acl_counts[ARRAY_SIZE(nfs3_acl_procedures)];
 const struct rpc_version nfsacl_version3 = {
        .number                 = 3,
        .nrprocs                = sizeof(nfs3_acl_procedures)/
                                  sizeof(nfs3_acl_procedures[0]),
        .procs                  = nfs3_acl_procedures,
+       .counts                 = nfs3_acl_counts,
 };
 #endif  /* CONFIG_NFS_V3_ACL */
index 797f3ce7528612eeee9a34a524d30acd24973aa0..40cf5529e65ffa7d7696d70766bc316bc3a240d6 100644 (file)
@@ -7661,10 +7661,12 @@ struct rpc_procinfo     nfs4_procedures[] = {
 #endif /* CONFIG_NFS_V4_2 */
 };
 
+static unsigned int nfs_version4_counts[ARRAY_SIZE(nfs4_procedures)];
 const struct rpc_version nfs_version4 = {
        .number                 = 4,
        .nrprocs                = ARRAY_SIZE(nfs4_procedures),
-       .procs                  = nfs4_procedures
+       .procs                  = nfs4_procedures,
+       .counts                 = nfs_version4_counts,
 };
 
 /*
index a2bedbd05b2bf76d97301e06e776cae0d85fb91f..afa961fe073c37ff7a6e6c1dd5f7113cb4c2a88e 100644 (file)
@@ -705,6 +705,7 @@ static struct rpc_procinfo nfs4_cb_procedures[] = {
        PROC(CB_NOTIFY_LOCK,    COMPOUND,       cb_notify_lock, cb_notify_lock),
 };
 
+static unsigned int nfs4_cb_counts[ARRAY_SIZE(nfs4_cb_procedures)];
 static struct rpc_version nfs_cb_version4 = {
 /*
  * Note on the callback rpc program version number: despite language in rfc
@@ -715,7 +716,8 @@ static struct rpc_version nfs_cb_version4 = {
  */
        .number                 = 1,
        .nrprocs                = ARRAY_SIZE(nfs4_cb_procedures),
-       .procs                  = nfs4_cb_procedures
+       .procs                  = nfs4_cb_procedures,
+       .counts                 = nfs4_cb_counts,
 };
 
 static const struct rpc_version *nfs_cb_version[] = {
index 6095ecba0ddee9193ae1a96ecf21bf903584c52b..c75ba37151fee5713958d950fa87d155e26f4d41 100644 (file)
@@ -88,6 +88,7 @@ struct rpc_version {
        u32                     number;         /* version number */
        unsigned int            nrprocs;        /* number of procs */
        struct rpc_procinfo *   procs;          /* procedure array */
+       unsigned int            *counts;        /* call counts */
 };
 
 /*
@@ -99,7 +100,6 @@ struct rpc_procinfo {
        kxdrdproc_t             p_decode;       /* XDR decode function */
        unsigned int            p_arglen;       /* argument hdr length (u32) */
        unsigned int            p_replen;       /* reply hdr length (u32) */
-       unsigned int            p_count;        /* call count */
        unsigned int            p_timer;        /* Which RTT timer to use */
        u32                     p_statidx;      /* Which procedure to account */
        const char *            p_name;         /* name of procedure */
index a80b8e6074781036af341d8381b7019ec5cd25c5..f8729b647605201d9161bfc2fe557875d95cb7aa 100644 (file)
@@ -364,11 +364,12 @@ void gssp_free_upcall_data(struct gssp_upcall_data *data)
 /*
  * Initialization stuff
  */
-
+static unsigned int gssp_version1_counts[ARRAY_SIZE(gssp_procedures)];
 static const struct rpc_version gssp_version1 = {
        .number         = GSSPROXY_VERS_1,
        .nrprocs        = ARRAY_SIZE(gssp_procedures),
        .procs          = gssp_procedures,
+       .counts         = gssp_version1_counts,
 };
 
 static const struct rpc_version *gssp_version[] = {
index 964d5c4a1b6096f831f53a044125b8449ee4b42c..f2d1f971247b132dc02baba1a242b93d6ce4c9d9 100644 (file)
@@ -1517,14 +1517,16 @@ static void
 call_start(struct rpc_task *task)
 {
        struct rpc_clnt *clnt = task->tk_client;
+       int idx = task->tk_msg.rpc_proc->p_statidx;
 
        dprintk("RPC: %5u call_start %s%d proc %s (%s)\n", task->tk_pid,
                        clnt->cl_program->name, clnt->cl_vers,
                        rpc_proc_name(task),
                        (RPC_IS_ASYNC(task) ? "async" : "sync"));
 
-       /* Increment call count */
-       task->tk_msg.rpc_proc->p_count++;
+       /* Increment call count (version might not be valid for ping) */
+       if (clnt->cl_program->version[clnt->cl_vers])
+               clnt->cl_program->version[clnt->cl_vers]->counts[idx]++;
        clnt->cl_stats->rpccnt++;
        task->tk_action = call_reserve;
 }
index f67b9e2897b497278b919ec1f0b270243fe6d006..9d47b9d3bbeed2b3e00c6c0f0a43bbfef68af99f 100644 (file)
@@ -1117,22 +1117,28 @@ static const struct rpcb_info rpcb_next_version6[] = {
        },
 };
 
+static unsigned int rpcb_version2_counts[ARRAY_SIZE(rpcb_procedures2)];
 static const struct rpc_version rpcb_version2 = {
        .number         = RPCBVERS_2,
        .nrprocs        = ARRAY_SIZE(rpcb_procedures2),
-       .procs          = rpcb_procedures2
+       .procs          = rpcb_procedures2,
+       .counts         = rpcb_version2_counts,
 };
 
+static unsigned int rpcb_version3_counts[ARRAY_SIZE(rpcb_procedures3)];
 static const struct rpc_version rpcb_version3 = {
        .number         = RPCBVERS_3,
        .nrprocs        = ARRAY_SIZE(rpcb_procedures3),
-       .procs          = rpcb_procedures3
+       .procs          = rpcb_procedures3,
+       .counts         = rpcb_version3_counts,
 };
 
+static unsigned int rpcb_version4_counts[ARRAY_SIZE(rpcb_procedures4)];
 static const struct rpc_version rpcb_version4 = {
        .number         = RPCBVERS_4,
        .nrprocs        = ARRAY_SIZE(rpcb_procedures4),
-       .procs          = rpcb_procedures4
+       .procs          = rpcb_procedures4,
+       .counts         = rpcb_version4_counts,
 };
 
 static const struct rpc_version *rpcb_version[] = {
index caeb01ad2b5aeb4ecc54cf9a15fe0a495b45c6d8..91c84d18bf9a5cf5d106e99a4b01ca45b26155fd 100644 (file)
@@ -55,8 +55,7 @@ static int rpc_proc_show(struct seq_file *seq, void *v) {
                seq_printf(seq, "proc%u %u",
                                        vers->number, vers->nrprocs);
                for (j = 0; j < vers->nrprocs; j++)
-                       seq_printf(seq, " %u",
-                                       vers->procs[j].p_count);
+                       seq_printf(seq, " %u", vers->counts[j]);
                seq_putc(seq, '\n');
        }
        return 0;