Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2652235pxa; Mon, 17 Aug 2020 15:34:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOE7O2gMmttUKujcuDqwB6J363lIkhbg4FjTKP+P5MdfOd73AxaF0puf3wqHzLaeCSENP2 X-Received: by 2002:a17:906:fa19:: with SMTP id lo25mr17140001ejb.456.1597703647569; Mon, 17 Aug 2020 15:34:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597703647; cv=none; d=google.com; s=arc-20160816; b=s+nrBh/csN/KK21UKMC8nJZlKK84Xpa0Zxur+bk4eNRwvChGzeQjSF/3dvlrEX95kh DArxVfY/37VPVyeDGJCvOkObcSL2QRjIcJiY0Bhgqd9tmxu4yrI13HzZS5Zv8EhTLpNw pVpF8a3xZHC8uCm31aCN4k8/rOXag0cehT1L3C63xGAWqLeToqZPC93MqDLzWunrxD8O huT0XdMI3iPYMyGYDsMH9Gd5rFsIJiMA8JxFe1YVaZXgf6S7v2f60TrhhRwaw55HXbFN x7YRfeAXT4qo+YkZDHeLyQeK4xyxlEMNhBHgWSi31EPwAShb+zRK6ao+AA3EiJ10RbHc tMrw== 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=kC7cmzTbMjU182F9dMfMe4slm0wBJ59S8C7efEfbe0A=; b=B+eFluNztz1T6oLlQqLhd4uPSwvc2XxEe91k6feYNM+Ns4ZmlmgAfhU8nbt1lXl9wm m3kwisJYKM/hSHu+JdMduKxYkVgrLjrcMykqxisX5U5LBFvJ4IL+BwE/OxZFaNtFtJCA 0G4BbshpcbO8DqfmAt22Nx2RB99xIiAUO1uxn9zkPGDR5VexA1bXT3PfFYIBSpRTPeSD 9fXpNf9l6z2gf0gq344xrTiMTDYbgi9lSNKbFxaqF7H8SID/B9TD3Hw1PyOjKpgLTWxQ e3rmhi/M49Zs+5ibbrraJNSWN8Qvn54eA88GZabaB12cN6BshqfOghOPKzWr/dF2UyoO kpRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=smtnGIpF; 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 b21si12177818eja.19.2020.08.17.15.33.25; Mon, 17 Aug 2020 15:34: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=@kernel.org header.s=default header.b=smtnGIpF; 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 S1731360AbgHQRFE (ORCPT + 99 others); Mon, 17 Aug 2020 13:05:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:60452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388507AbgHQQJ3 (ORCPT ); Mon, 17 Aug 2020 12:09:29 -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 46F4522BEF; Mon, 17 Aug 2020 16:09:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680567; bh=3ZUdMGNGVtzVHRjFEW6QRWy7L4pih5J5PASz2rAOfto=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=smtnGIpFbHk9zsVOVui9ykLgzU1tRkDBmxjb86VvNruYBUY7BgFCFNbwuSxnKWTih rybL8mzqKC81VpxspGa4gn6qv62A7ixh9ndcHYgYdtxvwI8iE1mVP+Uw+H88SHZo/I WGkVdUMA1uuDkOK3+X9UfhpbJaogqyW6NPHj1hWY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust Subject: [PATCH 5.4 239/270] NFS: Dont return layout segments that are in use Date: Mon, 17 Aug 2020 17:17:20 +0200 Message-Id: <20200817143807.711054341@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143755.807583758@linuxfoundation.org> References: <20200817143755.807583758@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 @@ -1198,31 +1198,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)