Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp843643rdh; Thu, 23 Nov 2023 22:06:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IH+xu2fr+0AT6AISGN5uj5yb6VD3v3BN5FRy6UGkX+KSMpVHsOgEixSEt/3g56/hGt9HQ3G X-Received: by 2002:a92:cd8a:0:b0:359:582c:c96b with SMTP id r10-20020a92cd8a000000b00359582cc96bmr2587293ilb.25.1700806017710; Thu, 23 Nov 2023 22:06:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700806017; cv=none; d=google.com; s=arc-20160816; b=f3K+n6ErCuzDBevZsBWd+9pQx7pNO/L1KGul9IoT1E5rjYhk+Tpp/tmNwJWQ4FeJbn hCiIpa6fzdP3C9fxee3Ikh2Z+QcqK+GFDctzg/ibpPLg/EJ16gfJy93kTtLRSQam9bTA ZfLV6vJuwV8R781lUWtST+KPHGjkhHGuIhaA819iK4aZBzKTF9EzWNQp5IZAZ5vn4gac 5dB51JGu9v0548rzvOuqK2iGfJu/tDVLCTUbmiDSEgzHurMwl2oIppcmjxfgF454iG/V eXvbbrXpiB5sZY075+br+oBba4IqnlGEzoD/4KE5JuxBdJ7VsEZ7i27sggSe1cTg39v6 zMtg== 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 :dkim-signature; bh=8RRk+S2n/uw/+Y4R6e9tnmBokKLdxLRo06V3rJC510w=; fh=vDsv/0Rb6aybIi/Xas2DR+uQpFXMLtn4no3J1t38V0s=; b=yDgcOR40K1MUqbERa0uUXZw/b2ELCKmyyWydQNFBacLLn07tbeixZmkpoB15jn1mRM 0DER3sKilzvSv3lynFZgOSHKD+bEAKWyl1am5P9x234ezsxmH6JXBkx1PJEqMX708RJr no69JSpbfj4momGMG/q9H943eHuiVprv9GzJd8gGQ3PWwOOOaXKwUabYvs4hZ15qmu9m byfqSUTUDseXC5olIQyeY1XI3k3cuK8RMxMODIWtnojeV0MXMAFHX/EMmVAC9VVVyXaw nYIFBKvfWFPlsNeXDYwPRTTXhyQTX4ULXnLUZ+Q9PGVTdcvatOInrwvldezP+QskwIR1 FcTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=cXc+PzGv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id k72-20020a62844b000000b006cb8c11d641si2832187pfd.53.2023.11.23.22.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 22:06:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=cXc+PzGv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B8D218095DF0; Thu, 23 Nov 2023 22:06:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344808AbjKXGFk (ORCPT + 99 others); Fri, 24 Nov 2023 01:05:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231478AbjKXGEV (ORCPT ); Fri, 24 Nov 2023 01:04:21 -0500 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7D6DD6F; Thu, 23 Nov 2023 22:04:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=8RRk+S2n/uw/+Y4R6e9tnmBokKLdxLRo06V3rJC510w=; b=cXc+PzGvTnLdl+fV1c3J1aMKt4 VUuI5hMfOehEIHZRdqFKT0cGImgrnUYLFpFBeZz0YghHlllPzM5a6a8j+XK1Jn702DoSYibWB5J6t e+cjDQ5UPG2DysKIR3D4/GGUFbFltx3Et8i8FB8k/t3xNPd8iukMAzefu3jfwvFU+zHnOj0pFtrCP WCxBWdECMfKfOg6181QJHKDSldgAnkb63P28c8oeJTwb6YWFOBRLVAXDLjmHhi/3YLgD2ab+YQGQt VF4yomOVzT58cZSgurHJjgWC4sKIsc8AlCytZwOkuVUwIWOu3pN28YyTPVAvSaSBo701jtj+jkf7q 8EMZW+rw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1r6PIg-002Pv0-0Z; Fri, 24 Nov 2023 06:04:26 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Linus Torvalds , Christian Brauner , linux-kernel@vger.kernel.org Subject: [PATCH v3 17/21] to_shrink_list(): call only if refcount is 0 Date: Fri, 24 Nov 2023 06:04:18 +0000 Message-Id: <20231124060422.576198-17-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231124060422.576198-1-viro@zeniv.linux.org.uk> References: <20231124060200.GR38156@ZenIV> <20231124060422.576198-1-viro@zeniv.linux.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Al Viro X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 23 Nov 2023 22:06:24 -0800 (PST) The only thing it does if refcount is not zero is d_lru_del(); no point, IMO, seeing that plain dput() does nothing of that sort... Note that 2 of 3 current callers are guaranteed that refcount is 0. Acked-by: Christian Brauner Signed-off-by: Al Viro --- fs/dcache.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 5284b02747cd..704676bf06fd 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -915,8 +915,7 @@ __must_hold(&dentry->d_lock) if (!(dentry->d_flags & DCACHE_SHRINK_LIST)) { if (dentry->d_flags & DCACHE_LRU_LIST) d_lru_del(dentry); - if (!dentry->d_lockref.count) - d_shrink_add(dentry, list); + d_shrink_add(dentry, list); } } @@ -1115,10 +1114,8 @@ EXPORT_SYMBOL(d_prune_aliases); static inline void shrink_kill(struct dentry *victim, struct list_head *list) { struct dentry *parent = victim->d_parent; - if (parent != victim) { - --parent->d_lockref.count; + if (parent != victim && !--parent->d_lockref.count) to_shrink_list(parent, list); - } __dentry_kill(victim); } -- 2.39.2