Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp842585rdh; Thu, 23 Nov 2023 22:05:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGc3bzTwTr33jFfXoJDt2PXZMunts9pYdZqLOKJHGGBeNZ17AQm01NP/wZjtAHsRvq2t1Uw X-Received: by 2002:a05:6808:1483:b0:3a7:1e3e:7f97 with SMTP id e3-20020a056808148300b003a71e3e7f97mr2293896oiw.4.1700805909964; Thu, 23 Nov 2023 22:05:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700805909; cv=none; d=google.com; s=arc-20160816; b=pRerUU7KBEY/cuJNNkzYlFQCqHHUI38COV9PjNgQ7+K9RW3oWk6e0Td2aVX/biVOPW Z5Qpil1tWvimv+Z7TiaNI1McAHFuIKv35f8OvFaATRrTp2WyT0fyAmpO8Z0OnekiKZAW 4eO1egLpWs0y/Pgctt9BUC3TqLr/rv2Chjta/Eh0QIWIGcDrOveHSog5oJAo1ZdrXO2V vDzGHohikZlIiickuFTvrNdPqCL+0Y2qmNWF8bYOtMUUp3XwC2vNTvL4LlM+xtOHPy3s MAQxXIV2E5dSOebu3dc+0iflrhIbIevpaQNJeUBfkNWPtHsLQXijX+JFdUuLxgtPTn48 I2HA== 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=OhCzST4Viql9jwYwDDeDZI5/cnICIyfnJcJBswRqBMo=; fh=vDsv/0Rb6aybIi/Xas2DR+uQpFXMLtn4no3J1t38V0s=; b=Hq4aysUJmqUTmde6qn3jgriznp4nHGHmvoowMx3ulZcDjpldg2f6asTXMQwmk56WOH q7kP0pjW8PGac/hsPWwwlVkuoRF42+4Y1hf7dDkfixQR2WAkgrParmrfyM+t8bpLOHi9 NmN+5MbIuq+NqY61Nnhm9M/eCPv/4WB0T8G3nHrwusCPziu+dbZ1UAs8RqWA7uabRZXJ Yr6uRoAPZJCZBBumBUouHa+dHC5J0UpNm+w8Yb6q+SRU7AxbI8ZxEvHls+mALnjYCNxE 3lcuTR07LGa63VryLQxVk8gvYout0ll5gS8kxY3byopals5HRO5tS0NhSSP27LWZOHNl HlDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=t84e8Fxe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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. [23.128.96.34]) by mx.google.com with ESMTPS id ck8-20020a056a02090800b00563ee04bbafsi2708394pgb.837.2023.11.23.22.05.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 22:05:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=t84e8Fxe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 ECE4180A7337; Thu, 23 Nov 2023 22:05:03 -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 S232503AbjKXGEn (ORCPT + 99 others); Fri, 24 Nov 2023 01:04:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbjKXGES (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 EC55B10C8; 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=OhCzST4Viql9jwYwDDeDZI5/cnICIyfnJcJBswRqBMo=; b=t84e8FxetnlLzWy6Ty94DCvdp+ V+lOFj3AjZZCzxAAB+FbLC5E7PoA1tyT2Himsg0ubdZrmaued/gFs8XQ7m90MyynxiIifH8ism8yU eeqc0tw2fyWrC3fa+/3a8wVXuqm929QwW99VDKHNj2DgawwS503lweZLdhrQrgADV0QZRvdanKhvm 6YpA7633x3LGyEB/j4VWDX87FJR7uTJtGN3yM0rUR8yiKg0AwLTBTBLdGe3fBlIf5QUvXQHDFoMrI IvkDn3KWOrqm0Ix3rsp4AwY8FASYrTTYfWeWC+ayNe9q2V8ij3ELqc/Y1u1wR+jR+rt2fHW2q8ct+ hWI6DAtA==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1r6PId-002PuB-1w; 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 08/21] fast_dput(): new rules for refcount Date: Fri, 24 Nov 2023 06:04:09 +0000 Message-Id: <20231124060422.576198-8-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:05:04 -0800 (PST) By now there is only one place in entire fast_dput() where we return false; that happens after refcount had been decremented and found (under ->d_lock) to be zero. In that case, just prior to returning false to caller, fast_dput() forcibly changes the refcount from 0 to 1. Lift that resetting refcount to 1 into the callers; later in the series it will be massaged out of existence. Reviewed-by: Christian Brauner Signed-off-by: Al Viro --- fs/dcache.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 9edabc7e2e64..a00e9ba22480 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -847,13 +847,6 @@ static inline bool fast_dput(struct dentry *dentry) spin_unlock(&dentry->d_lock); return true; } - - /* - * Re-get the reference we optimistically dropped. We hold the - * lock, and we just tested that it was zero, so we can just - * set it to 1. - */ - dentry->d_lockref.count = 1; return false; } @@ -896,6 +889,7 @@ void dput(struct dentry *dentry) } /* Slow case: now with the dentry lock held */ + dentry->d_lockref.count = 1; rcu_read_unlock(); if (likely(retain_dentry(dentry))) { @@ -930,6 +924,7 @@ void dput_to_list(struct dentry *dentry, struct list_head *list) return; } rcu_read_unlock(); + dentry->d_lockref.count = 1; if (!retain_dentry(dentry)) __dput_to_list(dentry, list); spin_unlock(&dentry->d_lock); -- 2.39.2