Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2639541pxa; Mon, 17 Aug 2020 15:11:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/lerYWPTx3C0V8J5M9Ksgq3xSoNerQRKwBhoQyIdPd+KiTHH86JwR82tXjXtgzEJGpqcz X-Received: by 2002:a17:906:430b:: with SMTP id j11mr16882273ejm.270.1597702264102; Mon, 17 Aug 2020 15:11:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597702264; cv=none; d=google.com; s=arc-20160816; b=mpwPl+/5ks1DQR+gCPqQL6FlrOeFxa6x+Zwp23sLzJBhH6gMiRRaB/OKoAhDlZ4dCf johHHNNBsk6Fg03RHE8e4xenJ8TQ7fINa3cgwdxF6uld6y8fW2IO34crIKIl8U8ku/A9 SsjHahze2mN+fZJeKtsXp9jIaPpL4LGT3u1cg+O3ptM6GMYYaS8sWjt1QbRYPyFf1mXM 9oD17qE/T8OueRlQ2tjuxdLdJ6aLQ0n9RGX5jpMAFur1iS1ujjOpntpEOK9LzTd1Z57T rQy0qDMvobSksE8XDKpvdCSSXKOPr3M2kMGjsAiFKhj/QSsuP9TOJ614PLp6Rl9/AqeS 1WEw== 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=tmMZx4a1RASD7/oUMHxY9KnbaYZVOyFXZcz3riU6BAY=; b=TcXDTWR2XqVRV/IKJUkVZCbc3fqLbqq/uzlOc7mlpEh1wob6ZIDSo5zBcrHWnBTO3K HeDqgdO0NpV+LNShcn7qfnnBSVxwP1K611Vw049eGKcvjhQb0vDmA8dXqxT5YNobVzrO pIHj8SMW1wkMhan3+XF2R2fGiG9m92mkmz092c4RYGaQ4NZQdATKYlXSKI+ftTj85prN v/q3+fk2rxuNMrOKOYlfJXmqUzsCak26uDkIOdqkSR86KAceknrnAnZDeCysJqiX3Ddz th9b6VrqEym8O/ZmiGaDQnnRv3f9Vt30AsRlOHb+/+SEwyz2QFeU7tjXDRfc0tgcLsav c8VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cfP0FwTD; 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=fail (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 j19si11856429edr.368.2020.08.17.15.10.40; Mon, 17 Aug 2020 15:11:04 -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=@kernel.org header.s=default header.b=cfP0FwTD; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388790AbgHQQnQ (ORCPT + 99 others); Mon, 17 Aug 2020 12:43:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:46416 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730950AbgHQP7L (ORCPT ); Mon, 17 Aug 2020 11:59:11 -0400 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 3B57D206FA; Mon, 17 Aug 2020 15:59:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597679949; bh=VxGE96xVX8mqRT56wQqLgk6r5LrYyc4XB8oho4I7MnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cfP0FwTD0yGxVyDnAPqGRkNwObxSesZlCsAlPMzdraqFzUYvI4HEB2MgKxmDFDJtS EUSwMKDszRUm74RZTkHGigy1r8jh4R9DRFJkhULvS7YTUKzh2R6ysUtLVuUjOchLhl mbYWn57DFAD1jDYf48ObtUVmG7AcGL8IW5AM9+EY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust Subject: [PATCH 5.7 359/393] NFS: Dont return layout segments that are in use Date: Mon, 17 Aug 2020 17:16:49 +0200 Message-Id: <20200817143837.016330666@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143819.579311991@linuxfoundation.org> References: <20200817143819.579311991@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 commit d474f96104bd4377573526ebae2ee212205a6839 upstream. If the NFS_LAYOUT_RETURN_REQUESTED flag is set, we want to return the layout as soon as possible, meaning that the affected layout segments should be marked as invalid, and should no longer be in use for I/O. Fixes: f0b429819b5f ("pNFS: Ignore non-recalled layouts in pnfs_layout_need_return()") Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Trond Myklebust Signed-off-by: Greg Kroah-Hartman --- fs/nfs/pnfs.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1226,31 +1226,27 @@ out: return status; } +static bool +pnfs_layout_segments_returnable(struct pnfs_layout_hdr *lo, + enum pnfs_iomode iomode, + u32 seq) +{ + struct pnfs_layout_range recall_range = { + .length = NFS4_MAX_UINT64, + .iomode = iomode, + }; + return pnfs_mark_matching_lsegs_return(lo, &lo->plh_return_segs, + &recall_range, seq) != -EBUSY; +} + /* Return true if layoutreturn is needed */ static bool pnfs_layout_need_return(struct pnfs_layout_hdr *lo) { - struct pnfs_layout_segment *s; - enum pnfs_iomode iomode; - u32 seq; - if (!test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags)) return false; - - seq = lo->plh_return_seq; - iomode = lo->plh_return_iomode; - - /* Defer layoutreturn until all recalled lsegs are done */ - list_for_each_entry(s, &lo->plh_segs, pls_list) { - if (seq && pnfs_seqid_is_newer(s->pls_seq, seq)) - continue; - if (iomode != IOMODE_ANY && s->pls_range.iomode != iomode) - continue; - if (test_bit(NFS_LSEG_LAYOUTRETURN, &s->pls_flags)) - return false; - } - - return true; + return pnfs_layout_segments_returnable(lo, lo->plh_return_iomode, + lo->plh_return_seq); } static void pnfs_layoutreturn_before_put_layout_hdr(struct pnfs_layout_hdr *lo)