Skip to content

Commit 07d0ff3

Browse files
chuckleverJ. Bruce Fields
authored andcommitted
svcrdma: Clean up Read chunk path
Simplify the error handling at the tail of recv_read_chunk() by re-arranging rq_pages[] housekeeping and documenting it properly. NB: In this path, svc_rdma_recvfrom returns zero. Therefore no subsequent reply processing is done on the svc_rqstp, and thus the rq_respages field does not need to be updated. Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent a53d5cb commit 07d0ff3

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

net/sunrpc/xprtrdma/svc_rdma_rw.c

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,7 @@ static int svc_rdma_build_read_chunk(struct svc_rqst *rqstp,
679679
struct svc_rdma_read_info *info,
680680
__be32 *p)
681681
{
682+
unsigned int i;
682683
int ret;
683684

684685
ret = -EINVAL;
@@ -701,6 +702,12 @@ static int svc_rdma_build_read_chunk(struct svc_rqst *rqstp,
701702
info->ri_chunklen += rs_length;
702703
}
703704

705+
/* Pages under I/O have been copied to head->rc_pages.
706+
* Prevent their premature release by svc_xprt_release() .
707+
*/
708+
for (i = 0; i < info->ri_readctxt->rc_page_count; i++)
709+
rqstp->rq_pages[i] = NULL;
710+
704711
return ret;
705712
}
706713

@@ -816,7 +823,6 @@ int svc_rdma_recv_read_chunk(struct svcxprt_rdma *rdma, struct svc_rqst *rqstp,
816823
struct svc_rdma_recv_ctxt *head, __be32 *p)
817824
{
818825
struct svc_rdma_read_info *info;
819-
struct page **page;
820826
int ret;
821827

822828
/* The request (with page list) is constructed in
@@ -843,27 +849,15 @@ int svc_rdma_recv_read_chunk(struct svcxprt_rdma *rdma, struct svc_rqst *rqstp,
843849
ret = svc_rdma_build_normal_read_chunk(rqstp, info, p);
844850
else
845851
ret = svc_rdma_build_pz_read_chunk(rqstp, info, p);
846-
847-
/* Mark the start of the pages that can be used for the reply */
848-
if (info->ri_pageoff > 0)
849-
info->ri_pageno++;
850-
rqstp->rq_respages = &rqstp->rq_pages[info->ri_pageno];
851-
rqstp->rq_next_page = rqstp->rq_respages + 1;
852-
853852
if (ret < 0)
854-
goto out;
853+
goto out_err;
855854

856855
ret = svc_rdma_post_chunk_ctxt(&info->ri_cc);
857-
858-
out:
859-
/* Read sink pages have been moved from rqstp->rq_pages to
860-
* head->rc_arg.pages. Force svc_recv to refill those slots
861-
* in rq_pages.
862-
*/
863-
for (page = rqstp->rq_pages; page < rqstp->rq_respages; page++)
864-
*page = NULL;
865-
866856
if (ret < 0)
867-
svc_rdma_read_info_free(info);
857+
goto out_err;
858+
return 0;
859+
860+
out_err:
861+
svc_rdma_read_info_free(info);
868862
return ret;
869863
}

0 commit comments

Comments
 (0)