Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp800171img; Fri, 22 Mar 2019 08:50:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeK20v+sT3WCSaLJ5KrHsgA6iRqR74yFlbVeZ4t8eDH+On6BHeA9v2wuvwOsaPDbABsn2F X-Received: by 2002:a65:50cc:: with SMTP id s12mr9554519pgp.130.1553269811331; Fri, 22 Mar 2019 08:50:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553269811; cv=none; d=google.com; s=arc-20160816; b=xAzBYd7Z6754wQHEWU5HVUTCFdxuLyNDX9XjfJL2z3QF2RUW+Wm5hsQ6LpflCs28xM ibcBGuBIc0IBwwZXVRFDCUo9K4LbXkNxJEBzfb/bF0uCePAfYsq9wgMSItd+GLPafvaQ Frvv8SRYFsCA+1xAXvKcR0q+gbYqsq7VQVE4WJ0qk+d5QN56ET+YSfqCT8PLSZZ4e80R QxZIfWzZgfQVouXkh9N7wiC9//pDW9/O+rr23qV0KkIkQ0ZG/VdDJFQU0bSyg8DWf88q 8kFHCpqzmTzKC74iID1xtElA9weKrjcexC8H6bYxMM4iFEhmbke7u8otDaIlfNP4n8RI Gutw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=4noY7Nuh+s/BSSVZ6VR1norKp9+TOV1te+aPfu/ertM=; b=1Hp5LpoAHEXxS5iH2Yd27Ic23fH3vVnWW2K6HNJyi+BqA6889jkSoSlyRMd4Gt4Pzr MCjSZSXmpDFUH827U8D4d4h7c7xvNOw9c4EfFl/kmhNGytndCQPztT2fa4pkZNHa1Wew OKqibkMrf/5LTDd+cq7SPzIxoqCs0UO3jNAalv7sTJmTQcydzimcwzamBpQ5hOT/Oxow UZMpSXcHe2PaW+1lDMMBwK9pkoowUbPiQfbBBzcD3vR9oTIZ6FfzQGD2KoECqKYUUhT5 WjgIpmK+s1mzixi2BaIrrCCxeLP3h2cqlGEv0fxB0FmgAAdiPuF5xWlPcd2l0dA7k5D5 nDzA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6si6494084pge.211.2019.03.22.08.49.53; Fri, 22 Mar 2019 08:50:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727736AbfCVPsx (ORCPT + 99 others); Fri, 22 Mar 2019 11:48:53 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:47103 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727169AbfCVPsw (ORCPT ); Fri, 22 Mar 2019 11:48:52 -0400 Received: from wuerfel.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1MEFrX-1hEp4Q01fp-00AE6h; Fri, 22 Mar 2019 16:48:43 +0100 From: Arnd Bergmann To: stable@vger.kernel.org, Alexander Viro Cc: Al Viro , Arnd Bergmann , Andrew Morton , Roman Gushchin , Waiman Long , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [BACKPORT 4.4.y 20/25] Hang/soft lockup in d_invalidate with simultaneous calls Date: Fri, 22 Mar 2019 16:44:11 +0100 Message-Id: <20190322154425.3852517-21-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190322154425.3852517-1-arnd@arndb.de> References: <20190322154425.3852517-1-arnd@arndb.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:d0xlr2K8dEQfJy6mi20uQzl6SrNBL/1a9vz7njWi1W20fXOfw8f GUHCunn54toqlYpKmZF+xbWn2Rb9zfUlYnlvnOB6DM75R1rrzn49oKK/1le/DiOhxaG68zZ qvZOJYAKt4IEkGuvLhENosiVKKpcdULM6Io5PU6pI9Pgeqsdrp1BNMYlb9xlAWy/sXB9cQN bs/inoqlhqiJHdsk1qCPg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:Yq39bHp/YZE=:q+MAwvTwnQSOcoeRAF3q98 PsCIkmtdtFzFVcYkMwg76R7g9q4iuuug4uyDc8N3DTb2T3aPQM9lIsqnJV6DUqjsndCtR5YIT s+PxkL7nYvGQz1e4rgK59SZhrp5z33buPElBD45WbcTKcHM0FbAQSHdpQH202QlQpnONMivfi nr0vmG5hXFPQWsF5iy5h5/waGxiSM6Fxh9s+Xq4Q5RLeXrPrw5MVtaD0qD1/OU7R8mF4eDYdC ySxb+U8dQINIudpPLnbKLtNRuC1lGmVwubX30YxG/zgL0XJhDnve/XWcQfsj9Cqp6tmvEIzKP 6u4n7S28KBir1yAg85+mOE113RuQByb1ecNPO01S4DqOmXpkx3sgAd7whrYD0ubqwLStuG0P9 jKpeZHfr3oM3XBhQLinp26vKLhea+jhStVF/cwLtFXU+XCBIJFLLdZp2RgtNcRdXxb5jlAFs3 JjXsN2gjmG5tXnAXDrmHnXlpixnCCCiSov5F15Hitb7dr+IU816dSUo0+jLev4sgxv2Z5OPcv PRB5VLoPAmkizgHDU+hOk62M1X66Kc9HF3gucww1Rm5VdhtnwpBpP4W/yvExKulmiDgpL7FKP tR2zNFYpY48USqkhOsFeqa0FRnyftBNqJ/pyIRBgrqqgc95pvYJkssj2/Zguj2tfghaqlZys+ 9WSl7XZBUOrkFulcuYKNO1VegmmSPXQZR7g/DHByq5jSgDKBBe8z2PepYZ17ukoNnMWFxww47 +Ug19tpB1N+oQn7AIZn6JbNDH2hYRrb0rh9mlQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro It's not hard to trigger a bunch of d_invalidate() on the same dentry in parallel. They end up fighting each other - any dentry picked for removal by one will be skipped by the rest and we'll go for the next iteration through the entire subtree, even if everything is being skipped. Morevoer, we immediately go back to scanning the subtree. The only thing we really need is to dissolve all mounts in the subtree and as soon as we've nothing left to do, we can just unhash the dentry and bugger off. Signed-off-by: Al Viro (cherry picked from commit 81be24d263dbeddaba35827036d6f6787a59c2c3) Signed-off-by: Arnd Bergmann --- fs/dcache.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 9ffe60702299..cb554e406545 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1510,7 +1510,7 @@ static void check_and_drop(void *_data) { struct detach_data *data = _data; - if (!data->mountpoint && !data->select.found) + if (!data->mountpoint && list_empty(&data->select.dispose)) __d_drop(data->select.start); } @@ -1552,17 +1552,15 @@ void d_invalidate(struct dentry *dentry) d_walk(dentry, &data, detach_and_collect, check_and_drop); - if (data.select.found) + if (!list_empty(&data.select.dispose)) shrink_dentry_list(&data.select.dispose); + else if (!data.mountpoint) + return; if (data.mountpoint) { detach_mounts(data.mountpoint); dput(data.mountpoint); } - - if (!data.mountpoint && !data.select.found) - break; - cond_resched(); } } -- 2.20.0