Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp886322rwi; Mon, 31 Oct 2022 08:40:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6+7wn4HycXAQs6IV/ppsfyOOASCj/kzbfT8p71D47rX3cGNOQTaJtJtRwDYv4c83o5GWiZ X-Received: by 2002:aa7:c7d1:0:b0:461:2a82:497e with SMTP id o17-20020aa7c7d1000000b004612a82497emr14468689eds.267.1667230852976; Mon, 31 Oct 2022 08:40:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667230852; cv=none; d=google.com; s=arc-20160816; b=ZNDvY3O4TNJlX+TB3jbADuH42WDo0sS7AZEivCTEtL77LnJ34uWpouu/s5u6dHuPQN O08k0TpBpA914DSoouR20jf8HLCua3u0z7L2Zow3TCXsleYw5LT6ZyFtnDXPZPjoSV/T OLS/8JIGeHW20TBAjuQtGQHtTeK4Dv+hMYJoBkBHGA2rWDUgrBjXdP74GWvCrsMmWHKW UcZdwwLbWy1SB65O1l+d/g8PgR5/mmFWN+OOfMjdQ/tnHIpZoEsEouEgC8OYJr2XLKUJ VsDRCo5FtWBzd+5Bd6yrauXBsk65JpUbKjP/KwJW2ieyn+Xu7qySBS2MKCU/eMkC8dho x9jQ== 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:cc:to:from:dkim-signature; bh=hlxOvxZlOECqQGkUUppkps5g8tHRBrgYN0lMYEMIZmc=; b=LAgZeG8kWMC4ge5KVU1r6MLVEwJ74fiFNtxuKD9HIzw+xSR+s/VTXrVVclo5Tgl0y4 LKB7zK0aQ74GVWZqKXmLpMy3+v0Y6nngHbcxieucGnK+T7zG6gNmAFRtgHJh93vyrU0c OztR1EkZkeRle/eWJdhT40cdYMw33eUzK06yHFcqMsSogblPnIt6691QrxLsuVaEjRkU jxuVPd7fu+bNW3HFEMCjkK0r5zreyAl7EGMldji9fEyIzuPdl9oFoRdRo3a/YU/VpXt/ Y2xKehg8ix1oS+4DO4bU4Bc1ve41Et+ExRujAeJH91UTRIBaQkVwcjRm1JOK9Mb+p7u/ q+UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oVvdeWPx; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hz5-20020a1709072ce500b00781b66e7065si8741837ejc.240.2022.10.31.08.40.17; Mon, 31 Oct 2022 08:40:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oVvdeWPx; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229787AbiJaPgC (ORCPT + 99 others); Mon, 31 Oct 2022 11:36:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231888AbiJaPgA (ORCPT ); Mon, 31 Oct 2022 11:36:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEC416575 for ; Mon, 31 Oct 2022 08:35:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7A506612AE for ; Mon, 31 Oct 2022 15:35:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B6ABC433D7; Mon, 31 Oct 2022 15:35:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667230556; bh=7Cimu96ndPeJ50Hetw9q5aYq10IbyynP4U+H5c2Y8C4=; h=From:To:Cc:Subject:Date:From; b=oVvdeWPxC8hDpxSnqgrAaD98Wy0VPJPGPHXXiXH8Fgs/DlwLK0NvX+JwFaZajYRVc AkiQ+w5tXExkpdV2VKkpWqX5rC3vuYCg8wE1HUaeYADpOm/QhAQLiIB+kptWXd1jwi CGti90HUUCN9yVuvI/q9BY8UpTr9Hf/3SKRMMctjzPcYwoTAyYDaU4F2dHz9xyVJpM RPS16LaJzCIxnGGVU0waLXB+DUtPrx/5m92FezZLCGCCRXuNpZuwTuMJ0bhxWw7NsU CuhWKcwPSDUkV8cQFYFp1BgiqwFQ+rPTBrCiz2RKBhQQJvTUzhArUzi+JAZcnMj/zv Gcj3lUxif0sFQ== From: Jeff Layton To: chuck.lever@oracle.com Cc: linux-nfs@vger.kernel.org, Petr Vorel Subject: [PATCH] nfsd: fix net-namespace logic in __nfsd_file_cache_purge Date: Mon, 31 Oct 2022 11:35:54 -0400 Message-Id: <20221031153554.498442-1-jlayton@kernel.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If the namespace doesn't match the one in "net", then we'll continue, but that doesn't cause another rhashtable_walk_next call, so it will loop infinitely. Fixes: ce502f81ba88 ("NFSD: Convert the filecache to use rhashtable") Reported-by: Petr Vorel Signed-off-by: Jeff Layton --- fs/nfsd/filecache.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) This should probably go to stable too. diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index eeed4ae5b4ad..f9ea89057ae8 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -908,19 +908,17 @@ __nfsd_file_cache_purge(struct net *net) nf = rhashtable_walk_next(&iter); while (!IS_ERR_OR_NULL(nf)) { - if (net && nf->nf_net != net) - continue; - del = nfsd_file_unhash_and_dispose(nf, &dispose); - - /* - * Deadlock detected! Something marked this entry as - * unhased, but hasn't removed it from the hash list. - */ - WARN_ON_ONCE(!del); - + if (!net || nf->nf_net == net) { + del = nfsd_file_unhash_and_dispose(nf, &dispose); + + /* + * Deadlock detected! Something marked this entry as + * unhased, but hasn't removed it from the hash list. + */ + WARN_ON_ONCE(!del); + } nf = rhashtable_walk_next(&iter); } - rhashtable_walk_stop(&iter); } while (nf == ERR_PTR(-EAGAIN)); rhashtable_walk_exit(&iter); -- 2.38.1