lkml.org 
[lkml]   [2017]   [Aug]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[[PATCH v1] 22/37] [CIFS] SMBD: Implement API for upper layer to receive data to page
Date
From: Long Li <longli@microsoft.com>

Sometimes upper layer may also want to read data to a page. Implement this API.

Signed-off-by: Long Li <longli@microsoft.com>
---
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
\
 
 \ /
  Last update: 2017-08-02 22:13    [W:0.178 / U:6.888 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site