From patchwork Fri May 18 00:22:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 10407955 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 4B2C8602CB for ; Fri, 18 May 2018 00:25:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39013287C7 for ; Fri, 18 May 2018 00:25:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D681287CB; Fri, 18 May 2018 00:25:37 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable 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 C0FD5287C7 for ; Fri, 18 May 2018 00:25:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752272AbeERAZX (ORCPT ); Thu, 17 May 2018 20:25:23 -0400 Received: from a2nlsmtp01-02.prod.iad2.secureserver.net ([198.71.225.36]:44438 "EHLO a2nlsmtp01-02.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752130AbeERAXf (ORCPT ); Thu, 17 May 2018 20:23:35 -0400 Received: from linuxonhyperv2.linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id JTA7faXjdPEk0JTA7fthMg; Thu, 17 May 2018 17:22:33 -0700 x-originating-ip: 107.180.71.197 Received: from longli by linuxonhyperv2.linuxonhyperv.com with local (Exim 4.91) (envelope-from ) id 1fJTA7-0001U7-A0; Thu, 17 May 2018 17:22:23 -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 Cc: Long Li Subject: [RFC PATCH 02/09] Change wdata alloc to support direct pages Date: Thu, 17 May 2018 17:22:07 -0700 Message-Id: <20180518002214.5657-3-longli@linuxonhyperv.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180518002214.5657-1-longli@linuxonhyperv.com> References: <20180518002214.5657-1-longli@linuxonhyperv.com> Reply-To: longli@microsoft.com X-CMAE-Envelope: MS4wfAJKzYlkdgYzaSwYT6TRJGL48k3j+wc7soNtoGr2qc9xkjewgOlkiy/ip41ldKn9stJCuwl8NuGP36P9miblNO3sEXRcHdIpE9Jdr9kHplAv29scZQGH /2GDrigOoDKjeu7fJm3ncBPu9A8fPBpk9tB5c9yFfj8PV2ht63oqBDMp+EPN+hCtJp5Vi6pyuELa3PcK/pUlxwiIBqb8p+SshHHohVMwXmEO7hr+lPuZFEPw ydnhdH/Y4BydeAZtH670wb/kvSXttPdillg/Jrir0N14Ne+kK4vMQtFOYrWX2vCvvl/3PeKKVNPvtRf/N74MwecwFw+FExQ4WkC3d8cP/J4ir7doVBkA1IWP r34M7cPdJwTo2iLVGdO0q7S1+Ijg02ja6R4NspSj6Y9d9nJv9C/Vq686YafUtcKe1XQSJsSG 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 When using direct pages from user space, there is no need to allocate pages. Just ping those user pages for RDMA. Signed-off-by: Long Li --- fs/cifs/cifsproto.h | 2 +- fs/cifs/cifssmb.c | 10 +++++++--- fs/cifs/file.c | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 365a414..94106b9 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -523,7 +523,7 @@ int cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid); int cifs_async_writev(struct cifs_writedata *wdata, void (*release)(struct kref *kref)); void cifs_writev_complete(struct work_struct *work); -struct cifs_writedata *cifs_writedata_alloc(unsigned int nr_pages, +struct cifs_writedata *cifs_writedata_alloc(unsigned int nr_pages, struct page **direct_pages, work_func_t complete); void cifs_writedata_release(struct kref *refcount); int cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 1529a08..3b1731d 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -1983,7 +1983,7 @@ cifs_writev_requeue(struct cifs_writedata *wdata) tailsz = rest_len - (nr_pages - 1) * PAGE_SIZE; } - wdata2 = cifs_writedata_alloc(nr_pages, cifs_writev_complete); + wdata2 = cifs_writedata_alloc(nr_pages, NULL, cifs_writev_complete); if (!wdata2) { rc = -ENOMEM; break; @@ -2067,12 +2067,16 @@ cifs_writev_complete(struct work_struct *work) } struct cifs_writedata * -cifs_writedata_alloc(unsigned int nr_pages, work_func_t complete) +cifs_writedata_alloc(unsigned int nr_pages, struct page **direct_pages, work_func_t complete) { struct cifs_writedata *wdata; /* writedata + number of page pointers */ - wdata = kzalloc(sizeof(*wdata) + + if (direct_pages) { + wdata = kzalloc(sizeof(*wdata), GFP_NOFS); + wdata->direct_pages = direct_pages; + } else + wdata = kzalloc(sizeof(*wdata) + sizeof(struct page *) * nr_pages, GFP_NOFS); if (wdata != NULL) { kref_init(&wdata->refcount); diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 23fd430..a6ec896 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -1965,7 +1965,7 @@ wdata_alloc_and_fillpages(pgoff_t tofind, struct address_space *mapping, { struct cifs_writedata *wdata; - wdata = cifs_writedata_alloc((unsigned int)tofind, + wdata = cifs_writedata_alloc((unsigned int)tofind, NULL, cifs_writev_complete); if (!wdata) return NULL; @@ -2554,7 +2554,7 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from, break; nr_pages = get_numpages(wsize, len, &cur_len); - wdata = cifs_writedata_alloc(nr_pages, + wdata = cifs_writedata_alloc(nr_pages, NULL, cifs_uncached_writev_complete); if (!wdata) { rc = -ENOMEM;