Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sunrpc: move pc_count out of struct svc_procinfo

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>

+28 -7
+6
fs/lockd/svc.c
··· 739 739 /* 740 740 * Define NLM program and procedures 741 741 */ 742 + static unsigned int nlmsvc_version1_count[17]; 742 743 static struct svc_version nlmsvc_version1 = { 743 744 .vs_vers = 1, 744 745 .vs_nproc = 17, 745 746 .vs_proc = nlmsvc_procedures, 747 + .vs_count = nlmsvc_version1_count, 746 748 .vs_xdrsize = NLMSVC_XDRSIZE, 747 749 }; 750 + static unsigned int nlmsvc_version3_count[24]; 748 751 static struct svc_version nlmsvc_version3 = { 749 752 .vs_vers = 3, 750 753 .vs_nproc = 24, 751 754 .vs_proc = nlmsvc_procedures, 755 + .vs_count = nlmsvc_version3_count, 752 756 .vs_xdrsize = NLMSVC_XDRSIZE, 753 757 }; 754 758 #ifdef CONFIG_LOCKD_V4 759 + static unsigned int nlmsvc_version4_count[24]; 755 760 static struct svc_version nlmsvc_version4 = { 756 761 .vs_vers = 4, 757 762 .vs_nproc = 24, 758 763 .vs_proc = nlmsvc_procedures4, 764 + .vs_count = nlmsvc_version4_count, 759 765 .vs_xdrsize = NLMSVC_XDRSIZE, 760 766 }; 761 767 #endif
+4
fs/nfs/callback_xdr.c
··· 1011 1011 } 1012 1012 }; 1013 1013 1014 + static unsigned int nfs4_callback_count1[ARRAY_SIZE(nfs4_callback_procedures1)]; 1014 1015 struct svc_version nfs4_callback_version1 = { 1015 1016 .vs_vers = 1, 1016 1017 .vs_nproc = ARRAY_SIZE(nfs4_callback_procedures1), 1017 1018 .vs_proc = nfs4_callback_procedures1, 1019 + .vs_count = nfs4_callback_count1, 1018 1020 .vs_xdrsize = NFS4_CALLBACK_XDRSIZE, 1019 1021 .vs_dispatch = NULL, 1020 1022 .vs_hidden = true, 1021 1023 .vs_need_cong_ctrl = true, 1022 1024 }; 1023 1025 1026 + static unsigned int nfs4_callback_count4[ARRAY_SIZE(nfs4_callback_procedures1)]; 1024 1027 struct svc_version nfs4_callback_version4 = { 1025 1028 .vs_vers = 4, 1026 1029 .vs_nproc = ARRAY_SIZE(nfs4_callback_procedures1), 1027 1030 .vs_proc = nfs4_callback_procedures1, 1031 + .vs_count = nfs4_callback_count4, 1028 1032 .vs_xdrsize = NFS4_CALLBACK_XDRSIZE, 1029 1033 .vs_dispatch = NULL, 1030 1034 .vs_hidden = true,
+2
fs/nfsd/nfs2acl.c
··· 378 378 PROC(access, access, access, access, RC_NOCACHE, ST+AT+1), 379 379 }; 380 380 381 + static unsigned int nfsd_acl_count2[ARRAY_SIZE(nfsd_acl_procedures2)]; 381 382 struct svc_version nfsd_acl_version2 = { 382 383 .vs_vers = 2, 383 384 .vs_nproc = 5, 384 385 .vs_proc = nfsd_acl_procedures2, 386 + .vs_count = nfsd_acl_count2, 385 387 .vs_dispatch = nfsd_dispatch, 386 388 .vs_xdrsize = NFS3_SVC_XDRSIZE, 387 389 };
+2
fs/nfsd/nfs3acl.c
··· 263 263 PROC(setacl, setacl, setacl, fhandle, RC_NOCACHE, ST+pAT), 264 264 }; 265 265 266 + static unsigned int nfsd_acl_count3[ARRAY_SIZE(nfsd_acl_procedures3)]; 266 267 struct svc_version nfsd_acl_version3 = { 267 268 .vs_vers = 3, 268 269 .vs_nproc = 3, 269 270 .vs_proc = nfsd_acl_procedures3, 271 + .vs_count = nfsd_acl_count3, 270 272 .vs_dispatch = nfsd_dispatch, 271 273 .vs_xdrsize = NFS3_SVC_XDRSIZE, 272 274 };
+2
fs/nfsd/nfs3proc.c
··· 890 890 }, 891 891 }; 892 892 893 + static unsigned int nfsd_count3[ARRAY_SIZE(nfsd_procedures3)]; 893 894 struct svc_version nfsd_version3 = { 894 895 .vs_vers = 3, 895 896 .vs_nproc = 22, 896 897 .vs_proc = nfsd_procedures3, 898 + .vs_count = nfsd_count3, 897 899 .vs_dispatch = nfsd_dispatch, 898 900 .vs_xdrsize = NFS3_SVC_XDRSIZE, 899 901 };
+2
fs/nfsd/nfs4proc.c
··· 2554 2554 }, 2555 2555 }; 2556 2556 2557 + static unsigned int nfsd_count3[ARRAY_SIZE(nfsd_procedures4)]; 2557 2558 struct svc_version nfsd_version4 = { 2558 2559 .vs_vers = 4, 2559 2560 .vs_nproc = 2, 2560 2561 .vs_proc = nfsd_procedures4, 2562 + .vs_count = nfsd_count3, 2561 2563 .vs_dispatch = nfsd_dispatch, 2562 2564 .vs_xdrsize = NFS4_SVC_XDRSIZE, 2563 2565 .vs_rpcb_optnl = true,
+2
fs/nfsd/nfsproc.c
··· 743 743 }; 744 744 745 745 746 + static unsigned int nfsd_count2[ARRAY_SIZE(nfsd_procedures2)]; 746 747 struct svc_version nfsd_version2 = { 747 748 .vs_vers = 2, 748 749 .vs_nproc = 18, 749 750 .vs_proc = nfsd_procedures2, 751 + .vs_count = nfsd_count2, 750 752 .vs_dispatch = nfsd_dispatch, 751 753 .vs_xdrsize = NFS2_SVC_XDRSIZE, 752 754 };
+1 -1
include/linux/sunrpc/svc.h
··· 397 397 u32 vs_vers; /* version number */ 398 398 u32 vs_nproc; /* number of procedures */ 399 399 struct svc_procedure * vs_proc; /* per-procedure info */ 400 + unsigned int *vs_count; /* call counts */ 400 401 u32 vs_xdrsize; /* xdrsize needed for this version */ 401 402 402 403 /* Don't register with rpcbind */ ··· 430 429 void (*pc_release)(struct svc_rqst *); 431 430 unsigned int pc_argsize; /* argument struct size */ 432 431 unsigned int pc_ressize; /* result struct size */ 433 - unsigned int pc_count; /* call count */ 434 432 unsigned int pc_cachetype; /* cache info (NFS) */ 435 433 unsigned int pc_xdrressize; /* maximum size of XDR reply */ 436 434 };
+6 -5
net/sunrpc/stats.c
··· 77 77 /* 78 78 * Get RPC server stats 79 79 */ 80 - void svc_seq_show(struct seq_file *seq, const struct svc_stat *statp) { 80 + void svc_seq_show(struct seq_file *seq, const struct svc_stat *statp) 81 + { 81 82 const struct svc_program *prog = statp->program; 82 - const struct svc_procedure *proc; 83 83 const struct svc_version *vers; 84 84 unsigned int i, j; 85 85 ··· 98 98 statp->rpcbadclnt); 99 99 100 100 for (i = 0; i < prog->pg_nvers; i++) { 101 - if (!(vers = prog->pg_vers[i]) || !(proc = vers->vs_proc)) 101 + vers = prog->pg_vers[i]; 102 + if (!vers) 102 103 continue; 103 104 seq_printf(seq, "proc%d %u", i, vers->vs_nproc); 104 - for (j = 0; j < vers->vs_nproc; j++, proc++) 105 - seq_printf(seq, " %u", proc->pc_count); 105 + for (j = 0; j < vers->vs_nproc; j++) 106 + seq_printf(seq, " %u", vers->vs_count[j]); 106 107 seq_putc(seq, '\n'); 107 108 } 108 109 }
+1 -1
net/sunrpc/svc.c
··· 1261 1261 svc_putnl(resv, RPC_SUCCESS); 1262 1262 1263 1263 /* Bump per-procedure stats counter */ 1264 - procp->pc_count++; 1264 + versp->vs_count[proc]++; 1265 1265 1266 1266 /* Initialize storage for argp and resp */ 1267 1267 memset(rqstp->rq_argp, 0, procp->pc_argsize);