Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4827894imm; Wed, 30 May 2018 12:50:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLRb2ni8zz7frCeIWsyUAae9Fqf4WLye1t1bgQBPBCCBdsgVIsFzPXdyXgt7wWl5F1y7lmE X-Received: by 2002:a63:7209:: with SMTP id n9-v6mr3259652pgc.146.1527709850067; Wed, 30 May 2018 12:50:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527709850; cv=none; d=google.com; s=arc-20160816; b=oblH7mI+fG+ve/b4aT7JxgDiKsYs3g19+SCyFHpIUOQGiqU9Zqec2+ZKv11AbMdfgj xUooeNzJ9bz1mMXofh+bd6FM/H1iMcdP0t/Eeko9IZoOFX6YzIKDSPE4autGw3lzNnWF aFsybvmHMF04fRni7rziHzdjlPXIAUqOtdqzQus34TrlnQbNKFXlixMfMSyRifxFPkgz GMVG996xNaYwQwFszZDeBreyR5JeVwGaxmk8qE5b5dB67W9vb2iIcfhLwfBLwijlz3DN bFMahb/s31PZvXMyvPAmjCspUUoJorZPwCdd2eDDDoPj4W8nEnKgl3XM0tiF7GpdHhWj 7YQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=y2PLnf31mc53vcmJ1sJi0RxcO4OkfoqpCw+7BHACcrg=; b=aJE0F2U+yrcyFx2+DgfjAl8EiPTLt90juObP6vCj7sOBM7xWPVQSWg4gTxTTiuTjqR ThUrDv34ikO/ZLN3SU7KkrAw0J09+/lQ8p0qMrxrBWVsiiO1iW3W4I7Zokyg9fWYEZ9J oCyiuNfflhb62GPx8a8DlEoGmFVN2DIs6+9eYk44UvnFvaVaeAn3IHB1YQ3HOgTEXbzP y6RF8p2BQ8KJ0bEAA13M3J64yhRWOQvHGI/Yut69FlWjk4pX2j7jqc9ZwXsGYJl+95cA Ro/Xze+lk7eaRVWS1v2cPf9mBCh5osq7nanIMQdE6teNJf0OOwzWLnAkn2eFfopMeaLQ MkZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r133-v6si7956821pfr.286.2018.05.30.12.50.35; Wed, 30 May 2018 12:50:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932293AbeE3Tt5 (ORCPT + 99 others); Wed, 30 May 2018 15:49:57 -0400 Received: from a2nlsmtp01-03.prod.iad2.secureserver.net ([198.71.225.37]:57164 "EHLO a2nlsmtp01-03.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932246AbeE3Ttu (ORCPT ); Wed, 30 May 2018 15:49:50 -0400 Received: from linuxonhyperv2.linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id O75KfmbumdjTiO75KfBjUv; Wed, 30 May 2018 12:48:48 -0700 x-originating-ip: 107.180.71.197 Received: from longli by linuxonhyperv2.linuxonhyperv.com with local (Exim 4.91) (envelope-from ) id 1fO75K-0008Fh-Ii; Wed, 30 May 2018 12:48:38 -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: [Patch v2 04/15] CIFS: Add support for direct pages in wdata Date: Wed, 30 May 2018 12:47:56 -0700 Message-Id: <20180530194807.31657-5-longli@linuxonhyperv.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180530194807.31657-1-longli@linuxonhyperv.com> References: <20180530194807.31657-1-longli@linuxonhyperv.com> Reply-To: longli@microsoft.com X-CMAE-Envelope: MS4wfMwOmAkMxSfDSZc4tE7rTC1zDeJKOHQ44FWamfyw6kSwAtThgrWxri+wJQGRNWnyQZi7pgKyFhrTptpTAl9jCxoXVj25RoCRmF2dKnYKviCS7t67MU7q FDetk+PRaRooqGG4ZBHAoB9GtFSJgboMF5VMWhw4fXso3RM+KzHeNUdAsi66OiJKvsEWzOF7hp7mzjTvWcaztmdKdWrp65RPX9mKTAsgXIiv+xdT1GGuXaEF uEHffLCkQTOmSM4lxn4TE9U2U3BiFn8GdSWbRR9bzljpWl2oKOd0NWi4b2Xo+j48ZGseTSYWj2EVyTZsRJvxRV3vSgsgtF6CzR0M3xN4HpFpVAOGQ3gJ0mgx 5BNPxRXvGxJ3oDlQXIkdtoUeLgBll/zCas6Lz/8dWfIVjIVrS0vHhOHzSID3W/uyWa6tlJsN Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Long Li Add a function to allocate wdata without allocating pages for data transfer. This gives the caller an option to pass a number of pages that point to the data buffer to write to. wdata is reponsible for free those pages after it's done. Signed-off-by: Long Li --- fs/cifs/cifsglob.h | 2 +- fs/cifs/cifsproto.h | 2 ++ fs/cifs/cifssmb.c | 17 ++++++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 56864a87..7f62c98 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -1205,7 +1205,7 @@ struct cifs_writedata { unsigned int tailsz; unsigned int credits; unsigned int nr_pages; - struct page *pages[]; + struct page **pages; }; /* diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 1f27d8e..7933c5f 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -533,6 +533,8 @@ int cifs_async_writev(struct cifs_writedata *wdata, void cifs_writev_complete(struct work_struct *work); struct cifs_writedata *cifs_writedata_alloc(unsigned int nr_pages, work_func_t complete); +struct cifs_writedata *cifs_writedata_direct_alloc(struct page **pages, + work_func_t complete); void cifs_writedata_release(struct kref *refcount); int cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, struct cifs_sb_info *cifs_sb, diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index c8e4278..5aca336 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -1952,6 +1952,7 @@ cifs_writedata_release(struct kref *refcount) if (wdata->cfile) cifsFileInfo_put(wdata->cfile); + kvfree(wdata->pages); kfree(wdata); } @@ -2075,12 +2076,22 @@ cifs_writev_complete(struct work_struct *work) struct cifs_writedata * cifs_writedata_alloc(unsigned int nr_pages, work_func_t complete) { + struct page **pages = + kzalloc(sizeof(struct page *) * nr_pages, GFP_NOFS); + if (pages) + return cifs_writedata_direct_alloc(pages, complete); + + return NULL; +} + +struct cifs_writedata * +cifs_writedata_direct_alloc(struct page **pages, work_func_t complete) +{ struct cifs_writedata *wdata; - /* writedata + number of page pointers */ - wdata = kzalloc(sizeof(*wdata) + - sizeof(struct page *) * nr_pages, GFP_NOFS); + wdata = kzalloc(sizeof(*wdata), GFP_NOFS); if (wdata != NULL) { + wdata->pages = pages; kref_init(&wdata->refcount); INIT_LIST_HEAD(&wdata->list); init_completion(&wdata->done); -- 2.7.4