Skip to content

Commit fda4944

Browse files
chuckleverJ. Bruce Fields
authored andcommitted
SUNRPC: Replace the "__be32 *p" parameter to .pc_encode
The passed-in value of the "__be32 *p" parameter is now unused in every server-side XDR encoder, and can be removed. Note also that there is a line in each encoder that sets up a local pointer to a struct xdr_stream. Passing that pointer from the dispatcher instead saves one line per encoder function. Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 3b0ebb2 commit fda4944

File tree

17 files changed

+85
-112
lines changed

17 files changed

+85
-112
lines changed

fs/lockd/svc.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,6 @@ module_exit(exit_nlm);
780780
static int nlmsvc_dispatch(struct svc_rqst *rqstp, __be32 *statp)
781781
{
782782
const struct svc_procedure *procp = rqstp->rq_procinfo;
783-
struct kvec *resv = rqstp->rq_res.head;
784783

785784
svcxdr_init_decode(rqstp);
786785
if (!procp->pc_decode(rqstp, &rqstp->rq_arg_stream))
@@ -793,7 +792,7 @@ static int nlmsvc_dispatch(struct svc_rqst *rqstp, __be32 *statp)
793792
return 1;
794793

795794
svcxdr_init_encode(rqstp);
796-
if (!procp->pc_encode(rqstp, resv->iov_base + resv->iov_len))
795+
if (!procp->pc_encode(rqstp, &rqstp->rq_res_stream))
797796
goto out_encode_err;
798797

799798
return 1;

fs/lockd/xdr.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -314,35 +314,32 @@ nlmsvc_decode_notify(struct svc_rqst *rqstp, struct xdr_stream *xdr)
314314
*/
315315

316316
int
317-
nlmsvc_encode_void(struct svc_rqst *rqstp, __be32 *p)
317+
nlmsvc_encode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr)
318318
{
319319
return 1;
320320
}
321321

322322
int
323-
nlmsvc_encode_testres(struct svc_rqst *rqstp, __be32 *p)
323+
nlmsvc_encode_testres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
324324
{
325-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
326325
struct nlm_res *resp = rqstp->rq_resp;
327326

328327
return svcxdr_encode_cookie(xdr, &resp->cookie) &&
329328
svcxdr_encode_testrply(xdr, resp);
330329
}
331330

332331
int
333-
nlmsvc_encode_res(struct svc_rqst *rqstp, __be32 *p)
332+
nlmsvc_encode_res(struct svc_rqst *rqstp, struct xdr_stream *xdr)
334333
{
335-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
336334
struct nlm_res *resp = rqstp->rq_resp;
337335

338336
return svcxdr_encode_cookie(xdr, &resp->cookie) &&
339337
svcxdr_encode_stats(xdr, resp->status);
340338
}
341339

342340
int
343-
nlmsvc_encode_shareres(struct svc_rqst *rqstp, __be32 *p)
341+
nlmsvc_encode_shareres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
344342
{
345-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
346343
struct nlm_res *resp = rqstp->rq_resp;
347344

348345
if (!svcxdr_encode_cookie(xdr, &resp->cookie))

fs/lockd/xdr4.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -313,35 +313,32 @@ nlm4svc_decode_notify(struct svc_rqst *rqstp, struct xdr_stream *xdr)
313313
*/
314314

315315
int
316-
nlm4svc_encode_void(struct svc_rqst *rqstp, __be32 *p)
316+
nlm4svc_encode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr)
317317
{
318318
return 1;
319319
}
320320

321321
int
322-
nlm4svc_encode_testres(struct svc_rqst *rqstp, __be32 *p)
322+
nlm4svc_encode_testres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
323323
{
324-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
325324
struct nlm_res *resp = rqstp->rq_resp;
326325

327326
return svcxdr_encode_cookie(xdr, &resp->cookie) &&
328327
svcxdr_encode_testrply(xdr, resp);
329328
}
330329

331330
int
332-
nlm4svc_encode_res(struct svc_rqst *rqstp, __be32 *p)
331+
nlm4svc_encode_res(struct svc_rqst *rqstp, struct xdr_stream *xdr)
333332
{
334-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
335333
struct nlm_res *resp = rqstp->rq_resp;
336334

337335
return svcxdr_encode_cookie(xdr, &resp->cookie) &&
338336
svcxdr_encode_stats(xdr, resp->status);
339337
}
340338

341339
int
342-
nlm4svc_encode_shareres(struct svc_rqst *rqstp, __be32 *p)
340+
nlm4svc_encode_shareres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
343341
{
344-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
345342
struct nlm_res *resp = rqstp->rq_resp;
346343

347344
if (!svcxdr_encode_cookie(xdr, &resp->cookie))

fs/nfs/callback_xdr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ static __be32 nfs4_callback_null(struct svc_rqst *rqstp)
6767
* svc_process_common() looks for an XDR encoder to know when
6868
* not to drop a Reply.
6969
*/
70-
static int nfs4_encode_void(struct svc_rqst *rqstp, __be32 *p)
70+
static int nfs4_encode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr)
7171
{
72-
return xdr_ressize_check(rqstp, p);
72+
return 1;
7373
}
7474

7575
static __be32 decode_string(struct xdr_stream *xdr, unsigned int *len,

fs/nfsd/nfs2acl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ nfsaclsvc_decode_accessargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
240240
*/
241241

242242
/* GETACL */
243-
static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p)
243+
static int
244+
nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
244245
{
245-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
246246
struct nfsd3_getaclres *resp = rqstp->rq_resp;
247247
struct dentry *dentry = resp->fh.fh_dentry;
248248
struct inode *inode;
@@ -280,9 +280,9 @@ static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p)
280280
}
281281

282282
/* ACCESS */
283-
static int nfsaclsvc_encode_accessres(struct svc_rqst *rqstp, __be32 *p)
283+
static int
284+
nfsaclsvc_encode_accessres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
284285
{
285-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
286286
struct nfsd3_accessres *resp = rqstp->rq_resp;
287287

288288
if (!svcxdr_encode_stat(xdr, resp->status))

fs/nfsd/nfs3acl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ nfs3svc_decode_setaclargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
166166
*/
167167

168168
/* GETACL */
169-
static int nfs3svc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p)
169+
static int
170+
nfs3svc_encode_getaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
170171
{
171-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
172172
struct nfsd3_getaclres *resp = rqstp->rq_resp;
173173
struct dentry *dentry = resp->fh.fh_dentry;
174174
struct kvec *head = rqstp->rq_res.head;
@@ -218,9 +218,9 @@ static int nfs3svc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p)
218218
}
219219

220220
/* SETACL */
221-
static int nfs3svc_encode_setaclres(struct svc_rqst *rqstp, __be32 *p)
221+
static int
222+
nfs3svc_encode_setaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
222223
{
223-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
224224
struct nfsd3_attrstat *resp = rqstp->rq_resp;
225225

226226
return svcxdr_encode_nfsstat3(xdr, resp->status) &&

fs/nfsd/nfs3xdr.c

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -813,9 +813,8 @@ nfs3svc_decode_commitargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
813813

814814
/* GETATTR */
815815
int
816-
nfs3svc_encode_getattrres(struct svc_rqst *rqstp, __be32 *p)
816+
nfs3svc_encode_getattrres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
817817
{
818-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
819818
struct nfsd3_attrstat *resp = rqstp->rq_resp;
820819

821820
if (!svcxdr_encode_nfsstat3(xdr, resp->status))
@@ -833,19 +832,18 @@ nfs3svc_encode_getattrres(struct svc_rqst *rqstp, __be32 *p)
833832

834833
/* SETATTR, REMOVE, RMDIR */
835834
int
836-
nfs3svc_encode_wccstat(struct svc_rqst *rqstp, __be32 *p)
835+
nfs3svc_encode_wccstat(struct svc_rqst *rqstp, struct xdr_stream *xdr)
837836
{
838-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
839837
struct nfsd3_attrstat *resp = rqstp->rq_resp;
840838

841839
return svcxdr_encode_nfsstat3(xdr, resp->status) &&
842840
svcxdr_encode_wcc_data(rqstp, xdr, &resp->fh);
843841
}
844842

845843
/* LOOKUP */
846-
int nfs3svc_encode_lookupres(struct svc_rqst *rqstp, __be32 *p)
844+
int
845+
nfs3svc_encode_lookupres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
847846
{
848-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
849847
struct nfsd3_diropres *resp = rqstp->rq_resp;
850848

851849
if (!svcxdr_encode_nfsstat3(xdr, resp->status))
@@ -869,9 +867,8 @@ int nfs3svc_encode_lookupres(struct svc_rqst *rqstp, __be32 *p)
869867

870868
/* ACCESS */
871869
int
872-
nfs3svc_encode_accessres(struct svc_rqst *rqstp, __be32 *p)
870+
nfs3svc_encode_accessres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
873871
{
874-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
875872
struct nfsd3_accessres *resp = rqstp->rq_resp;
876873

877874
if (!svcxdr_encode_nfsstat3(xdr, resp->status))
@@ -893,9 +890,8 @@ nfs3svc_encode_accessres(struct svc_rqst *rqstp, __be32 *p)
893890

894891
/* READLINK */
895892
int
896-
nfs3svc_encode_readlinkres(struct svc_rqst *rqstp, __be32 *p)
893+
nfs3svc_encode_readlinkres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
897894
{
898-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
899895
struct nfsd3_readlinkres *resp = rqstp->rq_resp;
900896
struct kvec *head = rqstp->rq_res.head;
901897

@@ -921,9 +917,8 @@ nfs3svc_encode_readlinkres(struct svc_rqst *rqstp, __be32 *p)
921917

922918
/* READ */
923919
int
924-
nfs3svc_encode_readres(struct svc_rqst *rqstp, __be32 *p)
920+
nfs3svc_encode_readres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
925921
{
926-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
927922
struct nfsd3_readres *resp = rqstp->rq_resp;
928923
struct kvec *head = rqstp->rq_res.head;
929924

@@ -954,9 +949,8 @@ nfs3svc_encode_readres(struct svc_rqst *rqstp, __be32 *p)
954949

955950
/* WRITE */
956951
int
957-
nfs3svc_encode_writeres(struct svc_rqst *rqstp, __be32 *p)
952+
nfs3svc_encode_writeres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
958953
{
959-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
960954
struct nfsd3_writeres *resp = rqstp->rq_resp;
961955

962956
if (!svcxdr_encode_nfsstat3(xdr, resp->status))
@@ -982,9 +976,8 @@ nfs3svc_encode_writeres(struct svc_rqst *rqstp, __be32 *p)
982976

983977
/* CREATE, MKDIR, SYMLINK, MKNOD */
984978
int
985-
nfs3svc_encode_createres(struct svc_rqst *rqstp, __be32 *p)
979+
nfs3svc_encode_createres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
986980
{
987-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
988981
struct nfsd3_diropres *resp = rqstp->rq_resp;
989982

990983
if (!svcxdr_encode_nfsstat3(xdr, resp->status))
@@ -1008,9 +1001,8 @@ nfs3svc_encode_createres(struct svc_rqst *rqstp, __be32 *p)
10081001

10091002
/* RENAME */
10101003
int
1011-
nfs3svc_encode_renameres(struct svc_rqst *rqstp, __be32 *p)
1004+
nfs3svc_encode_renameres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
10121005
{
1013-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
10141006
struct nfsd3_renameres *resp = rqstp->rq_resp;
10151007

10161008
return svcxdr_encode_nfsstat3(xdr, resp->status) &&
@@ -1020,9 +1012,8 @@ nfs3svc_encode_renameres(struct svc_rqst *rqstp, __be32 *p)
10201012

10211013
/* LINK */
10221014
int
1023-
nfs3svc_encode_linkres(struct svc_rqst *rqstp, __be32 *p)
1015+
nfs3svc_encode_linkres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
10241016
{
1025-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
10261017
struct nfsd3_linkres *resp = rqstp->rq_resp;
10271018

10281019
return svcxdr_encode_nfsstat3(xdr, resp->status) &&
@@ -1032,9 +1023,8 @@ nfs3svc_encode_linkres(struct svc_rqst *rqstp, __be32 *p)
10321023

10331024
/* READDIR */
10341025
int
1035-
nfs3svc_encode_readdirres(struct svc_rqst *rqstp, __be32 *p)
1026+
nfs3svc_encode_readdirres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
10361027
{
1037-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
10381028
struct nfsd3_readdirres *resp = rqstp->rq_resp;
10391029
struct xdr_buf *dirlist = &resp->dirlist;
10401030

@@ -1286,9 +1276,8 @@ svcxdr_encode_fsstat3resok(struct xdr_stream *xdr,
12861276

12871277
/* FSSTAT */
12881278
int
1289-
nfs3svc_encode_fsstatres(struct svc_rqst *rqstp, __be32 *p)
1279+
nfs3svc_encode_fsstatres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
12901280
{
1291-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
12921281
struct nfsd3_fsstatres *resp = rqstp->rq_resp;
12931282

12941283
if (!svcxdr_encode_nfsstat3(xdr, resp->status))
@@ -1333,9 +1322,8 @@ svcxdr_encode_fsinfo3resok(struct xdr_stream *xdr,
13331322

13341323
/* FSINFO */
13351324
int
1336-
nfs3svc_encode_fsinfores(struct svc_rqst *rqstp, __be32 *p)
1325+
nfs3svc_encode_fsinfores(struct svc_rqst *rqstp, struct xdr_stream *xdr)
13371326
{
1338-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
13391327
struct nfsd3_fsinfores *resp = rqstp->rq_resp;
13401328

13411329
if (!svcxdr_encode_nfsstat3(xdr, resp->status))
@@ -1376,9 +1364,8 @@ svcxdr_encode_pathconf3resok(struct xdr_stream *xdr,
13761364

13771365
/* PATHCONF */
13781366
int
1379-
nfs3svc_encode_pathconfres(struct svc_rqst *rqstp, __be32 *p)
1367+
nfs3svc_encode_pathconfres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
13801368
{
1381-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
13821369
struct nfsd3_pathconfres *resp = rqstp->rq_resp;
13831370

13841371
if (!svcxdr_encode_nfsstat3(xdr, resp->status))
@@ -1400,9 +1387,8 @@ nfs3svc_encode_pathconfres(struct svc_rqst *rqstp, __be32 *p)
14001387

14011388
/* COMMIT */
14021389
int
1403-
nfs3svc_encode_commitres(struct svc_rqst *rqstp, __be32 *p)
1390+
nfs3svc_encode_commitres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
14041391
{
1405-
struct xdr_stream *xdr = &rqstp->rq_res_stream;
14061392
struct nfsd3_commitres *resp = rqstp->rq_resp;
14071393

14081394
if (!svcxdr_encode_nfsstat3(xdr, resp->status))

fs/nfsd/nfs4xdr.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5427,10 +5427,11 @@ nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
54275427
}
54285428

54295429
int
5430-
nfs4svc_encode_compoundres(struct svc_rqst *rqstp, __be32 *p)
5430+
nfs4svc_encode_compoundres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
54315431
{
54325432
struct nfsd4_compoundres *resp = rqstp->rq_resp;
5433-
struct xdr_buf *buf = resp->xdr->buf;
5433+
struct xdr_buf *buf = xdr->buf;
5434+
__be32 *p;
54345435

54355436
WARN_ON_ONCE(buf->len != buf->head[0].iov_len + buf->page_len +
54365437
buf->tail[0].iov_len);
@@ -5443,7 +5444,7 @@ nfs4svc_encode_compoundres(struct svc_rqst *rqstp, __be32 *p)
54435444

54445445
*p++ = resp->cstate.status;
54455446

5446-
rqstp->rq_next_page = resp->xdr->page_ptr + 1;
5447+
rqstp->rq_next_page = xdr->page_ptr + 1;
54475448

54485449
*p++ = htonl(resp->taglen);
54495450
memcpy(p, resp->tag, resp->taglen);

fs/nfsd/nfsd.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ struct nfsd_voidargs { };
8080
struct nfsd_voidres { };
8181
bool nfssvc_decode_voidarg(struct svc_rqst *rqstp,
8282
struct xdr_stream *xdr);
83-
int nfssvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p);
83+
int nfssvc_encode_voidres(struct svc_rqst *rqstp,
84+
struct xdr_stream *xdr);
8485

8586
/*
8687
* Function prototypes.

fs/nfsd/nfssvc.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,8 +1004,6 @@ nfsd(void *vrqstp)
10041004
int nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
10051005
{
10061006
const struct svc_procedure *proc = rqstp->rq_procinfo;
1007-
struct kvec *resv = &rqstp->rq_res.head[0];
1008-
__be32 *p;
10091007

10101008
/*
10111009
* Give the xdr decoder a chance to change this if it wants
@@ -1030,14 +1028,13 @@ int nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
10301028
* Need to grab the location to store the status, as
10311029
* NFSv4 does some encoding while processing
10321030
*/
1033-
p = resv->iov_base + resv->iov_len;
10341031
svcxdr_init_encode(rqstp);
10351032

10361033
*statp = proc->pc_func(rqstp);
10371034
if (*statp == rpc_drop_reply || test_bit(RQ_DROPME, &rqstp->rq_flags))
10381035
goto out_update_drop;
10391036

1040-
if (!proc->pc_encode(rqstp, p))
1037+
if (!proc->pc_encode(rqstp, &rqstp->rq_res_stream))
10411038
goto out_encode_err;
10421039

10431040
nfsd_cache_update(rqstp, rqstp->rq_cachetype, statp + 1);
@@ -1078,13 +1075,13 @@ bool nfssvc_decode_voidarg(struct svc_rqst *rqstp, struct xdr_stream *xdr)
10781075
/**
10791076
* nfssvc_encode_voidres - Encode void results
10801077
* @rqstp: Server RPC transaction context
1081-
* @p: buffer in which to encode results
1078+
* @xdr: XDR stream into which to encode results
10821079
*
10831080
* Return values:
10841081
* %0: Local error while encoding
10851082
* %1: Encoding was successful
10861083
*/
1087-
int nfssvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p)
1084+
int nfssvc_encode_voidres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
10881085
{
10891086
return 1;
10901087
}

0 commit comments

Comments
 (0)