Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

svcrdma: Factor out WR chain linking into helper

svc_rdma_prepare_write_chunk() and svc_rdma_prepare_reply_chunk()
contain identical code for linking RDMA R/W work requests onto a
Send context's WR chain. This duplication increases maintenance
burden and risks divergent bug fixes.

Introduce svc_rdma_cc_link_wrs() to consolidate the WR chain
linking logic. The helper walks the chunk context's rwctxts list,
chains each WR via rdma_rw_ctx_wrs(), and updates the Send
context's chain head and SQE count. Completion signaling is
requested only for the tail WR (posted first).

No functional change.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>

+28 -39
+28 -39
net/sunrpc/xprtrdma/svc_rdma_rw.c
··· 619 619 return xdr->len; 620 620 } 621 621 622 - /* 623 - * svc_rdma_prepare_write_chunk - Link Write WRs for @chunk onto @sctxt's chain 624 - * 625 - * Write WRs are prepended to the Send WR chain so that a single 626 - * ib_post_send() posts both RDMA Writes and the final Send. Only 627 - * the first WR in each chunk gets a CQE for error detection; 628 - * subsequent WRs complete without individual completion events. 629 - * The Send WR's signaled completion indicates all chained 630 - * operations have finished. 622 + /* Link chunk WRs onto @sctxt's WR chain. Completion is requested 623 + * for the tail WR, which is posted first. 624 + */ 625 + static void svc_rdma_cc_link_wrs(struct svcxprt_rdma *rdma, 626 + struct svc_rdma_send_ctxt *sctxt, 627 + struct svc_rdma_chunk_ctxt *cc) 628 + { 629 + struct ib_send_wr *first_wr; 630 + struct list_head *pos; 631 + struct ib_cqe *cqe; 632 + 633 + first_wr = sctxt->sc_wr_chain; 634 + cqe = &cc->cc_cqe; 635 + list_for_each(pos, &cc->cc_rwctxts) { 636 + struct svc_rdma_rw_ctxt *rwc; 637 + 638 + rwc = list_entry(pos, struct svc_rdma_rw_ctxt, rw_list); 639 + first_wr = rdma_rw_ctx_wrs(&rwc->rw_ctx, rdma->sc_qp, 640 + rdma->sc_port_num, cqe, first_wr); 641 + cqe = NULL; 642 + } 643 + sctxt->sc_wr_chain = first_wr; 644 + sctxt->sc_sqecount += cc->cc_sqecount; 645 + } 646 + 647 + /* Link Write WRs for @chunk onto @sctxt's WR chain. 631 648 */ 632 649 static int svc_rdma_prepare_write_chunk(struct svcxprt_rdma *rdma, 633 650 struct svc_rdma_send_ctxt *sctxt, ··· 653 636 { 654 637 struct svc_rdma_write_info *info; 655 638 struct svc_rdma_chunk_ctxt *cc; 656 - struct ib_send_wr *first_wr; 657 639 struct xdr_buf payload; 658 - struct list_head *pos; 659 - struct ib_cqe *cqe; 660 640 int ret; 661 641 662 642 if (xdr_buf_subsegment(xdr, &payload, chunk->ch_position, ··· 673 659 if (unlikely(sctxt->sc_sqecount + cc->cc_sqecount > rdma->sc_sq_depth)) 674 660 goto out_err; 675 661 676 - first_wr = sctxt->sc_wr_chain; 677 - cqe = &cc->cc_cqe; 678 - list_for_each(pos, &cc->cc_rwctxts) { 679 - struct svc_rdma_rw_ctxt *rwc; 680 - 681 - rwc = list_entry(pos, struct svc_rdma_rw_ctxt, rw_list); 682 - first_wr = rdma_rw_ctx_wrs(&rwc->rw_ctx, rdma->sc_qp, 683 - rdma->sc_port_num, cqe, first_wr); 684 - cqe = NULL; 685 - } 686 - sctxt->sc_wr_chain = first_wr; 687 - sctxt->sc_sqecount += cc->cc_sqecount; 662 + svc_rdma_cc_link_wrs(rdma, sctxt, cc); 688 663 list_add(&info->wi_list, &sctxt->sc_write_info_list); 689 664 690 665 trace_svcrdma_post_write_chunk(&cc->cc_cid, cc->cc_sqecount); ··· 735 732 { 736 733 struct svc_rdma_write_info *info = &sctxt->sc_reply_info; 737 734 struct svc_rdma_chunk_ctxt *cc = &info->wi_cc; 738 - struct ib_send_wr *first_wr; 739 - struct list_head *pos; 740 - struct ib_cqe *cqe; 741 735 int ret; 742 736 743 737 info->wi_rdma = rdma; ··· 748 748 if (ret < 0) 749 749 return ret; 750 750 751 - first_wr = sctxt->sc_wr_chain; 752 - cqe = &cc->cc_cqe; 753 - list_for_each(pos, &cc->cc_rwctxts) { 754 - struct svc_rdma_rw_ctxt *rwc; 755 - 756 - rwc = list_entry(pos, struct svc_rdma_rw_ctxt, rw_list); 757 - first_wr = rdma_rw_ctx_wrs(&rwc->rw_ctx, rdma->sc_qp, 758 - rdma->sc_port_num, cqe, first_wr); 759 - cqe = NULL; 760 - } 761 - sctxt->sc_wr_chain = first_wr; 762 - sctxt->sc_sqecount += cc->cc_sqecount; 751 + svc_rdma_cc_link_wrs(rdma, sctxt, cc); 763 752 764 753 trace_svcrdma_post_reply_chunk(&cc->cc_cid, cc->cc_sqecount); 765 754 return xdr->len;