From: Long Li <longli@linuxonhyperv.com>
To: Steve French <sfrench@samba.org>,
linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org
Cc: Long Li <longli@microsoft.com>
Subject: [RFC PATCH 03/09] Change rdata alloc to support direct pages
Date: Thu, 17 May 2018 17:22:08 -0700 [thread overview]
Message-ID: <20180518002214.5657-4-longli@linuxonhyperv.com> (raw)
In-Reply-To: <20180518002214.5657-1-longli@linuxonhyperv.com>
From: Long Li <longli@microsoft.com>
There is no need to allocate pages when using pages directly from user buffer
Signed-off-by: Long Li <longli@microsoft.com>
---
fs/cifs/file.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index a6ec896..ed25e04 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2880,11 +2880,15 @@ cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from)
}
static struct cifs_readdata *
-cifs_readdata_alloc(unsigned int nr_pages, work_func_t complete)
+cifs_readdata_alloc(unsigned int nr_pages, struct page **direct_pages, work_func_t complete)
{
struct cifs_readdata *rdata;
- rdata = kzalloc(sizeof(*rdata) + (sizeof(struct page *) * nr_pages),
+ if (direct_pages) {
+ rdata = kzalloc(sizeof(*rdata), GFP_KERNEL);
+ rdata->direct_pages = direct_pages;
+ } else
+ rdata = kzalloc(sizeof(*rdata) + (sizeof(struct page *) * nr_pages),
GFP_KERNEL);
if (rdata != NULL) {
kref_init(&rdata->refcount);
@@ -3095,14 +3099,13 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file,
npages = DIV_ROUND_UP(cur_len, PAGE_SIZE);
/* allocate a readdata struct */
- rdata = cifs_readdata_alloc(npages,
+ rdata = cifs_readdata_alloc(npages, NULL,
cifs_uncached_readv_complete);
if (!rdata) {
add_credits_and_wake_if(server, credits, 0);
rc = -ENOMEM;
break;
}
-
rc = cifs_read_allocate_pages(rdata, npages);
if (rc)
goto error;
@@ -3770,7 +3773,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
break;
}
- rdata = cifs_readdata_alloc(nr_pages, cifs_readv_complete);
+ rdata = cifs_readdata_alloc(nr_pages, NULL, cifs_readv_complete);
if (!rdata) {
/* best to give up if we're out of mem */
list_for_each_entry_safe(page, tpage, &tmplist, lru) {
--
2.7.4
next prev parent reply other threads:[~2018-05-18 0:22 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-18 0:22 [RFC PATCH 00/09] Implement direct user I/O interfaces for RDMA Long Li
2018-05-17 23:10 ` Tom Talpey
2018-05-18 6:03 ` Long Li
2018-05-18 6:44 ` Christoph Hellwig
2018-05-19 0:58 ` Tom Talpey
2018-05-18 6:42 ` Christoph Hellwig
2018-05-18 0:22 ` [RFC PATCH 01/09] Introduce offset for the 1st page in data transfer structures Long Li
2018-05-18 6:37 ` Steve French
2018-05-18 0:22 ` [RFC PATCH 02/09] Change wdata alloc to support direct pages Long Li
2018-05-19 1:05 ` Tom Talpey
2018-05-18 0:22 ` Long Li [this message]
2018-05-18 0:22 ` [RFC PATCH 04/09] Change function to support offset when reading pages Long Li
2018-05-18 0:22 ` [RFC PATCH 05/09] Change RDMA send to regonize page offset in the 1st page Long Li
2018-05-19 1:09 ` Tom Talpey
2018-05-19 5:54 ` Long Li
2018-05-18 0:22 ` [RFC PATCH 06/09] Change RDMA recv to support " Long Li
2018-05-18 0:22 ` [RFC PATCH 07/09] Support page offset in memory regsitrations Long Li
2018-05-18 0:22 ` [RFC PATCH 08/09] Implement direct file I/O interfaces Long Li
2018-05-18 0:22 ` [RFC PATCH 09/09] Introduce cache=rdma moutning option Long Li
2018-05-18 7:26 ` Christoph Hellwig
2018-05-18 19:00 ` Long Li
2018-05-18 20:44 ` Steve French
2018-05-18 20:58 ` Long Li
2018-05-19 1:20 ` Tom Talpey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180518002214.5657-4-longli@linuxonhyperv.com \
--to=longli@linuxonhyperv.com \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=samba-technical@lists.samba.org \
--cc=sfrench@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).