Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp843392rdh; Thu, 23 Nov 2023 22:06:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFPBZK+yoCkAuCdnk0gbpB0KaPCn0IQEhRliu3Xedr96C7onSzQqdMGpPOtxx7fk5USqdZL X-Received: by 2002:a05:6e02:170a:b0:359:8ddf:5319 with SMTP id u10-20020a056e02170a00b003598ddf5319mr2689479ill.26.1700805985686; Thu, 23 Nov 2023 22:06:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700805985; cv=none; d=google.com; s=arc-20160816; b=U7KGHBDAPTECs4QYIBFqNpQLcDKNJT2INdMG/R+njt7cnaIcrxABTgB5LwHOsYS9L+ zHkdlLoxRj52pxKS9nalhOT1/eqzzTnGFg459OTnBqs0yKyWtOo8qXIqdRfaV5aacEIh AuaCImhuprIALZ248HdLf9NuL+5JBJGR+BGFVTnl5uMNKNNd0w6fr8tEwUmpz101iPXe 8ITLotGb6zHQXOMDPE9TvaPOT4DVZvMyvwjeeWYQE9EghkKIiZUl6FQyZXL8lPfPtbeg WHiKyIsVTlfiRdM5hEw14tk7juyymSmnZwZFk9Fhn2qvsplTTW8zXUVyLXch7US8E+PS rWGw== 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=vT3nlpEZeGzr7/rKI49SrykB8InZNoD2Xu4i2yt9WsU=; fh=vDsv/0Rb6aybIi/Xas2DR+uQpFXMLtn4no3J1t38V0s=; b=Ui8vevk2BjKXE0Tu0ZjysnefkoGYcN3VNLfhi4kssK9fm8BSIitiNYEbXsdYo2G1Ey OT5XQm/jAiMhyV/mwdMq467zSaCN4JrEgP3gJ3ujEQKd5BVL3zrLXls/KG077ua9zdUR ZHHWepGGTzk5G8doi0dUT2Rb/yJf+Qcz4vjgM+s+FQURq3AD7WfDJiej5ccqU5P/K+Gn eP5sI8Q+Ce2gJuNf9Ah9eCaaUPXSoZo/rvzoPUQ1Hgg/XF3ozRRspXNB4kLniZbCBXyi 7uEPuWmL2gKlX31OqRHChqMxJYD90GyYMaLDpxLk/jK6IQBcwvmVJAU9uiewVCgNpNxH mQxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=uDg1IyQe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id q15-20020a056a00084f00b006c040064180si2973911pfk.335.2023.11.23.22.06.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 22:06:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=uDg1IyQe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 4725D8083A82; Thu, 23 Nov 2023 22:06:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344669AbjKXGFf (ORCPT + 99 others); Fri, 24 Nov 2023 01:05:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231430AbjKXGEV (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 28B3310D9; 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=vT3nlpEZeGzr7/rKI49SrykB8InZNoD2Xu4i2yt9WsU=; b=uDg1IyQegNlFWVu0oGh2fv3IeR Q+1AfhR6srH1dTYlCIIxMnjuw6eWw72YGI476+CHpv8+IpIiYHT3R5tHoZ4QoDWYmSyjkggahMyjU r9NMDx/kT/wnQzMl2jYXAeXA74uRZpOVl60g7yFhRx9iqOC42vLo4oH2/0Zg9d6B4hHYwjlzrUTPi 3w/S4z0lajGYCF9nJbSTOC7OPs2uLgAsphCl34xn5Ieq6AC0PZa7ZtsJl/0hQdTSHwI+FN4zmKP3u ULQESX2UWp4xdLKfHSoWHxpTRYlrOWDKgiXDt/qf1qzz3DQXFAEW9yPDEiiLy4LzLOlv/dtQESue7 PBBZJAFw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1r6PIf-002Puo-2a; Fri, 24 Nov 2023 06:04:25 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Linus Torvalds , Christian Brauner , linux-kernel@vger.kernel.org Subject: [PATCH v3 14/21] fold the call of retain_dentry() into fast_dput() Date: Fri, 24 Nov 2023 06:04:15 +0000 Message-Id: <20231124060422.576198-14-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 howler.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 (howler.vger.email [0.0.0.0]); Thu, 23 Nov 2023 22:06:07 -0800 (PST) Calls of retain_dentry() happen immediately after getting false from fast_dput() and getting true from retain_dentry() is treated the same way as non-zero refcount would be treated by fast_dput() - unlock dentry and bugger off. Doing that in fast_dput() itself is simpler. Reviewed-by: Christian Brauner Signed-off-by: Al Viro --- fs/dcache.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 8ce0fe70f303..b69ff3a0b30f 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -757,6 +757,8 @@ static struct dentry *dentry_kill(struct dentry *dentry) * Try to do a lockless dput(), and return whether that was successful. * * If unsuccessful, we return false, having already taken the dentry lock. + * In that case refcount is guaranteed to be zero and we have already + * decided that it's not worth keeping around. * * The caller needs to hold the RCU read lock, so that the dentry is * guaranteed to stay around even if the refcount goes down to zero! @@ -842,7 +844,7 @@ static inline bool fast_dput(struct dentry *dentry) * don't need to do anything else. */ locked: - if (dentry->d_lockref.count) { + if (dentry->d_lockref.count || retain_dentry(dentry)) { spin_unlock(&dentry->d_lock); return true; } @@ -889,12 +891,6 @@ void dput(struct dentry *dentry) /* Slow case: now with the dentry lock held */ rcu_read_unlock(); - - if (likely(retain_dentry(dentry))) { - spin_unlock(&dentry->d_lock); - return; - } - dentry->d_lockref.count = 1; dentry = dentry_kill(dentry); } @@ -920,8 +916,7 @@ void dput_to_list(struct dentry *dentry, struct list_head *list) return; } rcu_read_unlock(); - if (!retain_dentry(dentry)) - to_shrink_list(dentry, list); + to_shrink_list(dentry, list); spin_unlock(&dentry->d_lock); } -- 2.39.2