Skip to content

Commit 1c5876d

Browse files
author
Christoph Hellwig
committed
sunrpc: move p_count out of struct rpc_procinfo
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 <[email protected]>
1 parent cdfa31e commit 1c5876d

File tree

13 files changed

+44
-15
lines changed

13 files changed

+44
-15
lines changed

fs/lockd/clnt4xdr.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,10 @@ static struct rpc_procinfo nlm4_procedures[] = {
602602
PROC(GRANTED_RES, res, norep),
603603
};
604604

605+
static unsigned int nlm_version4_counts[ARRAY_SIZE(nlm4_procedures)];
605606
const struct rpc_version nlm_version4 = {
606607
.number = 4,
607608
.nrprocs = ARRAY_SIZE(nlm4_procedures),
608609
.procs = nlm4_procedures,
610+
.counts = nlm_version4_counts,
609611
};

fs/lockd/clntxdr.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,16 +600,20 @@ static struct rpc_procinfo nlm_procedures[] = {
600600
PROC(GRANTED_RES, res, norep),
601601
};
602602

603+
static unsigned int nlm_version1_counts[ARRAY_SIZE(nlm_procedures)];
603604
static const struct rpc_version nlm_version1 = {
604605
.number = 1,
605606
.nrprocs = ARRAY_SIZE(nlm_procedures),
606607
.procs = nlm_procedures,
608+
.counts = nlm_version1_counts,
607609
};
608610

611+
static unsigned int nlm_version3_counts[ARRAY_SIZE(nlm_procedures)];
609612
static const struct rpc_version nlm_version3 = {
610613
.number = 3,
611614
.nrprocs = ARRAY_SIZE(nlm_procedures),
612615
.procs = nlm_procedures,
616+
.counts = nlm_version3_counts,
613617
};
614618

615619
static const struct rpc_version *nlm_versions[] = {

fs/lockd/mon.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,12 @@ static struct rpc_procinfo nsm_procedures[] = {
552552
},
553553
};
554554

555+
static unsigned int nsm_version1_counts[ARRAY_SIZE(nsm_procedures)];
555556
static const struct rpc_version nsm_version1 = {
556557
.number = 1,
557558
.nrprocs = ARRAY_SIZE(nsm_procedures),
558-
.procs = nsm_procedures
559+
.procs = nsm_procedures,
560+
.counts = nsm_version1_counts,
559561
};
560562

561563
static const struct rpc_version *nsm_version[] = {

fs/nfs/mount_clnt.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,17 +504,20 @@ static struct rpc_procinfo mnt3_procedures[] = {
504504
},
505505
};
506506

507-
507+
static unsigned int mnt_counts[ARRAY_SIZE(mnt_procedures)];
508508
static const struct rpc_version mnt_version1 = {
509509
.number = 1,
510510
.nrprocs = ARRAY_SIZE(mnt_procedures),
511511
.procs = mnt_procedures,
512+
.counts = mnt_counts,
512513
};
513514

515+
static unsigned int mnt3_counts[ARRAY_SIZE(mnt_procedures)];
514516
static const struct rpc_version mnt_version3 = {
515517
.number = 3,
516518
.nrprocs = ARRAY_SIZE(mnt3_procedures),
517519
.procs = mnt3_procedures,
520+
.counts = mnt3_counts,
518521
};
519522

520523
static const struct rpc_version *mnt_version[] = {

fs/nfs/nfs2xdr.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1170,8 +1170,10 @@ struct rpc_procinfo nfs_procedures[] = {
11701170
PROC(STATFS, fhandle, statfsres, 0),
11711171
};
11721172

1173+
static unsigned int nfs_version2_counts[ARRAY_SIZE(nfs_procedures)];
11731174
const struct rpc_version nfs_version2 = {
11741175
.number = 2,
11751176
.nrprocs = ARRAY_SIZE(nfs_procedures),
1176-
.procs = nfs_procedures
1177+
.procs = nfs_procedures,
1178+
.counts = nfs_version2_counts,
11771179
};

fs/nfs/nfs3xdr.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2578,10 +2578,12 @@ struct rpc_procinfo nfs3_procedures[] = {
25782578
PROC(COMMIT, commit, commit, 5),
25792579
};
25802580

2581+
static unsigned int nfs_version3_counts[ARRAY_SIZE(nfs3_procedures)];
25812582
const struct rpc_version nfs_version3 = {
25822583
.number = 3,
25832584
.nrprocs = ARRAY_SIZE(nfs3_procedures),
2584-
.procs = nfs3_procedures
2585+
.procs = nfs3_procedures,
2586+
.counts = nfs_version3_counts,
25852587
};
25862588

25872589
#ifdef CONFIG_NFS_V3_ACL
@@ -2606,10 +2608,12 @@ static struct rpc_procinfo nfs3_acl_procedures[] = {
26062608
},
26072609
};
26082610

2611+
static unsigned int nfs3_acl_counts[ARRAY_SIZE(nfs3_acl_procedures)];
26092612
const struct rpc_version nfsacl_version3 = {
26102613
.number = 3,
26112614
.nrprocs = sizeof(nfs3_acl_procedures)/
26122615
sizeof(nfs3_acl_procedures[0]),
26132616
.procs = nfs3_acl_procedures,
2617+
.counts = nfs3_acl_counts,
26142618
};
26152619
#endif /* CONFIG_NFS_V3_ACL */

fs/nfs/nfs4xdr.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7661,10 +7661,12 @@ struct rpc_procinfo nfs4_procedures[] = {
76617661
#endif /* CONFIG_NFS_V4_2 */
76627662
};
76637663

7664+
static unsigned int nfs_version4_counts[ARRAY_SIZE(nfs4_procedures)];
76647665
const struct rpc_version nfs_version4 = {
76657666
.number = 4,
76667667
.nrprocs = ARRAY_SIZE(nfs4_procedures),
7667-
.procs = nfs4_procedures
7668+
.procs = nfs4_procedures,
7669+
.counts = nfs_version4_counts,
76687670
};
76697671

76707672
/*

fs/nfsd/nfs4callback.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ static struct rpc_procinfo nfs4_cb_procedures[] = {
705705
PROC(CB_NOTIFY_LOCK, COMPOUND, cb_notify_lock, cb_notify_lock),
706706
};
707707

708+
static unsigned int nfs4_cb_counts[ARRAY_SIZE(nfs4_cb_procedures)];
708709
static struct rpc_version nfs_cb_version4 = {
709710
/*
710711
* Note on the callback rpc program version number: despite language in rfc
@@ -715,7 +716,8 @@ static struct rpc_version nfs_cb_version4 = {
715716
*/
716717
.number = 1,
717718
.nrprocs = ARRAY_SIZE(nfs4_cb_procedures),
718-
.procs = nfs4_cb_procedures
719+
.procs = nfs4_cb_procedures,
720+
.counts = nfs4_cb_counts,
719721
};
720722

721723
static const struct rpc_version *nfs_cb_version[] = {

include/linux/sunrpc/clnt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ struct rpc_version {
8888
u32 number; /* version number */
8989
unsigned int nrprocs; /* number of procs */
9090
struct rpc_procinfo * procs; /* procedure array */
91+
unsigned int *counts; /* call counts */
9192
};
9293

9394
/*
@@ -99,7 +100,6 @@ struct rpc_procinfo {
99100
kxdrdproc_t p_decode; /* XDR decode function */
100101
unsigned int p_arglen; /* argument hdr length (u32) */
101102
unsigned int p_replen; /* reply hdr length (u32) */
102-
unsigned int p_count; /* call count */
103103
unsigned int p_timer; /* Which RTT timer to use */
104104
u32 p_statidx; /* Which procedure to account */
105105
const char * p_name; /* name of procedure */

net/sunrpc/auth_gss/gss_rpc_upcall.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,12 @@ void gssp_free_upcall_data(struct gssp_upcall_data *data)
364364
/*
365365
* Initialization stuff
366366
*/
367-
367+
static unsigned int gssp_version1_counts[ARRAY_SIZE(gssp_procedures)];
368368
static const struct rpc_version gssp_version1 = {
369369
.number = GSSPROXY_VERS_1,
370370
.nrprocs = ARRAY_SIZE(gssp_procedures),
371371
.procs = gssp_procedures,
372+
.counts = gssp_version1_counts,
372373
};
373374

374375
static const struct rpc_version *gssp_version[] = {

0 commit comments

Comments
 (0)