Skip to content

Commit 0ae4c3e

Browse files
committed
SUNRPC: Add xdr_set_scratch_page() and xdr_reset_scratch_buffer()
Clean up: De-duplicate some frequently-used code. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 231307d commit 0ae4c3e

File tree

13 files changed

+59
-39
lines changed

13 files changed

+59
-39
lines changed

fs/nfs/blocklayout/blocklayout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ bl_alloc_lseg(struct pnfs_layout_hdr *lo, struct nfs4_layoutget_res *lgr,
697697

698698
xdr_init_decode_pages(&xdr, &buf,
699699
lgr->layoutp->pages, lgr->layoutp->len);
700-
xdr_set_scratch_buffer(&xdr, page_address(scratch), PAGE_SIZE);
700+
xdr_set_scratch_page(&xdr, scratch);
701701

702702
status = -EIO;
703703
p = xdr_inline_decode(&xdr, 4);

fs/nfs/blocklayout/dev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ bl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
510510
goto out;
511511

512512
xdr_init_decode_pages(&xdr, &buf, pdev->pages, pdev->pglen);
513-
xdr_set_scratch_buffer(&xdr, page_address(scratch), PAGE_SIZE);
513+
xdr_set_scratch_page(&xdr, scratch);
514514

515515
p = xdr_inline_decode(&xdr, sizeof(__be32));
516516
if (!p)

fs/nfs/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ int nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *en
576576
goto out_nopages;
577577

578578
xdr_init_decode_pages(&stream, &buf, xdr_pages, buflen);
579-
xdr_set_scratch_buffer(&stream, page_address(scratch), PAGE_SIZE);
579+
xdr_set_scratch_page(&stream, scratch);
580580

581581
do {
582582
if (entry->label)

fs/nfs/filelayout/filelayout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ filelayout_decode_layout(struct pnfs_layout_hdr *flo,
666666
return -ENOMEM;
667667

668668
xdr_init_decode_pages(&stream, &buf, lgr->layoutp->pages, lgr->layoutp->len);
669-
xdr_set_scratch_buffer(&stream, page_address(scratch), PAGE_SIZE);
669+
xdr_set_scratch_page(&stream, scratch);
670670

671671
/* 20 = ufl_util (4), first_stripe_index (4), pattern_offset (8),
672672
* num_fh (4) */

fs/nfs/filelayout/filelayoutdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ nfs4_fl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
8282
goto out_err;
8383

8484
xdr_init_decode_pages(&stream, &buf, pdev->pages, pdev->pglen);
85-
xdr_set_scratch_buffer(&stream, page_address(scratch), PAGE_SIZE);
85+
xdr_set_scratch_page(&stream, scratch);
8686

8787
/* Get the stripe count (number of stripe index) */
8888
p = xdr_inline_decode(&stream, 4);

fs/nfs/flexfilelayout/flexfilelayout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh,
378378

379379
xdr_init_decode_pages(&stream, &buf, lgr->layoutp->pages,
380380
lgr->layoutp->len);
381-
xdr_set_scratch_buffer(&stream, page_address(scratch), PAGE_SIZE);
381+
xdr_set_scratch_page(&stream, scratch);
382382

383383
/* stripe unit and mirror_array_cnt */
384384
rc = -EIO;

fs/nfs/flexfilelayout/flexfilelayoutdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
6969
INIT_LIST_HEAD(&dsaddrs);
7070

7171
xdr_init_decode_pages(&stream, &buf, pdev->pages, pdev->pglen);
72-
xdr_set_scratch_buffer(&stream, page_address(scratch), PAGE_SIZE);
72+
xdr_set_scratch_page(&stream, scratch);
7373

7474
/* multipath count */
7575
p = xdr_inline_decode(&stream, 4);

fs/nfs/nfs42xdr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@ static int nfs4_xdr_dec_listxattrs(struct rpc_rqst *rqstp,
15401540
struct compound_hdr hdr;
15411541
int status;
15421542

1543-
xdr_set_scratch_buffer(xdr, page_address(res->scratch), PAGE_SIZE);
1543+
xdr_set_scratch_page(xdr, res->scratch);
15441544

15451545
status = decode_compound_hdr(xdr, &hdr);
15461546
if (status)

fs/nfs/nfs4xdr.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6403,10 +6403,8 @@ nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
64036403
struct compound_hdr hdr;
64046404
int status;
64056405

6406-
if (res->acl_scratch != NULL) {
6407-
void *p = page_address(res->acl_scratch);
6408-
xdr_set_scratch_buffer(xdr, p, PAGE_SIZE);
6409-
}
6406+
if (res->acl_scratch != NULL)
6407+
xdr_set_scratch_page(xdr, res->acl_scratch);
64106408
status = decode_compound_hdr(xdr, &hdr);
64116409
if (status)
64126410
goto out;

fs/nfsd/nfs4proc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2276,7 +2276,7 @@ static void svcxdr_init_encode(struct svc_rqst *rqstp,
22762276
xdr->end = head->iov_base + PAGE_SIZE - rqstp->rq_auth_slack;
22772277
/* Tail and page_len should be zero at this point: */
22782278
buf->len = buf->head[0].iov_len;
2279-
xdr->scratch.iov_len = 0;
2279+
xdr_reset_scratch_buffer(xdr);
22802280
xdr->page_ptr = buf->pages - 1;
22812281
buf->buflen = PAGE_SIZE * (1 + rqstp->rq_page_end - buf->pages)
22822282
- rqstp->rq_auth_slack;

0 commit comments

Comments
 (0)