Skip to content

Commit 7fd38af

Browse files
author
Christoph Hellwig
committed
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>
1 parent eb69853 commit 7fd38af

10 files changed

Lines changed: 28 additions & 7 deletions

File tree

‎fs/lockd/svc.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,23 +739,29 @@ module_exit(exit_nlm);
739739
/*
740740
* Define NLM program and procedures
741741
*/
742+
static unsigned int nlmsvc_version1_count[17];
742743
static struct svc_version nlmsvc_version1 = {
743744
.vs_vers = 1,
744745
.vs_nproc = 17,
745746
.vs_proc = nlmsvc_procedures,
747+
.vs_count = nlmsvc_version1_count,
746748
.vs_xdrsize = NLMSVC_XDRSIZE,
747749
};
750+
static unsigned int nlmsvc_version3_count[24];
748751
static struct svc_version nlmsvc_version3 = {
749752
.vs_vers = 3,
750753
.vs_nproc = 24,
751754
.vs_proc = nlmsvc_procedures,
755+
.vs_count = nlmsvc_version3_count,
752756
.vs_xdrsize = NLMSVC_XDRSIZE,
753757
};
754758
#ifdef CONFIG_LOCKD_V4
759+
static unsigned int nlmsvc_version4_count[24];
755760
static struct svc_version nlmsvc_version4 = {
756761
.vs_vers = 4,
757762
.vs_nproc = 24,
758763
.vs_proc = nlmsvc_procedures4,
764+
.vs_count = nlmsvc_version4_count,
759765
.vs_xdrsize = NLMSVC_XDRSIZE,
760766
};
761767
#endif

‎fs/nfs/callback_xdr.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,20 +1011,24 @@ static struct svc_procedure nfs4_callback_procedures1[] = {
10111011
}
10121012
};
10131013

1014+
static unsigned int nfs4_callback_count1[ARRAY_SIZE(nfs4_callback_procedures1)];
10141015
struct svc_version nfs4_callback_version1 = {
10151016
.vs_vers = 1,
10161017
.vs_nproc = ARRAY_SIZE(nfs4_callback_procedures1),
10171018
.vs_proc = nfs4_callback_procedures1,
1019+
.vs_count = nfs4_callback_count1,
10181020
.vs_xdrsize = NFS4_CALLBACK_XDRSIZE,
10191021
.vs_dispatch = NULL,
10201022
.vs_hidden = true,
10211023
.vs_need_cong_ctrl = true,
10221024
};
10231025

1026+
static unsigned int nfs4_callback_count4[ARRAY_SIZE(nfs4_callback_procedures1)];
10241027
struct svc_version nfs4_callback_version4 = {
10251028
.vs_vers = 4,
10261029
.vs_nproc = ARRAY_SIZE(nfs4_callback_procedures1),
10271030
.vs_proc = nfs4_callback_procedures1,
1031+
.vs_count = nfs4_callback_count4,
10281032
.vs_xdrsize = NFS4_CALLBACK_XDRSIZE,
10291033
.vs_dispatch = NULL,
10301034
.vs_hidden = true,

‎fs/nfsd/nfs2acl.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,12 @@ static struct svc_procedure nfsd_acl_procedures2[] = {
378378
PROC(access, access, access, access, RC_NOCACHE, ST+AT+1),
379379
};
380380

381+
static unsigned int nfsd_acl_count2[ARRAY_SIZE(nfsd_acl_procedures2)];
381382
struct svc_version nfsd_acl_version2 = {
382383
.vs_vers = 2,
383384
.vs_nproc = 5,
384385
.vs_proc = nfsd_acl_procedures2,
386+
.vs_count = nfsd_acl_count2,
385387
.vs_dispatch = nfsd_dispatch,
386388
.vs_xdrsize = NFS3_SVC_XDRSIZE,
387389
};

‎fs/nfsd/nfs3acl.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,12 @@ static struct svc_procedure nfsd_acl_procedures3[] = {
263263
PROC(setacl, setacl, setacl, fhandle, RC_NOCACHE, ST+pAT),
264264
};
265265

266+
static unsigned int nfsd_acl_count3[ARRAY_SIZE(nfsd_acl_procedures3)];
266267
struct svc_version nfsd_acl_version3 = {
267268
.vs_vers = 3,
268269
.vs_nproc = 3,
269270
.vs_proc = nfsd_acl_procedures3,
271+
.vs_count = nfsd_acl_count3,
270272
.vs_dispatch = nfsd_dispatch,
271273
.vs_xdrsize = NFS3_SVC_XDRSIZE,
272274
};

‎fs/nfsd/nfs3proc.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,10 +890,12 @@ static struct svc_procedure nfsd_procedures3[22] = {
890890
},
891891
};
892892

893+
static unsigned int nfsd_count3[ARRAY_SIZE(nfsd_procedures3)];
893894
struct svc_version nfsd_version3 = {
894895
.vs_vers = 3,
895896
.vs_nproc = 22,
896897
.vs_proc = nfsd_procedures3,
898+
.vs_count = nfsd_count3,
897899
.vs_dispatch = nfsd_dispatch,
898900
.vs_xdrsize = NFS3_SVC_XDRSIZE,
899901
};

‎fs/nfsd/nfs4proc.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2554,10 +2554,12 @@ static struct svc_procedure nfsd_procedures4[2] = {
25542554
},
25552555
};
25562556

2557+
static unsigned int nfsd_count3[ARRAY_SIZE(nfsd_procedures4)];
25572558
struct svc_version nfsd_version4 = {
25582559
.vs_vers = 4,
25592560
.vs_nproc = 2,
25602561
.vs_proc = nfsd_procedures4,
2562+
.vs_count = nfsd_count3,
25612563
.vs_dispatch = nfsd_dispatch,
25622564
.vs_xdrsize = NFS4_SVC_XDRSIZE,
25632565
.vs_rpcb_optnl = true,

‎fs/nfsd/nfsproc.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,10 +743,12 @@ static struct svc_procedure nfsd_procedures2[18] = {
743743
};
744744

745745

746+
static unsigned int nfsd_count2[ARRAY_SIZE(nfsd_procedures2)];
746747
struct svc_version nfsd_version2 = {
747748
.vs_vers = 2,
748749
.vs_nproc = 18,
749750
.vs_proc = nfsd_procedures2,
751+
.vs_count = nfsd_count2,
750752
.vs_dispatch = nfsd_dispatch,
751753
.vs_xdrsize = NFS2_SVC_XDRSIZE,
752754
};

‎include/linux/sunrpc/svc.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ struct svc_version {
397397
u32 vs_vers; /* version number */
398398
u32 vs_nproc; /* number of procedures */
399399
struct svc_procedure * vs_proc; /* per-procedure info */
400+
unsigned int *vs_count; /* call counts */
400401
u32 vs_xdrsize; /* xdrsize needed for this version */
401402

402403
/* Don't register with rpcbind */
@@ -429,7 +430,6 @@ struct svc_procedure {
429430
void (*pc_release)(struct svc_rqst *);
430431
unsigned int pc_argsize; /* argument struct size */
431432
unsigned int pc_ressize; /* result struct size */
432-
unsigned int pc_count; /* call count */
433433
unsigned int pc_cachetype; /* cache info (NFS) */
434434
unsigned int pc_xdrressize; /* maximum size of XDR reply */
435435
};

‎net/sunrpc/stats.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ static const struct file_operations rpc_proc_fops = {
7777
/*
7878
* Get RPC server stats
7979
*/
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+
{
8182
const struct svc_program *prog = statp->program;
82-
const struct svc_procedure *proc;
8383
const struct svc_version *vers;
8484
unsigned int i, j;
8585

@@ -98,11 +98,12 @@ void svc_seq_show(struct seq_file *seq, const struct svc_stat *statp) {
9898
statp->rpcbadclnt);
9999

100100
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)
102103
continue;
103104
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]);
106107
seq_putc(seq, '\n');
107108
}
108109
}

‎net/sunrpc/svc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,7 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
12611261
svc_putnl(resv, RPC_SUCCESS);
12621262

12631263
/* Bump per-procedure stats counter */
1264-
procp->pc_count++;
1264+
versp->vs_count[proc]++;
12651265

12661266
/* Initialize storage for argp and resp */
12671267
memset(rqstp->rq_argp, 0, procp->pc_argsize);

0 commit comments

Comments
 (0)