From patchwork Tue May 20 18:08:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Schumaker, Anna" X-Patchwork-Id: 4212371 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CAF6F9F32A for ; Tue, 20 May 2014 18:08:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B76A420212 for ; Tue, 20 May 2014 18:08:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AC836201DE for ; Tue, 20 May 2014 18:08:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751374AbaETSIa (ORCPT ); Tue, 20 May 2014 14:08:30 -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 S1751039AbaETSI1 (ORCPT ); Tue, 20 May 2014 14:08:27 -0400 X-IronPort-AV: E=Sophos;i="4.98,875,1392192000"; d="scan'208";a="165539408" Received: from vmwexceht01-prd.hq.netapp.com ([10.106.76.239]) by mx12-out.netapp.com with ESMTP; 20 May 2014 11:08:27 -0700 Received: from VMWEXCHTS01-PRD.hq.netapp.com (10.122.105.12) by vmwexceht01-prd.hq.netapp.com (10.106.76.239) with Microsoft SMTP Server (TLS) id 14.3.123.3; Tue, 20 May 2014 11:08:27 -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:26 -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 s4KI8LYk029501; Tue, 20 May 2014 11:08:26 -0700 (PDT) From: Anna Schumaker To: , CC: , Subject: [RFC 04/12] nfs: Create a common pnfs_ld_rw_done() Date: Tue, 20 May 2014 14:08:11 -0400 Message-ID: <1400609299-32558-5-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 The read and write paths run mostly the same code, so it makes sense to combine them. Signed-off-by: Anna Schumaker --- fs/nfs/pnfs.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 4eaf74a..5976b87 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1457,6 +1457,18 @@ static void pnfs_ld_handle_rw_error(struct nfs_pgio_header *hdr, hdr->task.tk_status = resend_to_mds(hdr); } +static void pnfs_ld_rw_done(struct nfs_pgio_header *hdr, + void (*cb)(struct nfs_pgio_header *), + int (*resend_to_mds)(struct nfs_pgio_header *)) +{ + if (!hdr->pnfs_error) { + cb(hdr); + hdr->mds_ops->rpc_call_done(&hdr->task, hdr); + } else + pnfs_ld_handle_rw_error(hdr, resend_to_mds); + hdr->mds_ops->rpc_release(hdr); +} + void pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *req, u64 wb_size) @@ -1482,12 +1494,7 @@ EXPORT_SYMBOL_GPL(pnfs_write_done_resend_to_mds); void pnfs_ld_write_done(struct nfs_pgio_header *hdr) { trace_nfs4_pnfs_write(hdr, hdr->pnfs_error); - if (!hdr->pnfs_error) { - pnfs_set_layoutcommit(hdr); - hdr->mds_ops->rpc_call_done(&hdr->task, hdr); - } else - pnfs_ld_handle_rw_error(hdr, pnfs_write_done_resend_to_mds); - hdr->mds_ops->rpc_release(hdr); + pnfs_ld_rw_done(hdr, pnfs_set_layoutcommit, pnfs_write_done_resend_to_mds); } EXPORT_SYMBOL_GPL(pnfs_ld_write_done); @@ -1601,12 +1608,7 @@ EXPORT_SYMBOL_GPL(pnfs_read_done_resend_to_mds); void pnfs_ld_read_done(struct nfs_pgio_header *hdr) { trace_nfs4_pnfs_read(hdr, hdr->pnfs_error); - if (likely(!hdr->pnfs_error)) { - __nfs4_read_done_cb(hdr); - hdr->mds_ops->rpc_call_done(&hdr->task, hdr); - } else - pnfs_ld_handle_rw_error(hdr, pnfs_read_done_resend_to_mds); - hdr->mds_ops->rpc_release(hdr); + pnfs_ld_rw_done(hdr, __nfs4_read_done_cb, pnfs_read_done_resend_to_mds); } EXPORT_SYMBOL_GPL(pnfs_ld_read_done);