Received: by 10.223.164.197 with SMTP id h5csp685226wrb; Sat, 4 Nov 2017 22:48:25 -0700 (PDT) X-Google-Smtp-Source: ABhQp+R/uk5QB6zJFMxO+ZiwfMn0E3a2XzrWwRIrF9grsZWol11VfiV8E0mAth0faf5QwCT6FBg5 X-Received: by 10.98.65.156 with SMTP id g28mr12870946pfd.11.1509860905882; Sat, 04 Nov 2017 22:48:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509860905; cv=none; d=google.com; s=arc-20160816; b=E8rDgR97lxcwj3DCoB7qLx+uaXbpJyu3hDDecujGmWNOb2qPKDTO/LQllqEGP7de2T 52/FLjyvji3WKPu6/aK1stX8ArldgRmJSYg/C9ysjEJL0HSAVnnpdhnThsM9Z+EJAyBO 0hVC0X9ULTl8XbC9WkEls4E54n1W3q7wY3uOQktChp8HqLFanbkxfRihhYXaKdgbvImr N1wFmVQylhNL5fSaPBx/A5tJDpvW2uPaFl5Ca3rvuim3ZlEZX+f3qWF5CbjZ7klfoHTS IJ3K8XgwCwVLF/ILq5sOI8g3DAtERmAYtsXn5CdZ8nxYRY2r6PuLPhbQDPL8LCmaiF5X EmcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=M1uwYfOh7qjc57hqnOl3uEnB5aBeE4jdJOStIuUFjio=; b=bJuVcvB7YeJSFwJbU/9f/dUHBEiKtZcR0WbnWsKT75Wrd995sLjL3nhXcmCnXO2gZZ AU7rohJv4z+k6OYHV3z2tadiPMopr3VdU063HaS5A6VVocq3SrwpnHmtHOmUTpL+1xzZ FcwcZkHQGxEd1V3VBsbKgYAD3lQjMgEG4iDblKpKOYs3jVxa7YS6sd1/6NxDCQxN0HmV OTOWcfDmqeA+ZnEa47IIQwOGsQTo1mjCS/gnGOLuzJGqe0fAxxhsnWYHU/dSBRQTr1ES 22+R6lDKEFcpvk+pjAbKbdy3YsX4gjyFPaAihdtqB/Cy0Ys/MQiKOgz+PUJ581znFgHa +hYg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=exchange.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1si8156639plb.351.2017.11.04.22.48.12; Sat, 04 Nov 2017 22:48:25 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=exchange.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753052AbdKEFrR (ORCPT + 96 others); Sun, 5 Nov 2017 01:47:17 -0400 Received: from a2nlsmtp01-05.prod.iad2.secureserver.net ([198.71.225.49]:50148 "EHLO a2nlsmtp01-05.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750933AbdKEFpy (ORCPT ); Sun, 5 Nov 2017 01:45:54 -0400 Received: from linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id BDjVeq3po3w7hBDjVeBCdr; Sat, 04 Nov 2017 22:44:52 -0700 x-originating-ip: 107.180.71.197 Received: from longli by linuxonhyperv.com with local (Exim 4.89) (envelope-from ) id 1eBDjV-0006Fs-Nw; Sat, 04 Nov 2017 22:44:33 -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, Christoph Hellwig , Tom Talpey , Matthew Wilcox , Stephen Hemminger Cc: Long Li Subject: [Patch v6 20/22] CIFS: SMBD: Read correct returned data length for RDMA write (SMB read) I/O Date: Sat, 4 Nov 2017 22:44:02 -0700 Message-Id: <20171105054404.23886-21-longli@exchange.microsoft.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171105054404.23886-1-longli@exchange.microsoft.com> References: <20171105054404.23886-1-longli@exchange.microsoft.com> X-CMAE-Envelope: MS4wfLHlPcPZlNTMHg7yASbLW4oC9KTbrQGvcKBH2RnKtJeGoEyp5sHzUIWrQtu8zCrVWXoJTB3Y5VBk1hoviiVxJI+dwrQuy5xVz8hZnvOIq5X5kjiIkImj Z9Dj+Y1Gtnp/bfVINTJlm4AyGoJ0DF6hdkFUuIHU9mYNZTzNyA5PGMhjLyyu4CUf+h2Lfj6nivd7YRNDJJ9uVsDNZng0cxYbTnFHUBotk+HmvprAaCh5wLix GACvf/+mIjh+9lEQttHrmPxbsiUfZZ4d+jSnfSGHL4gASbqZgOR45sqWi7PQ2CFiHS7IMBuUCaPp1WyHs1Yt+nN/PuLKc9JoZ6geRefvaWZ/6Q7gzrWJze5z YPYL85ZF1W8QUKVWU2lWR7OcS++3HMmS5tXRFRG65QBTXFA9Lx3LiireDf9u0ZPc5Vf0/r0BwhmwzI4QAQ2Vi4oOWzswuEnQgS6pjUvH0CQ4s22R7PFbj5Y5 nBlMWkJjYf6U38fgxbYYWR9k8mDYzRoOi+nUDg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Long Li This patch is for preparing upper layer doing SMB read via RDMA write. When RDMA write is used for SMB read, the returned data length is in DataRemaining in the response packet. Reading it properly by adding a parameter to specifiy where the returned data length is. Add the defition for memory registration to wdata and return the correct length based on if RDMA write is used. Signed-off-by: Long Li --- fs/cifs/cifsglob.h | 13 +++++++++++-- fs/cifs/cifssmb.c | 7 ++++++- fs/cifs/smb1ops.c | 4 +++- fs/cifs/smb2ops.c | 12 ++++++++++-- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 2ae7d02..ddf83d8 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -228,8 +228,14 @@ struct smb_version_operations { __u64 (*get_next_mid)(struct TCP_Server_Info *); /* data offset from read response message */ unsigned int (*read_data_offset)(char *); - /* data length from read response message */ - unsigned int (*read_data_length)(char *); + /* + * Data length from read response message + * When in_remaining is true, the returned data length is in + * message field DataRemaining for out-of-band data read (e.g through + * Memory Registration RDMA write in SMBD). + * Otherwise, the returned data length is in message field DataLength. + */ + unsigned int (*read_data_length)(char *, bool in_remaining); /* map smb to linux error */ int (*map_error)(char *, bool); /* find mid corresponding to the response message */ @@ -1148,6 +1154,9 @@ struct cifs_readdata { struct cifs_readdata *rdata, struct iov_iter *iter); struct kvec iov[2]; +#ifdef CONFIG_CIFS_SMB_DIRECT + struct smbd_mr *mr; +#endif unsigned int pagesz; unsigned int tailsz; unsigned int credits; diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 08ff56a..a343db4 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -1533,8 +1533,13 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid) rdata->iov[0].iov_base, server->total_read); /* how much data is in the response? */ - data_len = server->ops->read_data_length(buf); +#ifdef CONFIG_CIFS_SMB_DIRECT + data_len = server->ops->read_data_length(buf, rdata->mr); + if (!rdata->mr && (data_offset + data_len > buflen)) { +#else + data_len = server->ops->read_data_length(buf, false); if (data_offset + data_len > buflen) { +#endif /* data_len is corrupt -- discard frame */ rdata->result = -EIO; return cifs_readv_discard(server, mid); diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c index a723df3..3d495e4 100644 --- a/fs/cifs/smb1ops.c +++ b/fs/cifs/smb1ops.c @@ -87,9 +87,11 @@ cifs_read_data_offset(char *buf) } static unsigned int -cifs_read_data_length(char *buf) +cifs_read_data_length(char *buf, bool in_remaining) { READ_RSP *rsp = (READ_RSP *)buf; + /* It's a bug reading remaining data for SMB1 packets */ + WARN_ON(in_remaining); return (le16_to_cpu(rsp->DataLengthHigh) << 16) + le16_to_cpu(rsp->DataLength); } diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 25028da..1bbd248 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -938,9 +938,13 @@ smb2_read_data_offset(char *buf) } static unsigned int -smb2_read_data_length(char *buf) +smb2_read_data_length(char *buf, bool in_remaining) { struct smb2_read_rsp *rsp = (struct smb2_read_rsp *)buf; + + if (in_remaining) + return le32_to_cpu(rsp->DataRemaining); + return le32_to_cpu(rsp->DataLength); } @@ -2449,7 +2453,11 @@ handle_read_data(struct TCP_Server_Info *server, struct mid_q_entry *mid, } data_offset = server->ops->read_data_offset(buf) + 4; - data_len = server->ops->read_data_length(buf); +#ifdef CONFIG_CIFS_SMB_DIRECT + data_len = server->ops->read_data_length(buf, rdata->mr); +#else + data_len = server->ops->read_data_length(buf, false); +#endif if (data_offset < server->vals->read_rsp_size) { /* -- 2.7.4 From 1583352220349874080@xxx Mon Nov 06 21:05:46 +0000 2017 X-GM-THRID: 1583352220349874080 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread