Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3467076pxv; Mon, 26 Jul 2021 05:00:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyjZt2U30jE9dTi7/QBLrdxGRIfDoHGWi/NI4d3InVu5aEGE1sXMPubzyMNxfjvnY81QY4 X-Received: by 2002:a05:6402:54d:: with SMTP id i13mr9992759edx.179.1627300836153; Mon, 26 Jul 2021 05:00:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627300836; cv=none; d=google.com; s=arc-20160816; b=W37KW86Pp3/WRgqssak6nBuNSwtb9oPoj0x4T7lGEz/GjTMRqJzKdVOQLm3iuS1l73 /SmafjglX4vCuPJCCNQQXTs655lk4oLVUvn39+KGHBofhj0nCPKaEl/AT3tqw9oxqExT P0YeVv1bowzhyF/oGB/eRAJ3bspeXl4DEfewNSeUIBWmpd8drqxs1g2oV34U1St0YaOy gcKSuNCJuTemo3UD65fcdEiVVlNm+VBi0fHcVbBCQR26NhQCcLIshZOsp0sXEuRZ45a7 iZmGvGW8sli/p9BVhleKbg3DftyGp0eK713feEP/N56OGzqEti+6xYva1nxhCTP2i1zC +WQA== 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 :message-id:date:subject:to:from:dkim-signature; bh=1BxxQNYb8SOLG5I/awSsrjOrKtDikzA1TI24SILLwKs=; b=cKkTc0JUElVXqRl0NBg1Ov0WDZ8HucLcyePkBgFfebpvW20LEbpRjMDn9eieBHZibX AmRW88O/asHizYn+HlKW8hb/qbz51swRwhmVsoQnfpvBc5IT/plOxMYwqrIgFvwqrN3f 8fvF1geu4krSAckcUfofk81WVK1PumRv5KndI7usr2nm28Rf9pyDJS/+jdT/cJS7DRgb tdadXtitTDmJ6UIpDVaRmkXIwOQE7v8HnNAZ8iTnw/DlidxW6BIgdVkEhm0WntqYrV5C Q4PjA5IGXTN5InJS0QlBEHXnbrxipH0s8a8iIgPgdkI/V8RsdDiR/mU/XARxuWl/n6PP Nzcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mi5MCR9u; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w11si49991444ejc.453.2021.07.26.05.00.13; Mon, 26 Jul 2021 05:00:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=@kernel.org header.s=k20201202 header.b=mi5MCR9u; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233812AbhGZLS4 (ORCPT + 99 others); Mon, 26 Jul 2021 07:18:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:37456 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233819AbhGZLSx (ORCPT ); Mon, 26 Jul 2021 07:18:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1840760F38 for ; Mon, 26 Jul 2021 11:59:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627300761; bh=MMfyyZxqw5O4APMcwE3iA/CIXTgyGAHHU/8qhpzkU54=; h=From:To:Subject:Date:From; b=mi5MCR9u94xATS+xXYAZe5gPrLDNxs0gWjIRmiw5OhTzS1Oa4Y5n2bk+DInhIVowd CNVReQQJY3ufyfR3S+zlgVK0Em5ojs+o7KzetDgrS5eqPj9K2VA8uE+PN5xzZTJsPm TNfjb9C8Jg5r4BBxHRklg/OEqsNPhj3WwSGB0JexC7kzuGxSiS7Nj2dIKIBTR+V90j 5gLbiuTmmMPPWw1REZ81NohVdZIOGweHUhnTGgQ4YRwqRzuGm/rbhkXnGR2m7zmxqg LFskn5AtQVkQCc5HPylxAxYqz+m/uP3KXZh0sTyrtDV/5+a1SfHnC6eEOkCwtr+fnk XcEEjpeB6TG4A== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH 1/2] NFSv4/pNFS: Fix a layoutget livelock loop Date: Mon, 26 Jul 2021 07:59:19 -0400 Message-Id: <20210726115920.8518-1-trondmy@kernel.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust 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 --- 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 4ed4586bc1a2..51049499e98f 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.31.1