Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp842759rdh; Thu, 23 Nov 2023 22:05:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IEBRED/SrpwaT9ZyPSopuvvDD8ykylXIpaGxd9enP3dHohiTa9EJwOljaTrZpr1GrwW3B+E X-Received: by 2002:a92:c265:0:b0:35b:bdf:aca4 with SMTP id h5-20020a92c265000000b0035b0bdfaca4mr2730293ild.7.1700805924204; Thu, 23 Nov 2023 22:05:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700805924; cv=none; d=google.com; s=arc-20160816; b=qRvAbz/7KLlzCMG/1GKq5mydOTNS+vGoIeAT+esUI7LoW+CAYvNuHVqBBHnFwpRCuj CCkEKJa1YFhd9uWsBmfpwhoel+AbHV8xwIVj2gHDXCRmz96JMSzq9pUucBu3Y4gZg2cl KgmqvPYYyszRAK+3Wlv7wllsQfu7lU1SVkKUPb3ZOUqu8qjYbNYQ04980D29c+UxIaI/ +H7pdKqODsSe18sPLnb2YTIIyD7OfKWdE16my1bb10xD5+2xPIRNC7YIZ4PQXIbu8idV +tehbHIIvTytyrOcL5ynzvgjkPKKWUScB4N8CiJHLjq8aZswbQ9fUpHAmjJQY9RLKAbt Guyw== 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=mZvJUgRxfEvEdrlH7O9TVKc6h6Mv5I6q24XfY7mIkN4=; fh=vDsv/0Rb6aybIi/Xas2DR+uQpFXMLtn4no3J1t38V0s=; b=yfXqxlUHN1ZwzpAn+V8SKqv2+v4ymEgYUPpE5N9ZOybz9JUWX0usGK57/7cSiB2cbR lwC9uAhpjx5dwME5G+XcWt2zhkuJlDyZBkiIFLxUXrIyWfJihORyoxd9qSKdY05j73e+ v/w1t8ei7du+E2KSuFoKauXzt/2mUREo3F1wKGJfnamcAmoCy3F0UJslpFXhGbmvDMMM T/yZWMngj3BTfcN0n3w51ysLyT4EQlz+a+9+mJR8S2T4MoVTSsITPxb6I8mta2+2Y4wV 113abCN1SC6x5BqSGXXM4h/fDQmkuex89WiAnKxaDXtXeAWXUyBlVFWkeYHbsQISjows vKsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=iVjIbodx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id r2-20020aa79882000000b006cb82bb5252si2718353pfl.393.2023.11.23.22.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 22:05:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=iVjIbodx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 0B20F81A43E3; Thu, 23 Nov 2023 22:05:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233004AbjKXGFK (ORCPT + 99 others); Fri, 24 Nov 2023 01:05:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231222AbjKXGET (ORCPT ); Fri, 24 Nov 2023 01:04:19 -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 6C15F10CA; Thu, 23 Nov 2023 22:04:25 -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=mZvJUgRxfEvEdrlH7O9TVKc6h6Mv5I6q24XfY7mIkN4=; b=iVjIbodxYD/q7Nt0AI5CVAWDi9 9D4i/vvHdj99R4D+9xtBtQnfNZmvX8Tgro9c8SdXIqnwcuZwgiy+6V8sCONBmXLkomc+0N7R/xwQC W0dHfK1fWGjT9qbcF1lzTuruayGDq7yaPZTIpWLnPJDSNJuI7iv1Mm6zVGYdYnme51Ymh0Am0jH0z VNv07AUe6zq0gyaYAqGLB9AS3AhIzJRdWTniFeBheMmGG5OrgATfN0+hu7bGUyIUDYELMVocEmmPE WrF+LgaBERkJM5OzgeQM9rnMmJA8lJizNthhoHXWMkCM/XBPHJvgC3VxW1V6Zaa7qsKvPN3I9UcXn dz0T0wLw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1r6PId-002PuL-2q; Fri, 24 Nov 2023 06:04:24 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Linus Torvalds , Christian Brauner , linux-kernel@vger.kernel.org Subject: [PATCH v3 10/21] make retain_dentry() neutral with respect to refcounting Date: Fri, 24 Nov 2023 06:04:11 +0000 Message-Id: <20231124060422.576198-10-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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 23 Nov 2023 22:05:23 -0800 (PST) retain_dentry() used to decrement refcount if and only if it returned true. Lift those decrements into the callers. Reviewed-by: Christian Brauner Signed-off-by: Al Viro --- fs/dcache.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/dcache.c b/fs/dcache.c index 0718b3895c12..2e74f3f2ce2e 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -680,7 +680,6 @@ static inline bool retain_dentry(struct dentry *dentry) return false; /* retain; LRU fodder */ - dentry->d_lockref.count--; if (unlikely(!(dentry->d_flags & DCACHE_LRU_LIST))) d_lru_add(dentry); else if (unlikely(!(dentry->d_flags & DCACHE_REFERENCED))) @@ -744,6 +743,8 @@ static struct dentry *dentry_kill(struct dentry *dentry) } else if (likely(!retain_dentry(dentry))) { __dentry_kill(dentry); return parent; + } else { + dentry->d_lockref.count--; } /* we are keeping it, after all */ if (inode) @@ -893,6 +894,7 @@ void dput(struct dentry *dentry) rcu_read_unlock(); if (likely(retain_dentry(dentry))) { + dentry->d_lockref.count--; spin_unlock(&dentry->d_lock); return; } @@ -925,6 +927,8 @@ void dput_to_list(struct dentry *dentry, struct list_head *list) if (!retain_dentry(dentry)) { --dentry->d_lockref.count; to_shrink_list(dentry, list); + } else { + --dentry->d_lockref.count; } spin_unlock(&dentry->d_lock); } -- 2.39.2