From patchwork Tue May 20 18:08:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Schumaker, Anna" X-Patchwork-Id: 4212351 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7DD88BEEAB for ; Tue, 20 May 2014 18:08:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 888A0201F2 for ; Tue, 20 May 2014 18:08:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A12212017E for ; Tue, 20 May 2014 18:08:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751008AbaETSI1 (ORCPT ); Tue, 20 May 2014 14:08:27 -0400 Received: from mx12.netapp.com ([216.240.18.77]:16546 "EHLO mx12.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750758AbaETSI0 (ORCPT ); Tue, 20 May 2014 14:08:26 -0400 X-IronPort-AV: E=Sophos;i="4.98,875,1392192000"; d="scan'208";a="165539397" Received: from vmwexceht02-prd.hq.netapp.com ([10.106.76.240]) by mx12-out.netapp.com with ESMTP; 20 May 2014 11:08:25 -0700 Received: from VMWEXCHTS01-PRD.hq.netapp.com (10.122.105.12) by vmwexceht02-prd.hq.netapp.com (10.106.76.240) with Microsoft SMTP Server (TLS) id 14.3.123.3; Tue, 20 May 2014 11:08:24 -0700 Received: from smtp2.corp.netapp.com (10.57.159.114) by VMWEXCHTS01-PRD.hq.netapp.com (10.122.105.12) with Microsoft SMTP Server id 15.0.847.32; Tue, 20 May 2014 11:08:24 -0700 Received: from davros.com (davros.ocarinaproject.vpn.netapp.com [10.63.224.110]) by smtp2.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id s4KI8LYi029501; Tue, 20 May 2014 11:08:23 -0700 (PDT) From: Anna Schumaker To: , CC: , Subject: [RFC 02/12] nfs: Create a common pnfs_generic_pg_init() function Date: Tue, 20 May 2014 14:08:09 -0400 Message-ID: <1400609299-32558-3-git-send-email-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 1.9.2 In-Reply-To: <1400609299-32558-1-git-send-email-Anna.Schumaker@Netapp.com> References: <1400609299-32558-1-git-send-email-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Most of this code can be shared. There are some differences with calculating bsize, but that needs to be changed in the layout drivers that call the read and write versions of this function. Signed-off-by: Anna Schumaker --- fs/nfs/pnfs.c | 61 +++++++++++++++++++++++++++-------------------------------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 8da7ff6..4d57003 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1387,48 +1387,22 @@ void pnfs_pageio_reset_mds(struct nfs_pageio_descriptor *pgio) } EXPORT_SYMBOL_GPL(pnfs_pageio_reset_mds); -void -pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req) -{ - u64 rd_size = req->wb_bytes; - - WARN_ON_ONCE(pgio->pg_lseg != NULL); - - if (pgio->pg_dreq == NULL) - rd_size = i_size_read(pgio->pg_inode) - req_offset(req); - else - rd_size = nfs_dreq_bytes_left(pgio->pg_dreq); - - pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, - req->wb_context, - req_offset(req), - rd_size, - IOMODE_READ, - GFP_KERNEL); - /* If no lseg, fall back to read through mds */ - if (pgio->pg_lseg == NULL) - pnfs_pageio_reset_mds(pgio); - -} -EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_read); - -void -pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio, - struct nfs_page *req, u64 wb_size) +static void pnfs_generic_pg_init(struct nfs_pageio_descriptor *pgio, + struct nfs_page *req, u64 bsize, + enum pnfs_iomode iomode, gfp_t gfp_flags) { WARN_ON_ONCE(pgio->pg_lseg != NULL); pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, req->wb_context, req_offset(req), - wb_size, - IOMODE_RW, - GFP_NOFS); - /* If no lseg, fall back to write through mds */ + bsize, + iomode, + gfp_flags); + /* If no lseg, fall back to IO through mds */ if (pgio->pg_lseg == NULL) pnfs_pageio_reset_mds(pgio); } -EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_write); /* * Return 0 if @req cannot be coalesced into @pgio, otherwise return the number @@ -1472,6 +1446,14 @@ pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, } EXPORT_SYMBOL_GPL(pnfs_generic_pg_test); +void +pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio, + struct nfs_page *req, u64 wb_size) +{ + pnfs_generic_pg_init(pgio, req, wb_size, IOMODE_RW, GFP_NOFS); +} +EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_write); + int pnfs_write_done_resend_to_mds(struct nfs_pgio_header *hdr) { struct nfs_pageio_descriptor pgio; @@ -1590,6 +1572,19 @@ pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc) } EXPORT_SYMBOL_GPL(pnfs_generic_pg_writepages); +void +pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req) +{ + u64 rd_size; + if (pgio->pg_dreq == NULL) + rd_size = i_size_read(pgio->pg_inode) - req_offset(req); + else + rd_size = nfs_dreq_bytes_left(pgio->pg_dreq); + + pnfs_generic_pg_init(pgio, req, rd_size, IOMODE_READ, GFP_KERNEL); +} +EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_read); + int pnfs_read_done_resend_to_mds(struct nfs_pgio_header *hdr) { struct nfs_pageio_descriptor pgio;