Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1549759pxb; Thu, 16 Sep 2021 09:42:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEyzuKvd2nqy8zFx3Om5nQA22gGiNsslx2kjiftLWRuZZACCzhdQ42KGyxcqHRiMLIehyA X-Received: by 2002:a17:907:76e7:: with SMTP id kg7mr7372141ejc.344.1631810578243; Thu, 16 Sep 2021 09:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631810578; cv=none; d=google.com; s=arc-20160816; b=mr6nzs2BFUHrJvUeblO/iq46gZc6PgZyHGftI5KJXuuXrijsTedQCULosKkxalIrA/ 4xs+Z7RfDvIsYfSkipO4kLUzbutZYk3D5N1JXs3NEd6SFOIfTPUwDUbhxp9wv6Zg7gGu Zh9uzUFSJ6QpwuEkipjRqVvLSsmSiP4OhL5PjEaK16Nnjv14lIYdeUg0PYVsWW3z1hrt I31njOL30AnXmRwQmS659SK9lhlzHURnCXYv6uoZjFCkO6Xw0cZkVN+8ZJmOFBsiPIz+ iDr/THkMyRMoVTzZUw+94CtwOXB8c/z5fOM7ky0+CnwdDXpRL/0PUO97DuyLTpoiZCcm 6UUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=i/APppUI7TjzQNQH/SSIMXuaz4IqCIOQBddQ5S7a4e8=; b=fJQPGEwq3ksP8WfWWkXlMusJA+hZfXT0FdFa9gOq86rPtxIxu14ISAj5Ahmm563uCw TmwEvf0OTNdKZ6RL+UqWE3JlYPPPCXLJCao6b0AmSsMSE5/JC5WYsPsWmROKDROt2hl1 J/z0cm549i4mLd9ITRozJN+L41+erZXjQNCyx/n8mE2j5XwYWSwy560KuYp8kCiH6aN5 QpDuu3utk4aXqEyrMhVy8Dg9J/xWuHrJm6dSJfAJYkCr3HN5FmzVUt5SZxszvlJ/0AlJ RXlpznI5YC79NkvWwBLsGjnlxcifGChgAqCup041yqrAupOPzcs/Ioe9y81Z5nYm0inS UoEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0K7xGy5E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y34si3845362ede.64.2021.09.16.09.42.32; Thu, 16 Sep 2021 09:42:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0K7xGy5E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244225AbhIPQl3 (ORCPT + 99 others); Thu, 16 Sep 2021 12:41:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:44670 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244375AbhIPQfJ (ORCPT ); Thu, 16 Sep 2021 12:35:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 75302613A5; Thu, 16 Sep 2021 16:21:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809274; bh=vYKXHe/jFrjiKy5qDGHYMQHLWC/Ba7C/sDk/9okOIKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0K7xGy5E5of2iKXowdeKHAtHSgIlvjPIDaXdHMBN2JjCE5kqEIiESwJCtQvV9IT2r pztAYlywjOpMAWHf9KtaWnEmVeDEddQB+REVO+zG/5BQPXPpoppUki02n4UAcGpLpk FcwILtWwe2zdBEOYWW4LmQJ/h3cJntrGHyVAPmWs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Anna Schumaker , Sasha Levin Subject: [PATCH 5.13 094/380] NFSv4/pNFS: Fix a layoutget livelock loop Date: Thu, 16 Sep 2021 17:57:31 +0200 Message-Id: <20210916155807.230295170@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155803.966362085@linuxfoundation.org> References: <20210916155803.966362085@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust [ Upstream commit e20772cbdf463c12088837e5a08bde1b876bfd25 ] If NFS_LAYOUT_RETURN_REQUESTED is set, but there is no value set for the layout plh_return_seq, we can end up in a livelock loop in which every layout segment retrieved by a new call to layoutget is immediately invalidated by pnfs_layout_need_return(). To get around this, we should just set plh_return_seq to the current value of the layout stateid's seqid. Fixes: d474f96104bd ("NFS: Don't return layout segments that are in use") Signed-off-by: Trond Myklebust Signed-off-by: Anna Schumaker Signed-off-by: Sasha Levin --- fs/nfs/pnfs.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index be960e47d7f6..3ee607aa007b 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -347,11 +347,15 @@ pnfs_set_plh_return_info(struct pnfs_layout_hdr *lo, enum pnfs_iomode iomode, iomode = IOMODE_ANY; lo->plh_return_iomode = iomode; set_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags); - if (seq != 0) { - WARN_ON_ONCE(lo->plh_return_seq != 0 && lo->plh_return_seq != seq); + /* + * We must set lo->plh_return_seq to avoid livelocks with + * pnfs_layout_need_return() + */ + if (seq == 0) + seq = be32_to_cpu(lo->plh_stateid.seqid); + if (!lo->plh_return_seq || pnfs_seqid_is_newer(seq, lo->plh_return_seq)) lo->plh_return_seq = seq; - pnfs_barrier_update(lo, seq); - } + pnfs_barrier_update(lo, seq); } static void -- 2.30.2