Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1531776pxb; Thu, 16 Sep 2021 09:21:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAyas85z6qNxIm9AG+61oywvnwcyLtOdCjxp0bNVNaHmANsDuSipBct48oZQ4xplucwpRz X-Received: by 2002:a05:6402:13d0:: with SMTP id a16mr7278777edx.155.1631809267124; Thu, 16 Sep 2021 09:21:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631809267; cv=none; d=google.com; s=arc-20160816; b=i93/NEDS48qGnV+R0E5KXw5IYcweFkSM1SQHl0reYsRa0LMy4IV+LbDfxttU6twfZC duK8RsJLXIvBJSN1hfS6BJJVtgqFaplWBrW0kzZmw5takkTbZkOdT0ceFDUBBsN5pO1u 8aFneRokUiWNM7kSwx/iTIpx97RwPijDo/sbzkfdHpNaAIRQVVp+4XdGIUdwT/HG6rVR Yijt+P5nbEpFyFGaFKvs85Hk22PeuhvyJ0rf9Df8jh0ABTuQ97xeyPXTsqiLxINdbksh hMPJUadklzCul7lTcxQJy/DfKn0Dj6M0RcvpEouYubPb57WPNCGDx3tUjmi3JxrwGgQk sc+Q== 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=9I0YoC8qx6pwwuXjQ2sYA6qh4hiiGG24KwtPQLrMgAc=; b=C7mFcUb6+rzrIwwdQ/B+o5lYqr9kGwMWkkXJGeYupYW/2GBdxBu5JZbMJL+NTT2xIO wfeoOIskj0s1p14sybgs4jf3bSjYy6wgQOLRmWyeUGMkdm6JSV1kuquYovq/qCGS+FuR wP2SAw2LOFQlTAb7S+e881V5immLRrL7A1Cm3NM4hINju0t+eAFOJGLZbjyMWuYeQwrd YAzzCEFlkEhAirmYc8qu6UYYyh31aW6cTV1BIbbo5d9ru5IFfYJt+YuqHnuiSpQlJh0Q yI9K1b9ZBldGEL4dM166pcy+5WSwJyTuZHExM+/j1Hap2ZZtVywSiQc+KhXewCGyTbGE eLXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FzMLl3uU; 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 de4si3792091ejc.615.2021.09.16.09.20.38; Thu, 16 Sep 2021 09:21:07 -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=FzMLl3uU; 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 S234681AbhIPQRA (ORCPT + 99 others); Thu, 16 Sep 2021 12:17:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:48798 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233875AbhIPQJg (ORCPT ); Thu, 16 Sep 2021 12:09:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 001866121F; Thu, 16 Sep 2021 16:08:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808482; bh=xSsEDJEwwJBjoM4dE0gI3zg3DShnLOHtZluEATll+rc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FzMLl3uUocE8DqpXhsuzmeBfbOCym+1XFPHmL25i812YmpwdhfTL7YSuk4yZmrkCu g7VOz6mPziSx0ILX5qdRclqNmyb2GETOl4nKD0Vi++bGXAJI5B+1jfT9KUSEHUjW1Z bLOOV2hSn/6zHm50+MkPcVtgGrwPmWUI7HdwlIMQ= 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.10 075/306] NFSv4/pNFS: Fix a layoutget livelock loop Date: Thu, 16 Sep 2021 17:57:00 +0200 Message-Id: <20210916155756.616367382@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@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 371665e0c154..fef0537d15b0 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