Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4829140imm; Wed, 30 May 2018 12:52:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJSo+4iNVJ3Auqc2MFam7hZsyqgf1C9c5eypxDsimU/jl3/KNTNQ/gbrAG5IttGEJqp4Nmo X-Received: by 2002:a65:44c3:: with SMTP id g3-v6mr3224272pgs.428.1527709955172; Wed, 30 May 2018 12:52:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527709955; cv=none; d=google.com; s=arc-20160816; b=n0/GP58U8uzT64QXb0kf8MwLwAmiayBauxP6Ok/tiLFqYUE2BVSSwMSYjK56j9OI+o PCp6Ax3XaZ+s6bhclQe5rSISN0Iq1awkhOnKk1PwUAilKAdaEHcVReAU9JP9qSN8l0bu ltuc6XiQOgxpXvBxhs9gmz8Vt7crS51RvP6Ot57E8Xeqm0tvG+YN2f9RkdvzbwE9uafI 6fDpb4sMO9yhF3PV/p6Pr62zV9cvm627nYWuvUuWLnA01Nzvk6Q0q722eeAqO3gaOw/j oJ/re+7Mzw4g+itbOpWfxVS7UsoIntHrb8i1/X5cAYw6z54SSwo9/Y41LXRRdFkle9MW 6r9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=zMiNFC8v782gbpjtZqAbEnnw9ai+Uic+YSrm9jMCOhM=; b=C/Si6I3hQlaaPYcFHETX4nzkFdgHgBZQHY8csqmlXvYsI+BgF+9RSTER6/0SpYZRz+ 5eGVItKCHj5aMMZG4066RPsSqkAEc2+CM4O7nvXq9rX/pQpXGC/J9tmwrlFKfJ9ldc6E XMihWeyJnQ+Kd7T/PKvnQq20hnX+z63JFppZpQbJOGxmidnqVSxGkKZUz50C61DiA9nQ /M0+GS3tKZ/6mX6U33oGepKa4/5AG7h1TBorvXkQib6Agkioy/V7mdKU5L1y7pRRqc2Z Px3k8rYNhbEhotwLWqYN3Ozxboqe17B7ESJATCbMEJeJyrycCrweShnHhQHh2OZ84pfu xEOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z10-v6si27489005pgz.443.2018.05.30.12.52.21; Wed, 30 May 2018 12:52:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932272AbeE3Ttz (ORCPT + 99 others); Wed, 30 May 2018 15:49:55 -0400 Received: from a2nlsmtp01-02.prod.iad2.secureserver.net ([198.71.225.36]:51060 "EHLO a2nlsmtp01-02.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932237AbeE3Ttt (ORCPT ); Wed, 30 May 2018 15:49:49 -0400 Received: from linuxonhyperv2.linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id O75UfpcBnPEk0O75UflAHF; Wed, 30 May 2018 12:48:48 -0700 x-originating-ip: 107.180.71.197 Received: from longli by linuxonhyperv2.linuxonhyperv.com with local (Exim 4.91) (envelope-from ) id 1fO75U-0008G5-Jg; Wed, 30 May 2018 12:48:48 -0700 From: Long Li To: Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org Cc: Long Li Subject: [Patch v2 08/15] CIFS: SMBD: Support page offset in RDMA send Date: Wed, 30 May 2018 12:48:00 -0700 Message-Id: <20180530194807.31657-9-longli@linuxonhyperv.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180530194807.31657-1-longli@linuxonhyperv.com> References: <20180530194807.31657-1-longli@linuxonhyperv.com> Reply-To: longli@microsoft.com X-CMAE-Envelope: MS4wfPcgvQofKi5rY9GShqFu8E5FzrtTGr9bk/wrj/vvvV0h/fXUZ8kw7W8e+vRWst8kTY/Cc84DudGUCXsVFUcuPxigGSFP+3bPsMnkPp8GHM2srJ6wScS3 phW0DdrL+IG+/jYyUWMG2anVYImzhzPaBU3YRufx2MqaYwlMnczGpglr1/LXqFD5cSCRMkdxzFRu4pLgjvQOoUdjHUEzoGVc2d04FFVS/8h5FkL7CN544Cne 7h/mqXKKOTkNmWJTubEy8trrrx3peLbYUgYRzFcMHrna14TIxo1QhIT/77uM77tYIpfPWvY9Z0iBrnW0IcE7jRKJgRv2iaiRXtiD4sFL8GYn5oMDJaXsSq/b KfwFnRhBOZd58Ki7UgN9lMTLu2SfAYs2MBlrm3hc7RYTAR5PEAwch8wy+6Ga2igGc4JYGiHt Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Long Li The RDMA send function needs to look at offset in the request pages, and send data starting from there. Signed-off-by: Long Li --- fs/cifs/smbdirect.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c index c62f7c9..6141e3c 100644 --- a/fs/cifs/smbdirect.c +++ b/fs/cifs/smbdirect.c @@ -17,6 +17,7 @@ #include #include "smbdirect.h" #include "cifs_debug.h" +#include "cifsproto.h" static struct smbd_response *get_empty_queue_buffer( struct smbd_connection *info); @@ -2082,7 +2083,7 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst) struct kvec vec; int nvecs; int size; - int buflen = 0, remaining_data_length; + unsigned int buflen = 0, remaining_data_length; int start, i, j; int max_iov_size = info->max_send_size - sizeof(struct smbd_data_transfer); @@ -2113,10 +2114,17 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst) buflen += iov[i].iov_len; } - /* add in the page array if there is one */ + /* + * Add in the page array if there is one. The caller needs to set + * rq_tailsz to PAGE_SIZE when the buffer has multiple pages and + * ends at page boundary + */ if (rqst->rq_npages) { - buflen += rqst->rq_pagesz * (rqst->rq_npages - 1); - buflen += rqst->rq_tailsz; + if (rqst->rq_npages == 1) + buflen += rqst->rq_tailsz; + else + buflen += rqst->rq_pagesz * (rqst->rq_npages - 1) - + rqst->rq_offset + rqst->rq_tailsz; } if (buflen + sizeof(struct smbd_data_transfer) > @@ -2213,8 +2221,9 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst) /* now sending pages if there are any */ for (i = 0; i < rqst->rq_npages; i++) { - buflen = (i == rqst->rq_npages-1) ? - rqst->rq_tailsz : rqst->rq_pagesz; + unsigned int offset; + + rqst_page_get_length(rqst, i, &buflen, &offset); nvecs = (buflen + max_iov_size - 1) / max_iov_size; log_write(INFO, "sending pages buflen=%d nvecs=%d\n", buflen, nvecs); @@ -2225,9 +2234,11 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst) remaining_data_length -= size; log_write(INFO, "sending pages i=%d offset=%d size=%d" " remaining_data_length=%d\n", - i, j*max_iov_size, size, remaining_data_length); + i, j*max_iov_size+offset, size, + remaining_data_length); rc = smbd_post_send_page( - info, rqst->rq_pages[i], j*max_iov_size, + info, rqst->rq_pages[i], + j*max_iov_size + offset, size, remaining_data_length); if (rc) goto done; -- 2.7.4