From patchwork Wed Sep 19 01:35:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 1475391 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id E5BE6DF24C for ; Wed, 19 Sep 2012 01:36:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752449Ab2ISBgJ (ORCPT ); Tue, 18 Sep 2012 21:36:09 -0400 Received: from mx2.netapp.com ([216.240.18.37]:52160 "EHLO mx2.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752646Ab2ISBgF (ORCPT ); Tue, 18 Sep 2012 21:36:05 -0400 X-IronPort-AV: E=Sophos;i="4.80,446,1344236400"; d="scan'208";a="691342596" Received: from smtp1.corp.netapp.com ([10.57.156.124]) by mx2-out.netapp.com with ESMTP; 18 Sep 2012 18:36:05 -0700 Received: from lade.trondhjem.org.com (lade.trondhjem.org [10.63.224.254] (may be forged)) by smtp1.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id q8J1ZxpZ012304; Tue, 18 Sep 2012 18:36:04 -0700 (PDT) From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 7/8] NFSv4.1: Retry pNFS after a 2 minute timeout Date: Tue, 18 Sep 2012 21:35:53 -0400 Message-Id: <1348018554-63137-7-git-send-email-Trond.Myklebust@netapp.com> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1348018554-63137-6-git-send-email-Trond.Myklebust@netapp.com> References: <1348018554-63137-1-git-send-email-Trond.Myklebust@netapp.com> <1348018554-63137-2-git-send-email-Trond.Myklebust@netapp.com> <1348018554-63137-3-git-send-email-Trond.Myklebust@netapp.com> <1348018554-63137-4-git-send-email-Trond.Myklebust@netapp.com> <1348018554-63137-5-git-send-email-Trond.Myklebust@netapp.com> <1348018554-63137-6-git-send-email-Trond.Myklebust@netapp.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If we had to fall back to read/write through MDS, then assume that we should retry pNFS after a suitable timeout period. The following patch sets a timeout of 2 minutes. Signed-off-by: Trond Myklebust --- fs/nfs/pnfs.c | 15 ++++++++++++++- fs/nfs/pnfs.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index a4713f9..3703a68 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -35,6 +35,7 @@ #include "iostat.h" #define NFSDBG_FACILITY NFSDBG_PNFS +#define PNFS_LAYOUTGET_RETRY_TIMEOUT (120*HZ) /* Locking: * @@ -248,6 +249,7 @@ pnfs_iomode_to_fail_bit(u32 iomode) static void pnfs_layout_io_set_failed(struct pnfs_layout_hdr *lo, u32 iomode) { + lo->plh_retry_timestamp = jiffies; set_bit(pnfs_iomode_to_fail_bit(iomode), &lo->plh_flags); dprintk("%s Setting layout IOMODE_%s fail bit\n", __func__, iomode == IOMODE_RW ? "RW" : "READ"); @@ -256,7 +258,18 @@ pnfs_layout_io_set_failed(struct pnfs_layout_hdr *lo, u32 iomode) static bool pnfs_layout_io_test_failed(struct pnfs_layout_hdr *lo, u32 iomode) { - return test_bit(pnfs_iomode_to_fail_bit(iomode), &lo->plh_flags) != 0; + unsigned long start, end; + if (test_bit(pnfs_iomode_to_fail_bit(iomode), &lo->plh_flags) == 0) + return false; + end = jiffies; + start = end - PNFS_LAYOUTGET_RETRY_TIMEOUT; + if (!time_in_range(lo->plh_retry_timestamp, start, end)) { + /* It is time to retry the failed layoutgets */ + clear_bit(NFS_LAYOUT_RW_FAILED, &lo->plh_flags); + clear_bit(NFS_LAYOUT_RO_FAILED, &lo->plh_flags); + return false; + } + return true; } static void diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index e3eb7d1..bc8e500 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -140,6 +140,7 @@ struct pnfs_layout_hdr { atomic_t plh_outstanding; /* number of RPCs out */ unsigned long plh_block_lgets; /* block LAYOUTGET if >0 */ u32 plh_barrier; /* ignore lower seqids */ + unsigned long plh_retry_timestamp; unsigned long plh_flags; loff_t plh_lwb; /* last write byte for layoutcommit */ struct rpc_cred *plh_lc_cred; /* layoutcommit cred */