From patchwork Wed Aug 2 20:10:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 9877473 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0C9F860390 for ; Wed, 2 Aug 2017 20:12:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD12528833 for ; Wed, 2 Aug 2017 20:12:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBCB12883A; Wed, 2 Aug 2017 20:12:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7DBD28861 for ; Wed, 2 Aug 2017 20:12:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753093AbdHBUM2 (ORCPT ); Wed, 2 Aug 2017 16:12:28 -0400 Received: from a2nlsmtp01-04.prod.iad2.secureserver.net ([198.71.225.38]:36968 "EHLO a2nlsmtp01-04.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753013AbdHBUMZ (ORCPT ); Wed, 2 Aug 2017 16:12:25 -0400 Received: from linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id czzId52zi3vhKczzIdxf2b; Wed, 02 Aug 2017 13:11:24 -0700 x-originating-ip: 107.180.71.197 Received: from longli by linuxonhyperv.com with local (Exim 4.89) (envelope-from ) id 1dczzI-0005Hp-PU; Wed, 02 Aug 2017 13:11:24 -0700 From: Long Li To: Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org Cc: Long Li Subject: [[PATCH v1] 22/37] [CIFS] SMBD: Implement API for upper layer to receive data to page Date: Wed, 2 Aug 2017 13:10:33 -0700 Message-Id: <1501704648-20159-23-git-send-email-longli@exchange.microsoft.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1501704648-20159-1-git-send-email-longli@exchange.microsoft.com> References: <1501704648-20159-1-git-send-email-longli@exchange.microsoft.com> X-CMAE-Envelope: MS4wfLp8aWyXiEZEB+XrQLNGMc13SHHAONMn/Mg9o7Xh5e2l46XQQMqGiGiQ2d29zGcPxiQFxZnNhEhdynQsvyPKF38Jcj32z8Yrs+IgoRjtXr81ant5oBqE pMkyBOVwOj+coYZtH3OM985kJvsFz+WuNse7q9FUQnkIrGLtjBLu3AiNComz0zUjG4DyJPgz4sl9Z2K853g123BtLJiFSODcC+L09sOqk+APfQtiB4tYJ6Uv 4UPH3T86GxkeVYO0+sRyFrU2zDs6ghdQGX/WPK9xPPytykMJypEFVSrqqJ7TVLoRKL6hF39B8gR7XFhVgVGRUtLwdxoXScUd2uLDIgId+0g= Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Long Li Sometimes upper layer may also want to read data to a page. Implement this API. Signed-off-by: Long Li --- fs/cifs/cifsrdma.c | 30 ++++++++++++++++++++++++++++++ fs/cifs/cifsrdma.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/fs/cifs/cifsrdma.c b/fs/cifs/cifsrdma.c index e5f6300..67a11d9 100644 --- a/fs/cifs/cifsrdma.c +++ b/fs/cifs/cifsrdma.c @@ -1316,6 +1316,36 @@ struct cifs_rdma_info* cifs_create_rdma_session( } /* + * Read a page from receive reassembly queue + * page: the page to read data into + * to_read: the length of data to read + * return value: actual data read + */ +int cifs_rdma_read_page(struct cifs_rdma_info *info, + struct page *page, unsigned int to_read) +{ + int ret; + char *to_address; + + // make sure we have the page ready for read + wait_event( + info->wait_reassembly_queue, + atomic_read(&info->reassembly_data_length) >= to_read || + info->transport_status != CIFS_RDMA_CONNECTED); + + // now we can read from reassembly queue and not sleep + to_address = kmap_atomic(page); + + log_cifs_read("reading from page=%p address=%p to_read=%d\n", + page, to_address, to_read); + + ret = cifs_rdma_read(info, to_address, to_read); + kunmap_atomic(to_address); + + return ret; +} + +/* * Read data from receive reassembly queue * All the incoming data packets are placed in reassembly queue * buf: the buffer to read data into diff --git a/fs/cifs/cifsrdma.h b/fs/cifs/cifsrdma.h index 8891e21..36f3e4c 100644 --- a/fs/cifs/cifsrdma.h +++ b/fs/cifs/cifsrdma.h @@ -215,5 +215,7 @@ struct cifs_rdma_info* cifs_create_rdma_session( // SMBDirect interface for carrying upper layer CIFS I/O int cifs_rdma_read( struct cifs_rdma_info *rdma, char *buf, unsigned int to_read); +int cifs_rdma_read_page( + struct cifs_rdma_info *rdma, struct page *page, unsigned int to_read); int cifs_rdma_write(struct cifs_rdma_info *rdma, struct smb_rqst *rqst); #endif