Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp844063rdh; Thu, 23 Nov 2023 22:07:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IFL2oL1VZmh+jCYE8zIpJOuXoDU+JE//rZCs6DKfWiL7s98f1o3KTgGF2SNPyVc6hPjpe7K X-Received: by 2002:a17:90a:e7c2:b0:283:27e0:652c with SMTP id kb2-20020a17090ae7c200b0028327e0652cmr1643638pjb.43.1700806064494; Thu, 23 Nov 2023 22:07:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700806064; cv=none; d=google.com; s=arc-20160816; b=1Kcy3irT3uZvUl3CO7mNwbyWVUhpKy7FqcyPGlJe9s2YCkO1ZQks3U4d27rYjZx3E8 F2Cbz6z8C6TAJ+9OnZZY7+yxyTUxKmcZhHmAUgIxpwe/o9z6Ikx22TEqPWaGdoBc5teq AY4Htq4o81ZFUfMNS0pGBA5cX6YopeSG3K/3x7Xtna8GwLk3MbM9PMq8DdQuMUVEXO/4 VP09dk/lJDymOC8gLqxuX24JxQ2hlkgVb0J62AAGMrU78PFR6S3NvsbwcmX6ZtCejvlz LmC+B3FwWiigzHZCMTxfgRMDeJ8AoHeedWDX77KqXZEtcL6nmihLglJBTyJv1peKM/ly zxmA== 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=87MIlCCmIaOxd94yAXrGBYoVc4Rj/Kyxm+zk/qVQJ28=; fh=vDsv/0Rb6aybIi/Xas2DR+uQpFXMLtn4no3J1t38V0s=; b=M23P7fnDDUmXujim31y5fPs05rohhk+WlyVnWBbGmr5SswIzYoyhaeeyPssH28jBe1 kwwcjlEOjZYGSA1Nvi9xCerG9IqaYOI8FX2eseTLhmtceSPVEBZ0223XidFBsMWo7hIm FfkrPQf/zTEms59SOqe7zIuW8wZjq2taXMCKIiH7MaTyrdpMEEZa9eK6UFKYbL3zl9j7 r9fWMDZw0mhAidsoEExVrsdG598IuBLYLIZWeuoAwVvQitWklPYiSx+7lth7+NH0dmUh nU93OWEsb08ZxWGRdUgKszhc7aXK7+NttROmtwST24Ds4N5AOlCv9ergWUBluSuHyn05 dopQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=SXf53u9P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id ca32-20020a056a0206a000b005be3685c1ccsi3240939pgb.567.2023.11.23.22.07.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 22:07:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=SXf53u9P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id AC5A383642A0; Thu, 23 Nov 2023 22:06:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231777AbjKXGFa (ORCPT + 99 others); Fri, 24 Nov 2023 01:05:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231466AbjKXGEV (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 61A3D10DC; 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=87MIlCCmIaOxd94yAXrGBYoVc4Rj/Kyxm+zk/qVQJ28=; b=SXf53u9Pl78qZ54zn362BHY3Iv SVYVUc4MqyLjILlzQN9B7dfqKIGeIjuhs+pya1X9gWtyEltTbTdNcyFJdXT+39q376/TVIafzHi5K ttAymuAEnduZEUwl3VgOCbAvIItw5aHVCJnIKahifzmwgSaGZXuv36p9FwiWdDP4fwXckmCOjsS0y 6hprCPpPKLSLUdQ0Y/Nkj0eefMoH4D3R2d9dgzhQPPnnNvgkGp9X0hyuVf82uhxqP4p/yGtWfxEMq aK3gsxMDEzwpm5Pm+FL8chZvJ8Ac27h5WdmY+fRof/Q/76qWh0bV/1SU3Zw3sQ58G/xicT8UWX88L xOyTCNfQ==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1r6PIg-002Puw-0L; 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 16/21] fold dentry_kill() into dput() Date: Fri, 24 Nov 2023 06:04:17 +0000 Message-Id: <20231124060422.576198-16-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 groat.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 (groat.vger.email [0.0.0.0]); Thu, 23 Nov 2023 22:06:04 -0800 (PST) Reviewed-by: Christian Brauner Signed-off-by: Al Viro --- fs/dcache.c | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index a7f99d46c41b..5284b02747cd 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -756,28 +756,6 @@ void d_mark_dontcache(struct inode *inode) } EXPORT_SYMBOL(d_mark_dontcache); -/* - * Finish off a dentry we've decided to kill. - * dentry->d_lock must be held, returns with it unlocked. - * Returns dentry requiring refcount drop, or NULL if we're done. - */ -static struct dentry *dentry_kill(struct dentry *dentry) - __releases(dentry->d_lock) -{ - - dentry->d_lockref.count--; - rcu_read_lock(); - if (likely(lock_for_kill(dentry))) { - struct dentry *parent = dentry->d_parent; - rcu_read_unlock(); - __dentry_kill(dentry); - return parent != dentry ? parent : NULL; - } - rcu_read_unlock(); - spin_unlock(&dentry->d_lock); - return NULL; -} - /* * Try to do a lockless dput(), and return whether that was successful. * @@ -915,9 +893,18 @@ void dput(struct dentry *dentry) } /* Slow case: now with the dentry lock held */ - rcu_read_unlock(); - dentry->d_lockref.count = 1; - dentry = dentry_kill(dentry); + if (likely(lock_for_kill(dentry))) { + struct dentry *parent = dentry->d_parent; + rcu_read_unlock(); + __dentry_kill(dentry); + if (dentry == parent) + return; + dentry = parent; + } else { + rcu_read_unlock(); + spin_unlock(&dentry->d_lock); + return; + } } } EXPORT_SYMBOL(dput); -- 2.39.2