Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp775627ybl; Fri, 24 Jan 2020 09:19:33 -0800 (PST) X-Google-Smtp-Source: APXvYqz4fY9M8Awns50zpSeTN6W6+bSGJRvZ3SOO7BfD/luui1vgdMnHKYyqGZty95t5Hv+FcKT6 X-Received: by 2002:a05:6808:3b4:: with SMTP id n20mr152602oie.123.1579886373533; Fri, 24 Jan 2020 09:19:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579886373; cv=none; d=google.com; s=arc-20160816; b=cPMXwpApy16HWMzT1R74QdrfNzjOSjHbWh3GkMsfnKfsz6I/bqgQIGG+FsCprNvFWD 32/wq+RWYnEPlfMhL08ES7h7U6OGbBUCQq/1tjvMXuv7+9gp8TKUyqcXTDQCD5upZtO4 fqS5aYuLlRtjY7pUazR3RJYO0F9ajU1dK1ez71slAXxwdm30N3Lald1QDNm+pApcCtTx HiiNO2HBleuAdAsG+QTz9WeNrOBXJILw45NG9ZhuuokMqcziesF89dCN2paA0TkZpD4Z LnqrexkB9BOBZwEYe+copc9K1B+OpKC1kvZBpuP3xq9WbxPQONkyVAh5eYewotzO/lds 2Ysw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=k3S+EJkvATN8POLaVo6vX2Z02NUZMTYOMtkNV5TiBpE=; b=Wc6Vg82LyLYSI62l7qr4at4p00I2U0XqEZkvyQRMCnDWoiVMaFexKxBKri09s3yNOy xoxG8ywFJu2AdU+vRYDGbjm357M2Scq4x5lhJn27ETnXBHtQKpK0Z2ttWIo+6jdANu6g f5L92KiMdJmwP46yatJAM2WUapkLBDcf3muhXVisePh0T3oFYTZWIsx5EPSO3MQ+v9MP xHM67jFZLkEf2QLUwZOAH/9uJtf6b5NP0PfJnIac/dEwUyrikqIxr09bU/0QUSSO/DT6 g61DCsI7INedZ4eAxBCI3OnXelcJqPKV2ovWOk7hsw3U4Y0ZxbjRLXtLc/MA/vekyZND m4qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g7Kgrpwu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s129si67918oig.177.2020.01.24.09.19.21; Fri, 24 Jan 2020 09:19:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g7Kgrpwu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389899AbgAXLLk (ORCPT + 99 others); Fri, 24 Jan 2020 06:11:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:47636 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389763AbgAXLLi (ORCPT ); Fri, 24 Jan 2020 06:11:38 -0500 Received: from localhost (ip-213-127-102-57.ip.prioritytelecom.net [213.127.102.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DB80B20663; Fri, 24 Jan 2020 11:11:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579864297; bh=wA66xn8xwT2YRuibEYOeBIITxq2WJ5SmlwKox+m4eYM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g7KgrpwuESRUuxR1JJTAjheCxnc3pg6MtRowy613nIqwvt7UTnMZOAO4KrJAfhjaz qGNAWxSee+MUg5L2DkMt9kbXzE4DJvpON3CXNFvafqiyPS9QHRnVjzOIsAyKOuCIrX BbClWGqJzd0ARgLZvvHzCoXln9QM93BJebnMCN0Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Sasha Levin Subject: [PATCH 4.19 227/639] NFS: Fix a soft lockup in the delegation recovery code Date: Fri, 24 Jan 2020 10:26:37 +0100 Message-Id: <20200124093115.321822499@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124093047.008739095@linuxfoundation.org> References: <20200124093047.008739095@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust [ Upstream commit 6f9449be53f3ce383caed797708b332ede8d952c ] Fix a soft lockup when NFS client delegation recovery is attempted but the inode is in the process of being freed. When the igrab(inode) call fails, and we have to restart the recovery process, we need to ensure that we won't attempt to recover the same delegation again. Fixes: 45870d6909d5a ("NFSv4.1: Test delegation stateids when server...") Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- fs/nfs/delegation.c | 20 ++++++++++++-------- fs/nfs/delegation.h | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 74ff459b75efa..b0c0c2fc2fbac 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -240,6 +240,8 @@ static struct inode *nfs_delegation_grab_inode(struct nfs_delegation *delegation spin_lock(&delegation->lock); if (delegation->inode != NULL) inode = igrab(delegation->inode); + if (!inode) + set_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags); spin_unlock(&delegation->lock); return inode; } @@ -955,10 +957,11 @@ restart: list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) { list_for_each_entry_rcu(delegation, &server->delegations, super_list) { - if (test_bit(NFS_DELEGATION_RETURNING, - &delegation->flags)) - continue; - if (test_bit(NFS_DELEGATION_NEED_RECLAIM, + if (test_bit(NFS_DELEGATION_INODE_FREEING, + &delegation->flags) || + test_bit(NFS_DELEGATION_RETURNING, + &delegation->flags) || + test_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags) == 0) continue; if (!nfs_sb_active(server->super)) @@ -1064,10 +1067,11 @@ restart: list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) { list_for_each_entry_rcu(delegation, &server->delegations, super_list) { - if (test_bit(NFS_DELEGATION_RETURNING, - &delegation->flags)) - continue; - if (test_bit(NFS_DELEGATION_TEST_EXPIRED, + if (test_bit(NFS_DELEGATION_INODE_FREEING, + &delegation->flags) || + test_bit(NFS_DELEGATION_RETURNING, + &delegation->flags) || + test_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags) == 0) continue; if (!nfs_sb_active(server->super)) diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h index dd0f3eed3890d..f09b153ac82ff 100644 --- a/fs/nfs/delegation.h +++ b/fs/nfs/delegation.h @@ -34,6 +34,7 @@ enum { NFS_DELEGATION_RETURNING, NFS_DELEGATION_REVOKED, NFS_DELEGATION_TEST_EXPIRED, + NFS_DELEGATION_INODE_FREEING, }; int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, -- 2.20.1