From patchwork Wed Dec 24 07:13:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Haynes X-Patchwork-Id: 5537231 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 B73F59F301 for ; Wed, 24 Dec 2014 07:14:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D26D8200F2 for ; Wed, 24 Dec 2014 07:14:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 314BD201C7 for ; Wed, 24 Dec 2014 07:14:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751778AbaLXHO1 (ORCPT ); Wed, 24 Dec 2014 02:14:27 -0500 Received: from mail-ie0-f170.google.com ([209.85.223.170]:58637 "EHLO mail-ie0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751866AbaLXHOS (ORCPT ); Wed, 24 Dec 2014 02:14:18 -0500 Received: by mail-ie0-f170.google.com with SMTP id rd18so7270357iec.15 for ; Tue, 23 Dec 2014 23:14:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OJbEe4Y1TKkVZFzoSXlIuu/0noS6X/vVWsah1RcAoCk=; b=VGNyyBlh9+iepPjl1NwdfgPsIrau06n6FjUMeNdvPTZ31DUftSwG/XVO1oud2W1ztc YLM+XN1/fGVMaKWGZjPOKRq5/cXH8mhNm2GybNDGySl/dRWVW0dCeEYPwRmCqi5b16m8 qpdmd80qKQ2NopeMxxGBqnkmECKruomE1+6xYH+6zmHGu19zNKzrAmoZewKhpI6fOvq6 EyYFISHC73fXIgQMu/sfwHqcq4XTLMovRGRZCgUVdy8r8jmUWlFTialwuMJhxyjVS0P2 EeKAsLwPjkSNJC3WPpsV727zMHC5OjlcU07t7GbVA4BucZS2KMELQesWqo9TvxKCtu2U 2Ucw== X-Gm-Message-State: ALoCoQnNHcUwKJK6vPAgSTS7apnqxxElqf9Jb8Six6XJ/36tA0Ycd4+53138tgynGl4pRdei6heM X-Received: by 10.50.102.4 with SMTP id fk4mr24996463igb.28.1419405257665; Tue, 23 Dec 2014 23:14:17 -0800 (PST) Received: from localhost.localdomain (c-68-40-185-14.hsd1.mi.comcast.net. [68.40.185.14]) by mx.google.com with ESMTPSA id 37sm8821410iog.39.2014.12.23.23.14.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Dec 2014 23:14:17 -0800 (PST) From: Tom Haynes X-Google-Original-From: Tom Haynes To: Trond Myklebust Cc: Linux NFS Mailing List Subject: [PATCH v2 46/49] nfs41: add NFS_LAYOUT_RETRY_LAYOUTGET to layout header flags Date: Tue, 23 Dec 2014 23:13:25 -0800 Message-Id: <1419405208-25975-47-git-send-email-loghyr@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1419405208-25975-1-git-send-email-loghyr@primarydata.com> References: <1419405208-25975-1-git-send-email-loghyr@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 From: Peng Tao Use it to indicate that LD wants to retry layoutget. LD can set it whenever it wants the common pnfs code to return and retry pnfs path through a new layout. The bit gets cleared when client does a new layoutget, when client closes the file (ROC case), or when kernel needs to evict the inode (non-ROC case). Signed-off-by: Peng Tao --- fs/nfs/pnfs.c | 3 +++ fs/nfs/pnfs.h | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 9e7092f..fec1d897 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -617,6 +617,7 @@ pnfs_destroy_layout(struct nfs_inode *nfsi) pnfs_get_layout_hdr(lo); pnfs_layout_clear_fail_bit(lo, NFS_LAYOUT_RO_FAILED); pnfs_layout_clear_fail_bit(lo, NFS_LAYOUT_RW_FAILED); + pnfs_clear_retry_layoutget(lo); spin_unlock(&nfsi->vfs_inode.i_lock); pnfs_free_lseg_list(&tmp_list); pnfs_put_layout_hdr(lo); @@ -1070,6 +1071,7 @@ bool pnfs_roc(struct inode *ino) if (!lo || !test_and_clear_bit(NFS_LAYOUT_ROC, &lo->plh_flags) || test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags)) goto out_nolayout; + pnfs_clear_retry_layoutget(lo); list_for_each_entry_safe(lseg, tmp, &lo->plh_segs, pls_list) if (test_bit(NFS_LSEG_ROC, &lseg->pls_flags)) { mark_lseg_invalid(lseg, &tmp_list); @@ -1497,6 +1499,7 @@ lookup_again: arg.length = PAGE_CACHE_ALIGN(arg.length); lseg = send_layoutget(lo, ctx, &arg, gfp_flags); + pnfs_clear_retry_layoutget(lo); atomic_dec(&lo->plh_outstanding); out_put_layout_hdr: if (first) { diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index 04a5a31..67a436b 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -99,6 +99,7 @@ enum { NFS_LAYOUT_RETURN_BEFORE_CLOSE, /* Return this layout before close */ NFS_LAYOUT_INVALID_STID, /* layout stateid id is invalid */ NFS_LAYOUT_FIRST_LAYOUTGET, /* Serialize first layoutget */ + NFS_LAYOUT_RETRY_LAYOUTGET, /* Retry layoutget */ }; enum layoutdriver_policy_flags { @@ -349,6 +350,23 @@ nfs4_get_deviceid(struct nfs4_deviceid_node *d) return d; } +static inline void pnfs_set_retry_layoutget(struct pnfs_layout_hdr *lo) +{ + if (!test_and_set_bit(NFS_LAYOUT_RETRY_LAYOUTGET, &lo->plh_flags)) + atomic_inc(&lo->plh_refcount); +} + +static inline void pnfs_clear_retry_layoutget(struct pnfs_layout_hdr *lo) +{ + if (test_and_clear_bit(NFS_LAYOUT_RETRY_LAYOUTGET, &lo->plh_flags)) + atomic_dec(&lo->plh_refcount); +} + +static inline bool pnfs_should_retry_layoutget(struct pnfs_layout_hdr *lo) +{ + return test_bit(NFS_LAYOUT_RETRY_LAYOUTGET, &lo->plh_flags); +} + static inline struct pnfs_layout_segment * pnfs_get_lseg(struct pnfs_layout_segment *lseg) {