From patchwork Thu Dec 1 22:19:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 9457163 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3971760235 for ; Thu, 1 Dec 2016 22:19:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BFB028540 for ; Thu, 1 Dec 2016 22:19:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20E0B28542; Thu, 1 Dec 2016 22:19:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C29F028540 for ; Thu, 1 Dec 2016 22:19:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758280AbcLAWTb (ORCPT ); Thu, 1 Dec 2016 17:19:31 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:34599 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753817AbcLAWTa (ORCPT ); Thu, 1 Dec 2016 17:19:30 -0500 Received: by mail-io0-f195.google.com with SMTP id r94so3916882ioe.1 for ; Thu, 01 Dec 2016 14:19:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=7QnECxev6p/jEId/WnLImZ2it5JaTeM99U+o6pDBOyM=; b=ILkTb/s7BHoxmI3KJvYvHF/hdiT/8zMaR0w++ZKHCWft7s8vkK5f9WuVIql4GygbuW mhjTxP3Dxa6jM3uPl+7zhq/7kVwJp0hJKyRw3L11h5dieUTPUwaQxoTsaXM7QUdNuUnt 234MoEMAz2CsNJPXAzbc4oe8vovibP5mlVDDGLHVoxzqQFCQB9VZmvMfEsn9OCpw9EQa Kfb1gs1weW+KY9lbD8sOBLfmFpKovI+GZGO73ArZEqygfKInG2moQoNCj3un3qgN1teR TtJcAY4AJ7O9q8r/vB08Dv0dMY9xyP7uTAhnIr0DSxS4ewq/xfsNpNPBclFBDBbhLHEy T0xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=7QnECxev6p/jEId/WnLImZ2it5JaTeM99U+o6pDBOyM=; b=Z46NbrNusjIjehfaHUnOcta2FBGnj0w/4NiLZKiJj9MCDF0hKwFIAn+HbAJstlP4xA F61IWy3A+R78MGancN5lEfQafBduvC7Y9xAUaPx2LsoQq1jT/Kttx0EDG47bTs7G3cxq BHpd2AUsgkT6UEr+GA2zRmgtdh5fyA8eQqJMdwaNHxuVVUTdKqxbgVakE/DNY0O5ttYN zM/uDUE8AKyhQGnE0sPNJEl1eZtVI3HNysRpbyczirWqhzukwhiWcgeugRqNqGhTBa0Q +8wLYPn/HdhX5cmjvOY+M7Rcdib7/KZZb350fUaiuftV5EJi6CAEUGynWIoa9YyHhCfU xSsw== X-Gm-Message-State: AKaTC01UKpBric383ENy4n1NxtHPslqtFHhCYOw9gxBKA+/og9jYd8ps3rbyhZ5GxllM2g== X-Received: by 10.36.20.4 with SMTP id 4mr35493113itg.93.1480630769945; Thu, 01 Dec 2016 14:19:29 -0800 (PST) Received: from leira.trondhjem.org.localdomain (c-68-49-162-121.hsd1.mi.comcast.net. [68.49.162.121]) by smtp.gmail.com with ESMTPSA id t20sm6532ita.7.2016.12.01.14.19.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Dec 2016 14:19:29 -0800 (PST) From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 05/26] pNFS: On error, do not send LAYOUTGET until the LAYOUTRETURN has completed Date: Thu, 1 Dec 2016 17:19:01 -0500 Message-Id: <20161201221922.15657-6-trond.myklebust@primarydata.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161201221922.15657-5-trond.myklebust@primarydata.com> References: <20161201221922.15657-1-trond.myklebust@primarydata.com> <20161201221922.15657-2-trond.myklebust@primarydata.com> <20161201221922.15657-3-trond.myklebust@primarydata.com> <20161201221922.15657-4-trond.myklebust@primarydata.com> <20161201221922.15657-5-trond.myklebust@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If there is an I/O error, we should not call LAYOUTGET until the LAYOUTRETURN that reports the error is complete. Signed-off-by: Trond Myklebust Cc: stable@vger.kernel.org # v4.8+ --- fs/nfs/pnfs.c | 6 +++++- fs/nfs/pnfs.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 9b7e88b7edfc..06bfcd277006 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -947,6 +947,7 @@ static void pnfs_clear_layoutcommit(struct inode *inode, void pnfs_clear_layoutreturn_waitbit(struct pnfs_layout_hdr *lo) { clear_bit_unlock(NFS_LAYOUT_RETURN, &lo->plh_flags); + clear_bit(NFS_LAYOUT_RETURN_LOCK, &lo->plh_flags); smp_mb__after_atomic(); wake_up_bit(&lo->plh_flags, NFS_LAYOUT_RETURN); rpc_wake_up(&NFS_SERVER(lo->plh_inode)->roc_rpcwaitq); @@ -960,8 +961,9 @@ pnfs_prepare_layoutreturn(struct pnfs_layout_hdr *lo, /* Serialise LAYOUTGET/LAYOUTRETURN */ if (atomic_read(&lo->plh_outstanding) != 0) return false; - if (test_and_set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags)) + if (test_and_set_bit(NFS_LAYOUT_RETURN_LOCK, &lo->plh_flags)) return false; + set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags); pnfs_get_layout_hdr(lo); if (test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags)) { if (stateid != NULL) { @@ -1954,6 +1956,8 @@ void pnfs_error_mark_layout_for_return(struct inode *inode, spin_lock(&inode->i_lock); pnfs_set_plh_return_info(lo, range.iomode, 0); + /* Block LAYOUTGET */ + set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags); /* * mark all matching lsegs so that we are sure to have no live * segments at hand when sending layoutreturn. See pnfs_put_lseg() diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index 5c295512c967..44cad8afda0e 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -96,6 +96,7 @@ enum { NFS_LAYOUT_RW_FAILED, /* get rw layout failed stop trying */ NFS_LAYOUT_BULK_RECALL, /* bulk recall affecting layout */ NFS_LAYOUT_RETURN, /* layoutreturn in progress */ + NFS_LAYOUT_RETURN_LOCK, /* Serialise layoutreturn */ NFS_LAYOUT_RETURN_REQUESTED, /* Return this layout ASAP */ NFS_LAYOUT_INVALID_STID, /* layout stateid id is invalid */ NFS_LAYOUT_FIRST_LAYOUTGET, /* Serialize first layoutget */