Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753147AbdHBUMb (ORCPT ); Wed, 2 Aug 2017 16:12:31 -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 x-originating-ip: 107.180.71.197 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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1986 Lines: 65 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 -- 2.7.4