Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp492229ybl; Tue, 28 Jan 2020 06:48:31 -0800 (PST) X-Google-Smtp-Source: APXvYqxujPDwszgHho6+HJHp8nIsYy0v7KsogmM+ola7o2dJvrHFRSGZCySun3/gAuWvGdSd3jsJ X-Received: by 2002:aca:a857:: with SMTP id r84mr2943962oie.41.1580222911746; Tue, 28 Jan 2020 06:48:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580222911; cv=none; d=google.com; s=arc-20160816; b=I7BhNeFzTLMk0rlF4RlmTjZ8VEYS5FKWlSN6GvqOVqD6IADNHFrvPGG3b/Kw9x+rEW ew+PNcqwKoSZM9gM9vpv+ygcq0mjHGcLbPJTevorCgy5E7Qv5DfuZIQ5Ejjj/Fnos1OY A9A5TPrZIu8wHe45GRrUxtMXTmNctQqs67DWARrS1hZ+AqtVler3u9mpjCGPsGn0RKgJ UWnfE/aQMMhrwXEp3dTNmAaVQ3xNjfgqhe3EnA+uSDuzaMA0qofxOW4qwW9G8c1HmbSe Pn7ZDp9EnqSyhWgF1mbv9dz6JuPH4unp4w3pKQJpT77C240IzUgfHygF3MnwNA7I4Y3r CNpg== 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=eMrhdeP+pHI6ofzsgcEn9SESwRR4ymsI0b/9sYq0J9U=; b=yeX6LRXE2jaxe+F53SfkpTJr0s9os8VdKk/cG12o8EqVZUaNzruAePLfwGcomFGCe5 4Cz21FU3ofYBtLSfVTVYBSHjMxr37Bzl9kiSBRTVeJes/+DhSfvbim+Dd0IiaNdeVb40 ho0MCpkRNgUAmMm1X2gETgd9IZlA0zJrcKzQlPyutjwGDwaZs8ISqoia3qvjw7x3onTM 0SjfAZ1Azatil8ZbEkq55rsbu8ohV5bFmDpEmM5jEQqlyy9l2CcAyk6nEsujuwGObyUZ i/LMVe2FuvfeYFS3mPswGw/DvF6nUfMVta6obiXzGa5Z13ZtbPVa+qvG/0eYhAK3NsT8 u4Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mGPjj74u; 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 n25si5172876oij.175.2020.01.28.06.48.19; Tue, 28 Jan 2020 06:48:31 -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=mGPjj74u; 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 S1730750AbgA1Oio (ORCPT + 99 others); Tue, 28 Jan 2020 09:38:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:42132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730621AbgA1OSN (ORCPT ); Tue, 28 Jan 2020 09:18:13 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 A68AB21739; Tue, 28 Jan 2020 14:18:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221092; bh=erU36mSuWyFSClo7QW4jYPmaXV6VmAAt49OmgnJyu0c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mGPjj74uEN4Ox2P5gDfjg3nWCpZAqeeAp9yHxaVWWmvWRAdKf23bEMx4vi5sHp/b2 WomrtCxxwJk3xrrxlaqAsnAbZA1/KN9cwKC5rMnRbnt1hlCgnpMgnnbkcvrIehcC8Y 6E2t4FjXJoJsHv+bLnr6GWGQdJnoJrahRECLK4kk= 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.9 086/271] NFS: Fix a soft lockup in the delegation recovery code Date: Tue, 28 Jan 2020 15:03:55 +0100 Message-Id: <20200128135858.977014036@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@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 9a8830a0f31f9..014039618cff0 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -234,6 +234,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; } @@ -867,10 +869,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)) @@ -975,10 +978,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 2c6cb7fb7d5ee..f72095bf9e107 100644 --- a/fs/nfs/delegation.h +++ b/fs/nfs/delegation.h @@ -33,6 +33,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, struct nfs_openres *res); -- 2.20.1