From patchwork Tue May 20 18:08:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Schumaker, Anna" X-Patchwork-Id: 4212401 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 0C3359F32A for ; Tue, 20 May 2014 18:08:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F04BD201DE for ; Tue, 20 May 2014 18:08:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 58591201F2 for ; Tue, 20 May 2014 18:08:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751238AbaETSIb (ORCPT ); Tue, 20 May 2014 14:08:31 -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 S1750868AbaETSI1 (ORCPT ); Tue, 20 May 2014 14:08:27 -0400 X-IronPort-AV: E=Sophos;i="4.98,875,1392192000"; d="scan'208";a="165539402" Received: from vmwexceht03-prd.hq.netapp.com ([10.106.76.241]) by mx12-out.netapp.com with ESMTP; 20 May 2014 11:08:26 -0700 Received: from VMWEXCHTS02-PRD.hq.netapp.com (10.122.105.23) by vmwexceht03-prd.hq.netapp.com (10.106.76.241) with Microsoft SMTP Server (TLS) id 14.3.123.3; Tue, 20 May 2014 11:08:26 -0700 Received: from smtp2.corp.netapp.com (10.57.159.114) by VMWEXCHTS02-PRD.hq.netapp.com (10.122.105.23) with Microsoft SMTP Server id 15.0.847.32; Tue, 20 May 2014 11:08:25 -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 s4KI8LYj029501; Tue, 20 May 2014 11:08:24 -0700 (PDT) From: Anna Schumaker To: , CC: , Subject: [RFC 03/12] nfs: Create a common pnfs_ld_handle_rw_error() function Date: Tue, 20 May 2014 14:08:10 -0400 Message-ID: <1400609299-32558-4-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 I use a simple function pointer to handle the difference between the read and write paths. Signed-off-by: Anna Schumaker --- fs/nfs/pnfs.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 4d57003..4eaf74a 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1446,6 +1446,17 @@ pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, } EXPORT_SYMBOL_GPL(pnfs_generic_pg_test); +static void pnfs_ld_handle_rw_error(struct nfs_pgio_header *hdr, + int (*resend_to_mds)(struct nfs_pgio_header *)) +{ + if (NFS_SERVER(hdr->inode)->pnfs_curr_ld->flags & + PNFS_LAYOUTRET_ON_ERROR) { + pnfs_return_layout(hdr->inode); + } + if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) + hdr->task.tk_status = resend_to_mds(hdr); +} + void pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *req, u64 wb_size) @@ -1465,18 +1476,6 @@ int pnfs_write_done_resend_to_mds(struct nfs_pgio_header *hdr) } EXPORT_SYMBOL_GPL(pnfs_write_done_resend_to_mds); -static void pnfs_ld_handle_write_error(struct nfs_pgio_header *hdr) -{ - - dprintk("pnfs write error = %d\n", hdr->pnfs_error); - if (NFS_SERVER(hdr->inode)->pnfs_curr_ld->flags & - PNFS_LAYOUTRET_ON_ERROR) { - pnfs_return_layout(hdr->inode); - } - if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) - hdr->task.tk_status = pnfs_write_done_resend_to_mds(hdr); -} - /* * Called by non rpc-based layout drivers */ @@ -1487,7 +1486,7 @@ void pnfs_ld_write_done(struct nfs_pgio_header *hdr) pnfs_set_layoutcommit(hdr); hdr->mds_ops->rpc_call_done(&hdr->task, hdr); } else - pnfs_ld_handle_write_error(hdr); + pnfs_ld_handle_rw_error(hdr, pnfs_write_done_resend_to_mds); hdr->mds_ops->rpc_release(hdr); } EXPORT_SYMBOL_GPL(pnfs_ld_write_done); @@ -1596,17 +1595,6 @@ int pnfs_read_done_resend_to_mds(struct nfs_pgio_header *hdr) } EXPORT_SYMBOL_GPL(pnfs_read_done_resend_to_mds); -static void pnfs_ld_handle_read_error(struct nfs_pgio_header *hdr) -{ - dprintk("pnfs read error = %d\n", hdr->pnfs_error); - if (NFS_SERVER(hdr->inode)->pnfs_curr_ld->flags & - PNFS_LAYOUTRET_ON_ERROR) { - pnfs_return_layout(hdr->inode); - } - if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) - hdr->task.tk_status = pnfs_read_done_resend_to_mds(hdr); -} - /* * Called by non rpc-based layout drivers */ @@ -1617,7 +1605,7 @@ void pnfs_ld_read_done(struct nfs_pgio_header *hdr) __nfs4_read_done_cb(hdr); hdr->mds_ops->rpc_call_done(&hdr->task, hdr); } else - pnfs_ld_handle_read_error(hdr); + pnfs_ld_handle_rw_error(hdr, pnfs_read_done_resend_to_mds); hdr->mds_ops->rpc_release(hdr); } EXPORT_SYMBOL_GPL(pnfs_ld_read_done);