Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6102060rwr; Tue, 9 May 2023 10:12:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6A4RmP6LeO5BYqe/pOlnzTBR8PLTAj4FjESp+GfEbaExTizvj9fxuRvG+MhRg1qaIgVjKZ X-Received: by 2002:a17:90a:a009:b0:250:462:d20e with SMTP id q9-20020a17090aa00900b002500462d20emr15013335pjp.45.1683652333932; Tue, 09 May 2023 10:12:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683652333; cv=none; d=google.com; s=arc-20160816; b=XqTYBwld70RCmT5eTpRDnmXQwArHP/4koDNd0R1q5HImRM3UJRrGNubi6/G6km65We 9KInDrWMfZ5SN5wue8b4CpSLFtxaBkjSQuxE9OPTyQGUPr8IKviG5hWorWUsIOiHYuUx KKyIxeTDLIOSxx4PCcO1B6GVF+nLFhxzOwY66g3XDLjBf7k6Hq2OK8vXQC+I0iTK5Dr5 mXyV1E1fEhe9kn8B4lAYMCQy34p4GGdY1kPzJk+yahIC5z252IOMwh3FpZBSk7sMWZ5N HVM71jmrCi0D9XCwNxOQ2c2w2fYyJasVaXjhpi+cBgezYzTuFCeBQ57P7GXRQUINZ7g5 Sokw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3fmI1GsqhKc/VjkbsmLsO1lPQkBpUyPyeZNLX2gLM4A=; b=uPBeSA22v9ZCQ93xwIMnqLFp76Q4xjxI3xYoKk5fBDvZm6jEGexCkWyRd4pFwKnbVN fL1J+8rZDbHet5rK4PrAm5c8gGDmJmytbCyCuowAamciDtK07s16Nt5I5Jc4+DDKuqdG 42MghXUY229/KEGRB2OVtBj4s+uC9jIb4vaL8EBXX/q3fMCnxxojpKJnVo20ovARf7mN w5eajznhyh9K1B8qwpIYBUhikNrJCQKxCYrCglwWs6xBAXR4RbTqmYrQvgLNFXz460kT T4LG7uuBMlfO3FK3zST4jNufZdCd3A09JRvQf3exaxtDd7w6xNuaKunTrEVkINxX1sai /wWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=HxbPD30d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b191-20020a6334c8000000b005303b08eb16si2014984pga.631.2023.05.09.10.12.01; Tue, 09 May 2023 10:12:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=HxbPD30d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234960AbjEIQ6L (ORCPT + 99 others); Tue, 9 May 2023 12:58:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229557AbjEIQ5b (ORCPT ); Tue, 9 May 2023 12:57:31 -0400 Received: from out-17.mta1.migadu.com (out-17.mta1.migadu.com [95.215.58.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74A46E71 for ; Tue, 9 May 2023 09:57:19 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1683651437; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3fmI1GsqhKc/VjkbsmLsO1lPQkBpUyPyeZNLX2gLM4A=; b=HxbPD30d9PS44l4BFocC7+4W53wukqnTMPxPn1K1Dbc9Y/EsxCrjkf4QSlJqxIFFlazBMT 6SVHA9CXL8xpVGqkipFpzj13Ez5vDhN2yCAlYAdQpq1Cff2u9KY26LppoRnsIuiZKmD0eD klJFD5WmmOeWr9WGDK7h91hyWwK5z5I= From: Kent Overstreet To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-bcachefs@vger.kernel.org Cc: Kent Overstreet , Kent Overstreet , Alexander Viro , Christian Brauner Subject: [PATCH 08/32] fs: factor out d_mark_tmpfile() Date: Tue, 9 May 2023 12:56:33 -0400 Message-Id: <20230509165657.1735798-9-kent.overstreet@linux.dev> In-Reply-To: <20230509165657.1735798-1-kent.overstreet@linux.dev> References: <20230509165657.1735798-1-kent.overstreet@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, 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 From: Kent Overstreet New helper for bcachefs - bcachefs doesn't want the inode_dec_link_count() call that d_tmpfile does, it handles i_nlink on its own atomically with other btree updates Signed-off-by: Kent Overstreet Cc: Alexander Viro Cc: Christian Brauner Cc: linux-fsdevel@vger.kernel.org --- fs/dcache.c | 12 ++++++++++-- include/linux/dcache.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 52e6d5fdab..dbdafa2617 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -3249,11 +3249,10 @@ void d_genocide(struct dentry *parent) EXPORT_SYMBOL(d_genocide); -void d_tmpfile(struct file *file, struct inode *inode) +void d_mark_tmpfile(struct file *file, struct inode *inode) { struct dentry *dentry = file->f_path.dentry; - inode_dec_link_count(inode); BUG_ON(dentry->d_name.name != dentry->d_iname || !hlist_unhashed(&dentry->d_u.d_alias) || !d_unlinked(dentry)); @@ -3263,6 +3262,15 @@ void d_tmpfile(struct file *file, struct inode *inode) (unsigned long long)inode->i_ino); spin_unlock(&dentry->d_lock); spin_unlock(&dentry->d_parent->d_lock); +} +EXPORT_SYMBOL(d_mark_tmpfile); + +void d_tmpfile(struct file *file, struct inode *inode) +{ + struct dentry *dentry = file->f_path.dentry; + + inode_dec_link_count(inode); + d_mark_tmpfile(file, inode); d_instantiate(dentry, inode); } EXPORT_SYMBOL(d_tmpfile); diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 6b351e009f..3da2f0545d 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -251,6 +251,7 @@ extern struct dentry * d_make_root(struct inode *); /* - the ramfs-type tree */ extern void d_genocide(struct dentry *); +extern void d_mark_tmpfile(struct file *, struct inode *); extern void d_tmpfile(struct file *, struct inode *); extern struct dentry *d_find_alias(struct inode *); -- 2.40.1