From patchwork Fri May 18 00:22:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 10407963 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 E998C602CB for ; Fri, 18 May 2018 00:26:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D86EC287C7 for ; Fri, 18 May 2018 00:26:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD3F7287CB; Fri, 18 May 2018 00:26:02 +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 76419287C7 for ; Fri, 18 May 2018 00:26:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751671AbeERAXa (ORCPT ); Thu, 17 May 2018 20:23:30 -0400 Received: from a2nlsmtp01-03.prod.iad2.secureserver.net ([198.71.225.37]:54946 "EHLO a2nlsmtp01-03.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751293AbeERAX3 (ORCPT ); Thu, 17 May 2018 20:23:29 -0400 Received: from linuxonhyperv2.linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id JTA8fWofsdjTiJTA8fL3jO; Thu, 17 May 2018 17:22:28 -0700 x-originating-ip: 107.180.71.197 Received: from longli by linuxonhyperv2.linuxonhyperv.com with local (Exim 4.91) (envelope-from ) id 1fJTA8-0001UD-Iu; Thu, 17 May 2018 17:22:24 -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 03/09] Change rdata alloc to support direct pages Date: Thu, 17 May 2018 17:22:08 -0700 Message-Id: <20180518002214.5657-4-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: MS4wfMhDLIYs8xHYq1k5o6aNxPJ67R1WRQW8Aqzrfn5hrfS2W328cbAEIQ6m+s4HT8jLyZInRoSt6s9Rurs4DgW7X53wBjUVUryZYgNzE2bxniBHJvEh1Bpo xHaHQGFJJJ/rahwaBbSu5SEbGBOO3qzdaEq9mAJQpmrLMft0nyjf7PxUtjiHoCtLunYNfWEe1YvCmPpKygRlhf03fX9IuJiU0pzAMCSUL7aGWU9AYrJaQkJX 6i0AA+FceAgxUqZkwrg+C9LHKwy33uh49ZWIEBjyBXzi2iXjWWqw6EW010lftU5IWrtvMhovCXCzdTgDPztkE94tD1KOge4Q0nYPnVwClu+VF2T+R0CoaY9D SbtLG8XsR3cE995JEoP1eCJtXlf/IOrs31T0USTQO0XOakjlWNlSdPKf4GlCN/t3/y/d/PX8 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 There is no need to allocate pages when using pages directly from user buffer Signed-off-by: Long Li --- 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) {