Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp842433rdh; Thu, 23 Nov 2023 22:04:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFROls056G7FvJxm6FI0N+G1+fznlPO3Cagk9qu1EQIO0sNqVHn53EQfznyCmdxPb0+7oYr X-Received: by 2002:a05:6a00:23d6:b0:6cb:8c70:47c3 with SMTP id g22-20020a056a0023d600b006cb8c7047c3mr7809839pfc.0.1700805897033; Thu, 23 Nov 2023 22:04:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700805897; cv=none; d=google.com; s=arc-20160816; b=K4bitUQHXCAd5sneyycJlt7aPng+JXaqthnu3dnDe+YdJlXi56+EjwIy34tnnsc1lq jAmfwXIweA7zhYvm07hKTNCm/GTJ14trNtu0osCOFyEWcKQ85FjUhViXI/EMY1XATJ6V /vkjjIO8jZ+jcxVaoHXDS4gLlf+e9UxWlSePR3IfWVEm+EwKvmDD7M+yTtZ8b5LbI2xK qAW/I4YVIz0XSD3T+lmXM2uIdSjnG6aKZ0CXTCkfvdX33izPQ/to4SqRKWonID8VpC0H p2oB8CZsONwaiG/h2d07pWcUqQhnu/945mefhiF4pAL04OJSxZ98T5tAqdHmnYvSIJpW BGXQ== 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=YQd0sVENc8vNXo6fQBPFKWdKkcW/WYyDOS5A5P7KNmA=; fh=vDsv/0Rb6aybIi/Xas2DR+uQpFXMLtn4no3J1t38V0s=; b=a7oPxGciA0+2SnwXddXnmt6p3vhpKc84XG4h1CqgWcyL1EBs+j7/RwtX2m0iC8wlrM AzW+3wGQEtiEh+3+WOG3Yi22rQcCE/jdL0Ii5TB8xspJW4rh1hQT9FY1AJW+IKFY7Yz0 XqybV50wkFQrR7W/fbfjLLJa66LLyUAfQuqCWsgFjl8gmK79IDo/qdi+x/7gqodwd5Nh Tpr3O6WJq5awN9KB80fZgazNVglCdPBhpkafiDIXVYYp8WCufc9894UZx3bfHufkBJK0 FvEz9We0i6coVEG+NNR/pA0lGZ2kf1Ge/p1UiQ3VsXO9776bQdiKMEC6inSMkPkAShPH nMcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=pumoDACQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id u17-20020a056a00125100b006cbb36b9060si2955095pfi.385.2023.11.23.22.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 22:04:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=pumoDACQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 2093E809C436; Thu, 23 Nov 2023 22:04:48 -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 S231221AbjKXGE2 (ORCPT + 99 others); Fri, 24 Nov 2023 01:04:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231169AbjKXGES (ORCPT ); Fri, 24 Nov 2023 01:04:18 -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 539EDD73; Thu, 23 Nov 2023 22:04:24 -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=YQd0sVENc8vNXo6fQBPFKWdKkcW/WYyDOS5A5P7KNmA=; b=pumoDACQA2Uo0ujIWHZBRBpsgm CZIGBoegoxuq/d30GAq6Pi5W9phVZkI7LreLbyXIKup34Nd8DtH9JcV8CyglqU0JPfXFNfEr8vYZD tOUh404G2VjiwZG4fn9moucUogjH5HFCkaGYOrzlSSBwY1Gt8Jc4Vy8larIdFXnzqT9uQ6wRNbwmU GvjuGMEnaozVB/LnO+/w5Pdx5x9QyD+G5vwl4EmeGHg5kWYkvEavOcPWbQ3RAjqWg3z8vpEgcrdxZ uK/ARVrauObzOsxj0o2xrC7b2PtjuPv7LhwAozlxKTcYoSU6UphF3qmv6pWeAJdEaH+oDAjx/1BZk KhJHS4GA==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1r6PIc-002Ptn-32; Fri, 24 Nov 2023 06:04:23 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Linus Torvalds , Christian Brauner , linux-kernel@vger.kernel.org Subject: [PATCH v3 04/21] centralize killing dentry from shrink list Date: Fri, 24 Nov 2023 06:04:05 +0000 Message-Id: <20231124060422.576198-4-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:04:48 -0800 (PST) new helper unifying identical bits of shrink_dentry_list() and shring_dcache_for_umount() Reviewed-by: Christian Brauner Signed-off-by: Al Viro --- fs/dcache.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 59f76c9a15d1..bb862a304e1b 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1174,10 +1174,18 @@ static bool shrink_lock_dentry(struct dentry *dentry) return false; } +static inline void shrink_kill(struct dentry *victim, struct list_head *list) +{ + struct dentry *parent = victim->d_parent; + if (parent != victim) + __dput_to_list(parent, list); + __dentry_kill(victim); +} + void shrink_dentry_list(struct list_head *list) { while (!list_empty(list)) { - struct dentry *dentry, *parent; + struct dentry *dentry; dentry = list_entry(list->prev, struct dentry, d_lru); spin_lock(&dentry->d_lock); @@ -1195,10 +1203,7 @@ void shrink_dentry_list(struct list_head *list) } rcu_read_unlock(); d_shrink_del(dentry); - parent = dentry->d_parent; - if (parent != dentry) - __dput_to_list(parent, list); - __dentry_kill(dentry); + shrink_kill(dentry, list); } } @@ -1629,17 +1634,13 @@ void shrink_dcache_parent(struct dentry *parent) data.victim = NULL; d_walk(parent, &data, select_collect2); if (data.victim) { - struct dentry *parent; spin_lock(&data.victim->d_lock); if (!shrink_lock_dentry(data.victim)) { spin_unlock(&data.victim->d_lock); rcu_read_unlock(); } else { rcu_read_unlock(); - parent = data.victim->d_parent; - if (parent != data.victim) - __dput_to_list(parent, &data.dispose); - __dentry_kill(data.victim); + shrink_kill(data.victim, &data.dispose); } } if (!list_empty(&data.dispose)) -- 2.39.2