Skip to content

Commit 788f718

Browse files
committed
NFSD: Add common helpers to decode void args and encode void results
Start off the conversion to xdr_stream by de-duplicating the functions that decode void arguments and encode void results. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 5191955 commit 788f718

File tree

13 files changed

+64
-86
lines changed

13 files changed

+64
-86
lines changed

fs/nfsd/nfs2acl.c

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,6 @@ static __be32 nfsacld_proc_access(struct svc_rqst *rqstp)
185185
/*
186186
* XDR decode functions
187187
*/
188-
static int nfsaclsvc_decode_voidarg(struct svc_rqst *rqstp, __be32 *p)
189-
{
190-
return 1;
191-
}
192188

193189
static int nfsaclsvc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p)
194190
{
@@ -255,15 +251,6 @@ static int nfsaclsvc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p)
255251
* XDR encode functions
256252
*/
257253

258-
/*
259-
* There must be an encoding function for void results so svc_process
260-
* will work properly.
261-
*/
262-
static int nfsaclsvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p)
263-
{
264-
return xdr_ressize_check(rqstp, p);
265-
}
266-
267254
/* GETACL */
268255
static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p)
269256
{
@@ -378,10 +365,10 @@ struct nfsd3_voidargs { int dummy; };
378365
static const struct svc_procedure nfsd_acl_procedures2[5] = {
379366
[ACLPROC2_NULL] = {
380367
.pc_func = nfsacld_proc_null,
381-
.pc_decode = nfsaclsvc_decode_voidarg,
382-
.pc_encode = nfsaclsvc_encode_voidres,
383-
.pc_argsize = sizeof(struct nfsd3_voidargs),
384-
.pc_ressize = sizeof(struct nfsd3_voidargs),
368+
.pc_decode = nfssvc_decode_voidarg,
369+
.pc_encode = nfssvc_encode_voidres,
370+
.pc_argsize = sizeof(struct nfsd_voidargs),
371+
.pc_ressize = sizeof(struct nfsd_voidres),
385372
.pc_cachetype = RC_NOCACHE,
386373
.pc_xdrressize = ST,
387374
},

fs/nfsd/nfs3acl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,10 @@ struct nfsd3_voidargs { int dummy; };
245245
static const struct svc_procedure nfsd_acl_procedures3[3] = {
246246
[ACLPROC3_NULL] = {
247247
.pc_func = nfsd3_proc_null,
248-
.pc_decode = nfs3svc_decode_voidarg,
249-
.pc_encode = nfs3svc_encode_voidres,
250-
.pc_argsize = sizeof(struct nfsd3_voidargs),
251-
.pc_ressize = sizeof(struct nfsd3_voidargs),
248+
.pc_decode = nfssvc_decode_voidarg,
249+
.pc_encode = nfssvc_encode_voidres,
250+
.pc_argsize = sizeof(struct nfsd_voidargs),
251+
.pc_ressize = sizeof(struct nfsd_voidres),
252252
.pc_cachetype = RC_NOCACHE,
253253
.pc_xdrressize = ST,
254254
},

fs/nfsd/nfs3proc.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,6 @@ nfsd3_proc_commit(struct svc_rqst *rqstp)
692692
#define nfsd3_attrstatres nfsd3_attrstat
693693
#define nfsd3_wccstatres nfsd3_attrstat
694694
#define nfsd3_createres nfsd3_diropres
695-
#define nfsd3_voidres nfsd3_voidargs
696-
struct nfsd3_voidargs { int dummy; };
697695

698696
#define ST 1 /* status*/
699697
#define FH 17 /* filehandle with length */
@@ -704,10 +702,10 @@ struct nfsd3_voidargs { int dummy; };
704702
static const struct svc_procedure nfsd_procedures3[22] = {
705703
[NFS3PROC_NULL] = {
706704
.pc_func = nfsd3_proc_null,
707-
.pc_decode = nfs3svc_decode_voidarg,
708-
.pc_encode = nfs3svc_encode_voidres,
709-
.pc_argsize = sizeof(struct nfsd3_voidargs),
710-
.pc_ressize = sizeof(struct nfsd3_voidres),
705+
.pc_decode = nfssvc_decode_voidarg,
706+
.pc_encode = nfssvc_encode_voidres,
707+
.pc_argsize = sizeof(struct nfsd_voidargs),
708+
.pc_ressize = sizeof(struct nfsd_voidres),
711709
.pc_cachetype = RC_NOCACHE,
712710
.pc_xdrressize = ST,
713711
},

fs/nfsd/nfs3xdr.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,6 @@ void fill_post_wcc(struct svc_fh *fhp)
304304
/*
305305
* XDR decode functions
306306
*/
307-
int
308-
nfs3svc_decode_voidarg(struct svc_rqst *rqstp, __be32 *p)
309-
{
310-
return 1;
311-
}
312307

313308
int
314309
nfs3svc_decode_fhandle(struct svc_rqst *rqstp, __be32 *p)
@@ -642,12 +637,6 @@ nfs3svc_decode_commitargs(struct svc_rqst *rqstp, __be32 *p)
642637
* XDR encode functions
643638
*/
644639

645-
int
646-
nfs3svc_encode_voidres(struct svc_rqst *rqstp, __be32 *p)
647-
{
648-
return xdr_ressize_check(rqstp, p);
649-
}
650-
651640
/* GETATTR */
652641
int
653642
nfs3svc_encode_attrstat(struct svc_rqst *rqstp, __be32 *p)

fs/nfsd/nfs4proc.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3295,16 +3295,13 @@ static const char *nfsd4_op_name(unsigned opnum)
32953295
return "unknown_operation";
32963296
}
32973297

3298-
#define nfsd4_voidres nfsd4_voidargs
3299-
struct nfsd4_voidargs { int dummy; };
3300-
33013298
static const struct svc_procedure nfsd_procedures4[2] = {
33023299
[NFSPROC4_NULL] = {
33033300
.pc_func = nfsd4_proc_null,
3304-
.pc_decode = nfs4svc_decode_voidarg,
3305-
.pc_encode = nfs4svc_encode_voidres,
3306-
.pc_argsize = sizeof(struct nfsd4_voidargs),
3307-
.pc_ressize = sizeof(struct nfsd4_voidres),
3301+
.pc_decode = nfssvc_decode_voidarg,
3302+
.pc_encode = nfssvc_encode_voidres,
3303+
.pc_argsize = sizeof(struct nfsd_voidargs),
3304+
.pc_ressize = sizeof(struct nfsd_voidres),
33083305
.pc_cachetype = RC_NOCACHE,
33093306
.pc_xdrressize = 1,
33103307
},

fs/nfsd/nfs4xdr.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5271,12 +5271,6 @@ nfsd4_encode_replay(struct xdr_stream *xdr, struct nfsd4_op *op)
52715271
p = xdr_encode_opaque_fixed(p, rp->rp_buf, rp->rp_buflen);
52725272
}
52735273

5274-
int
5275-
nfs4svc_encode_voidres(struct svc_rqst *rqstp, __be32 *p)
5276-
{
5277-
return xdr_ressize_check(rqstp, p);
5278-
}
5279-
52805274
void nfsd4_release_compoundargs(struct svc_rqst *rqstp)
52815275
{
52825276
struct nfsd4_compoundargs *args = rqstp->rq_argp;
@@ -5294,12 +5288,6 @@ void nfsd4_release_compoundargs(struct svc_rqst *rqstp)
52945288
}
52955289
}
52965290

5297-
int
5298-
nfs4svc_decode_voidarg(struct svc_rqst *rqstp, __be32 *p)
5299-
{
5300-
return 1;
5301-
}
5302-
53035291
int
53045292
nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, __be32 *p)
53055293
{

fs/nfsd/nfsd.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ extern unsigned long nfsd_drc_mem_used;
7373

7474
extern const struct seq_operations nfs_exports_op;
7575

76+
/*
77+
* Common void argument and result helpers
78+
*/
79+
struct nfsd_voidargs { };
80+
struct nfsd_voidres { };
81+
int nfssvc_decode_voidarg(struct svc_rqst *rqstp, __be32 *p);
82+
int nfssvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p);
83+
7684
/*
7785
* Function prototypes.
7886
*/

fs/nfsd/nfsproc.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,6 @@ nfsd_proc_statfs(struct svc_rqst *rqstp)
609609
* NFSv2 Server procedures.
610610
* Only the results of non-idempotent operations are cached.
611611
*/
612-
struct nfsd_void { int dummy; };
613612

614613
#define ST 1 /* status */
615614
#define FH 8 /* filehandle */
@@ -618,10 +617,10 @@ struct nfsd_void { int dummy; };
618617
static const struct svc_procedure nfsd_procedures2[18] = {
619618
[NFSPROC_NULL] = {
620619
.pc_func = nfsd_proc_null,
621-
.pc_decode = nfssvc_decode_void,
622-
.pc_encode = nfssvc_encode_void,
623-
.pc_argsize = sizeof(struct nfsd_void),
624-
.pc_ressize = sizeof(struct nfsd_void),
620+
.pc_decode = nfssvc_decode_voidarg,
621+
.pc_encode = nfssvc_encode_voidres,
622+
.pc_argsize = sizeof(struct nfsd_voidargs),
623+
.pc_ressize = sizeof(struct nfsd_voidres),
625624
.pc_cachetype = RC_NOCACHE,
626625
.pc_xdrressize = 0,
627626
},
@@ -647,10 +646,10 @@ static const struct svc_procedure nfsd_procedures2[18] = {
647646
},
648647
[NFSPROC_ROOT] = {
649648
.pc_func = nfsd_proc_root,
650-
.pc_decode = nfssvc_decode_void,
651-
.pc_encode = nfssvc_encode_void,
652-
.pc_argsize = sizeof(struct nfsd_void),
653-
.pc_ressize = sizeof(struct nfsd_void),
649+
.pc_decode = nfssvc_decode_voidarg,
650+
.pc_encode = nfssvc_encode_voidres,
651+
.pc_argsize = sizeof(struct nfsd_voidargs),
652+
.pc_ressize = sizeof(struct nfsd_voidres),
654653
.pc_cachetype = RC_NOCACHE,
655654
.pc_xdrressize = 0,
656655
},
@@ -685,10 +684,10 @@ static const struct svc_procedure nfsd_procedures2[18] = {
685684
},
686685
[NFSPROC_WRITECACHE] = {
687686
.pc_func = nfsd_proc_writecache,
688-
.pc_decode = nfssvc_decode_void,
689-
.pc_encode = nfssvc_encode_void,
690-
.pc_argsize = sizeof(struct nfsd_void),
691-
.pc_ressize = sizeof(struct nfsd_void),
687+
.pc_decode = nfssvc_decode_voidarg,
688+
.pc_encode = nfssvc_encode_voidres,
689+
.pc_argsize = sizeof(struct nfsd_voidargs),
690+
.pc_ressize = sizeof(struct nfsd_voidres),
692691
.pc_cachetype = RC_NOCACHE,
693692
.pc_xdrressize = 0,
694693
},

fs/nfsd/nfssvc.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,34 @@ int nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
10751075
return 1;
10761076
}
10771077

1078+
/**
1079+
* nfssvc_decode_voidarg - Decode void arguments
1080+
* @rqstp: Server RPC transaction context
1081+
* @p: buffer containing arguments to decode
1082+
*
1083+
* Return values:
1084+
* %0: Arguments were not valid
1085+
* %1: Decoding was successful
1086+
*/
1087+
int nfssvc_decode_voidarg(struct svc_rqst *rqstp, __be32 *p)
1088+
{
1089+
return 1;
1090+
}
1091+
1092+
/**
1093+
* nfssvc_encode_voidres - Encode void results
1094+
* @rqstp: Server RPC transaction context
1095+
* @p: buffer in which to encode results
1096+
*
1097+
* Return values:
1098+
* %0: Local error while encoding
1099+
* %1: Encoding was successful
1100+
*/
1101+
int nfssvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p)
1102+
{
1103+
return xdr_ressize_check(rqstp, p);
1104+
}
1105+
10781106
int nfsd_pool_stats_open(struct inode *inode, struct file *file)
10791107
{
10801108
int ret;

fs/nfsd/nfsxdr.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,6 @@ __be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *f
192192
/*
193193
* XDR decode functions
194194
*/
195-
int
196-
nfssvc_decode_void(struct svc_rqst *rqstp, __be32 *p)
197-
{
198-
return xdr_argsize_check(rqstp, p);
199-
}
200195

201196
int
202197
nfssvc_decode_fhandle(struct svc_rqst *rqstp, __be32 *p)
@@ -423,11 +418,6 @@ nfssvc_decode_readdirargs(struct svc_rqst *rqstp, __be32 *p)
423418
/*
424419
* XDR encode functions
425420
*/
426-
int
427-
nfssvc_encode_void(struct svc_rqst *rqstp, __be32 *p)
428-
{
429-
return xdr_ressize_check(rqstp, p);
430-
}
431421

432422
int
433423
nfssvc_encode_stat(struct svc_rqst *rqstp, __be32 *p)

0 commit comments

Comments
 (0)