From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A86D33F0768; Thu, 12 Mar 2026 21:44:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773351887; cv=none; b=llh2gSzSwODKwYw0k7XevUcZgbz6lpACYSH9rHpPYv+Nkn1vbNy2rmIAfri2i2zUsvPzVnOzdPJK7/FVfpksVt5g0BIsOVYM6k9hNG/Hyeyb+I2zb210jng+rw4C1RctVlgfRloytUEOUXSwUidZA/BR5Al8cdmPPCDOfB49TJQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773351887; c=relaxed/simple; bh=0bDAB6c7EuHeqIuPGREIg9nUnPVRPD5jo2LSE49nUuA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pkXS8dmlviUmIOndKnhs5Q9zw/jdEVrXrMGGyHEONtBC/s/3NPrbywHsnySXoDDwHbPAA6lkstTxh2KXq4u5pM9hqlm01Pal1T4wQEWPpY8Efvm7+kjHNdKJPdFhRxV0N/cvgMhxB+u+9YdFHqxv/qggoeDK5kq/BcJo29ud7j4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=PajocoyR; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=eiKEFyzI; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="PajocoyR"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="eiKEFyzI" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailflow.stl.internal (Postfix) with ESMTP id D4BF41301B37; Thu, 12 Mar 2026 17:44:43 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Thu, 12 Mar 2026 17:44:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773351883; x=1773359083; bh=6+mmsaKBniwLTeTPIsSiVJuLQl0gYbnHV92H9IS7A4Y=; b= PajocoyRnbmUsSEVN0KUCT/oAq8w7rz7XZBiWlFG6mILTzRMZadAVs9BMnUsdgpe VV5nKSfhYha9QGrwq154yebdSuYBX8+hBAeeSZRBxVC9NmmJJAT0nPf+13VMfxtf 2Ol/vyXx2RuSHp24+K4OoOZ4c6gWli7I6Ek/EqXSWX0L6Ycuth8+TDu4Nn+2y2ED 2AgfW76Z++0l2RrgWXbVFYHI/axuhx47RqBeYoyoaSOtVQOGxiDobmV+Ov+Ax42q yEGDJPGa1eEfseCt4wuoqX31vuuvtEvwijFAgA6thCViI54F0d6a1J/EaB+UANTS Y+5EmuH3P3aCXuDVWH4+1w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773351883; x=1773359083; bh=6 +mmsaKBniwLTeTPIsSiVJuLQl0gYbnHV92H9IS7A4Y=; b=eiKEFyzIZSyNAQzCX d+RQaHTOhHrbknO16+Wz/TPgBVYa1dqTafhGeNTm6HFQaU9Zpg99xU4J09EviScA y2QdwTApDbLsMmmwQnLewGL1vk+AFMuyJLCY975YHn3noQe7ewaX+iAEM/JkzoW9 Vi35ja7wL0tPHqJdxf9CnkiDk+wHurPo2EJsT4Ysz215r2GMlN48ywG9FhKqLmQ0 6F+5dRWUU121OP6gzdER+0xB/ZU5xIOKe46pmTIbIix1EbrObTt/tmGR45QAFNC3 3XUiPSR+383Wu3hyeASY8KiIFdQW9vRKIF9xyFsTBAM0WvDuxihL4Na8gIg6TD/U Eci2g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejkeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:44:29 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 01/53] VFS: fix various typos in documentation for start_creating start_removing etc Date: Fri, 13 Mar 2026 08:11:48 +1100 Message-ID: <20260312214330.3885211-2-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown Various typos fixes. start_creating_dentry() now documented as *creating*, not *removing* the entry. Signed-off-by: NeilBrown --- Documentation/filesystems/porting.rst | 8 +++---- fs/namei.c | 30 +++++++++++++-------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesyst= ems/porting.rst index d02aa57e4477..560b473e02d0 100644 --- a/Documentation/filesystems/porting.rst +++ b/Documentation/filesystems/porting.rst @@ -1203,7 +1203,7 @@ will fail-safe. =20 --- =20 -** mandatory** +**mandatory** =20 lookup_one(), lookup_one_unlocked(), lookup_one_positive_unlocked() now take a qstr instead of a name and len. These, not the "one_len" @@ -1212,7 +1212,7 @@ that filesysmtem, through a mount point - which will = have a mnt_idmap. =20 --- =20 -** mandatory** +**mandatory** =20 Functions try_lookup_one_len(), lookup_one_len(), lookup_one_len_unlocked() and lookup_positive_unlocked() have been @@ -1229,7 +1229,7 @@ already been performed such as after vfs_path_parent_= lookup() =20 --- =20 -** mandatory** +**mandatory** =20 d_hash_and_lookup() is no longer exported or available outside the VFS. Use try_lookup_noperm() instead. This adds name validation and takes @@ -1370,7 +1370,7 @@ lookup_one_qstr_excl() is no longer exported - use st= art_creating() or similar. --- =20 -** mandatory** +**mandatory** =20 lock_rename(), lock_rename_child(), unlock_rename() are no longer available. Use start_renaming() or similar. diff --git a/fs/namei.c b/fs/namei.c index 77189335bbcc..6ffb8367b1cf 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2936,8 +2936,8 @@ struct dentry *start_dirop(struct dentry *parent, str= uct qstr *name, * end_dirop - signal completion of a dirop * @de: the dentry which was returned by start_dirop or similar. * - * If the de is an error, nothing happens. Otherwise any lock taken to - * protect the dentry is dropped and the dentry itself is release (dput()). + * If the @de is an error, nothing happens. Otherwise any lock taken to + * protect the dentry is dropped and the dentry itself is released (dput()= ). */ void end_dirop(struct dentry *de) { @@ -3254,7 +3254,7 @@ EXPORT_SYMBOL(lookup_one_unlocked); * the i_rwsem itself if necessary. If a fatal signal is pending or * delivered, it will return %-EINTR if the lock is needed. * - * Returns: A dentry, possibly negative, or + * Returns: A positive dentry, or * - same errors as lookup_one_unlocked() or * - ERR_PTR(-EINTR) if a fatal signal is pending. */ @@ -3376,7 +3376,7 @@ struct dentry *lookup_noperm_positive_unlocked(struct= qstr *name, EXPORT_SYMBOL(lookup_noperm_positive_unlocked); =20 /** - * start_creating - prepare to create a given name with permission checking + * start_creating - prepare to access or create a given name with permissi= on checking * @idmap: idmap of the mount * @parent: directory in which to prepare to create the name * @name: the name to be created @@ -3408,8 +3408,8 @@ EXPORT_SYMBOL(start_creating); * @parent: directory in which to find the name * @name: the name to be removed * - * Locks are taken and a lookup in performed prior to removing - * an object from a directory. Permission checking (MAY_EXEC) is performed + * Locks are taken and a lookup is performed prior to removing an object + * from a directory. Permission checking (MAY_EXEC) is performed * against @idmap. * * If the name doesn't exist, an error is returned. @@ -3435,7 +3435,7 @@ EXPORT_SYMBOL(start_removing); * @parent: directory in which to prepare to create the name * @name: the name to be created * - * Locks are taken and a lookup in performed prior to creating + * Locks are taken and a lookup is performed prior to creating * an object in a directory. Permission checking (MAY_EXEC) is performed * against @idmap. * @@ -3464,7 +3464,7 @@ EXPORT_SYMBOL(start_creating_killable); * @parent: directory in which to find the name * @name: the name to be removed * - * Locks are taken and a lookup in performed prior to removing + * Locks are taken and a lookup is performed prior to removing * an object from a directory. Permission checking (MAY_EXEC) is performed * against @idmap. * @@ -3494,7 +3494,7 @@ EXPORT_SYMBOL(start_removing_killable); * @parent: directory in which to prepare to create the name * @name: the name to be created * - * Locks are taken and a lookup in performed prior to creating + * Locks are taken and a lookup is performed prior to creating * an object in a directory. * * If the name already exists, a positive dentry is returned. @@ -3517,7 +3517,7 @@ EXPORT_SYMBOL(start_creating_noperm); * @parent: directory in which to find the name * @name: the name to be removed * - * Locks are taken and a lookup in performed prior to removing + * Locks are taken and a lookup is performed prior to removing * an object from a directory. * * If the name doesn't exist, an error is returned. @@ -3538,11 +3538,11 @@ struct dentry *start_removing_noperm(struct dentry = *parent, EXPORT_SYMBOL(start_removing_noperm); =20 /** - * start_creating_dentry - prepare to create a given dentry - * @parent: directory from which dentry should be removed - * @child: the dentry to be removed + * start_creating_dentry - prepare to access or create a given dentry + * @parent: directory of dentry + * @child: the dentry to be prepared * - * A lock is taken to protect the dentry again other dirops and + * A lock is taken to protect the dentry against other dirops and * the validity of the dentry is checked: correct parent and still hashed. * * If the dentry is valid and negative a reference is taken and @@ -3575,7 +3575,7 @@ EXPORT_SYMBOL(start_creating_dentry); * @parent: directory from which dentry should be removed * @child: the dentry to be removed * - * A lock is taken to protect the dentry again other dirops and + * A lock is taken to protect the dentry against other dirops and * the validity of the dentry is checked: correct parent and still hashed. * * If the dentry is valid and positive, a reference is taken and --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5641E3FBECB; Thu, 12 Mar 2026 21:45:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773351905; cv=none; b=Wt4UDta7wuxOHUVdBwdDzPlki0+oZq1+Yen8V7vQ/OeBCIW1f04dNrCGqpTQ5DyISepPK+IO5+bI+p7sZo175WfjrwIgFUdO+E96vPYfHAau6kTk/K6AnL+gG5WPU3SEc3NUTb2YXdLSV5qC4ECAvXvJY3wX5lasTZbpLtVW/tg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773351905; c=relaxed/simple; bh=lzfrMWH5ucEdjaxtNb8IRio8YrNVnNRvEyHHmeNBdQw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qD8uVa+2wSwxJmIUjj8vHBomfVLnFxfS9Ti9FJkBKJXBtFUqOroKjB7MXdI+7kWTU6sI2bKQ7GHUHObFGy7WImulhLB4vEs7QVy1hLgqybTzvdRLyWL3wju3daCMjYADVaiR+NzvHx7BET4XtNjiNFPXHaO9ambJmxFdckBG16Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=IdiQOok0; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=gn3FSBiy; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="IdiQOok0"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="gn3FSBiy" Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailflow.stl.internal (Postfix) with ESMTP id 81DD11301B38; Thu, 12 Mar 2026 17:45:01 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Thu, 12 Mar 2026 17:45:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773351901; x=1773359101; bh=q86JqY5nWN61fk3HDIejbBzlZhC8qHqz4CWZQB9c0L0=; b= IdiQOok0NjcrVf3aBusgGZebFc2FHPnBB240qLNehAkc7QtrbGn+geGKng8idZGJ M8pgixjygkApnAS7lO7rlFmPWlnnVc7ZI+3NAFk4bKgxoEsSTJuJIpvXIQuhgkma hsj48bh9bZxX7e4DyJzIwbfCzQvDxXWTmxKYQxvUyWPBtqMB6vuaI8evFMQ+3Jzh YSXOHhEDMLnNXBxs3yMi4X2136zsPqA4HLfDUfQ5+O6mWKecRhNKoZtTqE1QKErs g24i9txs2z+6G+MZxrL9Ej0SJjyw4K3nGOm1peFDYO090Nbn5QSClI80O8eSgMF1 HbW6gTFEIoXvPCxkC4/H1g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773351901; x=1773359101; bh=q 86JqY5nWN61fk3HDIejbBzlZhC8qHqz4CWZQB9c0L0=; b=gn3FSBiya6mz1Vl3j ZeHBiF7isXmDXq2Bj4NSdhVT01lccsHK2oNMG6rixbhMm5laJfOC1MNhF8URhPjY zfPpCGAv3EMgHswdAkM/NC63JIWQyCZMIvD9eoFCbdGn+0yca0TbrUF3xlLPtfSV MUMJ9mlzkwgs9wiwJvdrDOJZhGBQSoaUTvFyqBIoZR0BlZ7ZR7J6/Nl2uiHx+yV0 OC48PirUBgXwfeDTTjEs0yLtaGLh608R+QD9jMUeUCQ8aCmPwgH4WdYQwhrv5rE+ vvwfvA29XDqkVJ0VtODTYv+fXm11AMn7ghiP+W2k7wX75lWIdJJmBRaa2rRnR1Xj ha7ag== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejkeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:44:47 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 02/53] VFS: enhance d_splice_alias() to handle in-lookup dentries Date: Fri, 13 Mar 2026 08:11:49 +1100 Message-ID: <20260312214330.3885211-3-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown We currently have three interfaces for attaching existing inodes to normal filesystems(*). - d_add() requires an unhashed or in-lookup dentry and doesn't handle splicing in case a directory already has dentry - d_instantiate() requires a hashed dentry, and also doesn't handle splicing. - d_splice_alias() requires unhashed or in-lookup and does handle splicing, and can return an alternate dentry. So there is no interface that supports both hashed and in-lookup, which is what ->atomic_open needs to deal with. Some filesystems check for in-lookup in their atomic_open and if found, perform a ->lookup and can subsequently use d_instantiate() if the dentry is still negative. Other d_drop() the dentry so they can use d_splice_alias(). This last will cause a problem for proposed changes to locking which require the dentry to remain hashed while and operation proceeds on it. There is also no interface which splices a directory (which might already have a dentry) to a hashed dentry. Filesystems which need to do this d_drop() first. So with this patch d_splice_alias() can handle hashed, unhashed, or in-lookup dentries. This makes it suitable for ->lookup, ->atomic_open, and ->mkdir. As a side effect d_add() will also now handle hashed dentries, but future patches will remove d_add() as there is no benefit having it as well as the others. __d_add() currently contains code that is identical to __d_instantiate(), so the former is changed to call the later, and both d_add() and d_instantiate() call __d_add(). * There is also d_make_persistent() for filesystems which are dcache-based and don't support mkdir, create etc, and d_instantiate_new() for newly created inodes that are still locked. Signed-off-by: NeilBrown --- Documentation/filesystems/vfs.rst | 4 ++-- fs/dcache.c | 31 ++++++++++++------------------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/= vfs.rst index 7c753148af88..d8df0a84cdba 100644 --- a/Documentation/filesystems/vfs.rst +++ b/Documentation/filesystems/vfs.rst @@ -507,8 +507,8 @@ otherwise noted. dentry before the first mkdir returns. =20 If there is any chance this could happen, then the new inode - should be d_drop()ed and attached with d_splice_alias(). The - returned dentry (if any) should be returned by ->mkdir(). + should be attached with d_splice_alias(). The returned + dentry (if any) should be returned by ->mkdir(). =20 ``rmdir`` called by the rmdir(2) system call. Only required if you want diff --git a/fs/dcache.c b/fs/dcache.c index 7ba1801d8132..2a100c616576 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2001,7 +2001,6 @@ static void __d_instantiate(struct dentry *dentry, st= ruct inode *inode) * (or otherwise set) by the caller to indicate that it is now * in use by the dcache. */ -=20 void d_instantiate(struct dentry *entry, struct inode * inode) { BUG_ON(!hlist_unhashed(&entry->d_u.d_alias)); @@ -2755,18 +2754,14 @@ static inline void __d_add(struct dentry *dentry, s= truct inode *inode, dir =3D dentry->d_parent->d_inode; n =3D start_dir_add(dir); d_wait =3D __d_lookup_unhash(dentry); + __d_rehash(dentry); + } else if (d_unhashed(dentry)) { + __d_rehash(dentry); } if (unlikely(ops)) d_set_d_op(dentry, ops); - if (inode) { - unsigned add_flags =3D d_flags_for_inode(inode); - hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry); - raw_write_seqcount_begin(&dentry->d_seq); - __d_set_inode_and_type(dentry, inode, add_flags); - raw_write_seqcount_end(&dentry->d_seq); - fsnotify_update_flags(dentry); - } - __d_rehash(dentry); + if (inode) + __d_instantiate(dentry, inode); if (dir) end_dir_add(dir, n, d_wait); spin_unlock(&dentry->d_lock); @@ -3066,8 +3061,6 @@ struct dentry *d_splice_alias_ops(struct inode *inode= , struct dentry *dentry, if (IS_ERR(inode)) return ERR_CAST(inode); =20 - BUG_ON(!d_unhashed(dentry)); - if (!inode) goto out; =20 @@ -3116,6 +3109,8 @@ struct dentry *d_splice_alias_ops(struct inode *inode= , struct dentry *dentry, * @inode: the inode which may have a disconnected dentry * @dentry: a negative dentry which we want to point to the inode. * + * @dentry must be negative and may be in-lookup or unhashed or hashed. + * * If inode is a directory and has an IS_ROOT alias, then d_move that in * place of the given dentry and return it, else simply d_add the inode * to the dentry and return NULL. @@ -3123,16 +3118,14 @@ struct dentry *d_splice_alias_ops(struct inode *ino= de, struct dentry *dentry, * If a non-IS_ROOT directory is found, the filesystem is corrupt, and * we should error out: directories can't have multiple aliases. * - * This is needed in the lookup routine of any filesystem that is exportab= le - * (via knfsd) so that we can build dcache paths to directories effectivel= y. + * This should be used to return the result of ->lookup() and to + * instantiate the result of ->mkdir(), is often useful for + * ->atomic_open, and may be used to instantiate other objects. * * If a dentry was found and moved, then it is returned. Otherwise NULL - * is returned. This matches the expected return value of ->lookup. + * is returned. This matches the expected return value of ->lookup and + * ->mkdir. * - * Cluster filesystems may call this function with a negative, hashed dent= ry. - * In that case, we know that the inode will be a regular file, and also t= his - * will only occur during atomic_open. So we need to check for the dentry - * being already hashed only in the final case. */ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) { --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A52C63233E8; Thu, 12 Mar 2026 21:45:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773351923; cv=none; b=sMCvo6BirXY14boYn7W6+hSkQsfqYMO0m4NkXZnv68gFQABEitgxXOB0NWre0ydANI0xBKuQgjcn2E3HXxetmV0dEUCnRglncebZ85rQnaaK0NJVp2Qzn62vDynCyOET7CODvgWOI9AnTPDhidrFFyBu8GQpklg/5I24cHDd5Po= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773351923; c=relaxed/simple; bh=9CedlkQ5HfTJMVd/G7+FcFAZvHe4gjb1LO+RxiNWF1o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pP7HnsJXimCTCqyVPhu/Lbuiq9Kn70qO8QzjjPitzVom+qol1cnbrj9vGMcJ5+n9LsUeRTNPkXBGQpkFwEuiqCjEeZm59s3qJI5h+JigA4dCbLiBoLbxVDpRlFEcjiZFdlYU3Xjhrlbgf1zWYG1RemBlEh3R2hGQ4LPz1MRLY9M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=oU7Dkvpe; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=XEukUI3V; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="oU7Dkvpe"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="XEukUI3V" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailflow.stl.internal (Postfix) with ESMTP id D6DE91301B40; Thu, 12 Mar 2026 17:45:18 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Thu, 12 Mar 2026 17:45:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773351918; x=1773359118; bh=OkNDZy1y0XcEqiMJfVuxaHOJivaG8+FsdaJGeUAPkhs=; b= oU7DkvpewrvzdiSKJXf+1LXKtPl8JAwiXQg+MNyMTHYoeeMPqHRXvj81aMRL3qvH cmWTZEUVpM6ISNXRk3Ve+FcQa1Bj5AKlfu4fO5BxyfFnQ1IF3/9qFpsCArrlZ7vw j1auSZiVRvDlCsp0UYsBQfDmeq2cDbh6NiTooBFahDPpj/0Un4Siq+qoSfetu8ny 7TYD3MS4Y4dQwvSzsMUIwmQr65VMCm5cLhgoMgm3SVq529RWmPLamSe6ZSXsifnQ aMQsZM73lq0zESINoCPITL5aMSKvnmq7IFVg8LurAlmYguXXWJbvWfEdQ8Hy9Lwh xDW834w2rlAsdRqC71VV7Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773351918; x=1773359118; bh=O kNDZy1y0XcEqiMJfVuxaHOJivaG8+FsdaJGeUAPkhs=; b=XEukUI3V/2YjPEFR4 0aIpLrtcxJ4a7LKdlkpP9HmN51hUAiNu7t0fJ/qeroOxIAfybZuMoq+PaRivD0UV 8eGVxpuDMSmiwmaTAwIJ2SgsSpRaoL4qfI/EnxoLUaxPPE/ogE7afoNNL+tZXXBE RFCfq2q6rZAKEd/p1tTtEpxGgXPiXEHBmiEN8/20oNkKhtQL67JvQpE+sWET5/07 BoQHPCYycVijulfNnU/Ino4fg4qXgO5ogkeL3vzYF5M7AiBc5eloHioXlKSTABVM 3alYD20GqpHfmYb0aD1smB6oFqY/hwX3+t8JW2/QIrjyXo0B2aeOaIoiaE9SD1ac zaL8Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejkeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:45:05 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 03/53] VFS: allow d_alloc_name() to be used with ->d_hash Date: Fri, 13 Mar 2026 08:11:50 +1100 Message-ID: <20260312214330.3885211-4-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown efivarfs() is similar to other filesystems which use d_alloc_name(), but it cannot use d_alloc_name() as it has a ->d_hash function. The only problem with using ->d_hash if available is that it can return an error, but d_alloc_name() cannot. If we document that d_alloc_name() cannot be used when ->d_hash returns an error, then any filesystem which has a safe ->d_hash can safely use d_alloc_name(). So enhance d_alloc_name() to check for a ->d_hash function and document that this is not permitted if the ->d_hash function can fail( which efivarfs_d_hash() cannot). Also document locking requirements for use. This is a step towards eventually deprecating d_alloc(). Signed-off-by: NeilBrown --- fs/dcache.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/fs/dcache.c b/fs/dcache.c index 2a100c616576..6dfc2c7110ba 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1878,12 +1878,29 @@ struct dentry *d_alloc_pseudo(struct super_block *s= b, const struct qstr *name) return dentry; } =20 +/** + * d_alloc_name: allocate a dentry for use in a dcache-based filesystem. + * @parent: dentry of the parent for the dentry + * @name: name of the dentry + * + * d_alloc_name() allocates a dentry without any protection against races. + * It should only be used in directories that do not support create/rename= /link + * inode operations. The result is typically passed to d_make_persistent(= ). + * + * This must NOT be used by filesystems which provide a d_hash() function + * which can return an error. + */ struct dentry *d_alloc_name(struct dentry *parent, const char *name) { struct qstr q; =20 q.name =3D name; q.hash_len =3D hashlen_string(parent, name); + if (parent->d_flags & DCACHE_OP_HASH) { + int err =3D parent->d_op->d_hash(parent, &q); + if (WARN_ON_ONCE(err)) + return NULL; + } return d_alloc(parent, &q); } EXPORT_SYMBOL(d_alloc_name); --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD93130EF6C; Thu, 12 Mar 2026 21:45:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773351940; cv=none; b=eQmRqzQNnxeNKxBrcG4F1a6lWyKA3Oc9gMGWRo3rNX9r4jKo0lsOjf6yANGxh7JHrpZ0HQiZ/zHC5HM7lr3YQSnJp86SDcOJhpDAhrOcz3ervM2IJULGPpOBmR+v8+lRkgQZMYnzPZ3P3tkp8QI47Hs9bl6EzJK++wBb2TxQ0JY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773351940; c=relaxed/simple; bh=YQkXOSgp83B/Cz1fXXisbAxol9xPiNsqyGq0ZBXi3UY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u5XwRHZyHnV8TuqIa4zwmZ90UwTMPOONeJFI/20yV1SSpGaq/HZ+ng+SNs+GpII53vgpsBrLyUzbC9Dp9ZLjpQ1u5GEWLajW9B4EnbyiRBOVgep8Xb8sX9yM5b5oN4n94Xr+Y4V2zMP2JdpZcffVkrHEkp9a1G0M0DQRCMKJGrc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=hbrrmB/a; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=RhphY9/j; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="hbrrmB/a"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="RhphY9/j" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailflow.stl.internal (Postfix) with ESMTP id 0E4311301B3F; Thu, 12 Mar 2026 17:45:36 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Thu, 12 Mar 2026 17:45:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773351935; x=1773359135; bh=O1YxbmqYb+khk6pko/HFlSvaKBSqoQTQ01IgO7TQZ74=; b= hbrrmB/a166tqOQOVT4NkAAwVTlDRNdyii5dwLNiRynQXXoWvbBbRtx+h88L4vOJ jIJXOLZgIp9GBPi2wJw/kV8H0LJEFuPwJQ2fxzOmZgyi1f4nTWKtJ7xIya9M3iRo KioHZgVxZ+etWjZIf9endsa4OD+fYoxHJ2K6hPu8+AjKfDQ5nACCD0mG77p2LVbR B7RFI0hXNJXvIQRo7/0ipuon8gODWLwoSlRMmD7tKQ5dMEx0EGWOkjccGppIdtjA IEDzA0FwhpfrwAts5mfFIBspOTQGMW3/CKxE0kXicOYHTPvyedCaZ+mM1MtzlyBQ LdyoCUNEoA8Lpjozc/kG0A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773351935; x=1773359135; bh=O 1YxbmqYb+khk6pko/HFlSvaKBSqoQTQ01IgO7TQZ74=; b=RhphY9/jKBnqOrXDs /qmHyDdkfvkv55x1YQPU3y3KMlv3+U80qJUNl0GchvJc6M4TpS72Tilj4eftZDoA Fxm0C2RLUllQ3UbnOphIWEAgzTMhkkiqc3Y1VD1zewnm0iOC8FscyO3FSSKby9IK Btmky+DqeaVKewKNCGQR7CnfQ/OyVtfaXSmt4o5RJ/VGq3cPmj5IHzKNmWlw1EiO EOjgG/5ownsl6rYlG+c0ZiEbjpUkMPOTlVNu+ohZHtMeSeypyl/h6MPSU0s55CLm XcnufTGYQAJzGWbsvO0ffzzKzpzOcQLHM+4bXJ6tKDg8YK4m2V02gJBCpSt3g0oO g15/A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejkeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:45:22 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 04/53] VFS: use global wait-queue table for d_alloc_parallel() Date: Fri, 13 Mar 2026 08:11:51 +1100 Message-ID: <20260312214330.3885211-5-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown d_alloc_parallel() currently requires a wait_queue_head to be passed in. This must have a life time which extends until the lookup is completed. Future patches will make more use of d_alloc_parallel() and use it in contexts where having an on-stack wait_queue_head is not convenient. For exaple lookup_one_qstr_excl() can only use d_alloc_parallel() if it accepts a wait_queue_head pass in by the caller. The interface would be easier to use if this need were removed. Rather than passing a wait_queue_head into lookup_one_qstr_excl() we can let d_alloc_parallel() manage the wait_queue_head entirely itself. This patch replaces the on-stack wqs with a global array of wqs which are used as needed. A wq is NOT assigned when a dentry is first created but only when a second thread attempts to use the same name and so is forced to wait. At this moment a wq is chosen using a hash of the dentry pointer and that wq is assigned to ->d_wait. The ->d_lock is then dropped and the task waits. When the dentry is finally moved out of "in_lookup" a wake up is only sent if ->d_wait is not NULL. This avoids an (uncontended) spin lock/unlock which saves a couple of atomic operations in a common case. The wake up passes the dentry that the wake up is for as the "key" and the waiter will only wake processes waiting on the same key. This means that when these global waitqueues are shared (which is inevitable though unlikely to be frequent), a task will not be woken prematurely. Signed-off-by: NeilBrown --- Documentation/filesystems/porting.rst | 6 +++ fs/afs/dir_silly.c | 4 +- fs/dcache.c | 78 ++++++++++++++++++++++----- fs/fuse/readdir.c | 3 +- fs/namei.c | 6 +-- fs/nfs/dir.c | 6 +-- fs/nfs/unlink.c | 3 +- fs/proc/base.c | 3 +- fs/proc/proc_sysctl.c | 3 +- fs/smb/client/readdir.c | 3 +- include/linux/dcache.h | 3 +- include/linux/nfs_xdr.h | 1 - 12 files changed, 81 insertions(+), 38 deletions(-) diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesyst= ems/porting.rst index 560b473e02d0..6a507c508ccf 100644 --- a/Documentation/filesystems/porting.rst +++ b/Documentation/filesystems/porting.rst @@ -1375,3 +1375,9 @@ similar. lock_rename(), lock_rename_child(), unlock_rename() are no longer available. Use start_renaming() or similar. =20 +--- + +**mandatory** + +d_alloc_parallel() no longer requires a waitqueue_head. It uses one +from an internal table when needed. diff --git a/fs/afs/dir_silly.c b/fs/afs/dir_silly.c index a748fd133faf..982bb6ec15f0 100644 --- a/fs/afs/dir_silly.c +++ b/fs/afs/dir_silly.c @@ -248,13 +248,11 @@ int afs_silly_iput(struct dentry *dentry, struct inod= e *inode) struct dentry *alias; int ret; =20 - DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); - _enter("%p{%pd},%llx", dentry, dentry, vnode->fid.vnode); =20 down_read(&dvnode->rmdir_lock); =20 - alias =3D d_alloc_parallel(dentry->d_parent, &dentry->d_name, &wq); + alias =3D d_alloc_parallel(dentry->d_parent, &dentry->d_name); if (IS_ERR(alias)) { up_read(&dvnode->rmdir_lock); return 0; diff --git a/fs/dcache.c b/fs/dcache.c index 6dfc2c7110ba..c80406bfa0d8 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2199,8 +2199,7 @@ struct dentry *d_add_ci(struct dentry *dentry, struct= inode *inode, return found; } if (d_in_lookup(dentry)) { - found =3D d_alloc_parallel(dentry->d_parent, name, - dentry->d_wait); + found =3D d_alloc_parallel(dentry->d_parent, name); if (IS_ERR(found) || !d_in_lookup(found)) { iput(inode); return found; @@ -2210,7 +2209,7 @@ struct dentry *d_add_ci(struct dentry *dentry, struct= inode *inode, if (!found) { iput(inode); return ERR_PTR(-ENOMEM); - }=20 + } } res =3D d_splice_alias(inode, found); if (res) { @@ -2576,6 +2575,46 @@ void d_rehash(struct dentry * entry) } EXPORT_SYMBOL(d_rehash); =20 +#define PAR_LOOKUP_WQ_BITS 8 +#define PAR_LOOKUP_WQS (1 << PAR_LOOKUP_WQ_BITS) +static wait_queue_head_t par_wait_table[PAR_LOOKUP_WQS] __cacheline_aligne= d; + +static int __init par_wait_init(void) +{ + int i; + + for (i =3D 0; i < PAR_LOOKUP_WQS; i++) + init_waitqueue_head(&par_wait_table[i]); + return 0; +} +fs_initcall(par_wait_init); + +struct par_wait_key { + struct dentry *de; + struct wait_queue_entry wqe; +}; + +static int d_wait_wake_fn(struct wait_queue_entry *wq_entry, + unsigned mode, int sync, void *key) +{ + struct par_wait_key *pwk =3D container_of(wq_entry, + struct par_wait_key, wqe); + if (pwk->de =3D=3D key) + return default_wake_function(wq_entry, mode, sync, key); + return 0; +} + +static inline void d_wake_waiters(struct wait_queue_head *d_wait, + struct dentry *dentry) +{ + /* ->d_wait is only set if some thread is actually waiting. + * If we find it is NULL - the common case - then there was no + * contention and there are no waiters to be woken. + */ + if (d_wait) + __wake_up(d_wait, TASK_NORMAL, 0, dentry); +} + static inline unsigned start_dir_add(struct inode *dir) { preempt_disable_nested(); @@ -2588,31 +2627,42 @@ static inline unsigned start_dir_add(struct inode *= dir) } =20 static inline void end_dir_add(struct inode *dir, unsigned int n, - wait_queue_head_t *d_wait) + wait_queue_head_t *d_wait, struct dentry *de) { smp_store_release(&dir->i_dir_seq, n + 2); preempt_enable_nested(); - if (wq_has_sleeper(d_wait)) - wake_up_all(d_wait); + d_wake_waiters(d_wait, de); } =20 static void d_wait_lookup(struct dentry *dentry) { if (d_in_lookup(dentry)) { - DECLARE_WAITQUEUE(wait, current); - add_wait_queue(dentry->d_wait, &wait); + struct par_wait_key wk =3D { + .de =3D dentry, + .wqe =3D { + .private =3D current, + .func =3D d_wait_wake_fn, + }, + }; + struct wait_queue_head *wq; + + if (!dentry->d_wait) + dentry->d_wait =3D &par_wait_table[hash_ptr(dentry, + PAR_LOOKUP_WQ_BITS)]; + wq =3D dentry->d_wait; + add_wait_queue(wq, &wk.wqe); do { set_current_state(TASK_UNINTERRUPTIBLE); spin_unlock(&dentry->d_lock); schedule(); spin_lock(&dentry->d_lock); } while (d_in_lookup(dentry)); + remove_wait_queue(wq, &wk.wqe); } } =20 struct dentry *d_alloc_parallel(struct dentry *parent, - const struct qstr *name, - wait_queue_head_t *wq) + const struct qstr *name) { unsigned int hash =3D name->hash; struct hlist_bl_head *b =3D in_lookup_hash(parent, hash); @@ -2625,6 +2675,7 @@ struct dentry *d_alloc_parallel(struct dentry *parent, return ERR_PTR(-ENOMEM); =20 new->d_flags |=3D DCACHE_PAR_LOOKUP; + new->d_wait =3D NULL; spin_lock(&parent->d_lock); new->d_parent =3D dget_dlock(parent); hlist_add_head(&new->d_sib, &parent->d_children); @@ -2715,7 +2766,6 @@ struct dentry *d_alloc_parallel(struct dentry *parent, return dentry; } rcu_read_unlock(); - new->d_wait =3D wq; hlist_bl_add_head(&new->d_u.d_in_lookup_hash, b); hlist_bl_unlock(b); return new; @@ -2753,7 +2803,7 @@ static wait_queue_head_t *__d_lookup_unhash(struct de= ntry *dentry) void __d_lookup_unhash_wake(struct dentry *dentry) { spin_lock(&dentry->d_lock); - wake_up_all(__d_lookup_unhash(dentry)); + d_wake_waiters(__d_lookup_unhash(dentry), dentry); spin_unlock(&dentry->d_lock); } EXPORT_SYMBOL(__d_lookup_unhash_wake); @@ -2780,7 +2830,7 @@ static inline void __d_add(struct dentry *dentry, str= uct inode *inode, if (inode) __d_instantiate(dentry, inode); if (dir) - end_dir_add(dir, n, d_wait); + end_dir_add(dir, n, d_wait, dentry); spin_unlock(&dentry->d_lock); if (inode) spin_unlock(&inode->i_lock); @@ -2964,7 +3014,7 @@ static void __d_move(struct dentry *dentry, struct de= ntry *target, write_seqcount_end(&dentry->d_seq); =20 if (dir) - end_dir_add(dir, n, d_wait); + end_dir_add(dir, n, d_wait, target); =20 if (dentry->d_parent !=3D old_parent) spin_unlock(&dentry->d_parent->d_lock); diff --git a/fs/fuse/readdir.c b/fs/fuse/readdir.c index c2aae2eef086..f588252891af 100644 --- a/fs/fuse/readdir.c +++ b/fs/fuse/readdir.c @@ -160,7 +160,6 @@ static int fuse_direntplus_link(struct file *file, struct inode *dir =3D d_inode(parent); struct fuse_conn *fc; struct inode *inode; - DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); int epoch; =20 if (!o->nodeid) { @@ -197,7 +196,7 @@ static int fuse_direntplus_link(struct file *file, dentry =3D d_lookup(parent, &name); if (!dentry) { retry: - dentry =3D d_alloc_parallel(parent, &name, &wq); + dentry =3D d_alloc_parallel(parent, &name); if (IS_ERR(dentry)) return PTR_ERR(dentry); } diff --git a/fs/namei.c b/fs/namei.c index 6ffb8367b1cf..d31c3db7eb5e 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1891,13 +1891,12 @@ static struct dentry *__lookup_slow(const struct qs= tr *name, { struct dentry *dentry, *old; struct inode *inode =3D dir->d_inode; - DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); =20 /* Don't go there if it's already dead */ if (unlikely(IS_DEADDIR(inode))) return ERR_PTR(-ENOENT); again: - dentry =3D d_alloc_parallel(dir, name, &wq); + dentry =3D d_alloc_parallel(dir, name); if (IS_ERR(dentry)) return dentry; if (unlikely(!d_in_lookup(dentry))) { @@ -4408,7 +4407,6 @@ static struct dentry *lookup_open(struct nameidata *n= d, struct file *file, struct dentry *dentry; int error, create_error =3D 0; umode_t mode =3D op->mode; - DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); =20 if (unlikely(IS_DEADDIR(dir_inode))) return ERR_PTR(-ENOENT); @@ -4417,7 +4415,7 @@ static struct dentry *lookup_open(struct nameidata *n= d, struct file *file, dentry =3D d_lookup(dir, &nd->last); for (;;) { if (!dentry) { - dentry =3D d_alloc_parallel(dir, &nd->last, &wq); + dentry =3D d_alloc_parallel(dir, &nd->last); if (IS_ERR(dentry)) return dentry; } diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 2402f57c8e7d..52e7656195ec 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -727,7 +727,6 @@ void nfs_prime_dcache(struct dentry *parent, struct nfs= _entry *entry, unsigned long dir_verifier) { struct qstr filename =3D QSTR_INIT(entry->name, entry->len); - DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); struct dentry *dentry; struct dentry *alias; struct inode *inode; @@ -756,7 +755,7 @@ void nfs_prime_dcache(struct dentry *parent, struct nfs= _entry *entry, dentry =3D d_lookup(parent, &filename); again: if (!dentry) { - dentry =3D d_alloc_parallel(parent, &filename, &wq); + dentry =3D d_alloc_parallel(parent, &filename); if (IS_ERR(dentry)) return; } @@ -2107,7 +2106,6 @@ int nfs_atomic_open(struct inode *dir, struct dentry = *dentry, struct file *file, unsigned open_flags, umode_t mode) { - DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); struct nfs_open_context *ctx; struct dentry *res; struct iattr attr =3D { .ia_valid =3D ATTR_OPEN }; @@ -2163,7 +2161,7 @@ int nfs_atomic_open(struct inode *dir, struct dentry = *dentry, d_drop(dentry); switched =3D true; dentry =3D d_alloc_parallel(dentry->d_parent, - &dentry->d_name, &wq); + &dentry->d_name); if (IS_ERR(dentry)) return PTR_ERR(dentry); if (unlikely(!d_in_lookup(dentry))) diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c index df3ca4669df6..43ea897943c0 100644 --- a/fs/nfs/unlink.c +++ b/fs/nfs/unlink.c @@ -124,7 +124,7 @@ static int nfs_call_unlink(struct dentry *dentry, struc= t inode *inode, struct nf struct dentry *alias; =20 down_read_non_owner(&NFS_I(dir)->rmdir_sem); - alias =3D d_alloc_parallel(dentry->d_parent, &data->args.name, &data->wq); + alias =3D d_alloc_parallel(dentry->d_parent, &data->args.name); if (IS_ERR(alias)) { up_read_non_owner(&NFS_I(dir)->rmdir_sem); return 0; @@ -185,7 +185,6 @@ nfs_async_unlink(struct dentry *dentry, const struct qs= tr *name) =20 data->cred =3D get_current_cred(); data->res.dir_attr =3D &data->dir_attr; - init_waitqueue_head(&data->wq); =20 status =3D -EBUSY; spin_lock(&dentry->d_lock); diff --git a/fs/proc/base.c b/fs/proc/base.c index 4eec684baca9..070c0d58b2da 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2129,8 +2129,7 @@ bool proc_fill_cache(struct file *file, struct dir_co= ntext *ctx, =20 child =3D try_lookup_noperm(&qname, dir); if (!child) { - DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); - child =3D d_alloc_parallel(dir, &qname, &wq); + child =3D d_alloc_parallel(dir, &qname); if (IS_ERR(child)) goto end_instantiate; if (d_in_lookup(child)) { diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 49ab74e0bfde..04a382178c65 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -692,8 +692,7 @@ static bool proc_sys_fill_cache(struct file *file, =20 child =3D d_lookup(dir, &qname); if (!child) { - DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); - child =3D d_alloc_parallel(dir, &qname, &wq); + child =3D d_alloc_parallel(dir, &qname); if (IS_ERR(child)) return false; if (d_in_lookup(child)) { diff --git a/fs/smb/client/readdir.c b/fs/smb/client/readdir.c index 8615a8747b7f..47f5d620b750 100644 --- a/fs/smb/client/readdir.c +++ b/fs/smb/client/readdir.c @@ -73,7 +73,6 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *nam= e, struct cifs_sb_info *cifs_sb =3D CIFS_SB(sb); bool posix =3D cifs_sb_master_tcon(cifs_sb)->posix_extensions; bool reparse_need_reval =3D false; - DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); int rc; =20 cifs_dbg(FYI, "%s: for %s\n", __func__, name->name); @@ -105,7 +104,7 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *n= ame, (fattr->cf_flags & CIFS_FATTR_NEED_REVAL)) return; =20 - dentry =3D d_alloc_parallel(parent, name, &wq); + dentry =3D d_alloc_parallel(parent, name); } if (IS_ERR(dentry)) return; diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 898c60d21c92..c6440c626a0f 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -244,8 +244,7 @@ extern void d_delete(struct dentry *); /* allocate/de-allocate */ extern struct dentry * d_alloc(struct dentry *, const struct qstr *); extern struct dentry * d_alloc_anon(struct super_block *); -extern struct dentry * d_alloc_parallel(struct dentry *, const struct qstr= *, - wait_queue_head_t *); +extern struct dentry * d_alloc_parallel(struct dentry *, const struct qstr= *); extern struct dentry * d_splice_alias(struct inode *, struct dentry *); /* weird procfs mess; *NOT* exported */ extern struct dentry * d_splice_alias_ops(struct inode *, struct dentry *, diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index ff1f12aa73d2..1acc2479cb38 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1740,7 +1740,6 @@ struct nfs_unlinkdata { struct nfs_removeargs args; struct nfs_removeres res; struct dentry *dentry; - wait_queue_head_t wq; const struct cred *cred; struct nfs_fattr dir_attr; long timeout; --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC58B30EF6C; Thu, 12 Mar 2026 21:45:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773351956; cv=none; b=hDgSxF/zUi9e36nnS0IRCZ11O+mK2bB42EGxYkB1i+k1Z9ItSeEseQb6kEk7XUJBOUHhd7JZ4vQwOPwa+aPuPlpSZl5OBF54ESZCPNUE6kdAC70RdbpqF8l8iMPd/jWY/qDYGAYxSB6J7tUMT36iPe3jFP2YjRy2StIJEsrSU6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773351956; c=relaxed/simple; bh=NP4fxbAgK/sTDH/N09RZdgSyoNWhHFPeHmiXu7XZLn0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g8dNWYLAHl6HOkHNaIC4xro3CPqXG+E00U2bIkSTHeVdVn4ulMr7OMCm76zJ0v/SiKjA7e7TDTl3wpqfrYY2zNvBNKFsL5iw5KrSKWFFjf7hqnDu6eQ5MWaGWzKF5AZ6JQvZjtP5EWb4eOIlW2B8vT6RAEeCulYr0bnQ+RQGveE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=pPGvE0/w; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=eFIhTwRQ; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="pPGvE0/w"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="eFIhTwRQ" Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailflow.stl.internal (Postfix) with ESMTP id 3580F1301B45; Thu, 12 Mar 2026 17:45:53 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Thu, 12 Mar 2026 17:45:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773351953; x=1773359153; bh=pOd6V7aKWFyKrN4KTkaFsGguAEcn5SSc/x2IfH39lBE=; b= pPGvE0/wze36tWU9meYWm71B5TEuwgjRl7cD7NY/VsCrs2UOu2H4cZhD6kfNHK43 Gr8Z3X40uCciBPHCc3eRyAxd0EHgpM0FWGMKdxp/Lit40UuawYIoChKd4ytFu+bO CTK+mieDXDcRAN+U05ePX8ZprftdvXdJsHYS8r3C+1MTsutJNW0FqPdRKSFiYaFT Pqawe5NhNacvc0OkXGvVXjEQqAlmMwvgk3rU83qWlvWjsWS/ZnyYUGpZ/usSmSdc AGeM7LfKykjTRzE1phaKDqaKG02WaJ0E/+KnLi17wRz8EFCnEX16D9eXuio1p71E oCnNMDE2YXOHhTwDCTQM5w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773351953; x=1773359153; bh=p Od6V7aKWFyKrN4KTkaFsGguAEcn5SSc/x2IfH39lBE=; b=eFIhTwRQmdA0/ycbp 8k0ZJ7O9a3vmHkwPo0UDJPa38tcW6T9LKWyKQHfAjkADzC3U71y4B7rTKoW0jIaf tsM6beiXSWuOpcbEyCcfhU2jv/1y/Kts15nH7ihQoxLpfH0I6VRBmHfyeRReNVo4 b0/JsGh7FRaLG/C/GLScSrCB7cbwYMNlzSOG6FyDcYRBiotzXpc70QmG2mbiCaDH YTYQtO5R/TPsIHwSTrhlkKSrP8toQTjRONGsz3tAKHk5XSLxx7gESTZIV43TxO1L PBtIW4sJGXH9emjdJB3Qa/nCukQmQopIL/3vXMQ6YMNKVJ66Fqn16mg5BqQSUbEA ifZ5g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejkeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:45:39 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 05/53] VFS: introduce d_alloc_noblock() Date: Fri, 13 Mar 2026 08:11:52 +1100 Message-ID: <20260312214330.3885211-6-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown Several filesystems use the results of readdir to prime the dcache. These filesystems use d_alloc_parallel() which can block if there is a concurrent lookup. Blocking in that case is pointless as the lookup will add info to the dcache and there is no value in the readdir waiting to see if it should add the info too. Also these calls to d_alloc_parallel() are made while the parent directory is locked. A proposed change to locking will lock the parent later, after d_alloc_parallel(). This means it won't be safe to wait in d_alloc_parallel() while holding the directory lock. So this patch introduces d_alloc_noblock() which doesn't block but instead returns ERR_PTR(-EWOULDBLOCK). Filesystems that prime the dcache (smb/client, nfs, fuse, cephfs) can now use that and ignore -EWOULDBLOCK errors as harmless. Signed-off-by: NeilBrown --- fs/dcache.c | 82 ++++++++++++++++++++++++++++++++++++++++-- include/linux/dcache.h | 1 + 2 files changed, 80 insertions(+), 3 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index c80406bfa0d8..f4d7d200bc46 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2661,8 +2661,16 @@ static void d_wait_lookup(struct dentry *dentry) } } =20 -struct dentry *d_alloc_parallel(struct dentry *parent, - const struct qstr *name) +/* What to do when __d_alloc_parallel finds a d_in_lookup dentry */ +enum alloc_para { + ALLOC_PARA_WAIT, + ALLOC_PARA_FAIL, +}; + +static inline +struct dentry *__d_alloc_parallel(struct dentry *parent, + const struct qstr *name, + enum alloc_para how) { unsigned int hash =3D name->hash; struct hlist_bl_head *b =3D in_lookup_hash(parent, hash); @@ -2745,7 +2753,18 @@ struct dentry *d_alloc_parallel(struct dentry *paren= t, * wait for them to finish */ spin_lock(&dentry->d_lock); - d_wait_lookup(dentry); + if (d_in_lookup(dentry)) + switch (how) { + case ALLOC_PARA_FAIL: + spin_unlock(&dentry->d_lock); + dput(new); + dput(dentry); + return ERR_PTR(-EWOULDBLOCK); + case ALLOC_PARA_WAIT: + d_wait_lookup(dentry); + /* ... and continue */ + } + /* * it's not in-lookup anymore; in principle we should repeat * everything from dcache lookup, but it's likely to be what @@ -2774,8 +2793,65 @@ struct dentry *d_alloc_parallel(struct dentry *paren= t, dput(dentry); goto retry; } + +/** + * d_alloc_parallel() - allocate a new dentry and ensure uniqueness + * @parent - dentry of the parent + * @name - name of the dentry within that parent. + * + * A new dentry is allocated and, providing it is unique, added to the + * relevant index. + * If an existing dentry is found with the same parent/name that is + * not d_in_lookup(), then that is returned instead. + * If the existing dentry is d_in_lookup(), d_alloc_parallel() waits for + * that lookup to complete before returning the dentry and then ensures the + * match is still valid. + * Thus if the returned dentry is d_in_lookup() then the caller has + * exclusive access until it completes the lookup. + * If the returned dentry is not d_in_lookup() then a lookup has + * already completed. + * + * The @name must already have ->hash set, as can be achieved + * by e.g. try_lookup_noperm(). + * + * Returns: the dentry, whether found or allocated, or an error %-ENOMEM. + */ +struct dentry *d_alloc_parallel(struct dentry *parent, + const struct qstr *name) +{ + return __d_alloc_parallel(parent, name, ALLOC_PARA_WAIT); +} EXPORT_SYMBOL(d_alloc_parallel); =20 +/** + * d_alloc_noblock() - find or allocate a new dentry + * @parent - dentry of the parent + * @name - name of the dentry within that parent. + * + * A new dentry is allocated and, providing it is unique, added to the + * relevant index. + * If an existing dentry is found with the same parent/name that is + * not d_in_lookup() then that is returned instead. + * If the existing dentry is d_in_lookup(), d_alloc_noblock() + * returns with error %-EWOULDBLOCK. + * Thus if the returned dentry is d_in_lookup() then the caller has + * exclusive access until it completes the lookup. + * If the returned dentry is not d_in_lookup() then a lookup has + * already completed. + * + * The @name must already have ->hash set, as can be achieved + * by e.g. try_lookup_noperm(). + * + * Returns: the dentry, whether found or allocated, or an error + * %-ENOMEM or %-EWOULDBLOCK. + */ +struct dentry *d_alloc_noblock(struct dentry *parent, + struct qstr *name) +{ + return __d_alloc_parallel(parent, name, ALLOC_PARA_FAIL); +} +EXPORT_SYMBOL(d_alloc_noblock); + /* * - Unhash the dentry * - Retrieve and clear the waitqueue head in dentry diff --git a/include/linux/dcache.h b/include/linux/dcache.h index c6440c626a0f..3cb70b3398f0 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -245,6 +245,7 @@ extern void d_delete(struct dentry *); extern struct dentry * d_alloc(struct dentry *, const struct qstr *); extern struct dentry * d_alloc_anon(struct super_block *); extern struct dentry * d_alloc_parallel(struct dentry *, const struct qstr= *); +extern struct dentry * d_alloc_noblock(struct dentry *, struct qstr *); extern struct dentry * d_splice_alias(struct inode *, struct dentry *); /* weird procfs mess; *NOT* exported */ extern struct dentry * d_splice_alias_ops(struct inode *, struct dentry *, --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19DD923EABA; Thu, 12 Mar 2026 21:46:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773351973; cv=none; b=gVDIFg6mkdUfFMFMZavLML1qSV44onb0VYmUxF65EBXAnP6CBE8QrF2/hcT6UWga2sAap0DeT+0lI/3bBhicXioqJVPiHitImQCRuxRml6fsqYx7gEJMV3QTeygQwuMoNjNwGVOBpZNfih0RqFzr1ru4h6MxVpISvc+yq7ngZ3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773351973; c=relaxed/simple; bh=fDGXpOXRUF/3BM1fPQrSgHvXIMv6aNXUNTjnw4ZCVns=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iLQJh8fGa9sHUYgE1yXF4Fax0x4BYdZeY+VY+Qe2ujd3j5j7V3961QSp0+4ZIwe4eYqfTqIgptcBmk1IRxS+gEy+PmAJo9qpjqfUuAyGpFP+oXv0UcGJt1aV/3z4Wg9F+G6Q5t4YaGWS3YSsOzn/+OMb5HPJOnx9dPjxCsriHCE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=WQJKthP0; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=XqN3zbVr; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="WQJKthP0"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="XqN3zbVr" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailflow.stl.internal (Postfix) with ESMTP id 5A0321301B47; Thu, 12 Mar 2026 17:46:10 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Thu, 12 Mar 2026 17:46:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773351970; x=1773359170; bh=jtoJ4VcsB5KJ5RIkAzW9fPn73bKnKljRG2pvIdddt9Y=; b= WQJKthP0rTsiI3RJocxIH3ZvletwK+s1SspQgny4TfWHov2isTsHrUD4GI2x+h1N 0Uz3Ba5LJCq/zK5+RzsV2iv55k10jF6H59khluBI7mUd+MOoaLyvYsOhfvQyAgVj zeCrNgqGyjwp2B+tZiItl7z8gshz0/F73xa/PNbn+IQTYiY1gr32QdTX2H7Hrw8C v2ChvnkqOxTcfxmT5LfOrub5UMwIcDz/kXudaMUhKmneYYSQME5b3zRy6VW9u4BV BlEmUX20QekaXZmvDj12T54B2/nh09aPaUIx5wAGpvwz5mHzIyUWvw8oh5jS9w89 3hHbH6QXcFcOR/CylE4G0g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773351970; x=1773359170; bh=j toJ4VcsB5KJ5RIkAzW9fPn73bKnKljRG2pvIdddt9Y=; b=XqN3zbVrMt4Dgh7Xe Hu9v4x7EFwXrTqUlq7pGIydeYfW4eXt0t2LewIJtqvHwWZQ5vpf0H+vKOJahySNe ly4TeGTRFpEdg/6Bv1bvNAezzqcp4yK98kxJn0+LkZSH866Fp88T0OTZeguLrslq EB4fcaD5sgj2UJILJgyCfYX/ohZjgN0WVfx80rKtOk7DvlXiIkfOuPyQGuLjcU4H pDO9Y3ljMvqWBzqQn1SL9Y6COsNusqrqWpN1JDr8F03oMSpiF1GNMBuemKgFrzkT RRG6Wqns755H7VAlLA4g0/2gE5Qy5zY4Nr0+UjY2OTfoBIPRyHZ78Gkm+MTFasH4 5PU+A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejledtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:45:56 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 06/53] VFS: add d_duplicate() Date: Fri, 13 Mar 2026 08:11:53 +1100 Message-ID: <20260312214330.3885211-7-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown Occasionally a single operation can require two sub-operations on the same name, and it is important that a d_alloc_parallel() (once that can be run unlocked) does not create another dentry with the same name between the operations. Two examples: 1/ rename where the target name (a positive dentry) needs to be "silly-renamed" to a temporary name so it will remain available on the server (NFS and AFS). Here the same name needs to be the subject of one rename, and the target of another. 2/ rename where the subject needs to be replaced with a white-out (shmemfs). Here the same name need to be the target of a rename and the target of a mknod() In both cases the original dentry is renamed to something else, and a replacement is instantiated, possibly as the target of d_move(), possibly by d_instantiate(). Currently d_alloc() is used to create the dentry and the exclusive lock on the parent ensures no other dentry is created. When d_alloc_parallel() is moved out of the parent lock, this will no longer be sufficient. In particular if the original is renamed away before the new is instantiated, there is a window where d_alloc_parallel() could create another name. "silly-rename" does work in this order. shmemfs whiteout doesn't open this hole but is essentially the same pattern and should use the same approach. The new d_duplicate() creates an in-lookup dentry with the same name as the original dentry, which must be hashed. There is no need to check if an in-lookup dentry exists with the same name as d_alloc_parallel() will never try add one while the hashed dentry exists. Once the new in-lookup is created, d_alloc_parallel() will find it and wait for it to complete, then use it. Signed-off-by: NeilBrown --- fs/dcache.c | 52 ++++++++++++++++++++++++++++++++++++++++++ include/linux/dcache.h | 1 + 2 files changed, 53 insertions(+) diff --git a/fs/dcache.c b/fs/dcache.c index f4d7d200bc46..c12319097d6e 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1832,6 +1832,58 @@ struct dentry *d_alloc(struct dentry * parent, const= struct qstr *name) } EXPORT_SYMBOL(d_alloc); =20 +/** + * d_duplicate: duplicate a dentry for combined atomic operation + * @dentry: the dentry to duplicate + * + * Some rename operations need to be combined with another operation + * inside the filesystem. + * 1/ A cluster filesystem when renaming to an in-use file might need to + * first "silly-rename" that target out of the way before the main rename + * 2/ A filesystem that supports white-out might want to create a whiteout + * in place of the file being moved. + * + * For this they need two dentries which temporarily have the same name, + * before one is renamed. d_duplicate() provides for this. Given a + * positive hashed dentry, it creates a second in-lookup dentry. + * Because the original dentry exists, no other thread will try to + * create an in-lookup dentry, os there can be no race in this create. + * + * The caller should d_move() the original to a new name, often via a + * rename request, and should call d_lookup_done() on the newly created + * dentry. If the new is instantiated and the old MUST either be moved + * or dropped. + * + * Parent must be locked. + * + * Returns: an in-lookup dentry, or an error. + */ +struct dentry *d_duplicate(struct dentry *dentry) +{ + unsigned int hash =3D dentry->d_name.hash; + struct dentry *parent =3D dentry->d_parent; + struct hlist_bl_head *b =3D in_lookup_hash(parent, hash); + struct dentry *new =3D __d_alloc(parent->d_sb, &dentry->d_name); + + if (unlikely(!new)) + return ERR_PTR(-ENOMEM); + + new->d_flags |=3D DCACHE_PAR_LOOKUP; + new->d_wait =3D NULL; + spin_lock(&parent->d_lock); + new->d_parent =3D dget_dlock(parent); + hlist_add_head(&new->d_sib, &parent->d_children); + if (parent->d_flags & DCACHE_DISCONNECTED) + new->d_flags |=3D DCACHE_DISCONNECTED; + spin_unlock(&dentry->d_parent->d_lock); + + hlist_bl_lock(b); + hlist_bl_add_head(&new->d_u.d_in_lookup_hash, b); + hlist_bl_unlock(b); + return new; +} +EXPORT_SYMBOL(d_duplicate); + struct dentry *d_alloc_anon(struct super_block *sb) { return __d_alloc(sb, NULL); diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 3cb70b3398f0..2a3ebd368ed9 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -247,6 +247,7 @@ extern struct dentry * d_alloc_anon(struct super_block = *); extern struct dentry * d_alloc_parallel(struct dentry *, const struct qstr= *); extern struct dentry * d_alloc_noblock(struct dentry *, struct qstr *); extern struct dentry * d_splice_alias(struct inode *, struct dentry *); +struct dentry *d_duplicate(struct dentry *dentry); /* weird procfs mess; *NOT* exported */ extern struct dentry * d_splice_alias_ops(struct inode *, struct dentry *, const struct dentry_operations *); --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 192A73AE1B0; Thu, 12 Mar 2026 21:46:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773351990; cv=none; b=Zmob4+w4KfzEQ6yfjeP91LKhPmlfbxFyp9Mt0UxIjWNWZV5tKd2O4Q5J7ZbcqOXvAkUOkPd8vPMTkGMVu7Fn3y1SjW3IayPAdI3kZsD8aZr1TmmVWDac0TLOSLRx3Y0SyKAfIKgIXQSPp9Kd3aJOWtWkcPWs/jAxDV5IW1E6u4c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773351990; c=relaxed/simple; bh=u3LBkXn15QIzqAss/2USWvprYCIhe/z34FJfzv6l5/Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H/UfETDojkldQ2KEBuOwMchfKmiZPgz2QTnnIFH5MjZ0vBKuKoQ5UTYqrAHW/aRcAGrYR0kh8Jrk5my9EoLhp0rNxCDKp9hzj8+oQPR0PB+EnzYKb429R7Yqw0kQMkjE/sEz008o6oFkF1r6RH1Cn/9fUe637aHNqlfvapMWT8k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=KP3KmofC; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=EM63CurB; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="KP3KmofC"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="EM63CurB" Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailflow.stl.internal (Postfix) with ESMTP id 4D4CA1301B58; Thu, 12 Mar 2026 17:46:27 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Thu, 12 Mar 2026 17:46:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773351987; x=1773359187; bh=jFIiei8hP9eouC0SsGkVtqGMAl3skHPWk1wOm65U/S4=; b= KP3KmofCjcr3B+X9NgLhehjjQWjvB0L1RxnigH1q3NmPi9z5tKUX53SA4RbRuAAh 8ICxhDkH3O0bnUE+qC+zFU8WNq8K0pq925UJpNLbld9S8U9nc0muHzfnMLHm9VUR vztXmdk/aM5P95nkL0XMwX9ybhH719+DWeHEGTao+UOWI7lxMrU6Mw1XbVWYtSXS EDCm2Nsb04P8CB/j4K9w6lr+hyB/igARie1rsG2NalgOGQVpFhXFEW88tyUsHj6B /6DRqiy9CeTAow8kFmGZBL8FFkmlKGzWV6GVq2kBJPXMv7mSVxlqdT440tnO+DNI y5unhWaVC+hb9Kko94krOw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773351987; x=1773359187; bh=j FIiei8hP9eouC0SsGkVtqGMAl3skHPWk1wOm65U/S4=; b=EM63CurB/EIqg0bzC mjMxQq3eNXKOpGBZJPriZWRxxClegJnzt4SKrP1g2qQfyNl16vjSk4AaldBZ+JWf qeiyyYsjRnwFCD/IF9FkKSPVhZbSLDgwR51afyFyygx9Wnwy//hLSL+OOOo8N7D2 zazNXklWj+3/4NZ/FP1rvYYUuPhkUP4Rst0agYj0sBdRYqduLOTb32mLrRUMZR/R rpZCOA9TydSifeXzyLzYJ5C5KJHz0h86TKjboP4Si9kcHib8C4yUTdyyS9x2Owwf lgjefxnpqi+o3ZpSMnNzmU6I02Wt/oP+Yqfvi0tAcxkoKNffFnQJG7HbO7b88hmI boTLw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejkeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:46:13 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 07/53] VFS: Add LOOKUP_SHARED flag. Date: Fri, 13 Mar 2026 08:11:54 +1100 Message-ID: <20260312214330.3885211-8-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown Some ->lookup handlers will need to drop and retake the parent lock, so they can safely use d_alloc_parallel(). ->lookup can be called with the parent lock either exclusive or shared. A new flag, LOOKUP_SHARED, tells ->lookup how the parent is locked. This is rather ugly, but will be gone by the end of the series when ->lookup is *always* called with a shared lock on the parent. Signed-off-by: NeilBrown --- fs/namei.c | 7 ++++--- include/linux/namei.h | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index d31c3db7eb5e..eed388ee8a30 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1928,7 +1928,7 @@ static noinline struct dentry *lookup_slow(const stru= ct qstr *name, struct inode *inode =3D dir->d_inode; struct dentry *res; inode_lock_shared(inode); - res =3D __lookup_slow(name, dir, flags); + res =3D __lookup_slow(name, dir, flags | LOOKUP_SHARED); inode_unlock_shared(inode); return res; } @@ -1942,7 +1942,7 @@ static struct dentry *lookup_slow_killable(const stru= ct qstr *name, =20 if (inode_lock_shared_killable(inode)) return ERR_PTR(-EINTR); - res =3D __lookup_slow(name, dir, flags); + res =3D __lookup_slow(name, dir, flags | LOOKUP_SHARED); inode_unlock_shared(inode); return res; } @@ -4407,6 +4407,7 @@ static struct dentry *lookup_open(struct nameidata *n= d, struct file *file, struct dentry *dentry; int error, create_error =3D 0; umode_t mode =3D op->mode; + unsigned int shared_flag =3D (op->open_flag & O_CREAT) ? 0 : LOOKUP_SHARE= D; =20 if (unlikely(IS_DEADDIR(dir_inode))) return ERR_PTR(-ENOENT); @@ -4474,7 +4475,7 @@ static struct dentry *lookup_open(struct nameidata *n= d, struct file *file, =20 if (d_in_lookup(dentry)) { struct dentry *res =3D dir_inode->i_op->lookup(dir_inode, dentry, - nd->flags); + nd->flags | shared_flag); d_lookup_done(dentry); if (unlikely(res)) { if (IS_ERR(res)) { diff --git a/include/linux/namei.h b/include/linux/namei.h index 2ad6dd9987b9..b3346a513d8f 100644 --- a/include/linux/namei.h +++ b/include/linux/namei.h @@ -37,8 +37,9 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT}; #define LOOKUP_CREATE BIT(17) /* ... in object creation */ #define LOOKUP_EXCL BIT(18) /* ... in target must not exist */ #define LOOKUP_RENAME_TARGET BIT(19) /* ... in destination of rename() */ +#define LOOKUP_SHARED BIT(20) /* Parent lock is held shared */ =20 -/* 4 spare bits for intent */ +/* 3 spare bits for intent */ =20 /* Scoping flags for lookup. */ #define LOOKUP_NO_SYMLINKS BIT(24) /* No symlink crossing. */ --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73D843A6B71; Thu, 12 Mar 2026 21:46:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352010; cv=none; b=bP9XdeTTmTEhzcUGdR620A/EUOJAMsRlHqRpsSWtH+hHHft9rOyc1hyANSvo/wncFKGfhf1vvd8ucaabIylQT2bM3cZUprdEd3koXveoKb9lghe6tEfYjlWzbPxPL/CbUx+UR/iJ1ty9rVzYtRDhMaei+BNrDYv5ps9AGuQefFE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352010; c=relaxed/simple; bh=0UbS3rgmCbSshMD+eXPex41XbcsyIS8pZIzWXdA+Vn8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LQ/97z4DEh07ycLodgrGcJZSgI09GJ3i2MwiR2bKpOfQj3RfzKcUXNFip2u8wEUfd/+ygl82okpe+sqAm8m79q6FveZK97i+73TLJXnjzT1OgdLdXIF0F9iLYHKRNOyVAsqXNefldliRIGEvuLfF2z3zZORwUGzBl9Y+EVFHHgE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=SerCWqLI; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=bz1e/Oln; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="SerCWqLI"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="bz1e/Oln" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailflow.stl.internal (Postfix) with ESMTP id 293E41300F6C; Thu, 12 Mar 2026 17:46:44 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Thu, 12 Mar 2026 17:46:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352004; x=1773359204; bh=4WJg8BesAO2r3vZCyn8Qj6EvQOGiM+109I5YGqS1b9I=; b= SerCWqLIgdWRLB6BFLBdqn2eI+vI5/t4G8+IU7QLeE8wYOrdHBw5HU694Zz4gf3W M6tCB5+ksA0SG/bjn4x5w9+oyXipICRWoxM0ehBTavuD1xt02fz2Jdhcbs1AqGB1 xcXbISL1jLJEABmTYnW/lMs2oqr2ta/3BNNWvrocKOn9gK+6mf47WNMrpBl592kJ FzscqO6u6qq4PnC9NiqFVwTPOrfVhOWBGK14bw6NESRrWKqV7Dl4Dco4/LE+hFbo HixqPSoOkkx2VI5A/uT1KJd7g0Oc5t/uavVuNubv5KUOz1eH1PyEG3UIsGNvyorv 2b/dfxvPTHpC0RdBiGo00g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352004; x=1773359204; bh=4 WJg8BesAO2r3vZCyn8Qj6EvQOGiM+109I5YGqS1b9I=; b=bz1e/OlnsMyj6akRb IxeYS9L2jvkQo8W89blCf+xp6yfqMO3SMeerllq7Ios+b+V5zIhfXemg6fgMmsA7 7ncn1BKA1nPjv9DXPEyTjhjjPbyzrQyvwa8Z4FIdur7w0pFW/P7SpKZQC1bNqVjG SQJ0LVU3ABw9muOjKVl8UHKkptWCo66BsQtjh8/a3tjtMpHJh3m3w6A/vrLCKGHr Jdm/2cEgZFqV81SboGMySRQNjqSXtpMWuMHpMv+gnZ+/tGg6J8nD3annX4j4KTaR /8dnRk1YiNlPOc2j5fyVdgnPf2yKQJ48BLw6M2c1qifsRF7kXNb3OXfFmGkRd5M/ CdYig== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejledtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:46:30 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 08/53] VFS/xfs: drop parent lock across d_alloc_parallel() in d_add_ci() Date: Fri, 13 Mar 2026 08:11:55 +1100 Message-ID: <20260312214330.3885211-9-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown A proposed change will invert the lock ordering between d_alloc_parallel() and inode_lock() on the parent. When that happens it will not be safe to call d_alloc_parallel() while holding the parent lock - even shared. We don't need to keep the parent lock held when d_add_ci() is run - the VFS doesn't need it as dentry is exclusively held due to DCACHE_PAR_LOOKUP and the filesystem has finished its work. So drop and reclaim the lock (shared or exclusive as determined by LOOKUP_SHARED) to avoid future deadlock. Signed-off-by: NeilBrown --- fs/dcache.c | 18 +++++++++++++++++- fs/xfs/xfs_iops.c | 3 ++- include/linux/dcache.h | 3 ++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index c12319097d6e..a1219b446b74 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2225,6 +2225,7 @@ EXPORT_SYMBOL(d_obtain_root); * @dentry: the negative dentry that was passed to the parent's lookup func * @inode: the inode case-insensitive lookup has found * @name: the case-exact name to be associated with the returned dentry + * @bool: %true if lookup was performed with LOOKUP_SHARED * * This is to avoid filling the dcache with case-insensitive names to the * same inode, only the actual correct case is stored in the dcache for @@ -2237,7 +2238,7 @@ EXPORT_SYMBOL(d_obtain_root); * the exact case, and return the spliced entry. */ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, - struct qstr *name) + struct qstr *name, bool shared) { struct dentry *found, *res; =20 @@ -2250,6 +2251,17 @@ struct dentry *d_add_ci(struct dentry *dentry, struc= t inode *inode, iput(inode); return found; } + /* + * We are holding parent lock and so don't want to wait for a + * d_in_lookup() dentry. We can safely drop the parent lock and + * reclaim it as we have exclusive access to dentry as it is + * d_in_lookup() (so ->d_parent is stable) and we are near the + * end ->lookup() and will shortly drop the lock anyway. + */ + if (shared) + inode_unlock_shared(d_inode(dentry->d_parent)); + else + inode_unlock(d_inode(dentry->d_parent)); if (d_in_lookup(dentry)) { found =3D d_alloc_parallel(dentry->d_parent, name); if (IS_ERR(found) || !d_in_lookup(found)) { @@ -2263,6 +2275,10 @@ struct dentry *d_add_ci(struct dentry *dentry, struc= t inode *inode, return ERR_PTR(-ENOMEM); } } + if (shared) + inode_lock_shared(d_inode(dentry->d_parent)); + else + inode_lock_nested(d_inode(dentry->d_parent), I_MUTEX_PARENT); res =3D d_splice_alias(inode, found); if (res) { d_lookup_done(found); diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 208543e57eda..ec19d3ec7cf0 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -35,6 +35,7 @@ #include #include #include +#include // for LOOKUP_SHARED =20 /* * Directories have different lock order w.r.t. mmap_lock compared to regu= lar @@ -369,7 +370,7 @@ xfs_vn_ci_lookup( /* else case-insensitive match... */ dname.name =3D ci_name.name; dname.len =3D ci_name.len; - dentry =3D d_add_ci(dentry, VFS_I(ip), &dname); + dentry =3D d_add_ci(dentry, VFS_I(ip), &dname, !!(flags & LOOKUP_SHARED)); kfree(ci_name.name); return dentry; } diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 2a3ebd368ed9..a97eb151d9db 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -251,7 +251,8 @@ struct dentry *d_duplicate(struct dentry *dentry); /* weird procfs mess; *NOT* exported */ extern struct dentry * d_splice_alias_ops(struct inode *, struct dentry *, const struct dentry_operations *); -extern struct dentry * d_add_ci(struct dentry *, struct inode *, struct qs= tr *); +extern struct dentry * d_add_ci(struct dentry *, struct inode *, struct qs= tr *, + bool); extern bool d_same_name(const struct dentry *dentry, const struct dentry *= parent, const struct qstr *name); extern struct dentry *d_find_any_alias(struct inode *inode); --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 741B83AB290; Thu, 12 Mar 2026 21:47:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352025; cv=none; b=AiHdKlFcgFpHiJn5Riv3lIMPrWpyAeXkDOPFI/ymfd53g7kAP9r5EpiNjsgEwQa48FUm+b8Xuk5NeILc983pdX+T2LvoSxN7eg1Dx1gXJISlp8UbWo1Xel+QUTRByen5zFq3z3zUm4Xx8cXVe2TfTsZPaD68sjnjcFnT3eTuWo4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352025; c=relaxed/simple; bh=8EFW4rG6MnNKfSYvHr+5gwbSRTR3ykiIKyTe8AdjEDY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IMK7oq8b28Y+ii2PkFHvi+zAPlC3miOwjsCTIEIkVSsw7BpjsYfnXIlUYUaM3eqTriIMZwO74QT88Dh4mFA7owOguqSVI0xeadXun3/TU34ozmYcHIDzjY7U7fL2rsxk7iVKWLfbjSCOCgZ45NmN8h02aFLP3VLzNBdXFl0i58A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=BC76xmpQ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=DCxT41qh; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="BC76xmpQ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="DCxT41qh" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailflow.stl.internal (Postfix) with ESMTP id 6586A1301B5F; Thu, 12 Mar 2026 17:47:01 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Thu, 12 Mar 2026 17:47:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352021; x=1773359221; bh=d9RhJ2BuLywXUJ/fvnCHaZYNU2thzEny+uIpuniq6ls=; b= BC76xmpQzBJ/5FWzgYwZ3exEB8Y9YxPHLjPvprCTetgklTOlLNdancD8t5ymMjZa 3NCix1LQtbhZKIJmxEJsx5VOEAsW8ee1C/VOGvYvKaDXzSQ7qm1PJWuggVq+7sOX RwRQfVuH121ZKNqX5D/PIfCsH/R6iyJhKA8S1o7+T0+6YM48RxlHwDogpHijdGHt SS6wqZBT0lkrQfBq4MLO1x3tvt0osH1t+pfpDHUUXYF4La5ohqB0DxS7k64FuKq4 /2t1hr7mfNYFsZZJGtj09uj4rOGEZYTnz7ENVdeRFWwkjiYo7XhaQ7N6ktWdp3BC HDT8R38jU0q4FXwFBawbLw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352021; x=1773359221; bh=d 9RhJ2BuLywXUJ/fvnCHaZYNU2thzEny+uIpuniq6ls=; b=DCxT41qhRsolTCr8S fmLfxVTn2usDZk1YalfS014uow6ZmLtFeCiClbu0uY1EqfEce3yq0r6X15MS9F9O f5KaXSo+ceu5kK+S14baxhrU7tWh8UL4DUJ+ZQfKlkyWEz7zM0VrHY42SKCSlbIk z+JPxA1n9EmcTefXq5hlS4p7dFYZ5qD2phNVpZqECjx0aLzOZWjwX/Je2vdTQJeE cDuagD/6uB7HJqWOXrwp3hGm29I2LG09xT8ITuzo532E7DZV63YmHP8I6C6p3yMQ qGGHEUDjoK0CXP0n28Zz3w6DZ6cRwngVDUDiVADWPhnRp98AFT0MsQ5OH3LvviFd CNZRg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejledtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:46:47 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 09/53] nfs: remove d_drop()/d_alloc_parallel() from nfs_atomic_open() Date: Fri, 13 Mar 2026 08:11:56 +1100 Message-ID: <20260312214330.3885211-10-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown It is important that two non-create NFS "open"s of a negative dentry don't race. They both have only a shared lock on i_rwsem and so could run concurrently, but they might both try to call d_splice_alias() at the same time which is confusing at best. nfs_atomic_open() currently avoids this by discarding the negative dentry and creating a new one using d_alloc_parallel(). Only one thread can successfully get the d_in_lookup() dentry, the other will wait for the first to finish, and can use the result of that first lookup. A proposed locking change inverts the order between i_rwsem and d_alloc_parallel() so it will not be safe to call d_alloc_parallel() while holding i_rwsem - even shared. We can achieve the same effect by causing ->d_revalidate to invalidate a negative dentry when LOOKUP_OPEN is set. Doing this is consistent with the "close to open" caching semantics of NFS which requires the server to be queried whenever opening a file - cached information must not be trusted. With this change to ->d_revaliate (implemented in nfs_neg_need_reval) we can be sure that we have exclusive access to any dentry that reaches nfs_atomic_open(). Either O_CREAT was requested and so the parent is locked exclusively, or the dentry will have DCACHE_PAR_LOOKUP set. This means that the d_drop() and d_alloc_parallel() calls in nfs_atomic_lookup() are no longer needed to provide exclusion Signed-off-by: NeilBrown --- fs/nfs/dir.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 52e7656195ec..3033cc5ce12f 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1657,6 +1657,13 @@ int nfs_neg_need_reval(struct inode *dir, struct den= try *dentry, { if (flags & (LOOKUP_CREATE | LOOKUP_RENAME_TARGET)) return 0; + if (flags & LOOKUP_OPEN) + /* close-to-open semantics require we go to server + * on each open. By invalidating the dentry we + * also ensure nfs_atomic_open() always has exclusive + * access to the dentry. + */ + return 0; if (NFS_SERVER(dir)->flags & NFS_MOUNT_LOOKUP_CACHE_NONEG) return 1; /* Case insensitive server? Revalidate negative dentries */ @@ -2112,7 +2119,6 @@ int nfs_atomic_open(struct inode *dir, struct dentry = *dentry, struct inode *inode; unsigned int lookup_flags =3D 0; unsigned long dir_verifier; - bool switched =3D false; int created =3D 0; int err; =20 @@ -2157,17 +2163,6 @@ int nfs_atomic_open(struct inode *dir, struct dentry= *dentry, attr.ia_size =3D 0; } =20 - if (!(open_flags & O_CREAT) && !d_in_lookup(dentry)) { - d_drop(dentry); - switched =3D true; - dentry =3D d_alloc_parallel(dentry->d_parent, - &dentry->d_name); - if (IS_ERR(dentry)) - return PTR_ERR(dentry); - if (unlikely(!d_in_lookup(dentry))) - return finish_no_open(file, dentry); - } - ctx =3D create_nfs_open_context(dentry, open_flags, file); err =3D PTR_ERR(ctx); if (IS_ERR(ctx)) @@ -2210,10 +2205,6 @@ int nfs_atomic_open(struct inode *dir, struct dentry= *dentry, trace_nfs_atomic_open_exit(dir, ctx, open_flags, err); put_nfs_open_context(ctx); out: - if (unlikely(switched)) { - d_lookup_done(dentry); - dput(dentry); - } return err; =20 no_open: @@ -2236,13 +2227,6 @@ int nfs_atomic_open(struct inode *dir, struct dentry= *dentry, res =3D ERR_PTR(-EOPENSTALE); } } - if (switched) { - d_lookup_done(dentry); - if (!res) - res =3D dentry; - else - dput(dentry); - } return finish_no_open(file, res); } EXPORT_SYMBOL_GPL(nfs_atomic_open); --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79A053233E8; Thu, 12 Mar 2026 21:47:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352041; cv=none; b=aJ7WD42Z210Wji2s14SsVe8TLRz1qyuy6jUIfAmMxQ0xmY8tlphx17Vl4rEc0snOWH4idf1ZYg43h3HSGAVYsYihV2T6HAp4+KjfasArhqiLi/QNFzIloBIMM81Wo5QdvliWh0LN55UZVT2+p+aZhZRhvFGVmj0sXz/Ng/RCgxg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352041; c=relaxed/simple; bh=L4DSrs1A1VM3jp3SaYWGahT0g1W2lWcLrqhvj2xmvdo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u42DdDP+IEDb/EAKhE0YaqHraJKxTerRtsjcpphTpsxs4fV/VLacq8EbS7tGruw/GarWcuJ7WHmMd53lcKzCpmmmnS8LiWIeky0iMrB+Y+sdglRmMgdtWTcF5I8jUSjtPlRVmTKacqTr22Qt+PRIeRlcO+uU3ReZCqV3npLgbs0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=M0GFvqkQ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=1/GE6Q4G; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="M0GFvqkQ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="1/GE6Q4G" Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailflow.stl.internal (Postfix) with ESMTP id CED9C1301B67; Thu, 12 Mar 2026 17:47:18 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Thu, 12 Mar 2026 17:47:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352038; x=1773359238; bh=CijUCx3yISxMWTDbwuIO0Uj8qxE5ByzXHAuT2ll77Kc=; b= M0GFvqkQA+hh9nwu7mc7JuOVZVPu+x8oqWAW5Vi1Rx0ZNPsVz7iMxZxDKcq92CRt w1O4ZA75sGW4LDIVw7O6OPJ5TEFeAuGPKTPe/7jj0ItCruKb1FNYdY27SqhvZ09e HQrUKDXLZ77hpZ3f5jgYHX/xKT6j73t2fG+qbzqf9J3oUiSlH08UW2HJtPZBZl4E tb3S6pnqBRQMWB5MJD7qakzz5t5Vcq4FHeC8JYwtac3CNO2XjQ3o8C+nf5JuyF16 FWLn2uA9VJxGu8LE7GwMewr9oJgdxJqtHJVrIkPAFUUXTRPZzAathqukS9KRqNd8 vGX+vFOH13CMrNdF9lzRxA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352038; x=1773359238; bh=C ijUCx3yISxMWTDbwuIO0Uj8qxE5ByzXHAuT2ll77Kc=; b=1/GE6Q4GOoKKny+rE 1MCv0IvGJwFowq3gK2WpQpCuceE0cpvuxFjvXlb6EWJLNxDdvDBFb7JWso2W7Kz4 mFFTfrB+C2ASTh9NC4SgG3HoHN43zfAxCmix5d+G+qZ+aEyNCsl3rNvSascyx4YJ TB8rxgDNbRLT7LoeFH5Cme9Q6tNfrxg9HzWUSDPszzVoCrORESTfN4bOq6nwEjj6 nETza6aQ5uv45gJWXn54lpcHJOjI6XXdrUFqpLGzMIRfCqkIT7j6Cl0tgJg0F5Yf GNRULcF7xFfRRsuAOZ9mhJL0pTFa5+J27A43M+te1whUV4b+qPS2w84fsWgiX6kO OBj6Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejledtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:47:05 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 10/53] nfs: use d_splice_alias() in nfs_link() Date: Fri, 13 Mar 2026 08:11:57 +1100 Message-ID: <20260312214330.3885211-11-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown When filename_linkat() calls filename_create() which ultimately calls ->lookup, the flags LOOKUP_CREATE|LOOKUP_EXCL are passed. nfs_lookup() treats this as an exclusive create (which it is) and skips the ->lookup, leaving the dentry unchanged. Currently that means nfs_link() can get a hashed dentry (if the name was already in the cache) or an unhashed dentry (if it wasn't). As none of d_add(), d_instantiate(), d_splice_alias() could handle both of these, nfs_link() calls d_drop() and then then d_add(). Recent changes to d_splice_alias() mean that it *can* work with either hashed or unhashed dentries. Future changes to locking mean that it will be unsafe to d_drop() a dentry while an operation (in this case "link()") is still ongoing. So change to use d_splice_alias(), and not to d_drop() until an error is detected (as in that case was can't be sure what is actually on the server). Also update the comment for nfs_is_exclusive_create() to note that link(), mkdir(), mknod(), symlink() all appear as exclusive creates. Those other than link() already used d_splice_alias() via nfs_add_or_obtain(). Signed-off-by: NeilBrown --- fs/nfs/dir.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 3033cc5ce12f..a188b09c9a54 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1571,6 +1571,9 @@ static int nfs_check_verifier(struct inode *dir, stru= ct dentry *dentry, /* * Use intent information to check whether or not we're going to do * an O_EXCL create using this path component. + * Note that link(), mkdir(), mknod(), symlink() all appear as + * exclusive creation. Regular file creation could be distinguished + * with LOOKUP_OPEN. */ static int nfs_is_exclusive_create(struct inode *dir, unsigned int flags) { @@ -2677,14 +2680,15 @@ nfs_link(struct dentry *old_dentry, struct inode *d= ir, struct dentry *dentry) old_dentry, dentry); =20 trace_nfs_link_enter(inode, dir, dentry); - d_drop(dentry); if (S_ISREG(inode->i_mode)) nfs_sync_inode(inode); error =3D NFS_PROTO(dir)->link(inode, dir, &dentry->d_name); if (error =3D=3D 0) { nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); ihold(inode); - d_add(dentry, inode); + d_splice_alias(inode, dentry); + } else { + d_drop(dentry); } trace_nfs_link_exit(inode, dir, dentry, error); return error; --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02961336EF8; Thu, 12 Mar 2026 21:47:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352059; cv=none; b=YH9JNGPeQAeQBIho8lm9PcgTFR87oBFJXrrb2UBZ3SZbOWdKajD+6tu29LL1bf+W0KhvSRoegDanMV37veeol59O9kQ1gkWcDAXoUKtGBZ7TVJIo1jLCfMh2K2IuJqKHnRJisFsi7YCg/3MZqvX2QQWBjWh6wgchn4gVUbuihGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352059; c=relaxed/simple; bh=3A3SQ2VrQvZNknUQ5qdDFG9Sap0OVcD2kF3Ips9VUVs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gf8K1xxIKwnr2U6SON7ElK95Cv9tAujFGZy4ARNUD9GD95BTAD1iSZDYvhPUNcK1LPG/ob4s+vtjp8Ok8n7ed97ycdWZyRsf9zzlzj8H6wmGTJidIXnn5kWhuvmK1HY2laAfx7te09f2qxEA5A84d0sUM8TsHAvQnFUxXxosGdA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=iPWOSxqZ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=unIU//e+; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="iPWOSxqZ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="unIU//e+" Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailflow.stl.internal (Postfix) with ESMTP id E848C1301B68; Thu, 12 Mar 2026 17:47:35 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Thu, 12 Mar 2026 17:47:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352055; x=1773359255; bh=IQfPF8qsPDD4y8gX0swga1hVwNgQjqyWwNEjHrIDNRM=; b= iPWOSxqZlSqyPdU6zTigaodUHhIuXMhwcY2p486hgesZ4N7bhchW/j7ATJHN9FBW oKMrqPBlqBMt3lkYCgSSFCKYXJmW9ODmThws66AtdxwYimzVfOz9cBugmFraUhdV YoO+Tg3MdlfJnhcIN9JfefQc+OGsJZ24NInAWQKWdb3ofc6nEyQw44fO+K1AQ1pL PckIAJ6PEuGLH3OUpr4l+1OppEhqfHtePP18EAfy8H3V1DfBdKsDc1LWDBmYxKsc 1007QHUZL97zu3IXO53mSATagMEzl3Qlsr521UnNLtczRjXcqKEV2fA3ORrfY0a3 MpOs5Xw5kf4wMfV1RUUcDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352055; x=1773359255; bh=I QfPF8qsPDD4y8gX0swga1hVwNgQjqyWwNEjHrIDNRM=; b=unIU//e+8gYENP4K1 FVVmPPrZh+cW9to8xynIOLL2gjLoSBNBWQceiEYqrtNCGzla1+3dWZUcITjMgi/X uuL46Ngko2u2uNp1O1vKehEFbTUjc4NkhiutBEF1BzxX5CZ/RVgo9uua3IfTb1U4 NGa3YLqzHArKaIKtpRK98PwLIBxeoOcWX+A+OTTeQa5687EfcLW0m0JQ4OCHV0qj k505GHZtj/bSahn2aOVVCe3jQhaIxFFRjMcooWaTHAaqasI9A/H+N3+vQ1i3PxZy LueNtc+7viQ3EYAT0DTVcQn6YEP2Q1GLKATntEhtaDEKcbXPcerB8IzWARCsLvWM IvM2Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejledtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:47:22 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 11/53] nfs: don't d_drop() before d_splice_alias() Date: Fri, 13 Mar 2026 08:11:58 +1100 Message-ID: <20260312214330.3885211-12-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown nfs_add_or_obtain() is used, often via nfs_instantiate(), to attach a newly created inode to the appropriate dentry - or to provide an alternate dentry. It has to drop the dentry first, which is problematic for proposed locking changes. As d_splice_alias() now works with hashed dentries, the d_drop() is no longer needed. However we still d_drop() on error as the status of the name is uncertain. nfs_open_and_get_state() is only used for files so we should be able to use d_instantiate(). However as that depends on the server for correctness, it is safer to stay with the current code pattern and use d_splice_alias() there too. Signed-off-by: NeilBrown --- fs/nfs/dir.c | 3 +-- fs/nfs/nfs4proc.c | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index a188b09c9a54..f92ea11aea44 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2330,8 +2330,6 @@ nfs_add_or_obtain(struct dentry *dentry, struct nfs_f= h *fhandle, struct dentry *d; int error; =20 - d_drop(dentry); - if (fhandle->size =3D=3D 0) { error =3D NFS_PROTO(dir)->lookup(dir, dentry, &dentry->d_name, fhandle, fattr); @@ -2352,6 +2350,7 @@ nfs_add_or_obtain(struct dentry *dentry, struct nfs_f= h *fhandle, dput(parent); return d; out_error: + d_drop(dentry); d =3D ERR_PTR(error); goto out; } diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 91bcf67bd743..a4ee0c0b4567 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3099,7 +3099,6 @@ static int _nfs4_open_and_get_state(struct nfs4_opend= ata *opendata, nfs_set_verifier(dentry, dir_verifier); if (d_really_is_negative(dentry)) { struct dentry *alias; - d_drop(dentry); alias =3D d_splice_alias(igrab(state->inode), dentry); /* d_splice_alias() can't fail here - it's a non-directory */ if (alias) { --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10E2830EF6C; Thu, 12 Mar 2026 21:47:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352076; cv=none; b=XkgLZvMmrJMFq6Hj4r2qklfFl+isML3Ymfc4zkPcv39U1OGVAjZ14BThItlxL9gK4oKQa4ZS+O7sf627Q/NSl/V4Dzz6AcptjZ2Bcyr2zjIg9Bn0ShxVSr/rH85u0n48UFEvolB3ZLhrfK3h6msms16X/3SWZzkUuWHsGKz7ybs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352076; c=relaxed/simple; bh=IanQ1s1cSo/azMNMbUJmvnmkKanVhMZGZpDAk8gG8A8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MH7zQQKLiGbq/iRMxy7BEZfvonqBLOEpNNLRfD/xJyn0kYXAybn78EcO7aH9JfkMpiY+dbnk/b+OE8rz67cGAemrEODNhbwS52G/1ygc50dm1RcJGFlGW0x672tRgG3jZ/EnNWDAbfZpRjbgCfuEHjB3LJluEQUgNcr3VqI6FPU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=c/pw77uh; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=MVii9L11; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="c/pw77uh"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="MVii9L11" Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailflow.stl.internal (Postfix) with ESMTP id 3C2BB1301B70; Thu, 12 Mar 2026 17:47:53 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Thu, 12 Mar 2026 17:47:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352073; x=1773359273; bh=W/Ak1KPwTmCaYgI05wA4foboiqmq4A6jkZq9iOG+AdU=; b= c/pw77uhzQwtu+x2rfy8YAQ8ODHIH6TqF5gjkDP3PnFVgS1yE39XzRUPiB7FP2sc RbT2SpGQkTPfjMjryKRQmCrUB49ETvDmOW/QLdaS3hsyuXpnCKPp4KpaG/88uh2b ZXJ9+VfUjmAlAqwi0KyMt/q9CW2hdecgqwGPYM6ENHXeNa2d3fgGwlvb8qBCnbPl x8pPfpV5ACsdJEY+vFgnJ5ttUL/vZ5lzs0FJW0pNjeM98B1mNj3S1TLDNNkpQ85G mrIMwkNyGULMNnaoWm3wi2W8zO4ZyGTiZJ5fNsPnxumyHNOH7BM2cdOc/C+ceQbo 7ROxYdy3UdkLgEgWoNY5Lg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352073; x=1773359273; bh=W /Ak1KPwTmCaYgI05wA4foboiqmq4A6jkZq9iOG+AdU=; b=MVii9L11GlwWtMhzZ n7iyDbPToR7JKb8T+MC59sZyBmXHZlJqZHj7ZQZrD1S9ZmYRwTLXpkBTfH/AH0ql XbK/noTmtQpNxvag+selT8UbNrzr/8IJl3kNxMvGZTLR+moT9KOT8al3IGiwNRoX j8ioh/jBUoLeJqAxmuqIyXvmtjLlIL56VrRHOV7H7mbB6T8HJiTueMd0tykadvXM ZaBajRtT7ugnSgBwWXivnDrJCmaH1qiDVbS3t+bJW+z4Vbk9MiVqyz7miWcV9qju MqrU8tjGSX+VM6REOR8up7aRz4q4674wBNNCUAlZBuJh49XTJzmrGGb3vo1RiPrw yZczg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejledtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:47:39 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 12/53] nfs: don't d_drop() before d_splice_alias() in atomic_create. Date: Fri, 13 Mar 2026 08:11:59 +1100 Message-ID: <20260312214330.3885211-13-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown When atomic_create fails with -ENOENT we currently d_drop() the dentry and then re-add it (d_splice_alias()) with a NULL inode. This drop-and-re-add will not work with proposed locking changes. As d_splice_alias() now supports hashed dentries, we don't need the d_drop() until it is determined that some other error has occurred. Signed-off-by: NeilBrown --- fs/nfs/dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index f92ea11aea44..ffba4de3df01 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2179,7 +2179,6 @@ int nfs_atomic_open(struct inode *dir, struct dentry = *dentry, err =3D PTR_ERR(inode); trace_nfs_atomic_open_exit(dir, ctx, open_flags, err); put_nfs_open_context(ctx); - d_drop(dentry); switch (err) { case -ENOENT: if (nfs_server_capable(dir, NFS_CAP_CASE_INSENSITIVE)) @@ -2188,7 +2187,7 @@ int nfs_atomic_open(struct inode *dir, struct dentry = *dentry, dir_verifier =3D nfs_save_change_attribute(dir); nfs_set_verifier(dentry, dir_verifier); d_splice_alias(NULL, dentry); - break; + goto out; case -EISDIR: case -ENOTDIR: goto no_open; @@ -2200,6 +2199,7 @@ int nfs_atomic_open(struct inode *dir, struct dentry = *dentry, default: break; } + d_drop(dentry); goto out; } file->f_mode |=3D FMODE_CAN_ODIRECT; --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E63B336EF8; Thu, 12 Mar 2026 21:48:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352094; cv=none; b=dFfUGgp2vU5IXFec/6mc7sUlogsHMdOqStNj9N1sf/IfGlgoF6IxHt0muhiuLq95iYcH086DcWPEY1/51izuscDG4KjHNY737dg/nlU+6KKU+SVPZ97xC9JZgQWyTgXfj+hfT5RA16JVHhCxnIbTwTLKvnY+Fm6EHn8lEbsYi+4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352094; c=relaxed/simple; bh=3R9MICHq0tfiVHVQzMt10rueJlsSKnW7TiNT7x+P6Zw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LRB55/CPSsELgKm7mCRcn6Dgug5WXxb13pnhr1l4yeYFhBT34M/ybEE9TobfbfNIgcEyX4ajKd/jNloVvjDE24s4PbRIcLq3NnMQTOCqJjlaUAdY6YE2F4dumpPO3LJrUk2OW2EQhdzGyWZhKWt9Xrwpoj7flS7fxEmLDbYi5zo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=gWllsYQz; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=1QbTSibC; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="gWllsYQz"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="1QbTSibC" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailflow.stl.internal (Postfix) with ESMTP id 8543F1301B73; Thu, 12 Mar 2026 17:48:10 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Thu, 12 Mar 2026 17:48:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352090; x=1773359290; bh=MvjNqMKuVfQXHETrd+SGIKnCs3zts7xUVvm6x+LJmMI=; b= gWllsYQz3mEA2jMLnm1iwaOv8Tt2H4rwH82GHyjMfv6YepkAwC/O+UlfXVfbC3Gh ueXZPPOdpP3xulQmdZxxRVEkFxYyxx1ToDvVC63ek4y3nTDYVvkpfStMyiWXmkRd fkV9Df1xtegee+SYwTvZ8ujcV1aIlaL/awlKX+BcG0Qy+E7hBOfTsK1E2FpVwfZb Vw3yFQe7/OT8j6qNNCNsEA/sLbaT6S6m75UO8zkReU+Ny1GbWgEtJhfqf6Uy/dYX f6TIaZrP86TA/nECvJCJGfBvL9fVuJt+rupymlKEQmgPDG1sUGlgOyjvy4Q7yJGg N49aWqF3TFatF7EmhXk2xg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352090; x=1773359290; bh=M vjNqMKuVfQXHETrd+SGIKnCs3zts7xUVvm6x+LJmMI=; b=1QbTSibCpARDuoZ6a qBXGjBjG605a1kHrNXvGK2EDNgsNPebEmS0LCdfNycqiJW6y0XS72nIolK0QQgb3 avki+yt5b3Qw4JQ5Aiu5A0r9FpQyj53k7GLhjZjlDieFxsRZhCYDzg/XlL36uRAz xHyrzP+wM7hlc8pcCvwvMYp8CZN7trtMnqEYqlMPs//4+h82amOGnS6lWFiXkTCr uH4ivBpDr4UYvERMqaIkvGkFoY5bBABprE0gB8RiuuaAyw17fvhlnIQvyWkqA0ag /3wU+iBXcux3YEyHDjuwWxUXZCSejGgN90VfAIrEWw8qHqZlW0e+7y9VpWl90OSn VpvHA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejledtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:47:56 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 13/53] nfs: Use d_alloc_noblock() in nfs_prime_dcache() Date: Fri, 13 Mar 2026 08:12:00 +1100 Message-ID: <20260312214330.3885211-14-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown NFS uses the results of readdir to prime the dcache. Using d_alloc_parallel() can block if there is a concurrent lookup. Blocking in that case is pointless as the lookup will add info to the dcache and there is no value in the readdir waiting to see if it should add the info too. Also this call to d_alloc_parallel() is made while the parent directory is locked. A proposed change to locking will lock the parent later, after d_alloc_parallel(). This means it won't be safe to wait in d_alloc_parallel() while holding the directory lock. So change to use d_alloc_noblock(), and use try_lookup_noperm() rather than full_name_hash and d_lookup. Signed-off-by: NeilBrown --- fs/nfs/dir.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index ffba4de3df01..4b73ec59bbcc 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -750,15 +750,14 @@ void nfs_prime_dcache(struct dentry *parent, struct n= fs_entry *entry, if (filename.len =3D=3D 2 && filename.name[1] =3D=3D '.') return; } - filename.hash =3D full_name_hash(parent, filename.name, filename.len); =20 - dentry =3D d_lookup(parent, &filename); + dentry =3D try_lookup_noperm(&filename, parent); again: - if (!dentry) { - dentry =3D d_alloc_parallel(parent, &filename); - if (IS_ERR(dentry)) - return; - } + if (!dentry) + dentry =3D d_alloc_noblock(parent, &filename); + if (IS_ERR(dentry)) + return; + if (!d_in_lookup(dentry)) { /* Is there a mountpoint here? If so, just exit */ if (!nfs_fsid_equal(&NFS_SB(dentry->d_sb)->fsid, --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96C4730EF6C; Thu, 12 Mar 2026 21:48:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352110; cv=none; b=ONlEJ+wLTMXQlxwLaNrFundbbgx4gyUTIteK8im7wGdB9hXeCZYxjyKHvRKp0hnoAM8wqEbhP2Btm91TDCS2ZliGHamAGdjjK1eK3fBIcp8tJpq/Hr/hSQiyFNBlaV39h406ZmClJF3JxVUUs9BuZ/i09gzExWRR8Qq+aFDOUcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352110; c=relaxed/simple; bh=G5V5crDVyLe8/maI9lfcZXKb10I7/mjupt819D+stws=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Td69b2YNfxvJBipUpN71vWj5ngfW1ucdhSd64Y2FICYMM3ZqNBBGRfw9ZmUaoeiOlVD7QPyqf/t3/M888I7QQ88gaSuR8beS0WkR68z04iRh8ZmVf50DnmyGabf1QWPKxkGdtm1fdPqkOKC4196Cle6RqhFUQCtEQX40PWw71zk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=Ulio8jdR; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=V1ILUza9; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="Ulio8jdR"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="V1ILUza9" Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailflow.stl.internal (Postfix) with ESMTP id E04541301B7D; Thu, 12 Mar 2026 17:48:27 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Thu, 12 Mar 2026 17:48:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352107; x=1773359307; bh=KmjblPgjMtNsKFHT5qnV9lxupCTmEj8C0v6XyHf7K7k=; b= Ulio8jdRV17YOr50t+t7boNaHOeF2wTQGOHtn+dNIoN5vKNfDyK0CD44CgXabKUK TV6nXN2knVpB++dAh4V5AAO9193CaTSvg7SQYb2sKyBBRHlJR2LidDplCTZEANqT vmfQ21wRbawPzNwJbwUvM+LB20U4hwnVaghMWWb2/YIpQqO+6cYfq3X0KzeCr1oi FJSDAmeGC9yvUXg0iUtYAJxZee59kb6/VwJuNxNGDE8ysKU1uxaXQjerR3m/1UF6 69fvZaLM9UVgD6sUjJm72z0yVSaXyyECAxCx2ODjn5Z8fqrU1RbyBsGwdzuxZIna WS+V65cIpf2Vv5kJeBkFWA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352107; x=1773359307; bh=K mjblPgjMtNsKFHT5qnV9lxupCTmEj8C0v6XyHf7K7k=; b=V1ILUza9NLQSxawiL eF0WlKAetuUAGiKullHxP7XEcjOGX0pSDLHT+d3ZxLUsukHA9enGP//FKvRTQqU/ IQAZbK9m1MrlRmvhragai8VPzskTiPUPw5NyPV93/lE9PPi0U7yTePGgPZuNDe8E 2KtvNIzplE7kIb4ZMNiFpnwQr67l2ZluVdaeE0+q7D672SbupcGOiQ4VPzXZuHU1 39+IR54k8h/yleEScI5O9sAqsimUETjsmYBMojccLsdfnvm6TOqgD0tMeq8OULl7 WdGrqgiD5VcVeh2H65t+c0B7nLPTaIdBrH6JiUsORtvwHWzELLSJEDuM/Y+JdCLT Rq27g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejledtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:48:14 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 14/53] nfs: use d_alloc_noblock() in silly-rename Date: Fri, 13 Mar 2026 08:12:01 +1100 Message-ID: <20260312214330.3885211-15-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown Rather than performing a normal lookup (which will be awkward with future locking changes) use d_alloc_noblock() to find a dentry for an unused name, and then open-code the rest of lookup_slow() to see if it is free on the server. Signed-off-by: NeilBrown --- fs/nfs/unlink.c | 56 +++++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c index 43ea897943c0..f112c13d97a1 100644 --- a/fs/nfs/unlink.c +++ b/fs/nfs/unlink.c @@ -445,7 +445,8 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentr= y) static unsigned int sillycounter; unsigned char silly[SILLYNAME_LEN + 1]; unsigned long long fileid; - struct dentry *sdentry; + struct dentry *sdentry, *old; + struct qstr qsilly; struct inode *inode =3D d_inode(dentry); struct rpc_task *task; int error =3D -EBUSY; @@ -462,26 +463,41 @@ nfs_sillyrename(struct inode *dir, struct dentry *den= try) =20 fileid =3D NFS_FILEID(d_inode(dentry)); =20 - sdentry =3D NULL; - do { +newname: + sillycounter++; + scnprintf(silly, sizeof(silly), + SILLYNAME_PREFIX "%0*llx%0*x", + SILLYNAME_FILEID_LEN, fileid, + SILLYNAME_COUNTER_LEN, sillycounter); + + dfprintk(VFS, "NFS: trying to rename %pd to %s\n", + dentry, silly); + qsilly =3D QSTR(silly); + sdentry =3D try_lookup_noperm(&qsilly, dentry->d_parent); + if (!sdentry) + sdentry =3D d_alloc_noblock(dentry->d_parent, &qsilly); + if (sdentry =3D=3D ERR_PTR(-EWOULDBLOCK)) + /* Name currently being looked up */ + goto newname; + /* + * N.B. Better to return EBUSY here ... it could be + * dangerous to delete the file while it's in use. + */ + if (IS_ERR(sdentry)) + goto out; + if (d_is_positive(sdentry)) { dput(sdentry); - sillycounter++; - scnprintf(silly, sizeof(silly), - SILLYNAME_PREFIX "%0*llx%0*x", - SILLYNAME_FILEID_LEN, fileid, - SILLYNAME_COUNTER_LEN, sillycounter); - - dfprintk(VFS, "NFS: trying to rename %pd to %s\n", - dentry, silly); - - sdentry =3D lookup_noperm(&QSTR(silly), dentry->d_parent); - /* - * N.B. Better to return EBUSY here ... it could be - * dangerous to delete the file while it's in use. - */ - if (IS_ERR(sdentry)) - goto out; - } while (d_inode(sdentry) !=3D NULL); /* need negative lookup */ + goto newname; + } + /* This name isn't known locally - check on server */ + old =3D dir->i_op->lookup(dir, sdentry, 0); + d_lookup_done(sdentry); + if (old || d_is_positive(sdentry)) { + if (!IS_ERR(old)) + dput(old); + dput(sdentry); + goto newname; + } =20 ihold(inode); =20 --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E56083A6B71; Thu, 12 Mar 2026 21:48:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352128; cv=none; b=boD69Sw034B7oGJob2n0j4IQNUVoQi5E0hX4F5CWPA4K4wbMEOQS3D9qRgAwMff1LiDrEJYnIohqdnwB37OZb5fvjSK4UehbWnlOmJ9y4eZfCzu7ToSkFSPrul7Mb0STxVF2cDR0TdAZAlst9Lm7jPM2mYo1IU2sLQtrqaBb4tQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352128; c=relaxed/simple; bh=epOzHU7HEkyrKRUf7bdGR5K8ao8kAYKse14qLmpmq4M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rvu/R/xMFrPxAX/4SrccedcfyMEe6EI4ELueQf/NYNeiFY1l//rhg1533REncu8DeajvX7k7LvLXfxrXh5v83BoO29SDq0HD+gigQY/krQdLIt7dhCd7NtsKzgEzAxEkUN8+5bZIWLR7DNb3L6+x0oWZ0QVUi9l7IS/fFFxq9jo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=YiFgW3M9; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=nvhsCJHi; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="YiFgW3M9"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="nvhsCJHi" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailflow.stl.internal (Postfix) with ESMTP id 0865D1301B8B; Thu, 12 Mar 2026 17:48:45 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Thu, 12 Mar 2026 17:48:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352124; x=1773359324; bh=8hxhCnV9U6zmeL8OYJrlmY7rj/yQGmrUt+8UFBTzKtg=; b= YiFgW3M9c4+BqqZQJA+22GBvrn30b/igbH0adx0uC69vr1gxmtdnWHTXSLtGZ1v7 vE8AO38ThUJuxgrxw9XxjwQUNmiEN3pJjN9OptD9mzSioPXADb7E1O+EsYDpyNTc YdDide8ZPwAVPNcdbMUJdPj3GrpsmnSxGlz6tNKTziSuxrFzDgABnzqIvg48Uo5A d+Pl4wmzy+RLHOf0e2eeJC2r9wTFiefv+UodRNLArqD91vyLKqd55rcnDT1x1RVd s0tzcQj3gWkhnCx3w8SwRX6n2lcgXO77X8jg7SxXoy33jHmIl7FwkDml0cUSuTSS EUcVXtbPpLAzS1r4NI//NA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352124; x=1773359324; bh=8 hxhCnV9U6zmeL8OYJrlmY7rj/yQGmrUt+8UFBTzKtg=; b=nvhsCJHiqZ+mas8ml KbZ0MpLKNgbhychg1yEE0z+mDKaZ2xC/Z7ex8NS3Ayigl2vn3dn2DpixzvgNyWGH EtAcbXjLqI2hmLhCVkKnPvjB54+2sXL4B6XMRBWvZKYbXubc412AfpNsT3mA+43U 9Zc3xeIA762Ej5UQeJiKcrkcCl3qndb3Gi9jhKAZgYkOw0NKm0d14b/+/q3UHC85 Woir5+CeVR+o8DsbEdUD74X/kDfbBBoEnKHDbeSqDsPRMT71BYUZsJw6dIverl2S rUDX4MtqSOexyOlIIikP62Ve4xks0MbrKiHi7RLjhMX9Ddqib31JGdw7vkM0IgnX h9mRA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejledtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:48:31 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 15/53] nfs: use d_duplicate() Date: Fri, 13 Mar 2026 08:12:02 +1100 Message-ID: <20260312214330.3885211-16-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown As preparation for d_alloc_parallel() being allowed without the directory locked, use d_duplicate() to duplicate a dentry for silly rename. Signed-off-by: NeilBrown --- fs/nfs/dir.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 4b73ec59bbcc..655a1e8467f7 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2781,11 +2781,9 @@ int nfs_rename(struct mnt_idmap *idmap, struct inode= *old_dir, spin_unlock(&new_dentry->d_lock); =20 /* copy the target dentry's name */ - dentry =3D d_alloc(new_dentry->d_parent, - &new_dentry->d_name); + dentry =3D d_duplicate(new_dentry); if (!dentry) goto out; - /* silly-rename the existing target ... */ err =3D nfs_sillyrename(new_dir, new_dentry); if (err) @@ -2850,8 +2848,10 @@ int nfs_rename(struct mnt_idmap *idmap, struct inode= *old_dir, nfs_dentry_handle_enoent(old_dentry); =20 /* new dentry created? */ - if (dentry) + if (dentry) { + d_lookup_done(dentry); dput(dentry); + } return error; } EXPORT_SYMBOL_GPL(nfs_rename); --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24CF33BADAD; Thu, 12 Mar 2026 21:49:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352147; cv=none; b=a9IDmBvzeGV9zHLK7Xc9H5yQNuqdeFkzvUXdUQbVy2/gjzlKw5pzzwrDWU7UGcqvUYSfPTtxXpkM4UxNc0ONfIKz27/LG5EFMOtFaMhnY1Z8yDWnMlnjLWOTl2qtWGtjTNfxSnOxBm3qWhOb19gqryNh/MqQvD16lYmuf7XFqx0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352147; c=relaxed/simple; bh=jSjdU8vngGbZtY+U9vRSrxvzSHttQ2w3RWSdr52436U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FfHvSpwHeYPVKUBhhYk8aVKXGHaLMRThZVX7qfR7bTjWe7/VUnYXbt4FegO1DcIvGCGj/JuUofolMguY6Qtd9chm9cSzZPT3W4HrqMpfwKn4D6O3o3AVXVzq3DKtcayd0t9rCLzz5nYcveVKp73L51XgM8Nrox5FHbdQyvXmamU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=gaAhEBPA; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=PYzTveHy; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="gaAhEBPA"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="PYzTveHy" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailflow.stl.internal (Postfix) with ESMTP id DEB981301B8E; Thu, 12 Mar 2026 17:49:01 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Thu, 12 Mar 2026 17:49:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352141; x=1773359341; bh=YL+J72s4jM/IFD83vUlKIIKhuJuEonEWtkSdhku4yoI=; b= gaAhEBPAdZ3kN0WV16+ugt1A/74DzdGxG8GEh+e+EQn0LxokiH00tux1d8sBHRcY Vg+7f+AOVRuHjhznqBd0sk41zkY9Vx4MFt96H29HY4RyG9/tLfLooU+qOjqy3Ip7 IH8RP4puRqDzsWiVR9OJNaF5F8IkaIv8EKzwUABlX5z0SXc9f3oqyE6HyxoBMDDS pc/vRkKXd+xwK5xh2M7mb3cTBfa30Q4hfYmSYHp47InunZ8s/qXNmlFjFULmHD7w 3+DbNHr3E7SKmihSlBhgNVVkp2v/H1cc12RtWmoaSN4ONlLZ4DcnjXpDPs4R6LkU ns6xJKqBdYIvZ4hcjjUj7Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352141; x=1773359341; bh=Y L+J72s4jM/IFD83vUlKIIKhuJuEonEWtkSdhku4yoI=; b=PYzTveHy9RbMJRFOG +aOYTisnLh1GssROIXjKgytZ4YxU9i+aq6o6xyI+wA2qQQ3phZD+7w9a+2oxR9sd MeqUQsL4Pikanpl6RF2Vlolwt8nVrrSGXImQw1AiavtrMeOHQp80gmJWpbwF2FLc nH2rodwDYZ8UVeQnQ/vcXJ7K/d1UnY3kPRC6+afOMbKrlwwk46kzWD211KuXsuNA OuNxbhRGhgyAjKWcJHaW4LaMvWUKu+JboX31okwJgjFqztHXyiMO5KvAJdk0mEfr nvn4Mqxg7kmCNIR8KgMyimzGJdQGOGVz0Rta8y6idYVjE7mud+m4qGXXI8tSbQc7 PLcCw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejledtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:48:48 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 16/53] ovl: drop dir lock for lookups in impure readdir Date: Fri, 13 Mar 2026 08:12:03 +1100 Message-ID: <20260312214330.3885211-17-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown When performing an "impure" readdir, ovl needs to perform a lookup on some of the names that it found. With proposed locking changes it will not be possible to perform this lookup (in particular, not safe to wait for d_alloc_parallel()) while holding a lock on the directory. ovl doesn't really need the lock at this point. It has already iterated the directory and has cached a list of the contents. It now needs to gather extra information about some contents. It can do this without the lock. After gathering that info it needs to retake the lock for API correctness. After doing this it must check IS_DEADDIR() again to ensure readdir always returns -ENOENT on a removed directory. Note that while ->iterate_shared is called with a shared lock, ovl uses WRAP_DIR_ITER() so an exclusive lock is held and so we drop and retake that exclusive lock. As the directory is no longer locked in ovl_cache_update() we need dget_parent() to get a reference to the parent. Signed-off-by: NeilBrown --- fs/overlayfs/readdir.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c index 1dcc75b3a90f..d5123b37921c 100644 --- a/fs/overlayfs/readdir.c +++ b/fs/overlayfs/readdir.c @@ -568,13 +568,12 @@ static int ovl_cache_update(const struct path *path, = struct ovl_cache_entry *p, goto get; } if (p->len =3D=3D 2) { - /* we shall not be moved */ - this =3D dget(dir->d_parent); + this =3D dget_parent(dir); goto get; } } /* This checks also for xwhiteouts */ - this =3D lookup_one(mnt_idmap(path->mnt), &QSTR_LEN(p->name, p->len), dir= ); + this =3D lookup_one_unlocked(mnt_idmap(path->mnt), &QSTR_LEN(p->name, p->= len), dir); if (IS_ERR_OR_NULL(this) || !this->d_inode) { /* Mark a stale entry */ p->is_whiteout =3D true; @@ -666,11 +665,12 @@ static int ovl_dir_read_impure(const struct path *pat= h, struct list_head *list, if (err) return err; =20 + inode_unlock(path->dentry->d_inode); list_for_each_entry_safe(p, n, list, l_node) { if (!name_is_dot_dotdot(p->name, p->len)) { err =3D ovl_cache_update(path, p, true); if (err) - return err; + break; } if (p->ino =3D=3D p->real_ino) { list_del(&p->l_node); @@ -680,14 +680,19 @@ static int ovl_dir_read_impure(const struct path *pat= h, struct list_head *list, struct rb_node *parent =3D NULL; =20 if (WARN_ON(ovl_cache_entry_find_link(p->name, p->len, - &newp, &parent))) - return -EIO; + &newp, &parent))) { + err =3D -EIO; + break; + } =20 rb_link_node(&p->node, parent, newp); rb_insert_color(&p->node, root); } } - return 0; + inode_lock(path->dentry->d_inode); + if (IS_DEADDIR(path->dentry->d_inode)) + err =3D -ENOENT; + return err; } =20 static struct ovl_dir_cache *ovl_cache_get_impure(const struct path *path) --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 002CF3FBEA7; Thu, 12 Mar 2026 21:49:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352163; cv=none; b=JKmlhNPpeFlnenqpYgoekJMCUyymkguEMLH8FfZYJdY6qGa0gEA+rn3n3ZfLswtrg9+ktwhPZfoz3/XuFXCoyBR7U41iCpHQ/VERLidhSFTuGJJ0VdeQzyhsnG//sRx4leaK9TvCp4fpCSmfN/V4yMFn1h4ovcBfwg5/rxh7+0A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352163; c=relaxed/simple; bh=dxKUjG9SS2CeJtB3EAkVmmT5Hr72DRw2QDn6pjI+9Ew=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ipm5b7oO+8B6Y1MLYMhtAousGTz9yrAmOJMt7HMWCnHAM07sny6Jifgf0eN/ACxvwixLG4QQ4pVrZMxGr/H8IxNzTNIiwTxj03gzUaTVh6jX04HydvYNvDiN2R30scIBIulZlNEroNwozPQiYPHJsZSmq65FqxWCXZwnGz/52F4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=TgyoTat1; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=obUK4rxu; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="TgyoTat1"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="obUK4rxu" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailflow.stl.internal (Postfix) with ESMTP id 204861301B98; Thu, 12 Mar 2026 17:49:19 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Thu, 12 Mar 2026 17:49:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352158; x=1773359358; bh=z+7QufvNN3q8n3hkdBe3X5vN3xc/nhZLNzYG67Syggw=; b= TgyoTat174eBaw3Mh4geA333otferDz8BBQPH1PgKmD7FJaHSr6GLkuhr2HlpJDw cVzZ84rQMihNKez8G7vGAleKuhXA4W5y9KIyFD4XN8Wb5z4C/GkUjuKskb+kJrR1 lC/yoVH9xfJudFAZY9VkxvQRWgVEaIklFmqwqosxDL5m24ZZf8ALkvi5+8kTNaRg JaI5ac5o4PkCD/awH8jjlvbtcksBwP/UrAs/wyTtRe9wh5vZIiq43rwWfSf23iAN ZvxN48yBCgh6KULlPPnNa2Bf7IuYhYgs2ho1t/OJA0HAv6x9x5aQGqJdst5665hw AUEGVu0PRgJJYV2cz8wi4A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352158; x=1773359358; bh=z +7QufvNN3q8n3hkdBe3X5vN3xc/nhZLNzYG67Syggw=; b=obUK4rxuvN2EEYhNI NtE674q93iVvjy5WR4fSqUmy8AHVYgkz/UxLyEHzkbsGA1QeFwYFB1iwCX/S2SXG /IPa6UfL54oQSq7sTP8Jf1YUCeNn82kWlW2yVSo7McnrgmZEJtbc4KeiMeYoKXAK BAY1RBx4D/DMmwFaIDCZXvTM+ujGQnIUM50S3v5o/1a4uwQV6C+pc0s9z8zOjwKh Wd4hbA4HdhrJjvqf1rT4/pg+E3TEO/wK8a/Md5olMOwIGDS9ErEvKobrJGJQZ9BD 2OjvflQ2QmT9rRSnyWJm3cSWLappWt7B0uGl9SqswPjgzsIGfheQXhEqfjP+ehhn ijVCQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejledtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:49:05 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 17/53] coda: don't d_drop() early. Date: Fri, 13 Mar 2026 08:12:04 +1100 Message-ID: <20260312214330.3885211-18-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown Proposed locking changes will mean that calling d_drop() could effectively unlock the name allowing a parallel lookup to proceed. For this reason it could only be called *after* the attempt to create a symlink (in this case) has completed (whether successfully or not). So move the d_drop() to after the venus_symlink() call. Signed-off-by: NeilBrown --- fs/coda/dir.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/coda/dir.c b/fs/coda/dir.c index c64b8cd81568..70eb6042fdaa 100644 --- a/fs/coda/dir.c +++ b/fs/coda/dir.c @@ -244,13 +244,13 @@ static int coda_symlink(struct mnt_idmap *idmap, if (symlen > CODA_MAXPATHLEN) return -ENAMETOOLONG; =20 + error =3D venus_symlink(dir_inode->i_sb, coda_i2f(dir_inode), name, len, + symname, symlen); /* - * This entry is now negative. Since we do not create + * This entry is still negative. Since we did not create * an inode for the entry we have to drop it. */ d_drop(de); - error =3D venus_symlink(dir_inode->i_sb, coda_i2f(dir_inode), name, len, - symname, symlen); =20 /* mtime is no good anymore */ if (!error) --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08BC523EABA; Thu, 12 Mar 2026 21:49:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352180; cv=none; b=C+JJbN82Aq2/Mo8uSRp1VlV3M8prVPz9dQrDfcHC0Eh3QmYtGmiuovvDs1frFCFWt+pCiSqR2QLWLhLO9s/sghBdnYHHCeHqZEOyF7nd/mNLvJ/BED7bEhiT5P0vxbCknNp3lLQDZoq2O0yCv56ODhoD06lVLePJkIBBS+3yR5o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352180; c=relaxed/simple; bh=VGwEZOS2xQR90lck3nphx6g+AoqwByQSrwXBkPz1zDo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h01DaeBqiqlI2sC8CTmRD0Rk+kQGJSKp2Iw/L+lSblJXgJNNj4LONBW+TRkM7nVIp4SSdoj/t5c3A/Ga8zruLg5NhwfeQC38JYzjosGv37v3nDP+phdKu1sdnQ483W2ukkzETA/BVNFD3bGGt9IH9JdBveVHjd2Cq4l88H+fC5Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=Xccu7BqG; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=m/gQSpd7; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="Xccu7BqG"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="m/gQSpd7" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailflow.stl.internal (Postfix) with ESMTP id 304841301B9C; Thu, 12 Mar 2026 17:49:37 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Thu, 12 Mar 2026 17:49:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352177; x=1773359377; bh=puUX/onZj/vaXC+2Vk95PLkQLCVwPSvUkX77dKofgTQ=; b= Xccu7BqGG8E2NDVZg/N4GFdwY2oD8s3CZ2ec6I8noK+y1khNNKwdQa3qSaE8p3ck 0l50JSAYQMZ5XRGqZ6Bm/NAd13BsbRhSkEdg7tqZU6lqcf02dFEy2EcSjKuts/ie 93Y1uP4EFwJeTb8r7VZMByZxlZdqGEPpizVdBZMUA2mImhfkLWcTIYnNYeFDeLsv 5FU2zkjTsrw3bSzl+CIzFJGHS1tbUaCwV+5sD1boXsVdn68Nb5W86QGVNW3kz1dO ZBA29VXiDgjJht9QJK+RFCH9oZopsofcKUpnEEHU0+MgBQGEzMOp4Bq2C4HkdvRc lnP0iuRl+qvkLgnss8CbMw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352177; x=1773359377; bh=p uUX/onZj/vaXC+2Vk95PLkQLCVwPSvUkX77dKofgTQ=; b=m/gQSpd72bOeZbbIs bt9p9HVZaVD6pf8ZLbR/liTkCv6KLk37Bwr8ICPhs7HK1JpcdmbvRz230O5ZCVWm bL1vRCv8aa/Xm/OpaO3WA7ztqdqawHLsbn96Qsi2daFjSCddFwzLvvwz4NQtqelr jJiohG5ZcJotwPQPUQg4NyRCl/Tlv1u4/GXgV4jKWFBH0UUA+Mqw1kR51FO2ihPR sv9Bl9N1dEqbD5ZMaW3p4mZ8SyUtMM0xpWUs4C7GXuaqyzfvyS/u1YLmjyB5CADx iwjOJR50j2ZM6njft50LG+J5rhWP3t9qo6Wg405WgsbPq6uZnUmaMgGVQl7jGsRk +xLJA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejledtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:49:22 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 18/53] shmem: use d_duplicate() Date: Fri, 13 Mar 2026 08:12:05 +1100 Message-ID: <20260312214330.3885211-19-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown To prepare for d_alloc_parallel() being permitted without a directory lock, use d_duplicate() when duplicating a dentry in order to create a whiteout. Signed-off-by: NeilBrown --- mm/shmem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index b40f3cd48961..6b39a59355d7 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -4030,11 +4030,12 @@ static int shmem_whiteout(struct mnt_idmap *idmap, struct dentry *whiteout; int error; =20 - whiteout =3D d_alloc(old_dentry->d_parent, &old_dentry->d_name); + whiteout =3D d_duplicate(old_dentry); if (!whiteout) return -ENOMEM; error =3D shmem_mknod(idmap, old_dir, whiteout, S_IFCHR | WHITEOUT_MODE, WHITEOUT_DEV); + d_lookup_done(whiteout); dput(whiteout); return error; } --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b5-smtp.messagingengine.com (flow-b5-smtp.messagingengine.com [202.12.124.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 241DB30FC29; Fri, 13 Mar 2026 00:48:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362905; cv=none; b=FfXDscDS/sEngEB/HT77iY/toZxY5fI51vrTdTXPNIQ7tmDG9qWONUGZzNAaAVjfBe+WdR7OnCnPMvt+IA3aIeqIzlaMn+OBSgi75iBEZDcgt0C2jvi1x8T2aNVXfiEdXN2uiHF60UntIi/GYBO9RmPPY2KeSBZJnWZshsrMli8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362905; c=relaxed/simple; bh=bPb+bIqpK5hvVK2d8DMn3IwNAwWZ+dX19WhkeuUgfD4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NB8qeLjWgF7NV0K0DYYOpDvQZQFO/o5P827Rhld7kvJxLpLITSKLbvz50eNHGVNezye97Q/ESKaK/ya/MXFD78HyaMwTNsTK6ePJ6SS/7mnlYsuf6nDu/IRKDO4QlWjcQDSC+380ayL2ZdvMbsjOsw7z9SG202NM194ArGIBxkQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=dN+zoQ+X; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=34dgo/VI; arc=none smtp.client-ip=202.12.124.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="dN+zoQ+X"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="34dgo/VI" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailflow.stl.internal (Postfix) with ESMTP id 723B61301B7D; Thu, 12 Mar 2026 20:48:22 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Thu, 12 Mar 2026 20:48:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773362902; x=1773370102; bh=3OVL4XXP8pGkqIJaCgrneigzeg9lURjpYtnSBAI2TgY=; b= dN+zoQ+X4IMCOwHYdmkT/bGnzCHvuxlXBbrpp9O8UwCmnQeDDi7ioO7y2/TUY8l5 mQGtxsh3qVE4W70GI8wjUfwVDAFocwzcsunO2RHndj6ssUSoW5JU5xyWRUYJYDG9 NMIjn03yZHXunWH8BNEHahsglP7uOUYKduvq4RcsnRx45o5+YD6/oyA0D9GyutPP mLXDY4UxeKqfkDk1pTNpvWvnW1/dJJmaIfcBQR9lGPgKHB0zDYqbbg/WeD543BZ1 YZZiFH4HEkOT7GPsszH0tbfrqAMP2nkAl+SHWoXH2ZfgLfzJ7G8Da4TigmEpPMMB kWwgCUIZj7EH1b7QHZSsmw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773362902; x=1773370102; bh=3 OVL4XXP8pGkqIJaCgrneigzeg9lURjpYtnSBAI2TgY=; b=34dgo/VIKgtmzJGsl miC6lP3iQWBH1TiVT3V5XLsNBZ4hEoP69rm02c/9mKZc3HpddJ+Jm5BVWcJn9DkB 57t0tJJgDeHpeL+ua3mR8GhZPmEwPi0lQb3PwN14P92l/6Ep6Qp5LUxmLxKuHb0F wZYQlWii+7LBp+7LMX/8e2iuf/gsPxQRwWVKDTbZSMt9L0ZT01nsdAwc9YTMK1yk 3Ch2rxde/oduz5imnG5I61fP0o7Q2RmqJ7K3UEHPNtcBLNHsLWMstLaJPoAb0igY 8DF5fJdmXv6TlSvdhF6xHSluXNYiYlg4IeJQvDDCwPSoyDiP0Juj0NE2pRGV7aHr PQHYQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeekvdeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epteetteeuteffveduveetgfdtuedvfffhudetuefgffejgffhgffhgfetffetudeinecu ffhomhgrihhnpehsthgrthhushdruggrthgrnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepnhgvihhlsgesohifnhhmrghilhdrnhgvthdpnhgs pghrtghpthhtohephedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehvihhroh esiigvnhhivhdrlhhinhhugidrohhrghdruhhkpdhrtghpthhtoheplhhinhhugidqgihf shesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhunhhioh hnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqthhr rggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplh hinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhn uhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlih hnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohep lhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplh hinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 20:48:08 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 19/53] afs: use d_time instead of d_fsdata Date: Fri, 13 Mar 2026 08:12:06 +1100 Message-ID: <20260312214330.3885211-20-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown afs uses ->d_fsdata to store version information for the parent directory. ->d_time is arguably a better field to store this information as the version is like a time stamp, and ->d_time is an unsigned long, while ->d_fsdata is a void *. This will leave ->d_fsdata free for a different use ... which admittedly is also not a void*, but is certainly not at all a time. Interesting the value stored in ->d_time or d_fsdata is u64 which is a different size of 32 bit hosts. Maybe that doesn't matter. Signed-off-by: NeilBrown --- fs/afs/dir.c | 18 +++++++++--------- fs/afs/internal.h | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index 78caef3f1338..a0417292314c 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -808,7 +808,7 @@ static struct inode *afs_do_lookup(struct inode *dir, s= truct dentry *dentry) afs_dir_iterate(dir, &cookie->ctx, NULL, &data_version); } =20 - dentry->d_fsdata =3D (void *)(unsigned long)data_version; + dentry->d_time =3D (unsigned long)data_version; =20 /* Check to see if we already have an inode for the primary fid. */ inode =3D ilookup5(dir->i_sb, cookie->fids[1].vnode, @@ -895,9 +895,9 @@ static struct inode *afs_do_lookup(struct inode *dir, s= truct dentry *dentry) } =20 if (op->file[0].scb.have_status) - dentry->d_fsdata =3D (void *)(unsigned long)op->file[0].scb.status.data_= version; + dentry->d_time =3D (unsigned long)op->file[0].scb.status.data_version; else - dentry->d_fsdata =3D (void *)(unsigned long)op->file[0].dv_before; + dentry->d_time =3D (unsigned long)op->file[0].dv_before; ret =3D afs_put_operation(op); out: kfree(cookie); @@ -1010,7 +1010,7 @@ static struct dentry *afs_lookup(struct inode *dir, s= truct dentry *dentry, _debug("splice %p", dentry->d_inode); d =3D d_splice_alias(inode, dentry); if (!IS_ERR_OR_NULL(d)) { - d->d_fsdata =3D dentry->d_fsdata; + d->d_time =3D dentry->d_time; trace_afs_lookup(dvnode, &d->d_name, &fid); } else { trace_afs_lookup(dvnode, &dentry->d_name, &fid); @@ -1040,7 +1040,7 @@ static int afs_d_revalidate_rcu(struct afs_vnode *dvn= ode, struct dentry *dentry) * version. */ dir_version =3D (long)READ_ONCE(dvnode->status.data_version); - de_version =3D (long)READ_ONCE(dentry->d_fsdata); + de_version =3D (long)READ_ONCE(dentry->d_time); if (de_version !=3D dir_version) { dir_version =3D (long)READ_ONCE(dvnode->invalid_before); if (de_version - dir_version < 0) @@ -1100,7 +1100,7 @@ static int afs_d_revalidate(struct inode *parent_dir,= const struct qstr *name, * version. */ dir_version =3D dir->status.data_version; - de_version =3D (long)dentry->d_fsdata; + de_version =3D (long)dentry->d_time; if (de_version =3D=3D (long)dir_version) goto out_valid_noupdate; =20 @@ -1161,7 +1161,7 @@ static int afs_d_revalidate(struct inode *parent_dir,= const struct qstr *name, } =20 out_valid: - dentry->d_fsdata =3D (void *)(unsigned long)dir_version; + dentry->d_time =3D (unsigned long)dir_version; out_valid_noupdate: key_put(key); _leave(" =3D 1 [valid]"); @@ -1931,7 +1931,7 @@ static void afs_rename_edit_dir(struct afs_operation = *op) spin_unlock(&new_inode->i_lock); } =20 - /* Now we can update d_fsdata on the dentries to reflect their + /* Now we can update d_time on the dentries to reflect their * new parent's data_version. */ afs_update_dentry_version(op, new_dvp, op->dentry); @@ -2167,7 +2167,7 @@ static int afs_rename(struct mnt_idmap *idmap, struct= inode *old_dir, } =20 /* This bit is potentially nasty as there's a potential race with - * afs_d_revalidate{,_rcu}(). We have to change d_fsdata on the dentry + * afs_d_revalidate{,_rcu}(). We have to change d_time_ on the dentry * to reflect it's new parent's new data_version after the op, but * d_revalidate may see old_dentry between the op having taken place * and the version being updated. diff --git a/fs/afs/internal.h b/fs/afs/internal.h index 009064b8d661..106a7fe06b56 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h @@ -1746,17 +1746,17 @@ static inline struct inode *AFS_VNODE_TO_I(struct a= fs_vnode *vnode) } =20 /* - * Note that a dentry got changed. We need to set d_fsdata to the data ve= rsion + * Note that a dentry got changed. We need to set d_time to the data vers= ion * number derived from the result of the operation. It doesn't matter if - * d_fsdata goes backwards as we'll just revalidate. + * d_time goes backwards as we'll just revalidate. */ static inline void afs_update_dentry_version(struct afs_operation *op, struct afs_vnode_param *dir_vp, struct dentry *dentry) { if (!op->cumul_error.error) - dentry->d_fsdata =3D - (void *)(unsigned long)dir_vp->scb.status.data_version; + dentry->d_time =3D + (unsigned long)dir_vp->scb.status.data_version; } =20 /* --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b5-smtp.messagingengine.com (flow-b5-smtp.messagingengine.com [202.12.124.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9958829BD82; Fri, 13 Mar 2026 00:48:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362888; cv=none; b=T0eWVYADOZkpqeBtEbdXrI3qRY/8SJFfsK2MfynLZlsv9ND+zk8pBq1wptol3aQBirVjO3QJ9LMFiYvqSdAiLndOs9Ju5iAYLiXtHNDAcdwts2PKVSIWJ+La8YcLhfeuOVq6SbN1Qle/dGLb3wx0QOO6duuwGz5B7wkPrDn9ldk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362888; c=relaxed/simple; bh=J2J65yPHZ8aYn1x2FV6a4SeL2IbdAXmJXNoFbksmJ00=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TG3XajR/KTV0aXC8Uc32po083cfiMlfXmyzyyqR/qIqoNRUf8vWjVEkxYmLw5RdBuBa6ZSLklxP2VcSnXGFFzEVGYu0pkuapfmp6OZYajad6OVgW3A90bZBstw9K2r5juM92CeCmvXCdH6DqL+plj6pY5IDocvunJvBGzOb7aag= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=mdKzMrUC; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=yDEdPqox; arc=none smtp.client-ip=202.12.124.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="mdKzMrUC"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="yDEdPqox" Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailflow.stl.internal (Postfix) with ESMTP id ABF701301B7A; Thu, 12 Mar 2026 20:48:04 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Thu, 12 Mar 2026 20:48:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773362884; x=1773370084; bh=vcLY9NjcITx2BXCNwc1K2QRLwUNNN9sEl0XxFiatrQo=; b= mdKzMrUCmCgev5rjqMYLbCk9/NmPt8l5SN1cuh/XYEGVQSm40ukfPkz/tmPxK/Fw C8CU42AUDwoB+BWyvZtfv3qDJQwJMZqdkw0S72eJstmGGGMBhaX3ZHeVREPYyC2V fvUXlbJyg6aO5H4oucGa1RsaVgY2d21FE00GybtMYM8I1ew/f4keraC6xDUPB7c+ 5Pn0hGoCJlIddOhvP8sj6pXnoHeVeH2/moOy4KjHgIUwC35SmgVP2TRJhtJl4ARo qOU1z9u/0AZz+m+raqJO2irqtfbC4sPHEnz+cJH8kzFrV31gL9Yt6CTvQ0AfNIcZ ThO11BMQNTi0fw4x0ZoXng== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773362884; x=1773370084; bh=v cLY9NjcITx2BXCNwc1K2QRLwUNNN9sEl0XxFiatrQo=; b=yDEdPqoxm0mvV/5PV Tn/eyzEfPnGUZEUvP0huJ0EgtFB+R+oNg15Lem1KP+cIB5aYs2Z0gfeS39ngIbKd sOWHNPGK+ZBSJt6wqiz2s389Zx158JBtkDde4mi+o9LWu2L220htc5Z57Rzo3VCu Z90aAHSpgBiPjX8Yb5AmV6q6FQWHuRjLfpHlr9jZjWb14gW0ydd4OI2iRf2hiTOH MlOKV6hphPTxCpVXdLyVJMEyK2ZBPk/i/vECEPqsu4qQtVl5VtfC5ZMnfsQ25QJV yMMfqpO4OcTvkWzFGghdY4we94eIkCp4DUNmAIn0DHytKFG5IxjjFvYe1zdHOPjm yg30A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeekvdeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 20:47:50 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 20/53] afs: don't unhash/rehash dentries during unlink/rename Date: Fri, 13 Mar 2026 08:12:07 +1100 Message-ID: <20260312214330.3885211-21-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown afs needs to block lookup of dentries during unlink and rename. There are two reasons: 1/ If the target is to be removed, not silly-renamed, the subsequent opens cannot be allowed as the file won't exist on the server. 2/ If the rename source is being moved between directories a lookup, particularly d_revalidate, might change ->d_time asynchronously with rename changing ->d_time with possible incorrect results. afs current unhashes the dentry to force a lookup which will wait on the directory lock, and rehashes afterwards. This is incompatible with proposed changed to directory locking which will require a dentry to remain hashed throughout rename/unlink/etc operations. This patch copies a mechanism developed for NFS. ->d_fsdata which is currently unused is now set to a non-NULL value when lookups must be blocked. d_revalidate checks for this value, and waits for it to become NULL. ->d_lock is used to ensure d_revalidate never updates ->d_time while ->d_fsdata is set. Signed-off-by: NeilBrown --- fs/afs/afs.h | 7 ++++++ fs/afs/dir.c | 64 +++++++++++++++++++++++++++++------------------ fs/afs/internal.h | 5 +--- 3 files changed, 47 insertions(+), 29 deletions(-) diff --git a/fs/afs/afs.h b/fs/afs/afs.h index ec3db00bd081..019e77b08458 100644 --- a/fs/afs/afs.h +++ b/fs/afs/afs.h @@ -26,6 +26,13 @@ typedef u64 afs_volid_t; typedef u64 afs_vnodeid_t; typedef u64 afs_dataversion_t; =20 +/* This is stored in ->d_fsdata to stop d_revalidate looking at, + * and possibly changing, ->d_time on a dentry which is being moved + * between directories, and to block lookup for dentry that is + * being removed without silly-rename. + */ +#define AFS_FSDATA_BLOCKED ((void*)1) + typedef enum { AFSVL_RWVOL, /* read/write volume */ AFSVL_ROVOL, /* read-only volume */ diff --git a/fs/afs/dir.c b/fs/afs/dir.c index a0417292314c..9c57614feccf 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -1034,6 +1034,10 @@ static int afs_d_revalidate_rcu(struct afs_vnode *dv= node, struct dentry *dentry) if (!afs_check_validity(dvnode)) return -ECHILD; =20 + /* A rename/unlink is pending */ + if (dentry->d_fsdata) + return -ECHILD; + /* We only need to invalidate a dentry if the server's copy changed * behind our back. If we made the change, it's no problem. Note that * on a 32-bit system, we only have 32 bits in the dentry to store the @@ -1069,6 +1073,10 @@ static int afs_d_revalidate(struct inode *parent_dir= , const struct qstr *name, if (flags & LOOKUP_RCU) return afs_d_revalidate_rcu(dir, dentry); =20 + /* Wait for rename/unlink to complete */ +wait_for_rename: + wait_var_event(&dentry->d_fsdata, dentry->d_fsdata =3D=3D NULL); + if (d_really_is_positive(dentry)) { vnode =3D AFS_FS_I(d_inode(dentry)); _enter("{v=3D{%llx:%llu} n=3D%pd fl=3D%lx},", @@ -1161,7 +1169,13 @@ static int afs_d_revalidate(struct inode *parent_dir= , const struct qstr *name, } =20 out_valid: + spin_lock(&dentry->d_lock); + if (dentry->d_fsdata) { + spin_unlock(&dentry->d_lock); + goto wait_for_rename; + } dentry->d_time =3D (unsigned long)dir_version; + spin_unlock(&dentry->d_lock); out_valid_noupdate: key_put(key); _leave(" =3D 1 [valid]"); @@ -1536,8 +1550,7 @@ static void afs_unlink_edit_dir(struct afs_operation = *op) static void afs_unlink_put(struct afs_operation *op) { _enter("op=3D%08x", op->debug_id); - if (op->unlink.need_rehash && afs_op_error(op) < 0 && afs_op_error(op) != =3D -ENOENT) - d_rehash(op->dentry); + store_release_wake_up(&op->dentry->d_fsdata, NULL); } =20 static const struct afs_operation_ops afs_unlink_operation =3D { @@ -1591,11 +1604,7 @@ static int afs_unlink(struct inode *dir, struct dent= ry *dentry) afs_op_set_error(op, afs_sillyrename(dvnode, vnode, dentry, op->key)); goto error; } - if (!d_unhashed(dentry)) { - /* Prevent a race with RCU lookup. */ - __d_drop(dentry); - op->unlink.need_rehash =3D true; - } + dentry->d_fsdata =3D AFS_FSDATA_BLOCKED; spin_unlock(&dentry->d_lock); =20 op->file[1].vnode =3D vnode; @@ -1885,9 +1894,10 @@ static void afs_rename_edit_dir(struct afs_operation= *op) =20 _enter("op=3D%08x", op->debug_id); =20 - if (op->rename.rehash) { - d_rehash(op->rename.rehash); - op->rename.rehash =3D NULL; + if (op->rename.unblock) { + /* Rename has finished, so unlocks lookups to target */ + store_release_wake_up(&op->rename.unblock->d_fsdata, NULL); + op->rename.unblock =3D NULL; } =20 fscache_begin_write_operation(&orig_cres, afs_vnode_cache(orig_dvnode)); @@ -1970,6 +1980,9 @@ static void afs_rename_exchange_edit_dir(struct afs_o= peration *op) =20 d_exchange(old_dentry, new_dentry); up_write(&orig_dvnode->validate_lock); + /* dentry has been moved, so d_validate can safely proceed */ + store_release_wake_up(&old_dentry->d_fsdata, NULL); + } else { down_write(&orig_dvnode->validate_lock); if (test_bit(AFS_VNODE_DIR_VALID, &orig_dvnode->flags) && @@ -2009,11 +2022,10 @@ static void afs_rename_exchange_edit_dir(struct afs= _operation *op) static void afs_rename_put(struct afs_operation *op) { _enter("op=3D%08x", op->debug_id); - if (op->rename.rehash) - d_rehash(op->rename.rehash); + if (op->rename.unblock) + store_release_wake_up(&op->rename.unblock->d_fsdata, NULL); + store_release_wake_up(&op->dentry->d_fsdata, NULL); dput(op->rename.tmp); - if (afs_op_error(op)) - d_rehash(op->dentry); } =20 static const struct afs_operation_ops afs_rename_operation =3D { @@ -2121,7 +2133,6 @@ static int afs_rename(struct mnt_idmap *idmap, struct= inode *old_dir, op->ops =3D &afs_rename_noreplace_operation; } else if (flags & RENAME_EXCHANGE) { op->ops =3D &afs_rename_exchange_operation; - d_drop(new_dentry); } else { /* If we might displace the target, we might need to do silly * rename. @@ -2135,14 +2146,12 @@ static int afs_rename(struct mnt_idmap *idmap, stru= ct inode *old_dir, */ if (d_is_positive(new_dentry) && !d_is_dir(new_dentry)) { /* To prevent any new references to the target during - * the rename, we unhash the dentry in advance. + * the rename, we set d_fsdata which afs_d_revalidate will wait for. + * d_lock ensures d_count() and ->d_fsdata are consistent. */ - if (!d_unhashed(new_dentry)) { - d_drop(new_dentry); - op->rename.rehash =3D new_dentry; - } - + spin_lock(&new_dentry->d_lock); if (d_count(new_dentry) > 2) { + spin_unlock(&new_dentry->d_lock); /* copy the target dentry's name */ op->rename.tmp =3D d_alloc(new_dentry->d_parent, &new_dentry->d_name); @@ -2160,8 +2169,12 @@ static int afs_rename(struct mnt_idmap *idmap, struc= t inode *old_dir, } =20 op->dentry_2 =3D op->rename.tmp; - op->rename.rehash =3D NULL; op->rename.new_negative =3D true; + } else { + /* Block any lookups to target until the rename completes */ + new_dentry->d_fsdata =3D AFS_FSDATA_BLOCKED; + op->rename.unblock =3D new_dentry; + spin_unlock(&new_dentry->d_lock); } } } @@ -2172,10 +2185,11 @@ static int afs_rename(struct mnt_idmap *idmap, stru= ct inode *old_dir, * d_revalidate may see old_dentry between the op having taken place * and the version being updated. * - * So drop the old_dentry for now to make other threads go through - * lookup instead - which we hold a lock against. + * So block revalidate on the old_dentry until the rename completes. */ - d_drop(old_dentry); + spin_lock(&old_dentry->d_lock); + old_dentry->d_fsdata =3D AFS_FSDATA_BLOCKED; + spin_unlock(&old_dentry->d_lock); =20 ret =3D afs_do_sync_operation(op); if (ret =3D=3D -ENOTSUPP) diff --git a/fs/afs/internal.h b/fs/afs/internal.h index 106a7fe06b56..f2898ce9c0e6 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h @@ -891,10 +891,7 @@ struct afs_operation { const char *symlink; } create; struct { - bool need_rehash; - } unlink; - struct { - struct dentry *rehash; + struct dentry *unblock; struct dentry *tmp; unsigned int rename_flags; bool new_negative; --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b5-smtp.messagingengine.com (flow-b5-smtp.messagingengine.com [202.12.124.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 008EC1E5B64; Fri, 13 Mar 2026 00:47:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362870; cv=none; b=Bz1Jvz33lIM4/2bt0CJReo/6kSsqboooP8exTAgNr6QybzWzqgmydKMfYSdpkGOmEnFnzclEWcQX0HJbqj+7MLHFdPkLlJwbFRUE20Co+vx/Id3Ys+KhKmZ1mgy5EeJDICVHAllnRH0WBbIgN0bo6eDYy5GqFZ/nxylDT0G6Pww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362870; c=relaxed/simple; bh=/FnpQ8Pohju5+XQoIkCNoBImWsERUFhb9mpgXKmX+Pc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MGnmTgCWBn7sdMcqR2t6GRbMsRh/lX6tcR+sWgU7WwZTXJOXLqZRhUyQ64wXqmY4gKX8jSwSyjbxdsFV9HlGS99/aPRMDwg8LP6/Y7N9ylY9Tcy4NtIOPQBeY0oY7yyPN1namKNGlN1IFsqIu0wCxeVD0WzunZWJU5FHBXmOWOo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=kDoltOk9; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=fLlbZhFz; arc=none smtp.client-ip=202.12.124.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="kDoltOk9"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="fLlbZhFz" Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailflow.stl.internal (Postfix) with ESMTP id 525851301B74; Thu, 12 Mar 2026 20:47:47 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Thu, 12 Mar 2026 20:47:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773362867; x=1773370067; bh=IKC2mXuXBSvpu/yXLNU8JNN/9B9bcozYCtRp08XnGKg=; b= kDoltOk9PS7j42/x8/QD6W2oySfH8jqtPn+udHVYH0MDyECLvp3g7QS7jalbAMpU eMimso/ozabOCqmYob+F+bx6ZH+xyy12nIx8jz5w/HQRO+brXlRSgeDbBeQc1vp5 rwnbuAPA61dGJZ2OJvVLgtM8YGVE8OPfDhwWbbJ7c+PWZUldd3UtgxzXmvSyURKf r4+Zi6dNkDdhbxO9uVPdUGOmwGwapSfHGqwmz28c3AQCMDtMC25ElplGN7Uejeoo ZvxKZA1SW/rrh4Of2rBjHHTaF+gXQntOs5vHb9vtZsHebUgxTPaX6w6Zy3UlYLP7 N1fZbJtIPeDqYNdbo5oyDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773362867; x=1773370067; bh=I KC2mXuXBSvpu/yXLNU8JNN/9B9bcozYCtRp08XnGKg=; b=fLlbZhFzwd90VIqqe qYrOogss2BKl4uOQU0iVdtU8kNX0XHhSxmS2esGSjI2DreIGsCE2h//QAC2BK1h7 31X9Ii5WxuWCUcsxGyQP0XOlhY1AY9QsaoYlzbNKHSvrphU+k1lFDc6C4fHPgkRr BRdgSdFyL0PXFJHboOrYRwzF/2iX2lvJ75lvYBZY4xuk3s1bY+f3PDj1Y/uy7X8S uQCyJPqAWKZDnIuLAgHCIsRtC0O8+C+4BpjD4HdtqKBwoCslIfl3kOSwazcKw0s3 6j/mrP3zPbwdOXsv0PfPh9ZeIhPxNXjEseN3qe2xmr/mTvWCgWzHD75V4WIkXXtp 6qagQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeekvdeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 20:47:33 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 21/53] afs: use d_splice_alias() in afs_vnode_new_inode() Date: Fri, 13 Mar 2026 08:12:08 +1100 Message-ID: <20260312214330.3885211-22-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown As afs supports the fhandle interfaces there is a theoretical possibility that the inode created for mkdir could be found by open_by_handle_at() and given a dentry before d_instantiate() is called. This would result in two dentries for the one directory inode, which is not permitted. So this patch changes afs_mkdir() to use d_splice_alias() and to return the alternate dentry from ->mkdir() if appropriate. Signed-off-by: NeilBrown --- fs/afs/dir.c | 14 ++++++++++---- fs/afs/internal.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index 9c57614feccf..1e472768e1f1 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -1248,7 +1248,7 @@ void afs_check_for_remote_deletion(struct afs_operati= on *op) /* * Create a new inode for create/mkdir/symlink */ -static void afs_vnode_new_inode(struct afs_operation *op) +static struct dentry *afs_vnode_new_inode(struct afs_operation *op) { struct afs_vnode_param *dvp =3D &op->file[0]; struct afs_vnode_param *vp =3D &op->file[1]; @@ -1265,7 +1265,7 @@ static void afs_vnode_new_inode(struct afs_operation = *op) * the new directory on the server. */ afs_op_accumulate_error(op, PTR_ERR(inode), 0); - return; + return NULL; } =20 vnode =3D AFS_FS_I(inode); @@ -1276,7 +1276,7 @@ static void afs_vnode_new_inode(struct afs_operation = *op) afs_init_new_symlink(vnode, op); if (!afs_op_error(op)) afs_cache_permit(vnode, op->key, vnode->cb_break, &vp->scb); - d_instantiate(op->dentry, inode); + return d_splice_alias(inode, op->dentry); } =20 static void afs_create_success(struct afs_operation *op) @@ -1285,7 +1285,7 @@ static void afs_create_success(struct afs_operation *= op) op->ctime =3D op->file[0].scb.status.mtime_client; afs_vnode_commit_status(op, &op->file[0]); afs_update_dentry_version(op, &op->file[0], op->dentry); - afs_vnode_new_inode(op); + op->create.ret =3D afs_vnode_new_inode(op); } =20 static void afs_create_edit_dir(struct afs_operation *op) @@ -1356,6 +1356,12 @@ static struct dentry *afs_mkdir(struct mnt_idmap *id= map, struct inode *dir, op->ops =3D &afs_mkdir_operation; ret =3D afs_do_sync_operation(op); afs_dir_unuse_cookie(dvnode, ret); + if (op->create.ret) { + /* Alternate dentry */ + if (ret =3D=3D 0) + return op->create.ret; + dput(op->create.ret); + } return ERR_PTR(ret); } =20 diff --git a/fs/afs/internal.h b/fs/afs/internal.h index f2898ce9c0e6..ce94f10a14c0 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h @@ -889,6 +889,7 @@ struct afs_operation { int reason; /* enum afs_edit_dir_reason */ mode_t mode; const char *symlink; + struct dentry *ret; } create; struct { struct dentry *unblock; --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b5-smtp.messagingengine.com (flow-b5-smtp.messagingengine.com [202.12.124.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAB27242D70; Fri, 13 Mar 2026 00:47:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362853; cv=none; b=u1PzZDm1xsrNA+kEJM8/bzgI+7MvMUbAgDWd0UidQmDXv/RTrxSYeTy3lwfo0O/u49McMEhmvLN7g3ASOk7wYFo/IAbqe3MROGgbvJPeCCuTNFz2SRAxGRnBPU9bi65+Q0SGEJWyyRnXejS9X3r6BcwYor9CKwbDyp2DUUHj38s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362853; c=relaxed/simple; bh=LjRfbo8WCUGSLHVLwMlqwZIIRrZr5rl1vIhEtLVay24=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BA70zJORXFzwjF0+Sqi+pwT8dcXor4lp5Sj6VVGAoS/CmKFySci2mh88cctQIog0xaYvN0NE2wtgI3oA4Wwg/A/Bihdq47YXY8mfkt4lGbnYtorirU11tnKuOF79TiKGE9oP6Co5VPO3g3im7tOxJTgqg11v71dWzuu8MTicOVc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=HmxnQzsE; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=OlXvAtNG; arc=none smtp.client-ip=202.12.124.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="HmxnQzsE"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="OlXvAtNG" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailflow.stl.internal (Postfix) with ESMTP id 2E9171301B70; Thu, 12 Mar 2026 20:47:30 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Thu, 12 Mar 2026 20:47:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773362850; x=1773370050; bh=xGOrm2m9mt9eD9zeGh+FgoHjVnxN1Npoe+4KJW4hbgM=; b= HmxnQzsEnZP/3l1ULThI1EtrBcCNolH2f3MeN7w4c7RJaHXm+vKCYNwg9f3DJff1 He4j2oJck+izrAriM0w1WckxI1d50V6JuDB7luBVfoFucpQwFSyRdFlrMACyav88 z3F62CiYUIe4w38nrZqPSz/x+Uca/8LPpSTqUVrbC2vf+MdaV+bpTyFrg05XUAtB B3M7AUCtRd1OANkg0nNQSSStmbmlAdin/TrJ/Y1X0zb8u3+Svl2yvFwiJGX2S+lf Yy8oXSi9SqkCgzJiCJL/7BIDxye786uTWcG1xdHO/ONL3+Cme4YJHQkRJmw4TH6e 0pqhq1WLr0M0qhxdeh3x9g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773362850; x=1773370050; bh=x GOrm2m9mt9eD9zeGh+FgoHjVnxN1Npoe+4KJW4hbgM=; b=OlXvAtNGHI5ULo/6q P/Vj6urZdgs1H9LmeFtWV92pQiyGGsFsQLzw2hqtOML7WuKq6gzXZmMNfTa/b4aH MvZmVk13SFwaVAzxGcqjAzAFz5AEJjlQaa261ykzd4mSt7ZkX/lX8B/uYUiaeyEP z6UO2DmP5pMfz7Jp/O81kXT+Y3S2m7AH0ogPR58xpqGpBpKCeeIdF7cHIPa3hoav MXBVERHJZmLvfmcOJ+U4kOuXPqmtq103L804YDCQoS21cXOg8POrnxQA8jH3Ju5z g57pDN5L/F62MOFgw62EHoRcXWNPOfLKHcdo0MDyH6W7fyzS1k0rTYgkJiYfEtQa 1uMfQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeekvdeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 20:47:16 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 22/53] afs: use d_alloc_nonblock in afs_sillyrename() Date: Fri, 13 Mar 2026 08:12:09 +1100 Message-ID: <20260312214330.3885211-23-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown Rather than performing a normal lookup (which will be awkward with future locking changes) use d_alloc_noblock() to find a dentry for an unused name, and use an open-coded lookup_slow() to see if it is free on the server. Signed-off-by: NeilBrown --- fs/afs/dir_silly.c | 51 ++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/fs/afs/dir_silly.c b/fs/afs/dir_silly.c index 982bb6ec15f0..699143b21cdd 100644 --- a/fs/afs/dir_silly.c +++ b/fs/afs/dir_silly.c @@ -112,7 +112,9 @@ int afs_sillyrename(struct afs_vnode *dvnode, struct af= s_vnode *vnode, struct dentry *dentry, struct key *key) { static unsigned int sillycounter; - struct dentry *sdentry =3D NULL; + struct dentry *sdentry =3D NULL, *old; + struct inode *dir =3D dentry->d_parent->d_inode; + struct qstr qsilly; unsigned char silly[16]; int ret =3D -EBUSY; =20 @@ -122,23 +124,38 @@ int afs_sillyrename(struct afs_vnode *dvnode, struct = afs_vnode *vnode, if (dentry->d_flags & DCACHE_NFSFS_RENAMED) return -EBUSY; =20 - sdentry =3D NULL; - do { - dput(sdentry); - sillycounter++; - - /* Create a silly name. Note that the ".__afs" prefix is - * understood by the salvager and must not be changed. - */ - scnprintf(silly, sizeof(silly), ".__afs%04X", sillycounter); - sdentry =3D lookup_noperm(&QSTR(silly), dentry->d_parent); +newname: + sillycounter++; =20 - /* N.B. Better to return EBUSY here ... it could be dangerous - * to delete the file while it's in use. - */ - if (IS_ERR(sdentry)) - goto out; - } while (!d_is_negative(sdentry)); + /* Create a silly name. Note that the ".__afs" prefix is + * understood by the salvager and must not be changed. + */ + scnprintf(silly, sizeof(silly), ".__afs%04X", sillycounter); + qsilly =3D QSTR(silly); + sdentry =3D try_lookup_noperm(&qsilly, dentry->d_parent); + if (!sdentry) + sdentry =3D d_alloc_noblock(dentry->d_parent, &qsilly); + if (sdentry =3D=3D ERR_PTR(-EWOULDBLOCK)) + /* try another name */ + goto newname; + /* N.B. Better to return EBUSY here ... it could be dangerous + * to delete the file while it's in use. + */ + if (IS_ERR(sdentry)) + goto out; + if (d_is_positive(sdentry)) { + dput(sdentry); + goto newname; + } + /* This name isn't known locally - check on server */ + old =3D dir->i_op->lookup(dir, sdentry, 0); + d_lookup_done(sdentry); + if (old || d_is_positive(sdentry)) { + if (!IS_ERR(old)) + dput(old); + dput(sdentry); + goto newname; + } =20 ihold(&vnode->netfs.inode); =20 --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b5-smtp.messagingengine.com (flow-b5-smtp.messagingengine.com [202.12.124.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B31BF30DEB0; Fri, 13 Mar 2026 00:47:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362835; cv=none; b=eEcBY9TJEMMMD64rfm8DVo687SZ7mFxIOdvpwvIp1lRrWN/opoTu8A+Jmh8PfbL//otUF1LTnQBLN2JaVWc/LFdTHckOWxmcBhsdgThtz2T8t/SDDMNC3P4oZfjWOzz10jrfEfzpBoHNAnhbau5qO8bUsSQ17vZexSeAKz7If7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362835; c=relaxed/simple; bh=M+pj1aweERiV90n0rYRzeVYYR+PmCvz+3Vh3CZXEIx0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cBZxbhUO8AjX20oxV2/TQgwYeXtw2PYIEuxRAA+WyOHthZCyzozhYbQ3NqOHuL0A8x7exwvHO1uUzx/3hu3ImSyIXce0spUTqujw9HNcan7+s4Ibw/XasPDDv1HMgK93jTlTSfqJHYJocRIinBOScJFYtCxunqiXsrKyLVG30Vs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=IpsMpfFe; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=G8JHmFu5; arc=none smtp.client-ip=202.12.124.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="IpsMpfFe"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="G8JHmFu5" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailflow.stl.internal (Postfix) with ESMTP id B9F1C1301B6E; Thu, 12 Mar 2026 20:47:12 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Thu, 12 Mar 2026 20:47:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773362832; x=1773370032; bh=Qz44r/cI/H+P66r7rjgQTu2SyU7wjlJxbU1IwzedCr8=; b= IpsMpfFevA+mEhkdruCUf1Vu9FEmLzrEWAtb4IDHjustVcc660x5nQzIEH+zM7+n F7xem84KPhj9hWFRzoN31Jzl2kLAcLz5C41k8KF8DDc2o4mfWEEH6308fDzSejrk AorOd82znIkjc2rhRbi8CcLttXgvES5I5n9aRJa1sym6k9LnaGvmiOPtg4JaoClH E0GZdfUMmErgqYA2F+MxWkHZOVdGxA5gC99x4eWzvtHdwM3bSZVia7h1wLflwgGX KQHLoziyxbJHp75VC9zMqgFzhJDRW4bSOVnZITlnR83AmG4HdVrOomHAmHpQJLkD HBP2qOLbjyiF5zP3BpxzQg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773362832; x=1773370032; bh=Q z44r/cI/H+P66r7rjgQTu2SyU7wjlJxbU1IwzedCr8=; b=G8JHmFu5KQLBpNeDN zld/gBCZXli4GS4wIem/PbJqdIIhih3tiaKE/N90l8FUrwJW8+gU2YeDvGTUBthJ rkgMGcdPlD1fIWMo1biHaQo9/WLjEYSr4vVAu27PxvDXdpU++7hfY7L//0Jwh1vH tzV6BPqgVS3EsG8sXh4xhvpy93GmQMFAKAaTw03Y5NAL6DAPPg5Wqs5sjjStPu0f cLxuKrZDYNCr9qnEHNk94ODc/hUxWL67t8Fh7zQzN0r9Wm/zV2Yq30KwIEHJu9yc t/JWWAUZfgxJ26ZwGO6uIfjpuQTO8vMuyP8XPTU8suyyC2YPRzT8hE/YRgFJTBwT ND/vQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeekvdehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 20:46:58 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 23/53] afs: lookup_atsys to drop and reclaim lock. Date: Fri, 13 Mar 2026 08:12:10 +1100 Message-ID: <20260312214330.3885211-24-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown If afs is asked to lookup a name ending with @sys, it needs to look up a different name for which is allocates a dentry with d_alloc_parallel(). This is done while the parent lock is held which will be a problem in a future patch where the ordering of the parent lock and d_alloc_parallel() locking is reversed. There is no actual need to hold the lock while d_alloc_parallel() is called, so with this patch we drop the lock and reclaim it. Signed-off-by: NeilBrown --- fs/afs/dir.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index 1e472768e1f1..c195ee851191 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -908,12 +908,14 @@ static struct inode *afs_do_lookup(struct inode *dir,= struct dentry *dentry) /* * Look up an entry in a directory with @sys substitution. */ -static struct dentry *afs_lookup_atsys(struct inode *dir, struct dentry *d= entry) +static struct dentry *afs_lookup_atsys(struct inode *dir, struct dentry *d= entry, + unsigned int flags) { struct afs_sysnames *subs; struct afs_net *net =3D afs_i2net(dir); struct dentry *ret; char *buf, *p, *name; + struct qstr nm; int len, i; =20 _enter(""); @@ -933,6 +935,13 @@ static struct dentry *afs_lookup_atsys(struct inode *d= ir, struct dentry *dentry) refcount_inc(&subs->usage); read_unlock(&net->sysnames_lock); =20 + /* Calling d_alloc_parallel() while holding parent locked is undesirable. + * We don't really need the lock any more. + */ + if (flags & LOOKUP_SHARED) + inode_unlock_shared(dir); + else + inode_unlock(dir); for (i =3D 0; i < subs->nr; i++) { name =3D subs->subs[i]; len =3D dentry->d_name.len - 4 + strlen(name); @@ -942,7 +951,10 @@ static struct dentry *afs_lookup_atsys(struct inode *d= ir, struct dentry *dentry) } =20 strcpy(p, name); - ret =3D lookup_noperm(&QSTR(buf), dentry->d_parent); + nm =3D QSTR(buf); + ret =3D try_lookup_noperm(&nm, dentry->d_parent); + if (!ret) + ret =3D d_alloc_parallel(dentry->d_parent, &nm); if (IS_ERR(ret) || d_is_positive(ret)) goto out_s; dput(ret); @@ -953,6 +965,10 @@ static struct dentry *afs_lookup_atsys(struct inode *d= ir, struct dentry *dentry) */ ret =3D NULL; out_s: + if (flags & LOOKUP_SHARED) + inode_lock_shared(dir); + else + inode_lock_nested(dir, I_MUTEX_PARENT); afs_put_sysnames(subs); kfree(buf); out_p: @@ -998,7 +1014,7 @@ static struct dentry *afs_lookup(struct inode *dir, st= ruct dentry *dentry, dentry->d_name.name[dentry->d_name.len - 3] =3D=3D 's' && dentry->d_name.name[dentry->d_name.len - 2] =3D=3D 'y' && dentry->d_name.name[dentry->d_name.len - 1] =3D=3D 's') - return afs_lookup_atsys(dir, dentry); + return afs_lookup_atsys(dir, dentry, flags); =20 afs_stat_v(dvnode, n_lookup); inode =3D afs_do_lookup(dir, dentry); --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b5-smtp.messagingengine.com (flow-b5-smtp.messagingengine.com [202.12.124.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37A3E242D70; Fri, 13 Mar 2026 00:46:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362818; cv=none; b=A/rCK2j47kAz0WJNJrhjqgRgo7/heHCkd0Xr27qp6YXyqG6nxE2JQQIfJ7JNNhs7UqowpzVsk0UFRnicDfUI1RWPZBi9a56+JAp+74G+ikOUmuifNmrwChF4rSYwViUsUj1f/51rIyA//WPnjGbPrx38L3Ra7Hv5RmEAU8k00zY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362818; c=relaxed/simple; bh=BjD01fjUfpiWAuDi8h8umH9WTPM2waEwnWOFXx5wFxE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pHbrYJ4UMnU2/QuAzYfg0np/eiIEBi74RxPdUYZzj6r+jcznLQUQsUxHZ6iuLuaBUe3ZCAML0qTRiSe+m2PUHeIOcN6TEJ2aq5ILDYvxFzXqTl9YdrD9nUd/Fw4dkEwylIEgETc9sua2IQlnHYADAhkEh9UhBXZ/SX37okHq/bc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=RNXQe8RC; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=wfskezN6; arc=none smtp.client-ip=202.12.124.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="RNXQe8RC"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="wfskezN6" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailflow.stl.internal (Postfix) with ESMTP id 605B01300BDB; Thu, 12 Mar 2026 20:46:55 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Thu, 12 Mar 2026 20:46:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773362815; x=1773370015; bh=K3IStrNmQd52sbuvLJgTXGgXoqLBL9Wr3QWVkKkzQVI=; b= RNXQe8RCRsLKMGTZv3GRKZahOC0IxxlJic/ko0MFy4a1ctyXK6vvz4ReaSk7Wtb/ mAzGCuXrdmdZBQIRLvL9TgyL2qlc45O0kQ3l8qXW16jE7P6d9LqJCqRvPWC/uzxz Fg4Z9KDdzbQTjvMOHVIfVhzYLGcWWMkbkuEXMLMZZKzxUaOV6SPZtD3+P7r4CdlO YReiac+iMDhQdyLzaO6kSMLbrOxlDborVcCeQAMrmsrVMTfxIzMeSF5US+w16WfM ACO2ucwH/a+sdYpvVApyX2BOUWYS4NgQgEXOKZ4Urg3/g1TPjzQe8VBcsJ455SzX 9KAVhZnChtKP/WL+6dyBwQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773362815; x=1773370015; bh=K 3IStrNmQd52sbuvLJgTXGgXoqLBL9Wr3QWVkKkzQVI=; b=wfskezN6avTEhR19Y nyFK8EjU0/MMk1mTZsKRrgviM3fKXxJNJu1JVFZMcMVBW/OhFGdzQV2zxrvMHOyI +wsRPzWoNSHHCaB3Uz6Z2Z50+4HPTAToivoCuItoC7GdStbUhlwIos6CNfKYetOs dtWj4+DVfGt5fqQnqBjG1Dqg+KH1ydv5G4O84e2/iXhc9Ryvf0hXvivBdRiWWVUz ln4nRLs8aYjEr1bv8aqsemzU1pcoJrsa+DX022p8AWsPy7cwqUau5yZRIa7kTqSX KkLiJjVMjxGllDLHldeMf1HfZBS49/IiohaDFc6csqGAyWyuyBEkdFBLfaeltNSp jBt2A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeekvdeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 20:46:41 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 24/53] afs: use d_duplicate() Date: Fri, 13 Mar 2026 08:12:11 +1100 Message-ID: <20260312214330.3885211-25-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown To prepare for d_alloc_parallel() being permitted without a directory lock, use d_duplicate() when duplicating a dentry in order to create a whiteout. Signed-off-by: NeilBrown --- fs/afs/dir.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index c195ee851191..b5c593f50079 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -2047,6 +2047,8 @@ static void afs_rename_put(struct afs_operation *op) if (op->rename.unblock) store_release_wake_up(&op->rename.unblock->d_fsdata, NULL); store_release_wake_up(&op->dentry->d_fsdata, NULL); + if (op->rename.tmp) + d_lookup_done(op->rename.tmp); dput(op->rename.tmp); } =20 @@ -2175,8 +2177,7 @@ static int afs_rename(struct mnt_idmap *idmap, struct= inode *old_dir, if (d_count(new_dentry) > 2) { spin_unlock(&new_dentry->d_lock); /* copy the target dentry's name */ - op->rename.tmp =3D d_alloc(new_dentry->d_parent, - &new_dentry->d_name); + op->rename.tmp =3D d_duplicate(new_dentry); if (!op->rename.tmp) { afs_op_nomem(op); goto error; --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b5-smtp.messagingengine.com (flow-b5-smtp.messagingengine.com [202.12.124.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6D021E5B64; Fri, 13 Mar 2026 00:46:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362801; cv=none; b=vDvG44y68Z3G2/8+urDFwX5ejsujtLjCtE8Yd/cizUg/eV6agFJtsb9IKTDLXV88Jdw5uAp2IOf5VDOkuu+a12pdPpdMcWdaTJtwafkeKfSeFjdaPocMU8uDJhQUUohqqkvXejw5MH8ccJrupMbbptlnGLKckkIQUFSkY7vrL8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362801; c=relaxed/simple; bh=arB3c2qXqlUdWivHK4hRPllO1dT8AFqMMCogTLltFlY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=peD25Ag04KNlfnvVnToCF+pSQ83W067WMz2UPLzbZFho9nZQirFxycsTHh98oGJB6iFsWmv8DQcBM+YjrYxLRxv6bkClP8Bxzy98bEQcWw59gtvwNzyYv6HhIS79V/l/XKG+IF+LpN8Tp+bQR+eV0gzHTYt9/5mda1FTT3gbkqk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=mRnZ0YGC; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Viy4tpks; arc=none smtp.client-ip=202.12.124.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="mRnZ0YGC"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Viy4tpks" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailflow.stl.internal (Postfix) with ESMTP id 36F521301B63; Thu, 12 Mar 2026 20:46:38 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Thu, 12 Mar 2026 20:46:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773362798; x=1773369998; bh=uW0rtLXFkbaBWXfGN4/JFrVlhcpfsZme8A1/pyxgR7Q=; b= mRnZ0YGCx3gLm0wWBHdN72SdQLIjJRWNHgfmRzo1EeqngvhpXsIr4of+UqGu9OeW pUmJLqiIiGQHyeSyktpTCMTAETBXWvPA3OSWBncolVh/nheFGMbFXBXOVYOkqc7j FlCEobV9Mp281to+TUFV3T7YHeRK8mPY35N/T7oIyDl6/vfGeOlanFxYy27FByF0 Wz8wZEy8G8xWc1POLg6uW+P54Kao4gR50BRmV33zpljxSDZ2XKTOWwnbzyaHHJgQ q/l/0Jn3R6TRw9lfxXdwBt4cADGARrgvooLknBc3Pk8nLE8+yFY5yj8xeo7zbuLn MvAJD9QttjXchwHdcv0txA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773362798; x=1773369998; bh=u W0rtLXFkbaBWXfGN4/JFrVlhcpfsZme8A1/pyxgR7Q=; b=Viy4tpkswwmJzmT/i EILuXqKRFNSgtS2iM9oKc6cjwsKTDd4DN8r1iNUHTfMZqZQOoA27qlLOy+aNCqfl scyU5vWIq+dNNVGQzb6L4jTw0gApXgrVxp0OlD5OFr2m2WRVBn5F82cAVUn53wKR Rh8CbSYEov+8EEP9iox4dX9pctgJyfOQIu8fkTixZcVobtZOl9otr4gzkcB2LYhN q62Ie+fo1atQQJKNJwG6CvWqL3NiRqbZG2j0AlP0L1gKhb7vwzLiXxVsR9jCHSo4 JHgWRp7aaCFWITa39njjDD5hka9V7wBP3GzeawT/o7YxiSRL8CvJFxM180AOUpkX pAkMA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeekvdeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 20:46:24 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 25/53] smb/client: use d_time to store a timestamp in dentry, not d_fsdata Date: Fri, 13 Mar 2026 08:12:12 +1100 Message-ID: <20260312214330.3885211-26-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown smb/client uses d_fsdata is exactly the way that d_time is intended to be used. It previous used d_time but this was changed in Commit: a00be0e31f8d ("cifs: don't use ->d_time") without any reason being given. This patch effectively reverts that patch (though it doesn't remove the helpers) so that d_fsdata can be used for something more generic. Cc: Miklos Szeredi Signed-off-by: NeilBrown --- fs/smb/client/cifsfs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h index e320d39b01f5..5153e811c50b 100644 --- a/fs/smb/client/cifsfs.h +++ b/fs/smb/client/cifsfs.h @@ -30,12 +30,12 @@ cifs_uniqueid_to_ino_t(u64 fileid) =20 static inline void cifs_set_time(struct dentry *dentry, unsigned long time) { - dentry->d_fsdata =3D (void *) time; + dentry->d_time =3D time; } =20 static inline unsigned long cifs_get_time(struct dentry *dentry) { - return (unsigned long) dentry->d_fsdata; + return dentry->d_time; } =20 extern struct file_system_type cifs_fs_type, smb3_fs_type; --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b5-smtp.messagingengine.com (flow-b5-smtp.messagingengine.com [202.12.124.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1F7F30E0F5; Fri, 13 Mar 2026 00:46:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362785; cv=none; b=fDtKIH7WKHYoawMyRMIADuSWc+yBdyrVj5mULZ8CL6vt0R+0PwzrBgGqKi/fzaz6yQtDD3yK/RnqsqZADIiWrZf8GptoQvregszQZaxzhW0PCukso1f3i9T+Hi/Pw0fV2fGyVqyNF5y4JwyE8XgpJiZGR/BdNIgETgJ9NcKRTMQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362785; c=relaxed/simple; bh=tv8rKn4N2IeoFeMnFx+2x9JGOMGaY+wE9fF08LJwdQU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=coavq4eHehs7M7b7ep4G5L7sEGWLykXSOI3H3GYZbc2bW0jReJAIeLcl2Ziu6F6DdQ1WnCMWiqmTqAaTT+uf9ope/lkvIZf0kt0qXU+fCurp2tfeRC7EZzV829LAw/FZ4qaTR73xLsFtuXN7txQiFvFfiiw2rgBG7Z+mBvzSL+k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=WHV8jLjR; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=ZIH5/VZH; arc=none smtp.client-ip=202.12.124.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="WHV8jLjR"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="ZIH5/VZH" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailflow.stl.internal (Postfix) with ESMTP id 2F4F01301B58; Thu, 12 Mar 2026 20:46:21 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Thu, 12 Mar 2026 20:46:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773362781; x=1773369981; bh=beibKrJw8gVlJSS1MC+gPsWPAAjnc1lfM9GVMreQ7l0=; b= WHV8jLjRFjvExaZUz/IeuFgzAji4iuC1qCdaaeCT+yhJO1A8Jy46xlJATz84RftX 8ziuDP+FIoVk37AiwmkWNq59mHh58p+afnfWD/PswUpqQxv2VeqaDwUpCCy1ua2S UTsPcAo+khmfNmWIe4/dEMaxZPSeXxrGb/QhRIAyhV4Q0EucmpogkjrKFycwgKSu 8XvmsnDj5S9ck3EDBgdc36XgPp5YT7phSDnE54m2kT6FBaPSFqUxsEP5LfQT8Ibd kwPFZIqhYefJcMp6GHUuks2lW91o2lXD9/uMMRk5odSMf2vU+pN6LAFgjwuofxko Pxd4qYjc0WMvZ9umgpIH+Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773362781; x=1773369981; bh=b eibKrJw8gVlJSS1MC+gPsWPAAjnc1lfM9GVMreQ7l0=; b=ZIH5/VZHZrMfU1cW/ wG0qw06iFIqEqoHXhM5fZAFsUmmSTK8s5iHKFawt41sSzRFI2voGV/g2vxNPRvvZ QT4aLkhEZTZsQGWPLjlqLtmevQqurNCd2EhPslV4EIvWQatGKGq6tQ6DUKA7hkfJ wjgHPYeUDwzEedB/fhcD6NPn128Xk4owWwoTOWNwhF+JKbEEbpihYJy0ES1ozFab f79UKDfTMpYIQuiK2/rFGv9Osd/YLjjgERMzFcZkc7zkq+y6Jg08tF8TybJSGwX8 LmtR+qvbnSUv3BTDBUn27O3PhnWN1IVPZyiwC0uUVCe52zEbcPFy0n0GgdtLfz4g ljLng== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeekvdeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 20:46:07 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 26/53] smb/client: don't unhashed and rehash to prevent new opens. Date: Fri, 13 Mar 2026 08:12:13 +1100 Message-ID: <20260312214330.3885211-27-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown smb/client needs to block new opens of the target of unlink and rename while the operation is progressing. This stablises d_count() and allows a determination of whether a "silly-rename" is required. It currently unhashes the dentry which will cause lookup to block on the parent directory i_rwsem. Proposed changes to locking will cause this approach to stop working and the exclusivity will be provided for the dentry only, and only while it is hashed. So we introduce a new machanism similar to that used by nfs and afs. ->d_fsdata (currently unused by smb/client) is set to a non-NULL value when lookups need to be blocked. ->d_revalidate checks for this and blocks. This might still allow d_count() to increment, but once it has been tested as 1, there can be no new opens completed. Signed-off-by: NeilBrown --- fs/smb/client/dir.c | 3 +++ fs/smb/client/inode.c | 48 +++++++++++++++++-------------------------- 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/fs/smb/client/dir.c b/fs/smb/client/dir.c index cb10088197d2..cecbc0cce5c5 100644 --- a/fs/smb/client/dir.c +++ b/fs/smb/client/dir.c @@ -790,6 +790,9 @@ cifs_d_revalidate(struct inode *dir, const struct qstr = *name, if (flags & LOOKUP_RCU) return -ECHILD; =20 + /* Wait for pending rename/unlink */ + wait_var_event(&direntry->d_fsdata, direntry->d_fsdata =3D=3D NULL); + if (d_really_is_positive(direntry)) { int rc; struct inode *inode =3D d_inode(direntry); diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c index d4d3cfeb6c90..3549605fa9c2 100644 --- a/fs/smb/client/inode.c +++ b/fs/smb/client/inode.c @@ -28,6 +28,13 @@ #include "cached_dir.h" #include "reparse.h" =20 +/* This is stored in ->d_fsdata to block d_revalidate on a + * file dentry that is being removed - unlink or rename target. + * This causes any open attempt to block. There may be existing opens + * but they can be detected by checking d_count() under ->d_lock. + */ +#define CIFS_FSDATA_BLOCKED ((void *)1) + /* * Set parameters for the netfs library */ @@ -1946,27 +1953,21 @@ static int __cifs_unlink(struct inode *dir, struct = dentry *dentry, bool sillyren __u32 dosattr =3D 0, origattr =3D 0; struct TCP_Server_Info *server; struct iattr *attrs =3D NULL; - bool rehash =3D false; =20 cifs_dbg(FYI, "cifs_unlink, dir=3D0x%p, dentry=3D0x%p\n", dir, dentry); =20 if (unlikely(cifs_forced_shutdown(cifs_sb))) return smb_EIO(smb_eio_trace_forced_shutdown); =20 - /* Unhash dentry in advance to prevent any concurrent opens */ - spin_lock(&dentry->d_lock); - if (!d_unhashed(dentry)) { - __d_drop(dentry); - rehash =3D true; - } - spin_unlock(&dentry->d_lock); - tlink =3D cifs_sb_tlink(cifs_sb); if (IS_ERR(tlink)) return PTR_ERR(tlink); tcon =3D tlink_tcon(tlink); server =3D tcon->ses->server; =20 + /* Set d_fsdata to prevent any concurrent opens */ + dentry->d_fsdata =3D CIFS_FSDATA_BLOCKED; + xid =3D get_xid(); page =3D alloc_dentry_path(); =20 @@ -2083,8 +2084,9 @@ static int __cifs_unlink(struct inode *dir, struct de= ntry *dentry, bool sillyren kfree(attrs); free_xid(xid); cifs_put_tlink(tlink); - if (rehash) - d_rehash(dentry); + + /* Allow lookups */ + store_release_wake_up(&dentry->d_fsdata, NULL); return rc; } =20 @@ -2501,7 +2503,6 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *s= ource_dir, struct cifs_sb_info *cifs_sb; struct tcon_link *tlink; struct cifs_tcon *tcon; - bool rehash =3D false; unsigned int xid; int rc, tmprc; int retry_count =3D 0; @@ -2517,23 +2518,15 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode = *source_dir, if (unlikely(cifs_forced_shutdown(cifs_sb))) return smb_EIO(smb_eio_trace_forced_shutdown); =20 - /* - * Prevent any concurrent opens on the target by unhashing the dentry. - * VFS already unhashes the target when renaming directories. - */ - if (d_is_positive(target_dentry) && !d_is_dir(target_dentry)) { - if (!d_unhashed(target_dentry)) { - d_drop(target_dentry); - rehash =3D true; - } - } - tlink =3D cifs_sb_tlink(cifs_sb); if (IS_ERR(tlink)) return PTR_ERR(tlink); tcon =3D tlink_tcon(tlink); server =3D tcon->ses->server; =20 + /* Set d_fsdata to prevent any concurrent opens */ + target_dentry->d_fsdata =3D CIFS_FSDATA_BLOCKED; + page1 =3D alloc_dentry_path(); page2 =3D alloc_dentry_path(); xid =3D get_xid(); @@ -2570,8 +2563,6 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *s= ource_dir, } } =20 - if (!rc) - rehash =3D false; /* * No-replace is the natural behavior for CIFS, so skip unlink hacks. */ @@ -2662,8 +2653,6 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *s= ource_dir, } rc =3D cifs_do_rename(xid, source_dentry, from_name, target_dentry, to_name); - if (!rc) - rehash =3D false; } } =20 @@ -2671,8 +2660,9 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *s= ource_dir, CIFS_I(source_dir)->time =3D CIFS_I(target_dir)->time =3D 0; =20 cifs_rename_exit: - if (rehash) - d_rehash(target_dentry); + /* Allow lookups */ + store_release_wake_up(&target_dentry->d_fsdata, NULL); + kfree(info_buf_source); free_dentry_path(page2); free_dentry_path(page1); --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b5-smtp.messagingengine.com (flow-b5-smtp.messagingengine.com [202.12.124.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9CBC5285C8B; Fri, 13 Mar 2026 00:46:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362767; cv=none; b=i28lY795jQCO2UpEXNGDXcYzxLLVUE5AiW012alI9lqS7/A+pPz/M0+ogv2ZGjlHQ2Q3vAVwPW+WZVE3pWkx9sEzOd4/DV9ZQ/IWX/QF9o2GY2e9DHt+sydDx5jjhtJQsu4eljeZcS5wXGu1vxQU9OtQyWTSs4HKHNzKtkPVhmw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362767; c=relaxed/simple; bh=rzAkLHyrQaOfugKPiq7TWkHZcHs6kmsMMapDc7O/Ysg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nBEbrdJhrVrIE7phvT5Cq/HI92JgYXUhW25rhrz0ToauXVCnrPcKqAfecn7jfI+d5RjqR2tkvyzbjL2P6NzQLThiZDdgVjoqF6ss7BdYeajhhYhBF00WYC5V72C+nCHEwNblkfR//ab5bJAYPNHTeP1JvGjv4/PK1bfGOuShrcg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=gKwSPNrD; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=lBx8/it3; arc=none smtp.client-ip=202.12.124.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="gKwSPNrD"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="lBx8/it3" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailflow.stl.internal (Postfix) with ESMTP id C57AE1301B4C; Thu, 12 Mar 2026 20:46:03 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Thu, 12 Mar 2026 20:46:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773362763; x=1773369963; bh=PvJJgAoi6+6/iAinwR5eAmiVL7AkcVBlOABk7/2rYco=; b= gKwSPNrDp/Lh0K2AdmDPuP81x/xKJYynieIS613cuyIap5TJBGt5zoBJQkcnLx+P wIIpre2IzG82z5AyDZagtjjr4EtLFHuY+3ew5fDab1/yIPB/uUEieMSrkA3SAGQh 0hw7ulI7fDK+6bhU0r4qO4EEemUcLLydcBXxhaWveI05xHIYigrT2kv6HGB22iDl Pm7Z70iYJsrxhQm/lNa8SebZsdmRrivu1M2XBRDOdTP/LlqHocEGRvESnBiNX92B JLUzL7W8K2qPLuHSJfmCX21NPVd1NhNhOrW+1abIUaEPZHtwCQuWsFmoxcxpcZoQ s9OP3WR1HmclPU7UtiAU5g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773362763; x=1773369963; bh=P vJJgAoi6+6/iAinwR5eAmiVL7AkcVBlOABk7/2rYco=; b=lBx8/it30WvLfM1Ut 4V40yFC8YMQTxuozALmQF1Kz8GrZRjYHh0SEma52k1oUapkTo/R08AT0F53b9/VY xdwzYS7PxHPQqsugkTC7WGac+zdsWTTGVKW6btlA+rILgtb5JxhC04Vy/65L2Xdv gVJcdhH41QdzdnSyemJSUkWvzFljqohC48EoOSDQD2TO/gvb0ZljX3XBCb38KUN/ K+Vr6CN7cP5atIEEGvmRRks84tlmL3uGXzUXmKCpw01j5H5hJwsVnCDxu6xxFoYd SqpnoXrKs1sjPLo+NcbXGxHzrmCTuu76BPw50bfweWvA1mDAr7hV9ogvlDfmv7zI 1xFmw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeekvdeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 20:45:50 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 27/53] smb/client: use d_splice_alias() in atomic_open Date: Fri, 13 Mar 2026 08:12:14 +1100 Message-ID: <20260312214330.3885211-28-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown atomic_open can be called with a hashed-negative dentry or an in-lookup dentry. Rather than d_drop() and d_add() we can use d_splice_alias() which keeps the dentry hashed - important for proposed locking changes. Signed-off-by: NeilBrown --- fs/smb/client/dir.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/smb/client/dir.c b/fs/smb/client/dir.c index cecbc0cce5c5..361a20987927 100644 --- a/fs/smb/client/dir.c +++ b/fs/smb/client/dir.c @@ -439,8 +439,7 @@ static int cifs_do_create(struct inode *inode, struct d= entry *direntry, unsigned goto out_err; } =20 - d_drop(direntry); - d_add(direntry, newinode); + d_splice_alias(newinode, direntry); =20 out: free_dentry_path(page); --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b5-smtp.messagingengine.com (flow-b5-smtp.messagingengine.com [202.12.124.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FA551E5B64; Fri, 13 Mar 2026 00:45:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362749; cv=none; b=LjfHCXb1eZkGvFoEMe6fCGrMRKwiiUEy2/oB+F8XIi1JkRI/XxABlaIkJPQK2LCoZyeR+aXhkYUQH6/YNkVhXL3hH6PHBe173zVTYluwah+2i+YMMm/eKxidMQZgi1HqUhcRms5/pre8Oi6VkpF5+iRsKaXLijsq2xP0SYcsvhM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362749; c=relaxed/simple; bh=g9vnkC7ctlL2n6jegN5oKCEOB5+TJXS9/I+ZsrZjP7M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mAquLAn63iPFCqyvgJ8Cy4PD6Jrk1uYtTBx3z4K42XrCBB3NoYiP6u5JuYxefs4jpJCpNCBMDuNo5BdLzHqVB/xdoB8aaiW3l9jPSIxopwqo1dB0ZCgLdYkmseYsVf7t9I646IVZ/s3vDO8+8q0NtXi4mD+0sI0pWra4lrSMxXs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=cE1Lg/xF; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=jM9+cNGi; arc=none smtp.client-ip=202.12.124.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="cE1Lg/xF"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="jM9+cNGi" Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailflow.stl.internal (Postfix) with ESMTP id B728A1301B4D; Thu, 12 Mar 2026 20:45:46 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-11.internal (MEProxy); Thu, 12 Mar 2026 20:45:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773362746; x=1773369946; bh=yta/ONG6ZSj6rRZhdNMJVWJN5o8jH9bKyVShEpbtcv8=; b= cE1Lg/xFP0Sm6V6om+xiR/woiTWX3KvncecIx4H7TAb7iajTj5fptF2VjhZpgpd0 ysGa6UL0ZOe44vo9fTWe2s1758oiXSmJXRDbStoiiOYNb+G9/etnJNkRra4M5omW o64ruAeKGRLUYzLPoIZ9aCSyQPaC5Ukxh1B1OhK7z2H5FJQQw9ASMVBMD25RzYzi q2TOTwjNXuXCv/Bq5muEBZJ+JHbO9mmaH/rWBsYqQZb5lD4v4JbjoJpiPNi3odoa yTtnxM4U1DcBgoK/KMObBZDwPj5ll6Js8Ek3NeZ8y4iE/SaV+MfJX23XtPecVIsU NOB8quAvQHVIeMvGkWnN0Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773362746; x=1773369946; bh=y ta/ONG6ZSj6rRZhdNMJVWJN5o8jH9bKyVShEpbtcv8=; b=jM9+cNGiMa0yJ821j XIe2hxjc7cs5JRvyn7N6B5ZpVJXWj9HHAS2ZvHu3CkvqpXMjLDtwMJjFOi9cFMEu Rk3aQr6q4AX5TkjM0iTuRxCSwHdBERW3BTGo/GzfF9O7hqF5xllNf3j+JQ9BIm07 BbbnxSIgg3jKpkp1rl9gnujcjR/h+SycfQQ2Aw1zeb/bZoETR8Ln24k6bNqXqhDn VXaDWsXcHn0IhZaz4RAdBSwoKuRcFM2Mxtmju40VQ0Dgbsb2r7ZjKEACZ8XG5vki bQ08kv/ZDmo/me5yB8dh9Bl0ipZV5O9Pr21Ssej5wEjMd91ZsFHSDNQioqUwGP1e xMYwg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeekvdehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 20:45:32 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 28/53] smb/client: Use d_alloc_noblock() in cifs_prime_dcache() Date: Fri, 13 Mar 2026 08:12:15 +1100 Message-ID: <20260312214330.3885211-29-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown cifs uses the results of readdir to prime the dcache. Using d_alloc_parallel() can block if there is a concurrent lookup. Blocking in that case is pointless as the lookup will add info to the dcache and there is no value in the readdir waiting to see if it should add the info too. Also this call to d_alloc_parallel() is made while the parent directory is locked. A proposed change to locking will lock the parent later, after d_alloc_parallel(). This means it won't be safe to wait in d_alloc_parallel() while holding the directory lock. So change to use d_alloc_noblock(). Signed-off-by: NeilBrown --- fs/smb/client/readdir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/smb/client/readdir.c b/fs/smb/client/readdir.c index 47f5d620b750..dabf9507bc40 100644 --- a/fs/smb/client/readdir.c +++ b/fs/smb/client/readdir.c @@ -104,7 +104,7 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *n= ame, (fattr->cf_flags & CIFS_FATTR_NEED_REVAL)) return; =20 - dentry =3D d_alloc_parallel(parent, name); + dentry =3D d_alloc_noblock(parent, name); } if (IS_ERR(dentry)) return; --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b5-smtp.messagingengine.com (flow-b5-smtp.messagingengine.com [202.12.124.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C33330AAD0; Fri, 13 Mar 2026 00:45:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362733; cv=none; b=SsBWdKSMKj01oCDwANocY9afieHdnxydEx8Xi9df8GPu+bVRNu5Agx4LjF1XBU12JyhYnzY4sEdmu91FwPF/JY7mguvQrrSU9ZOqAL0rT5GSfyBhWH0T5FGNAVuZjuqeNzVam3l+IGsPQKYHYpKk01/yLO2awNJ5IQ0nQ47Fxbs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362733; c=relaxed/simple; bh=5YfDw7LrlOQhF52b/60zX5HsaX+8xwtDUhWoOG5zh3k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bmCub0XhHbzM6Kfmo1YsY+Jlh+jICp0LJUw8Yt+J+9vBf6RgvcQYuS7GLePYmPKdDlw3glj3Rg2fnz3Qlvdlnzexg+hn2q0PNxbvkZNyiEOTSaOTa+UwEhwwRJhQvcAOz3+RWqCgJW2deK1UJuFuULbOUaZZvfS7Vna6wKr4Lfk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=Xigasop1; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=FvytbuZD; arc=none smtp.client-ip=202.12.124.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="Xigasop1"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="FvytbuZD" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailflow.stl.internal (Postfix) with ESMTP id 723A11301B47; Thu, 12 Mar 2026 20:45:29 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Thu, 12 Mar 2026 20:45:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773362729; x=1773369929; bh=R05x33rqt4D3Op1mihSzRwcI3EKvb6TFzzswayv/Ksw=; b= Xigasop1MFc1BQXQk0iq0PfuDE5mE+cILrPFMrDYi2HMs5dOR7m3kR60PFE0o//D aw2w/JFsCcl4UMgrADlcOW7LnhmzPFw08CFCSey71EXkDmErCHEi+jV1cGpk00Ts tEFSho7APavmIZUF0dMzV9Gkq78RsEPr1fAJ1JQVkbh4z/t24eBjVMJ2iQ2FDZ9Y 7ketqCAapUiVN1O9T16DVsGZ/8cXOCWKejAqG2k6NgW2cxG45qPNMJl9IPFen5V/ orYVj3SFsDH2EOV0JHX6QCoGsJzMb8M4NMZohb+vDl7P5TEDtUi5kJP2hvJVYvqh F12YY7eWyASDT/+ROxjrlw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773362729; x=1773369929; bh=R 05x33rqt4D3Op1mihSzRwcI3EKvb6TFzzswayv/Ksw=; b=FvytbuZDDevI4Y9VG JVZqSJMtkrWNxz48lVJmr/EpHNXAk7GWlVs1oWlFVkAQTUVnGKy2Dbd3N857jru0 c2IoXqdFdnReDa6d8K2oodMGlOj8GCefMCv+cRaC7IjCCbbuTZklNYoL8xRuYr0F g2vk1l3mBLBWqC3Ym8bfh90KxjjC66/YiXzk0siKTVi0/DIYZnRN2EJqa02yyRpS vEs5fDDK5GYYr0uCIn0BmwwcOxDjkV0BR9kEP0Sn1Tx7ezF6Af3gnhuCMP4Z3sz8 vaPSeIjskEaJHNN6PGjenL/R1IF5oAuSRIvL/OBiCSQpf8gBGcD8V3ZV2/2ls1h/ Ycpqg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeekvdehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 20:45:15 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 29/53] exfat: simplify exfat_lookup() Date: Fri, 13 Mar 2026 08:12:16 +1100 Message-ID: <20260312214330.3885211-30-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown 1/ exfat_d_anon_disconn() serves no purpose. It is only called (on alias) when alias->d_parent =3D=3D dentry->d_parent and in that case IS_ROOT(dentry) will return false, so the whole function will return false. So we can remove it. 2/ When an alias for the inode is found in the same parent it is always sufficient to d_move() the alias to the new name. This will keep just one dentry around when there are multiple effective names, and it will always show the most recently used name, which appears to be the intention. Signed-off-by: NeilBrown --- fs/exfat/namei.c | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 670116ae9ec8..e04cda7425da 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -711,11 +711,6 @@ static int exfat_find(struct inode *dir, const struct = qstr *qname, return 0; } =20 -static int exfat_d_anon_disconn(struct dentry *dentry) -{ - return IS_ROOT(dentry) && (dentry->d_flags & DCACHE_DISCONNECTED); -} - static struct dentry *exfat_lookup(struct inode *dir, struct dentry *dentr= y, unsigned int flags) { @@ -750,32 +745,15 @@ static struct dentry *exfat_lookup(struct inode *dir,= struct dentry *dentry, * Checking "alias->d_parent =3D=3D dentry->d_parent" to make sure * FS is not corrupted (especially double linked dir). */ - if (alias && alias->d_parent =3D=3D dentry->d_parent && - !exfat_d_anon_disconn(alias)) { - + if (alias && alias->d_parent =3D=3D dentry->d_parent) { /* - * Unhashed alias is able to exist because of revalidate() - * called by lookup_fast. You can easily make this status - * by calling create and lookup concurrently - * In such case, we reuse an alias instead of new dentry + * As EXFAT does not support hard-links this must + * be an alternate name for the same file, + * possibly longname vs 8.3 alias. + * Rather than allocating a new dentry, use the old + * one but keep the most recently used name. */ - if (d_unhashed(alias)) { - WARN_ON(alias->d_name.hash_len !=3D - dentry->d_name.hash_len); - exfat_info(sb, "rehashed a dentry(%p) in read lookup", - alias); - d_drop(dentry); - d_rehash(alias); - } else if (!S_ISDIR(i_mode)) { - /* - * This inode has non anonymous-DCACHE_DISCONNECTED - * dentry. This means, the user did ->lookup() by an - * another name (longname vs 8.3 alias of it) in past. - * - * Switch to new one for reason of locality if possible. - */ - d_move(alias, dentry); - } + d_move(alias, dentry); iput(inode); mutex_unlock(&EXFAT_SB(sb)->s_lock); return alias; --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b5-smtp.messagingengine.com (flow-b5-smtp.messagingengine.com [202.12.124.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D3DE3093B5; Fri, 13 Mar 2026 00:45:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362715; cv=none; b=QS3yD+xZLaE7/TTP7OlHesNNXJq2byHHesBC/Ibg5fq91w9zPx3FDNS17oo5GorrytrL34Qir1pzC5vVEB5s4EmRXaMFzUVCkgUn81fKjy27CQCVrf1VbABjeYF7nWu431U9qtwQcolw5zhRxBP6WRcvCG/FCPClAsieapeHHog= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362715; c=relaxed/simple; bh=f18OcmtFFvcADSvzQSJbfW5cw/pwFr0vZirs7YULIMU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y477s2gl/oxvy1cQcGqagqNEcbCvdWX/Eq7jS5n+bn1vvpXD+Pk5LJnOv54Bcj7VkY/eD6suhLU+MvU6Tx3v/bbHKASwjVGcbc/dY8tk5HSmtBtQGscp/TFKCyC/KBwoj3kVGyLCnBywp601xMkFcZZsY7cr+EgMIMtZTbWFqo8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=gZ+8j40U; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=zzfvAvPP; arc=none smtp.client-ip=202.12.124.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="gZ+8j40U"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="zzfvAvPP" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailflow.stl.internal (Postfix) with ESMTP id 4ED741301B42; Thu, 12 Mar 2026 20:45:12 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Thu, 12 Mar 2026 20:45:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773362712; x=1773369912; bh=WEn/ifGqMa6Ax93LDCMof9WVE/J3cBfFQIVVntI4FSU=; b= gZ+8j40UJfd35YHLEn8GltXBxrkHPPJuG8UzNQ3aeCppl0Bx/G/7pz2k7GhTJmjj mMkAf0dDw+XbG44/22ZHnC0JRrXwzH8q+b82+ON+NK+C1ecJu5I0G6cz+Vt/yust YtInsQcWto7IBJEOT8YxmPsZCQpX3QkE4fAQTc0qcS4tV0zoArACYwrCYiAcYuR2 IU3IwRQR4aA2y5hgvfqRNgHlsCxk0iBegjLC050ZkP1ZyWpg+OZEQdX1QuP/ytZl /kpi2YCwgiIZQX+OdMfzYWmhsrdWZfMNXzIpSMtOnpwWF/EVPknBbGGcynUfDN8U DaCcDEvlgv1AfZcLYJmQlA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773362712; x=1773369912; bh=W En/ifGqMa6Ax93LDCMof9WVE/J3cBfFQIVVntI4FSU=; b=zzfvAvPPEd2RUPFHZ l0AGY0rUFybvZ//8GerfoYDoJ/RiOp618aTFUWOlyRcqPbjs+TwRL0gLxxsIgn9B 9D19+ZiWTLY6YmJghBQ0EtLyi32bLsLapT86+x3V0Oyr4WcdSP8ViASeFCxFlipW +h2cuSFfiKsYtmGkwNjMFh5Wks22+oCYAhUFbfGjj9uat3x3i2ZjM/1YiaEpE+e8 nv5myRHW2Ieskf5HzoPTOIZ08+j8wF95yGOTtnv4tZUYVtQggkg0IQjwJNs9fLnp cK+VOUlhixrvzRekBrrG3Sdeah9seF20NJJD+piNW3SbCTgj0k1feZCLF4BxGTMl +rclw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeekvdehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 20:44:58 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 30/53] configfs: remove d_add() calls before configfs_attach_group() Date: Fri, 13 Mar 2026 08:12:17 +1100 Message-ID: <20260312214330.3885211-31-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown These d_add() calls cannot be necessary. The inode given is NULL so all they do is attach the dentry to the hash table. If configfs_attach_group() fails, then d_drop() is called so the dentry will be detached. If configfs_attach_group() succeeds, then configfs_attach_group -> configfs_attach_item ->configfs_create_dir must have succeeded, so d_instantiate() will have been called and the dentry hashed there. So the only effect is that the dentry will be hashed-negative for a short period which will allow a lookup to find nothing without waiting for the directory i_rwsem. I can find no indication that this might be important. Adding a dentry as negative, and then later making it positive is an unusual pattern and appears to be unnecessary, so it is best avoided. Signed-off-by: NeilBrown --- fs/configfs/dir.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index 362b6ff9b908..c82eca0b5d73 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c @@ -706,8 +706,6 @@ static int create_default_group(struct config_group *pa= rent_group, ret =3D -ENOMEM; child =3D d_alloc_name(parent, group->cg_item.ci_name); if (child) { - d_add(child, NULL); - ret =3D configfs_attach_group(&parent_group->cg_item, &group->cg_item, child, frag); if (!ret) { @@ -1904,8 +1902,6 @@ int configfs_register_subsystem(struct configfs_subsy= stem *subsys) err =3D -ENOMEM; dentry =3D d_alloc_name(root, group->cg_item.ci_name); if (dentry) { - d_add(dentry, NULL); - err =3D configfs_dirent_exists(dentry); if (!err) err =3D configfs_attach_group(sd->s_element, --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b5-smtp.messagingengine.com (flow-b5-smtp.messagingengine.com [202.12.124.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E515D242D7F; Fri, 13 Mar 2026 00:44:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362698; cv=none; b=WcTBQk8n5rJYwwM5Tw4Na0PX42E9cOdlQoxn3QMquHCcKnhZJgSRq+Ewlear1qW5w4jwOCCxVs3jKFWsAZHyJ59krvRoQdHDRaxmqRpcfWEJkII+sXS5Au93/untsuQxIYwZkHmfa0X+T1/ULBOqxHRhhjb6Xc9Wp1D1KwLwlgY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362698; c=relaxed/simple; bh=1GEdUWGxzBWcip32FwhChqRsoRwk1KYoMgvnGuh140U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O2wb/09Mh94SJDGmh4qYpLAC4dRiB6QLi8VWcP3EL7fvTpBfHSRXQbM6BTOKcDC3I5ByYGmoSjdgoKZIK4NL4/iCNvaRsmUyUDUriFr0xgRrSssA8xwlJQteX52d31pKVQiZNzZG+DbDShMHx9mn8dsCyAp6JR2cZgug3Ue28Kg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=CqROUpl0; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=z24mIuT+; arc=none smtp.client-ip=202.12.124.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="CqROUpl0"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="z24mIuT+" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailflow.stl.internal (Postfix) with ESMTP id 273051301B3C; Thu, 12 Mar 2026 20:44:55 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Thu, 12 Mar 2026 20:44:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773362695; x=1773369895; bh=epUsWlAclv1DX2KFvnl7YFoPpzqQm77MgVOFM+B8UxU=; b= CqROUpl0SFgdLYM+5S4HfZslkqN7s5xdFeJrWFhMGpiUdyODd7Z+7ZvN1Cp31hpK ZT7KdwX8nus+Re9RyFZ7Lmx2HS/y4aAbuKPyjNSlyG4QT9GlQP35c7Qc/wveUpJc R6fyTEJL1SYXniLv5tJqSk0lVP4TG9izP0Z5673lCC1cVr3QRjNHb2xuAnovPDIN SWebynoCqykrPAnihTtAf4L4HNSaXCdZDUwo3lrKJrbCjD9/oexYvaM0MJCepNAl UAzWnRabXqQJKdQ+UqQhD+TSINUJmdz5L/8VPRv5cvG/4/0ylXxVgi/4RB5tBewr q+8rr17BgBMChmtR+WIx8A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773362695; x=1773369895; bh=e pUsWlAclv1DX2KFvnl7YFoPpzqQm77MgVOFM+B8UxU=; b=z24mIuT+M2aYx8BDn /SvHK2UeiuT9Zv020rqyHMZx6iwO9BhUEN4xj0P9wfCsYHthOQ7I3eXW+qtsed2n /hGxBGJFKKkTmgXNYq9tJp1zytp6kg+1P5x0LuPwfGAY/urC++X+Rh/67vfy5hZl DF1pkcDi9UQPUY2J1H/YNQzRgxd7MjUUl8aQvK/mKz5IoPlHl9bi+l9YIlwoaZgH Zk1LmrrSqNDSvYiABRJ2cxUaljb/oxyhp6EmBjDzWaeW+e+D8vTq2jf3ic7Ke1iv RjnCU9b8SvZ4hBQDdVmd8EVd30w+Luquz27gPL6jEjG5gzX9KlTD0SzRez021FFn iosiw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeekvdeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 20:44:41 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 31/53] configfs: stop using d_add(). Date: Fri, 13 Mar 2026 08:12:18 +1100 Message-ID: <20260312214330.3885211-32-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown "Best practice" is to use d_splice_alias() at the end of a ->lookup function. d_add() often works and is not incorrect in configfs, but as it is planned to remove d_add(), change to use d_splice_alias(). Signed-off-by: NeilBrown --- fs/configfs/dir.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index c82eca0b5d73..6ec589b6b8a4 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c @@ -501,8 +501,7 @@ static struct dentry * configfs_lookup(struct inode *di= r, } spin_unlock(&configfs_dirent_lock); done: - d_add(dentry, inode); - return NULL; + return d_splice_alias(inode, dentry); } =20 /* --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b5-smtp.messagingengine.com (flow-b5-smtp.messagingengine.com [202.12.124.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5B3028690; Fri, 13 Mar 2026 00:44:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362681; cv=none; b=UdlvT3f6+nYMGcLpCrcpBLky0He2UJYC/XDVg1I3FtKnRNR6HauOBcEBtjnKeE8WSD7yOpV7lriPcFCZ+pzJMYvXDMCiKpILK5HRdaga05Q4RrmykhzY90TcnxzQPYGKlDt18kGSHwGjAr2Ja/5Nl+mDBFOwXUg2JbVSOhrXiTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362681; c=relaxed/simple; bh=mClAU9+MY2++0S4AUnzUn/uSCtCfpygQCVUKEYN56Hg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DFsG/l88Ibm8qGksFh0AUBxbwMKVpJeikO1XdYtc2tp5iGTxWkLbGf2trrRSPQtDSnVkIK/Lh7frQK1Z+A7gkpjgmsbW9fPCNr5PxBu6z8n8dXEo3ox4z/4Thlt4cO0bpz2rVlA1IRNnO4/mvOsECQWtPX/B08pbarXPO5+2b58= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=Uiezvf1W; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=aFZ9JpaM; arc=none smtp.client-ip=202.12.124.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="Uiezvf1W"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="aFZ9JpaM" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailflow.stl.internal (Postfix) with ESMTP id E582F1301B38; Thu, 12 Mar 2026 20:44:37 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Thu, 12 Mar 2026 20:44:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773362677; x=1773369877; bh=W+v0RL/pMIx9j3nL0G9XTRWShzNEiYc7Idmh4VPeJRE=; b= Uiezvf1WupOqSkTJUVDzQj/e45sCFlF/EsxnaQRySLaMDeWubPQp5OddX1k1Tvyc fM8hXdjfAyk7mBWyOtJyl1XY3cLisZtYpoTj/wWI94u1+6Q1OTxA1xkorKNlWngZ 19E1fuDeIU0QMydCYSd84SxYxTpG7sb9SkBfgNPvcxBV0NZIOsCaBRE1a4KLzZE1 GjAYqOrBgI9TC6KxLc2SGiccYXPQXEx7/Wi8CMKCPXcZgKxji1zDJ/7l359QMTZa ywFy44n0vrD30GmvqShSeh7b/fwsohR/niM5kxoAlO95aTu0XwAx0CU7d688/FST arzVZR6P9jQqOOl/aBeZTQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773362677; x=1773369877; bh=W +v0RL/pMIx9j3nL0G9XTRWShzNEiYc7Idmh4VPeJRE=; b=aFZ9JpaMDgkx+1Rfj 50EtuvgPbTu5u0p7h44/q79D178w3fkvuVwv2nTvXR1ZNLOWKPhEDjcXjRir7VU7 zylNpYhPxXxgBAKwhYD5kG02FWQKM1yzB/OjVyPTUbXfqbNW7xMtuQ11zWCu5qhy 8Qc/j0zpzCEtWZ5Pm5ap8yjnRvZxGUiVrHBgy5LW4llPZ1rSVe7AWeu11RiniJgk At57JqIa/txEQMSlOGgTWOftoLO6WArZ/AByvN2cKJ5FpiPU8PweDjNbLU/7Vf0Y BOGmEgiG57SWk7kyCNZ8fVwmdnUIkfzFF4d8/iw2mdvQvfAm9DHbT2S7Su5nZHrl zS9Vg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeekvdehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgepfeenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 20:44:24 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 32/53] ext4: move dcache modifying code out of __ext4_link() Date: Fri, 13 Mar 2026 08:12:19 +1100 Message-ID: <20260312214330.3885211-33-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown __ext4_link() is separate from ext4_link() so that it can be used for replaying a "fast_commit" which records a link operation. Replaying the fast_commit does not require any interaction with the dcache - it is purely ext4-local - but it uses a dentry to simplify code reuse. An interface it uses - d_alloc() - is not generally useful and will soon be removed. This patch prepares ext4 for that removal. Specifically it removes all dcache-modification code from __ext4_link(). This will mean that __ext4_link() treats the dentry as read-only so fast_commit reply can simply provide an on-stack dentry. Various "const" markers are sprinkled around to confirm that the dentry is treated read-only. This patch only rearranges code and slightly re-orders it, so those changes can be reviewed separately. The next patch will remove the use of d_alloc(). Signed-off-by: NeilBrown --- fs/dcache.c | 2 +- fs/ext4/ext4.h | 4 ++-- fs/ext4/fast_commit.c | 14 +++++++++++--- fs/ext4/namei.c | 23 +++++++++++++---------- include/linux/dcache.h | 2 +- include/trace/events/ext4.h | 4 ++-- 6 files changed, 30 insertions(+), 19 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index a1219b446b74..c48337d95f9a 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -358,7 +358,7 @@ static inline int dname_external(const struct dentry *d= entry) return dentry->d_name.name !=3D dentry->d_shortname.string; } =20 -void take_dentry_name_snapshot(struct name_snapshot *name, struct dentry *= dentry) +void take_dentry_name_snapshot(struct name_snapshot *name, const struct de= ntry *dentry) { unsigned seq; const unsigned char *s; diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 293f698b7042..1794407652ff 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2972,7 +2972,7 @@ void ext4_fc_track_range(handle_t *handle, struct ino= de *inode, ext4_lblk_t star void __ext4_fc_track_unlink(handle_t *handle, struct inode *inode, struct dentry *dentry); void __ext4_fc_track_link(handle_t *handle, struct inode *inode, - struct dentry *dentry); + const struct dentry *dentry); void ext4_fc_track_unlink(handle_t *handle, struct dentry *dentry); void ext4_fc_track_link(handle_t *handle, struct dentry *dentry); void __ext4_fc_track_create(handle_t *handle, struct inode *inode, @@ -3719,7 +3719,7 @@ extern int ext4_handle_dirty_dirblock(handle_t *handl= e, struct inode *inode, extern int __ext4_unlink(struct inode *dir, const struct qstr *d_name, struct inode *inode, struct dentry *dentry); extern int __ext4_link(struct inode *dir, struct inode *inode, - struct dentry *dentry); + const struct dentry *dentry); =20 #define S_SHIFT 12 static const unsigned char ext4_type_by_mode[(S_IFMT >> S_SHIFT) + 1] =3D { diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index f575751f1cae..2a5daf1d9667 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -388,7 +388,7 @@ static int ext4_fc_track_template( } =20 struct __track_dentry_update_args { - struct dentry *dentry; + const struct dentry *dentry; int op; }; =20 @@ -400,7 +400,7 @@ static int __track_dentry_update(handle_t *handle, stru= ct inode *inode, struct ext4_inode_info *ei =3D EXT4_I(inode); struct __track_dentry_update_args *dentry_update =3D (struct __track_dentry_update_args *)arg; - struct dentry *dentry =3D dentry_update->dentry; + const struct dentry *dentry =3D dentry_update->dentry; struct inode *dir =3D dentry->d_parent->d_inode; struct super_block *sb =3D inode->i_sb; struct ext4_sb_info *sbi =3D EXT4_SB(sb); @@ -483,7 +483,7 @@ void ext4_fc_track_unlink(handle_t *handle, struct dent= ry *dentry) } =20 void __ext4_fc_track_link(handle_t *handle, - struct inode *inode, struct dentry *dentry) + struct inode *inode, const struct dentry *dentry) { struct __track_dentry_update_args args; int ret; @@ -1471,7 +1471,15 @@ static int ext4_fc_replay_link_internal(struct super= _block *sb, goto out; } =20 + ihold(inode); + inc_nlink(inode); ret =3D __ext4_link(dir, inode, dentry_inode); + if (ret) { + drop_nlink(inode); + iput(inode); + } else { + d_instantiate(dentry_inode, inode); + } /* * It's possible that link already existed since data blocks * for the dir in question got persisted before we crashed OR diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index c4b5e252af0e..80e1051cab44 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -2353,7 +2353,7 @@ static int make_indexed_dir(handle_t *handle, struct = ext4_filename *fname, * may not sleep between calling this and putting something into * the entry, as someone else might have used it while you slept. */ -static int ext4_add_entry(handle_t *handle, struct dentry *dentry, +static int ext4_add_entry(handle_t *handle, const struct dentry *dentry, struct inode *inode) { struct inode *dir =3D d_inode(dentry->d_parent); @@ -3445,7 +3445,7 @@ static int ext4_symlink(struct mnt_idmap *idmap, stru= ct inode *dir, return err; } =20 -int __ext4_link(struct inode *dir, struct inode *inode, struct dentry *den= try) +int __ext4_link(struct inode *dir, struct inode *inode, const struct dentr= y *dentry) { handle_t *handle; int err, retries =3D 0; @@ -3460,8 +3460,6 @@ int __ext4_link(struct inode *dir, struct inode *inod= e, struct dentry *dentry) ext4_handle_sync(handle); =20 inode_set_ctime_current(inode); - ext4_inc_count(inode); - ihold(inode); =20 err =3D ext4_add_entry(handle, dentry, inode); if (!err) { @@ -3471,11 +3469,7 @@ int __ext4_link(struct inode *dir, struct inode *ino= de, struct dentry *dentry) */ if (inode->i_nlink =3D=3D 1) ext4_orphan_del(handle, inode); - d_instantiate(dentry, inode); - ext4_fc_track_link(handle, dentry); - } else { - drop_nlink(inode); - iput(inode); + __ext4_fc_track_link(handle, inode, dentry); } ext4_journal_stop(handle); if (err =3D=3D -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) @@ -3504,7 +3498,16 @@ static int ext4_link(struct dentry *old_dentry, err =3D dquot_initialize(dir); if (err) return err; - return __ext4_link(dir, inode, dentry); + ihold(inode); + ext4_inc_count(inode); + err =3D __ext4_link(dir, inode, dentry); + if (err) { + drop_nlink(inode); + iput(inode); + } else { + d_instantiate(dentry, inode); + } + return err; } =20 /* diff --git a/include/linux/dcache.h b/include/linux/dcache.h index a97eb151d9db..3b12577ddfbb 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -600,7 +600,7 @@ struct name_snapshot { struct qstr name; union shortname_store inline_name; }; -void take_dentry_name_snapshot(struct name_snapshot *, struct dentry *); +void take_dentry_name_snapshot(struct name_snapshot *, const struct dentry= *); void release_dentry_name_snapshot(struct name_snapshot *); =20 static inline struct dentry *d_first_child(const struct dentry *dentry) diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h index a3e8fe414df8..efcf1018c208 100644 --- a/include/trace/events/ext4.h +++ b/include/trace/events/ext4.h @@ -2870,7 +2870,7 @@ TRACE_EVENT(ext4_fc_stats, DECLARE_EVENT_CLASS(ext4_fc_track_dentry, =20 TP_PROTO(handle_t *handle, struct inode *inode, - struct dentry *dentry, int ret), + const struct dentry *dentry, int ret), =20 TP_ARGS(handle, inode, dentry, ret), =20 @@ -2902,7 +2902,7 @@ DECLARE_EVENT_CLASS(ext4_fc_track_dentry, #define DEFINE_EVENT_CLASS_DENTRY(__type) \ DEFINE_EVENT(ext4_fc_track_dentry, ext4_fc_track_##__type, \ TP_PROTO(handle_t *handle, struct inode *inode, \ - struct dentry *dentry, int ret), \ + const struct dentry *dentry, int ret), \ TP_ARGS(handle, inode, dentry, ret) \ ) =20 --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b5-smtp.messagingengine.com (flow-b5-smtp.messagingengine.com [202.12.124.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BED1C2D061D; Fri, 13 Mar 2026 00:44:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362664; cv=none; b=IVuVL5Wd6oJGXS98ZBuivtKeSPhb412/xY9vLOyfb37fqzhN8IcJ4170z3SKZNJcgova3CxVr4UxQNO/TUIEOqewdUw7GMtWSx1+vNV2B9bc9o8em3xiLEtPAKa86YrA+2mm0yqINgcawSOB6kxF1eXpcO2OICT8Ql5579uQAfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362664; c=relaxed/simple; bh=9GrYZJTr1huYHX1gLb2iNf9op2Xtbz6nw85bt8JodAk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JWNNJmixYIijBQyxJ8ylORcCMW2eR/XbWkEPpItLiP+pU0xRg4n9qk0SIAxFEGdM5HswAw9LECouejOxYqYzBTg8eTqVgOIjrSeTrsOSzUc+X/MrLsNEAzcLp8mGJdMzujecaFXfcZBpnpjYdF27E58+B/Oefs0j5qLzUmc1iFI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=HtGyc6qG; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=cGZE7jMy; arc=none smtp.client-ip=202.12.124.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="HtGyc6qG"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="cGZE7jMy" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailflow.stl.internal (Postfix) with ESMTP id 1C1651301B36; Thu, 12 Mar 2026 20:44:21 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Thu, 12 Mar 2026 20:44:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773362660; x=1773369860; bh=EchxTXDSTALGT/SYRwTZVf/wCe3kGgvEe9z67tw1N/I=; b= HtGyc6qG86oz5kPvVFKloxRAiiPrdOpKU8L6wLUUYdjZZtzmK8nkkRoRc4Ob/zDE ygWeDDQ7jByf/H36cgdfqD2YT8xrlT5AnRfqLG6YYDduADlVEQcPZKFCOFEq7efp W0PV4tzGLYO7R7+Bi8QoTHgftdcdAbG2cmbRdSq7IiPJrej/xGh8Sis7vcSb5NUp 8p9RKdBEfwd8U9POVkTHLrI8JD7f/jqhMlJETvpWzrtU+xKrqH6+DdkWl9BZAf3N 0STPIxH4lQraZKks4fXTtb9nzvy+JFzG89W3Fsfemen70/tWjCFitTexXEMl+aF6 MdwcnBbmpBgBWkwcmrlWrQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773362660; x=1773369860; bh=E chxTXDSTALGT/SYRwTZVf/wCe3kGgvEe9z67tw1N/I=; b=cGZE7jMy2SV9uoVbT q+IZzNuzXM+hYp7X/7RyEelmnM4UrPJGwKgU90XEnptRogSnhLgrodnjWWKRdW6V AQ2OpzAPnuid/OLVu+UcDPlHx8xARolg4F09VwR1VkrdXcXUZU3U5Q/ecPnnrOZf SYXSxRBpzCG7sc8smUlxY8lKJ6slf1JpRJFSI4EJH5Sn6FJIQ9W0S72D+0grR2eW eRAGsh4DDkSU9EgUFpYcUsAr3jEhGPLkD/lIXTiZxQR15ET1AfwNhG2Uyk8kFZEA eJf1QWHbL/Mhmx2NzRvIensmEAwQ5KJ9/ygKBb3mV2toMoGumq2oOmUfpqyuBCg1 QIv+A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeekvdehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 20:44:07 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 33/53] ext4: use on-stack dentries in ext4_fc_replay_link_internal() Date: Fri, 13 Mar 2026 08:12:20 +1100 Message-ID: <20260312214330.3885211-34-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown ext4_fc_replay_link_internal() uses two dentries to simply code-reuse when replaying a "link" operation. It does not need to interact with the dcache and removes the dentries shortly after adding them. They are passed to __ext4_link() which only performs read accesses on these dentries and only uses the name and parent of dentry_inode (plus checking a flag is unset) and only uses the inode of the parent. So instead of allocating dentries and adding them to the dcache, allocat two dentries on the stack, set up the required fields, and pass these to __ext4_link(). This substantially simplifies the code and removes on of the few uses of d_alloc() - preparing for its removal. Signed-off-by: NeilBrown Reviewed-by: Jan Kara --- fs/ext4/fast_commit.c | 40 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index 2a5daf1d9667..e3593bb90a62 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -1446,8 +1446,6 @@ static int ext4_fc_replay_link_internal(struct super_= block *sb, struct inode *inode) { struct inode *dir =3D NULL; - struct dentry *dentry_dir =3D NULL, *dentry_inode =3D NULL; - struct qstr qstr_dname =3D QSTR_INIT(darg->dname, darg->dname_len); int ret =3D 0; =20 dir =3D ext4_iget(sb, darg->parent_ino, EXT4_IGET_NORMAL); @@ -1457,28 +1455,14 @@ static int ext4_fc_replay_link_internal(struct supe= r_block *sb, goto out; } =20 - dentry_dir =3D d_obtain_alias(dir); - if (IS_ERR(dentry_dir)) { - ext4_debug("Failed to obtain dentry"); - dentry_dir =3D NULL; - goto out; - } + { + struct dentry dentry_dir =3D { .d_inode =3D dir }; + const struct dentry dentry_inode =3D { + .d_parent =3D &dentry_dir, + .d_name =3D QSTR_LEN(darg->dname, darg->dname_len), + }; =20 - dentry_inode =3D d_alloc(dentry_dir, &qstr_dname); - if (!dentry_inode) { - ext4_debug("Inode dentry not created."); - ret =3D -ENOMEM; - goto out; - } - - ihold(inode); - inc_nlink(inode); - ret =3D __ext4_link(dir, inode, dentry_inode); - if (ret) { - drop_nlink(inode); - iput(inode); - } else { - d_instantiate(dentry_inode, inode); + ret =3D __ext4_link(dir, inode, &dentry_inode); } /* * It's possible that link already existed since data blocks @@ -1493,16 +1477,8 @@ static int ext4_fc_replay_link_internal(struct super= _block *sb, =20 ret =3D 0; out: - if (dentry_dir) { - d_drop(dentry_dir); - dput(dentry_dir); - } else if (dir) { + if (dir) iput(dir); - } - if (dentry_inode) { - d_drop(dentry_inode); - dput(dentry_inode); - } =20 return ret; } --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b5-smtp.messagingengine.com (flow-b5-smtp.messagingengine.com [202.12.124.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9430928690; Fri, 13 Mar 2026 00:44:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362647; cv=none; b=Tv7EOj2vf/pP6n7Z4RcMZA6cUWKb+4CoAFN0SQdWSEZ9biGeVJ6oI47Hv/CMJlH4T3DRPLAmN8FHvX3SyJ1G54qBOb8tc0Vz8Cqsy1zfOZl3Rod+LHsXDSc9MbKL2ThMzFgAcVouig1MJzjyIbNrAVib3Lo6xzqoikj7w/T9xYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362647; c=relaxed/simple; bh=HQ/V/boL1lWC2FAVdkM1ZhJgQQuIPa3WWx+sWxg3L+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SfqI0IIrVIuq3S3kKYYSYM3mUUbusTXyavQropREz/+//u9kyWVM9lvw1SEuiVSdGZMFCemjzAwdghdray1GeFWuJcF27jT8kZH2JigPpOgSkaXhDnCle9svMihf9INPIu4y3UK/Wt1S7SqivcPNt8OjnScS2O68heJi9SvnFk0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=eCvS91w+; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=VOKUtq/0; arc=none smtp.client-ip=202.12.124.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="eCvS91w+"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="VOKUtq/0" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailflow.stl.internal (Postfix) with ESMTP id 9997B1301B2F; Thu, 12 Mar 2026 20:44:03 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Thu, 12 Mar 2026 20:44:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773362643; x=1773369843; bh=j63R+vGSqFIeC0SCj0jcb9BcsciO20wok4YExEEnIuU=; b= eCvS91w+DhWkcI9jjJdNUADcxRGhElzytgMJasgIzKJtuooXaIh3KKja0pUFfX6O fgYAReRrX9HpVO7F12hftQ0cSIl24yo01gvuoWwgQ+0LBkoLFsR05RvwjsbQ/xGe TARIB8LZx92xUD+U+XYJVZBaPlMp/mwNUr6o9DINS6+42ydzcFDjycZgH68WWE6o C3GjVtvxBt81M8NGL0of9lLYsOHaaCljR0612e0zlQfV27RuAQZNtF61tH98aa3Y SztxAesntkfAUiZ3e07BF5twMFIeG7LcYeif3ZUiOH9o5O91dPmpaZ9mcvHyC7F5 pzd5Q75S3kEWTz9D7gVIYw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773362643; x=1773369843; bh=j 63R+vGSqFIeC0SCj0jcb9BcsciO20wok4YExEEnIuU=; b=VOKUtq/0Ox3dCym8N La/hchRjt+rNU/iyTLG4kwEHuMKD4y3a/JkwzJH9LuB11f5JIetBBVHMt9ViJypU UjyLlnUHckM8bh9QjAY4Jyd/C7N5jwudw1JHDUa9iXFd7am+GANyEnLlgi/obehc ULSfiEhaSLtneM7w7UNW2TpbgbwcaZ5Y83VVFAz+dm25dDXamEX/5/azTn0wR4rH T5eikG9cF+xC+X5DUfa2srcny2SiEQpjWf7Wv50KDnPD1IC+BRLh5gtaUkd0Xqxn q7lCrpBBSd1OGWFQIKyOZeBKLnQT8rrdPD3KtmKkTnMRm+b0/M3MehJ+STL1Wogh t4YJw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeekvdehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 20:43:49 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 34/53] tracefs: stop using d_add(). Date: Fri, 13 Mar 2026 08:12:21 +1100 Message-ID: <20260312214330.3885211-35-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown "Best practice" is to use d_splice_alias() at the end of a ->lookup function. d_add() often works and is not incorrect in tracefs, but as it is planned to remove d_add(), change to use d_splice_alias(). Signed-off-by: NeilBrown --- fs/tracefs/event_inode.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 8e5ac464b328..c30567b5331e 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -393,8 +393,7 @@ static struct dentry *lookup_file(struct eventfs_inode = *parent_ei, // Files have their parent's ei as their fsdata dentry->d_fsdata =3D get_ei(parent_ei); =20 - d_add(dentry, inode); - return NULL; + return d_splice_alias(inode, dentry); }; =20 /** @@ -424,8 +423,7 @@ static struct dentry *lookup_dir_entry(struct dentry *d= entry, =20 dentry->d_fsdata =3D get_ei(ei); =20 - d_add(dentry, inode); - return NULL; + return d_splice_alias(inode, dentry); } =20 static inline struct eventfs_inode *init_ei(struct eventfs_inode *ei, cons= t char *name) --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b5-smtp.messagingengine.com (flow-b5-smtp.messagingengine.com [202.12.124.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40AF12D061D; Fri, 13 Mar 2026 00:43:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362630; cv=none; b=TxRNNri5BEe2cjo/cfLJIcXZyi5BGCu7XGMNj+gNvQ0EMX+/clSHuDsgrMzT1h3yxwPwSPjeProiiVOAW7E4MHU3IzsPRXI4nZDLa7aS2PNCHr7/fhwpHSxVuLk6A4NUlJ6MH0Ah3EIRb1i6bvrhrumb2A9G4euGE+34SqM9fyM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362630; c=relaxed/simple; bh=7wDBnpi78RtIzlHMeriwbRIS5fGE4CmYZL1MvSiLxm8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=grU/b4NKOM14d3M08cWZGn9O7qLXXaB9VYT7DhcBMxDN3GG/P6vYpfCo/+PJnlvwXG+pwHhtP7tssjOwIMNhcNfrzjyMQxvJSuzXnlNdmrkIhpJCfy6T6y2RYVZJC0IPcG9QpVz1Aqr04P2sHntfU7aBGvV/gEXmMS31dcCmXus= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=HjfBkdDo; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=OJg/U+At; arc=none smtp.client-ip=202.12.124.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="HjfBkdDo"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="OJg/U+At" Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailflow.stl.internal (Postfix) with ESMTP id 7B8D91301B2A; Thu, 12 Mar 2026 20:43:46 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Thu, 12 Mar 2026 20:43:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773362626; x=1773369826; bh=hkrbz7rqb+Pf2fLQdUTn4dR7TTJgxGfMaCdEXnGBb3Y=; b= HjfBkdDoAYwQQJLASCTx4N7D2Oi1gBPTlgkcYOo+WwQly3gu8BxcWETej8E7Y+vC 7v0fubBGopf7L6qgpale0ldkZ1B3u5NVTNvg1/TUjoqYZU5l0RND/fCU926UE1Cf dU52J1R3IvMMwiwCn7OkqthnAbmNeQY0wfFveismXYFlK1lQkp1m9AISmvS7p8Ph 2303a7f6K5Jlx6zDz19ofnGSqPmwovGDcXYodslmNv0d7WdUJtB9eTYsL8UW0U11 0GUIOw1bNhAiMgqZY0i4MGRQ55IZgV8SiwsyP0fNcsShifYyYJOt+wEA1ov7f0eD PdnJa8hSTogxexnc9oafsg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773362626; x=1773369826; bh=h krbz7rqb+Pf2fLQdUTn4dR7TTJgxGfMaCdEXnGBb3Y=; b=OJg/U+At7OucCvylK iUzd6DL7jCUcyjQlX78GwqJ/I6vv5ihkeS435nBM5355zdePzGM36LT4OexR0MRH 4lFKw8lzT25lxABE9ocUZMJqYrflNdpOeF742itP/1xqaMnbimOGJbINuPn3DCB6 78lFrxBVAc+TEEOa/aL4peQFYcNfkDvkayfMDVZVCJTVMXnAR+QqmP+X6jPGUX48 4eQs5VFQkcGcKjiIlmezH2hMkyivHCkm6/sZZuVlnduqKbI9sW3ivQ1XUkRrPQMs UX4u0qKhx023bdinP+vM4JzLq51NNl99ZTh37MUoQxcyxT2cDqefqczEqOVUaQb9 MTpFg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeekvdehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 20:43:32 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 35/53] cephfs: stop using d_add(). Date: Fri, 13 Mar 2026 08:12:22 +1100 Message-ID: <20260312214330.3885211-36-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown "Best practice" is to use d_splice_alias() at the end of a ->lookup function. d_add() often works and is not incorrect in tracefs, as the inode is always NULL, but as it is planned to remove d_add(), change to use d_splice_alias(). Signed-off-by: NeilBrown --- fs/ceph/dir.c | 5 ++--- fs/ceph/inode.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 86d7aa594ea9..c7dac71b55bd 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -769,7 +769,7 @@ struct dentry *ceph_finish_lookup(struct ceph_mds_reque= st *req, d_drop(dentry); err =3D -ENOENT; } else { - d_add(dentry, NULL); + d_splice_alias(NULL, dentry); } } } @@ -840,9 +840,8 @@ static struct dentry *ceph_lookup(struct inode *dir, st= ruct dentry *dentry, spin_unlock(&ci->i_ceph_lock); doutc(cl, " dir %llx.%llx complete, -ENOENT\n", ceph_vinop(dir)); - d_add(dentry, NULL); di->lease_shared_gen =3D atomic_read(&ci->i_shared_gen); - return NULL; + return d_splice_alias(NULL, dentry); } spin_unlock(&ci->i_ceph_lock); } diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index d76f9a79dc0c..59f9f6948bb2 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -1773,7 +1773,7 @@ int ceph_fill_trace(struct super_block *sb, struct ce= ph_mds_request *req) d_delete(dn); } else if (have_lease) { if (d_unhashed(dn)) - d_add(dn, NULL); + d_splice_alias(NULL, dn); } =20 if (!d_unhashed(dn) && have_lease) --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b5-smtp.messagingengine.com (flow-b5-smtp.messagingengine.com [202.12.124.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A04D7275B18; Fri, 13 Mar 2026 00:43:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362613; cv=none; b=M4XTur3tottSfeLtpJV1SjJDBLyfoHVdfAbb24sRUtOmuhabn+owWNxhENHIeBA6DhRpWwW0SOojVoh2M89aQIzmYllvyNPCyhMl4s22C2wiGBHaA2LPql4ESwxtyMgKYXYzoDdezAIB2xZ7BO2/yF+rC4t16uCUeXvwQaUDvB0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362613; c=relaxed/simple; bh=H53rHtuIKkJV2K/5nZ4HjRth0TKSPLKyiXBZ0GjJYsI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B1NnYPP6DexDEQQ78g5W3Yvs3HD69c5MXHh97N1+Q+KZYVer+d2ThAlUM3ep6/1yi3UQllt4XJRmFR0y4mURSUz6KLrZ+/KP7zJzB15b6HJHqgfJ0kjRi8ayYWdqi1Puajud0gix9iYLaQtfPdkYrtSGDD6+5C+oU1SpG8yntrE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=WX7c3DKP; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=TKoMfHHk; arc=none smtp.client-ip=202.12.124.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="WX7c3DKP"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="TKoMfHHk" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailflow.stl.internal (Postfix) with ESMTP id DDA261301B24; Thu, 12 Mar 2026 20:43:28 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Thu, 12 Mar 2026 20:43:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773362608; x=1773369808; bh=8aHffWYVzxlbvh037JlVhR8ERE/IxGWBZRv5qHj7bJk=; b= WX7c3DKPx+tVVhFVjUW8//0VWvS4las6XMedU6aTYpr242woaOIcqjdZZVJ4yVnC P88WJrijdCqh71ZQjfLl+xhjGoQMg/F8wZ7GNOHUOS+3PK7l64Z9RcJfHzu3EJx+ 9kiGTP3jc4KeZly7RqBISMFoHeUWIhyiLSOgatDGNqU+ils1tsCxI9p7zB3O39nq cROINYPyREvgD1SKVCYqH32NWAcedBFxE+Wuyiva088VcFlPPudW1EKncv3fsuaA BShtlQMTfihkHb/wYJyVBjIX251wX3ueq3TmnmoWiRxo/NGW66kYiWp2sylnh++s bFkFlicATpGbeU9QOA95Jw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773362608; x=1773369808; bh=8 aHffWYVzxlbvh037JlVhR8ERE/IxGWBZRv5qHj7bJk=; b=TKoMfHHkIQcef4oL9 WCvsrpW+mTxjtA3eu9J9hQdlSACakLolIy62RydRB3PnAitR2M2UBSxOg6u41jAQ orR8E5pfwsu4X5hri4xNT6JK2donC1MWsL/u0WbE7rRdrQQpndWHCmOLcrn85w5q SI+HqYSuDNwoKNY/0GBR6Pi4KU3xLzz6Q+JVFC40HVtSP3UyiF03OUmeTa8dDPt6 DcuHCt92Cd2YJ7SYU+vMYMh3KnIdv8pfwE/90UpO7I3xohC3Jy56VaPbigBQF9ob 6qBILVQxLXuHVd9mMl4KuNfCKXc+3cO+4irgJurxJUSavrvBRuwB40RYu4N6E0i6 RGNjg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeekvdehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 20:43:15 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 36/53] cephfs: remove d_alloc from CEPH_MDS_OP_LOOKUPNAME handling in ceph_fill_trace() Date: Fri, 13 Mar 2026 08:12:23 +1100 Message-ID: <20260312214330.3885211-37-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown When performing a get_name export_operation, ceph sends a LOOKUPNAME op to the server. When it gets a reply it tries to look up the name locally and if the name exists in the dcache with the wrong inode, it discards the result and tries again. If it doesn't find the name in the dcache it will allocate a new dentry and never make any use of it. The dentry is never instantiated and is assigned to ->r_dentry which is then freed by post-op cleanup. As this is a waste, and as there is a plan to remove d_alloc(), this code is discarded. Also try_lookup_noperm() is used in place of full_name_hash() and d_lookup(), and QSTR_LEN() is used to initialise dname. Signed-off-by: NeilBrown --- fs/ceph/inode.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 59f9f6948bb2..0982fbda2a82 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -15,6 +15,7 @@ #include #include #include +#include =20 #include "super.h" #include "mds_client.h" @@ -1623,33 +1624,17 @@ int ceph_fill_trace(struct super_block *sb, struct = ceph_mds_request *req) ceph_fname_free_buffer(parent_dir, &oname); goto done; } - dname.name =3D oname.name; - dname.len =3D oname.len; - dname.hash =3D full_name_hash(parent, dname.name, dname.len); + dname =3D QSTR_LEN(oname.name, oname.len); tvino.ino =3D le64_to_cpu(rinfo->targeti.in->ino); tvino.snap =3D le64_to_cpu(rinfo->targeti.in->snapid); retry_lookup: - dn =3D d_lookup(parent, &dname); + dn =3D try_lookup_noperm(&dname, parent); doutc(cl, "d_lookup on parent=3D%p name=3D%.*s got %p\n", parent, dname.len, dname.name, dn); - - if (!dn) { - dn =3D d_alloc(parent, &dname); - doutc(cl, "d_alloc %p '%.*s' =3D %p\n", parent, - dname.len, dname.name, dn); - if (!dn) { - dput(parent); - ceph_fname_free_buffer(parent_dir, &oname); - err =3D -ENOMEM; - goto done; - } - if (is_nokey) { - spin_lock(&dn->d_lock); - dn->d_flags |=3D DCACHE_NOKEY_NAME; - spin_unlock(&dn->d_lock); - } - err =3D 0; - } else if (d_really_is_positive(dn) && + if (IS_ERR(dn)) + /* should be impossible */ + dn =3D NULL; + if (dn && d_really_is_positive(dn) && (ceph_ino(d_inode(dn)) !=3D tvino.ino || ceph_snap(d_inode(dn)) !=3D tvino.snap)) { doutc(cl, " dn %p points to wrong inode %p\n", --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b5-smtp.messagingengine.com (flow-b5-smtp.messagingengine.com [202.12.124.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 364832FAC14; Fri, 13 Mar 2026 00:43:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362597; cv=none; b=PvaOmLI8BRbnyCx7ZfNvAF8Os1ShAyT3wYdX6XBchBiyRLa1V8L1C/FNP4WDqVRG6lkX76xIE2/qCWHBK+p6yzE1rPMatqTePDXRz6ebMojopR4/Jph/B5mtK5ml+mlTLpEj4kZeEt9rQQFuT+dJ6pNR4a+39Jctv3/uwEv947Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773362597; c=relaxed/simple; bh=V1LusLfhIYS279k6+gPTO3CAtyNEfgSX9UJqBDT2m6g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q9Y+fhHPOc9+2oA1nUHi6kMTNCnLpKPy7BGdEMS4JuF3uzQgx6Q1Pf9m6FfMbj1OKYuuQmZtnGWW/6QOOE5vn867VNqd0x0sORkgXtTn6xErJ2TKyb0FA2HZ+/y3HiVnJmcfRYXq3tkYUCg6xZbi2W39HiH74yLbhyCzb5GfZs4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=evZBO/FT; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=tlm7pJXg; arc=none smtp.client-ip=202.12.124.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="evZBO/FT"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="tlm7pJXg" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailflow.stl.internal (Postfix) with ESMTP id 1863C1301B1D; Thu, 12 Mar 2026 20:43:10 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Thu, 12 Mar 2026 20:43:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773362590; x=1773369790; bh=mtJ/saZCLiCxFDNQljniHYoFSU4uzdwtWsgXO8zNDIk=; b= evZBO/FT5uLkrmbp/p/bKHGn86ivpuWIB8uwzomHLGU6kH6lhmmlCRwiDJoWV39q TXhehd3v184kz2tKDZFnYt3nMYpGYs0FHIDP5P1WpT7DuL/s4rQw/xsDTsgE9QLg /164043xlTxtGbkRkgPLxopa5nRZXLGdKExiyrVeEWQB7Z6SjppifuMa+H+nAnt/ Y9UIllgVcpdMC3ryQir69hasMs4sAzed4op96lB/0i6WUn6Uhf0fVcGFEXiSJozk InAA9BqTgm3htPeeddGMpXgGFTZior38m4S57df0DQ4nN26Wz6Bnup7omFSZuA/V bXDsxk1oRwy+oBWG8yzDjw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773362590; x=1773369790; bh=m tJ/saZCLiCxFDNQljniHYoFSU4uzdwtWsgXO8zNDIk=; b=tlm7pJXgvMRnwrzqw 361ob53tdiymOgQgABOTedImHhfzfyXrgBfCei5K7ic4kOntEU7/s+f5sGh5Urct yi6RhxZa9AKNdjteFK4EVVHFzPhf0rBHY7+D36NQKzOYqyDZTXwjWo75g7RIoUOt +1Y24Dtef108V7gC/hPAOKuoKHxLQb6ez/GO9OthDEETcJ7ke8mp144qJcMLu188 7QoX5KdxhtTAeNLGhB9EFu+7bHr1B8GbxO8xT5UwDkDbvUE6Kv/LXlywzoVIfx8H 5/sPhbm9H87cFjM4xoYFeNlJ51RwpxBUAAY7/b3qCojyfoXALXgP5SiZxeMBLz3U TvcfA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeekvdehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 20:42:56 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 37/53] cephfs: Use d_alloc_noblock() in ceph_readdir_prepopulate() Date: Fri, 13 Mar 2026 08:12:24 +1100 Message-ID: <20260312214330.3885211-38-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown cephfs uses the results of readdir to prime the dcache. Using d_alloc() is no longer safe, even with an exclusive lock on the parent, as d_alloc_parallel() will be allowed to run unlocked. The safe interface is d_alloc_noblock(). In the rare case that this blocks because there is a concurrent lookup for the same name there is little cost in not completing the allocating in the directory code. It it still possible to create an inode at this point so we do that even when there is no dentry. So change to use d_alloc_noblock() and handle -EWOULDBLOCK. Also use QSTR_LEN() to initialise dname, and try_lookup_noperm instead of full_name_hash() and d_lookup(). Signed-off-by: NeilBrown --- fs/ceph/inode.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 0982fbda2a82..8557b207d337 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2011,9 +2011,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request = *req, struct ceph_mds_reply_dir_entry *rde =3D rinfo->dir_entries + i; struct ceph_vino tvino; =20 - dname.name =3D rde->name; - dname.len =3D rde->name_len; - dname.hash =3D full_name_hash(parent, dname.name, dname.len); + dname =3D QSTR_LEN(rde->name, rde->name_len); =20 tvino.ino =3D le64_to_cpu(rde->inode.in->ino); tvino.snap =3D le64_to_cpu(rde->inode.in->snapid); @@ -2029,20 +2027,24 @@ int ceph_readdir_prepopulate(struct ceph_mds_reques= t *req, } =20 retry_lookup: - dn =3D d_lookup(parent, &dname); + dn =3D try_lookup_noperm(&dname, parent); doutc(cl, "d_lookup on parent=3D%p name=3D%.*s got %p\n", parent, dname.len, dname.name, dn); - - if (!dn) { - dn =3D d_alloc(parent, &dname); - doutc(cl, "d_alloc %p '%.*s' =3D %p\n", parent, + if (IS_ERR(dn)) { + err =3D PTR_ERR(dn); + goto out; + } else if (!dn) { + dn =3D d_alloc_noblock(parent, &dname); + doutc(cl, "d_alloc_noblock %p '%.*s' =3D %p\n", parent, dname.len, dname.name, dn); - if (!dn) { - doutc(cl, "d_alloc badness\n"); - err =3D -ENOMEM; + if (dn =3D=3D ERR_PTR(-EWOULDBLOCK)) { + /* Just handle the inode info */ + dn =3D NULL; + } else if (IS_ERR(dn)) { + doutc(cl, "d_alloc_noblock badness\n"); + err =3D PTR_ERR(dn); goto out; - } - if (rde->is_nokey) { + } else if (rde->is_nokey) { spin_lock(&dn->d_lock); dn->d_flags |=3D DCACHE_NOKEY_NAME; spin_unlock(&dn->d_lock); @@ -2069,7 +2071,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request = *req, } =20 /* inode */ - if (d_really_is_positive(dn)) { + if (dn && d_really_is_positive(dn)) { in =3D d_inode(dn); } else { in =3D ceph_get_inode(parent->d_sb, tvino, NULL); @@ -2087,21 +2089,22 @@ int ceph_readdir_prepopulate(struct ceph_mds_reques= t *req, if (ret < 0) { pr_err_client(cl, "badness on %p %llx.%llx\n", in, ceph_vinop(in)); - if (d_really_is_negative(dn)) { + if (!dn || d_really_is_negative(dn)) { if (inode_state_read_once(in) & I_NEW) { ihold(in); discard_new_inode(in); } iput(in); } - d_drop(dn); + if (dn) + d_drop(dn); err =3D ret; goto next_item; } if (inode_state_read_once(in) & I_NEW) unlock_new_inode(in); =20 - if (d_really_is_negative(dn)) { + if (d_in_lookup(dn) || d_really_is_negative(dn)) { if (ceph_security_xattr_deadlock(in)) { doutc(cl, " skip splicing dn %p to inode %p" " (security xattr deadlock)\n", dn, in); --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90EF7309F1D; Thu, 12 Mar 2026 21:54:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352471; cv=none; b=mMHUUEDkXgWqHnMqIE/Jn7oZWp0At8Co0GCMH2qqfbaG6PLalJcsxZsIvbyu0iv8UXe3tyhuXr92JhHnI8KwCcA3c52ql4HFehPSS7tYxrZD7CWN71ZPQUDRt/Ug6W6mcu06tgjweQg2s9r3BNPnyTBquSwWg+nvag/UCoWWhKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352471; c=relaxed/simple; bh=CKKDH3OvgdUZHlw6DEhu3V+APgTia4OWQcwK0cNE0Lc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mx7MCnLPASjBP1cXykypAQyXI3SHwNbX3+O09iQjZvlSq7sY0nqAOSgS7tUTtayQo39lFbMUVPfh4+9OVRyAKDZaTHpIMO66U7Zej3emE9bXfOroZDj1t+n2cmkWw2k5zF4ubXl8xzKPHWC8PtIMwK8YoV0TJj94/tvFyjnzBUM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=knwvQbEG; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=4Zu9WuMX; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="knwvQbEG"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="4Zu9WuMX" Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailflow.stl.internal (Postfix) with ESMTP id 764DE1301B4D; Thu, 12 Mar 2026 17:54:28 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-10.internal (MEProxy); Thu, 12 Mar 2026 17:54:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352468; x=1773359668; bh=6rEBHIocsGomFaeNZ8FKVkPPiCLC3KUr0T88wGXsY+w=; b= knwvQbEGvEIqlMfPnGjtJpPojdNrNczYPtebe2Z4kPKMkUCzRctdcCXACQElzs21 5O2a+QMmSwXVS7mmXVu2UbB62pEo78a9LLmTYGivD7du0jEWHQCQNY9CqyyjZM0D WxQVP+B/lLDgba8OONiDmEMwfdC99MyLWeo5sUXoJpj2s0/eqU6juECWNWTZd58e f2JUhGZZOdAKXc5zKwvqkmFAR+ulhtk7F4N+/VKAGM16LSYty6niYrfDL3MhwWZQ 5F7UPhU37iVLnKURGdbIUXSCxaF0GsKm5E/ELskY9F7iGXtUNUkh7m1SAYob5ueD tG+cNMx+lV41n5I+6+vVUw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352468; x=1773359668; bh=6 rEBHIocsGomFaeNZ8FKVkPPiCLC3KUr0T88wGXsY+w=; b=4Zu9WuMXKiMeGX/7/ ze2DMZPQ/soZLDQ/oXU+K/4hHMjcEbwuRZzOQNn/0FYKubqN7uvd+xUhQsXGDVfc XFQx9NIeuhB4i9Fdw+0hLLcGCxsoXgvauzXIgttzQmRQRIMSqUVbZ83wnbvBzzTO LXU0seG7VBKWtNnozR19mdRgFEyA4pYMjPGA/j7LYSGbfIowMBFBZEYKa8ZivFjZ wCZFyMVCKIXP7JjAvEk3jKEPxxVTswqg27R3aHZpcyHuzR6zYaa9mxb3FygDZl2f k88L/InMovZo682809zK4ENFUDAn25o7ypfmHbL8vM48dnX2pKAMzl5X2ab+Svl4 ddZIw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejleduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:54:14 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 38/53] cephfs: Don't d_drop() before d_splice_alias() Date: Fri, 13 Mar 2026 08:12:25 +1100 Message-ID: <20260312214330.3885211-39-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown In two places ceph drops a dentry and then calls d_splice_alias(). The d_drop() is no longer needed before d_splice_alias() and will cause problems for proposed changes to locking. Signed-off-by: NeilBrown --- fs/ceph/file.c | 2 -- fs/ceph/inode.c | 3 --- 2 files changed, 5 deletions(-) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 66bbf6d517a9..c40d129bbd03 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -751,8 +751,6 @@ static int ceph_finish_async_create(struct inode *dir, = struct inode *inode, unlock_new_inode(inode); } if (d_in_lookup(dentry) || d_really_is_negative(dentry)) { - if (!d_unhashed(dentry)) - d_drop(dentry); dn =3D d_splice_alias(inode, dentry); WARN_ON_ONCE(dn && dn !=3D dentry); } diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 8557b207d337..32bac5cac8c4 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -1517,9 +1517,6 @@ static int splice_dentry(struct dentry **pdn, struct = inode *in) } } =20 - /* dn must be unhashed */ - if (!d_unhashed(dn)) - d_drop(dn); realdn =3D d_splice_alias(in, dn); if (IS_ERR(realdn)) { pr_err_client(cl, "error %ld %p inode %p ino %llx.%llx\n", --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E602317142; Thu, 12 Mar 2026 21:54:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352489; cv=none; b=H1jtjsANCG6WnO1Nqx7BUxuWKWZ4wV5mmh9DrW4UejjDTT9NcGptdvFLryTgpRmnUKQsE9fCflJH3ySecpKNAJRBzMAjxzM1syrXtXbE7HAjbGz8JrnpNbooJ92B6czZ9rhzw0PJgrXSsYELWVCbR+PMSsX5Vt/P+DxqouNrFNg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352489; c=relaxed/simple; bh=F0lJe9mu/33crn7zFR7KnLT88WZWwFKdTtxGMeD90wc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R5JuLTdaCNfHMqfkxdOFSif9F7TaYcAfDkT+F0EoULo0UKlKF3kjlvsy32qiGRHYqtzqXuJfYAC1GJec8K7d6k7uXQfEFALK+9e6pZUoOFn5CcOM1ZfLZWgAOKgbFcrqUe9JYDeBIwJhXAO4rC6tcOMqcbwHTLhsAR4ZuZJxMNA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=R9VPv/zi; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=lvCNqQrx; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="R9VPv/zi"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="lvCNqQrx" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailflow.stl.internal (Postfix) with ESMTP id 897D11301BB1; Thu, 12 Mar 2026 17:54:46 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Thu, 12 Mar 2026 17:54:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352486; x=1773359686; bh=fpyBzrNDFKyBNYiy64/Yla5qtyKgmTDryIXyDQiUsjs=; b= R9VPv/ziHvarZw/AQGr9s/6SlcupzBGjtLFg1jEyRvdzFV/RJz3QlbiVW9PogxcB uq19ftZqv/w/QB+pWd/PtWQzykeuu9rN81RyybCP7p3uOes5ycCdcxkqVLcaFgPt GbQUYu/U5zZS8o5E7pQfGKiz957WUj9u86OrYOiA2bVJEDZlUx7NES0TytyApQGj x/jLnyCWW18lBbJSw9b8gm5gl/mwwM9pz1Dw/lA9mL8IRMxgFcmDqjLK7IMbs3Gc bPfTT5o+RFQFgP29SGUNKI8B7dY5Gskl7wM8hscfVf6RYD+N5EHvFqkJI112v06w cZ0Y3KvOZIJXTgIefJVRXA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352486; x=1773359686; bh=f pyBzrNDFKyBNYiy64/Yla5qtyKgmTDryIXyDQiUsjs=; b=lvCNqQrxDQEkh9EE9 DHdnoLQKJXZuHP0lw6gbA/RNYrUbKF152er2Ht3nW70QAjga1J49zCLwHjK2p/Y7 BJswoCBt0LZR+bUq+QMqYPbhP8R3Xp09DwafNs5xNgE3kD5ZV0k+BJq98zKU9Zqj sFQJ2d+d7F/KRlK06Vfv/0SRfilvI/OTiBSxO0HngUIpIhxrNM9wM/PFIIuR7uOL 15ONu6WzjQxb92eSo1if9CPu6HIkyIhlPYQFlroJS4Yn9zoLdn+2uv3griNSBuSn VQ+9fPyb/vhGnCvTBIdeahqB7kgmyUz0Xfp3NYe+xhSZqP+PK8CIlW8j2sDwrak8 c88vA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejleduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:54:32 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 39/53] ecryptfs: stop using d_add(). Date: Fri, 13 Mar 2026 08:12:26 +1100 Message-ID: <20260312214330.3885211-40-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown "Best practice" is to use d_splice_alias() at the end of a ->lookup function. d_add() often works and is not incorrect in ecryptfs, but as it is planned to remove d_add(), change to use d_splice_alias(). Signed-off-by: NeilBrown --- fs/ecryptfs/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 8ab014db3e03..beb9e2c8b8b3 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c @@ -352,8 +352,7 @@ static struct dentry *ecryptfs_lookup_interpose(struct = dentry *dentry, =20 if (!lower_inode) { /* We want to add because we couldn't find in lower */ - d_add(dentry, NULL); - return NULL; + return d_splice_alias(NULL, dentry); } inode =3D __ecryptfs_get_inode(lower_inode, dentry->d_sb); if (IS_ERR(inode)) { --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A82838C2C0; Thu, 12 Mar 2026 21:55:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352508; cv=none; b=nVA4uhkf8lAaJqxbKAXSpFy8bcyQW/OhW4DXqC/GoJFL3QANkYaUouXHorbLpP+dMcWyokZhunOLerWG062i6JzhzD4HrkY6cM+4AMZSaZ2cLpXqpYuF2lNyRA7fnjh8mluR6d+SAQheLUU595p18Phc2tM9omwsJwK70nrqt0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352508; c=relaxed/simple; bh=9VTSF8yUpjoy7Ucs3aGsu4bxlj0Czeu92BoI1xPbgH0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HMgT/GzU8MuU8qwcSS8EbXz9lhBv8mXmoTn7RtEjMriMXrIGWJWlOUCoyPXb6v7uip6a7+ivkPWosmxlcEZKO7hEWg077QidMJAK5hR3JRQ/4Jp5hncH58RfffOg+IkJv553UlS/LTX86gSzEBM3JIazKGqAhW/2LpUvZVUVlr4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=LvUkteWZ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=FJNskYCq; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="LvUkteWZ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="FJNskYCq" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailflow.stl.internal (Postfix) with ESMTP id A5B1B1301B6A; Thu, 12 Mar 2026 17:55:05 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Thu, 12 Mar 2026 17:55:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352505; x=1773359705; bh=QdLbzmw/KSDnf0Z+kMRVM204bGIQfGT5DsH4LYpn9rk=; b= LvUkteWZCDaoWYqvI6Uisnfitx8+ggZ7C+jDVARmw4MfgDHjnDypqJJX1nPL95Es Nag0d95y4bOlXv5m+pKizu4jWh5ahcynJTeDGkIUolBj+IgzzhsyXjFo2bfH0Qyv tKaQT582rw+TPUHzjlFD/YzofmzYyhPIuVAyhZa+ANuqDH7cXjyaGIOgEiIAmPMj /yBD02o3rX20ddAj2X9Lja60A73KqNH7Vbumy6bJPWqkV/J7oJhkcQE+7e0oY9oj 8yrxJYAMSoJ2oQnH4ii8XAtCwFXq0JdtQ+OZyBx9LBztC94estrJlQ7Fb2RpHNci j9HTBYX57sNFqJtdD257YA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352505; x=1773359705; bh=Q dLbzmw/KSDnf0Z+kMRVM204bGIQfGT5DsH4LYpn9rk=; b=FJNskYCqOEZkh+b+X kjQKFHwDK4nlkiMOH79i49kx6oyszytp/7cRmbQdR4TG6i+WX1zSfAfDFSj2Y1NX urfJRQbAe2/ZivP8ZlFzYw5Xx4Tjt0gBM+SYtqpX6Kgsv306S8wBnJ3NPxRIo8Gr U5NJ5syIF6Ijl8lBWd3BsfXtGZ4Xp0xg+1uBM5qufDdgQAu95mr5nsWl6MMtoXlQ /0yyYgynJbthg1j1IiLBfYq1sU6SKAay8XiDekf9/sJ9Swz/so6Zcq4L7c2DgnYV ED/qOoO5zm9sFslZ6prlPbvaBfLftMXMK7/uaBYc2tOu/H1h5F+TOPuSFUXn/JDI t0ykw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejleduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:54:50 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 40/53] gfs2: stop using d_add(). Date: Fri, 13 Mar 2026 08:12:27 +1100 Message-ID: <20260312214330.3885211-41-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown "Best practice" is to use d_splice_alias() at the end of a ->lookup function. d_add() often works and is not incorrect in gfs2, as the inode is always NULL, but as it is planned to remove d_add(), change to use d_splice_alias(). Signed-off-by: NeilBrown --- fs/gfs2/inode.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 8344040ecaf7..9997fbc1084c 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -988,10 +988,9 @@ static struct dentry *__gfs2_lookup(struct inode *dir,= struct dentry *dentry, int error; =20 inode =3D gfs2_lookupi(dir, &dentry->d_name, 0); - if (inode =3D=3D NULL) { - d_add(dentry, NULL); - return NULL; - } + if (inode =3D=3D NULL) + return d_splice_alias(NULL, dentry); + if (IS_ERR(inode)) return ERR_CAST(inode); =20 --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBFDC38B135; Thu, 12 Mar 2026 21:55:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352525; cv=none; b=XjDOosGqDATTbwwZwuuABMOFiZM5uRcKqwZ8aiyQXuR0D8KRYSFjRXGtBy8bA20YX0O80GmkTH4X08uQ928MI5KTBrOQaUORYM4+qugXQHTx/5L48cPn4DCtdRmyoQTmsvw6RDFzCc0l2+v79rHhSsvKu3/upARsDEs7xIW1u4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352525; c=relaxed/simple; bh=LfNbjqer1Kv+ypM57v2HBgD2IirhDRkKCBZt5umc0Rs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fb+vGx7I0a2DIrDKe9YZmVxo9Gd7Ya4ZaxsCHFSdNqZSYltvuzlW+Qz+7HFsusoqBi4BVZK43z+/cl0/yYbAnsdP6Z33RkCyS9wwVAdF94GZAJoHtDRohf0ZJxGOluLAM54hoQbMtWSjeIRXwQF6cX4gSUJOGuShHPvrLCL3oZg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=H9EUTHF4; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=mgyMS/w/; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="H9EUTHF4"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="mgyMS/w/" Received: from phl-compute-07.internal (phl-compute-07.internal [10.202.2.47]) by mailflow.stl.internal (Postfix) with ESMTP id B10021301BB1; Thu, 12 Mar 2026 17:55:22 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-07.internal (MEProxy); Thu, 12 Mar 2026 17:55:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352522; x=1773359722; bh=3if7F0C5AAC1JbkpbjSMCxjLy6rTA44JQ48V382ux68=; b= H9EUTHF4r4ntt850sUfeaQwtq1wg4xsapXTK+Bmbed5aBY6rGmecjBhkdb50KJJw yozmTs8rF52SI0/+6uErAmNlGCje+eaAeWizSuONzzKl6bXgUCbXrhvC50Ypb7Af BuGa9IVDBtnD0iI8cWgMLPEUvMmEROZjn+AsiwMbv31vHNMtLCOR4d07pF0F4Lhg SNbbwsak0t8uJDaZE9lEde5l/a/YGjv6Xm4eNNckpbnB0IlGBxn/KhnzKdHNNzFZ knquaTl2pgOiMYO5E3YdT59XdMgZ0B1OMFY55kq1VrLl65vHBs54fKiIaiYZmgZO fqr3ecAc7MP8Ib5llOeGMA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352522; x=1773359722; bh=3 if7F0C5AAC1JbkpbjSMCxjLy6rTA44JQ48V382ux68=; b=mgyMS/w//zLJozQuG iBMTVjEfl0NOrr7Zw66UNwTwbYxizmZhVHmA+lAQV7/jBPswUdXTZ/qZkmNM0DbI hKs8be9mTKQLa70XyuohH5vgJkcJ1Lf8CHfRHjX7K138+x0nvdCHx2JEpJOh8Q9K b7tWB+BgUW+qbsdIbWL49y0BSSPZZBWkUT/0NROD3UXKrVMw/3e1jvhZvGmRDQPf rIucBRKYZcMMA5TWkb9RLF9azs/HYd20sSGyOiiSqcmLp07MuJSg0uO1QiHA+HDc kRdsREoMdkfSJ28UBPTNkNY1lteIgQBwopJWj/nyyb32cXnM/7f4uBkmUlEFoI/+ ZjyBQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejleduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:55:09 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 41/53] libfs: stop using d_add(). Date: Fri, 13 Mar 2026 08:12:28 +1100 Message-ID: <20260312214330.3885211-42-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown "Best practice" is to use d_splice_alias() at the end of a ->lookup function. d_add() often works and is not incorrect in libfs, as the inode is always NULL, but as it is planned to remove d_add(), change to use d_splice_alias(). Signed-off-by: NeilBrown --- fs/libfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index 63b4fb082435..75f44341f98b 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -79,8 +79,7 @@ struct dentry *simple_lookup(struct inode *dir, struct de= ntry *dentry, unsigned if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) return NULL; =20 - d_add(dentry, NULL); - return NULL; + return d_splice_alias(NULL, dentry); } EXPORT_SYMBOL(simple_lookup); =20 --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97B343AD517; Thu, 12 Mar 2026 21:55:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352542; cv=none; b=bILxFQWpy904ehiuOFumsvOjqfzL4O0hszfW0KB7fwCDVRUruED4/kmYk6RZ7MayYODxb07s12bk/RjKVtSr5J9atYS6v1bFIlUrHtLMUqvm4KPrrSEC17Y4F43HD8OSs35MVsH6TIFNGC1M0tkOg7Dz0fakFYmNFJLJOs0KSkg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352542; c=relaxed/simple; bh=vh2aDCEgfp3FPB4dEbyu1s2jF3bkIa2ejltwYp1QTPE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dEa+yq5QiIpQrCfnC16/LoVNYuek7YDbWT9wdUqYgKmlvES8kHTY7bJXOB3SXFJTubP/9OJqNfjCMaV7+Mq2DHFUN0RPGgd/nTHJ3hkZS3YIZ6EIAuyTDJH5QakqALhjnCyk/fuX4QCZR4aYVKOQCGVRHY1QtzWGRu0ZqPDiCig= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=QWDEme8q; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=uCftpOHJ; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="QWDEme8q"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="uCftpOHJ" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailflow.stl.internal (Postfix) with ESMTP id CDE231301BB9; Thu, 12 Mar 2026 17:55:39 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Thu, 12 Mar 2026 17:55:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352539; x=1773359739; bh=7EkI+1dYSsaNPhaQL4RFoi/L2xXEeUvFR4/hMXQ6Tv8=; b= QWDEme8qECmbVrBBbWwkEiohStbLaNDmXHMhulBhyoA2EG4o9Klb1AYQqUq0RNC5 nnDBs7m1PE9pcBUM4WeYuhcvjHqs2D1sE3ayPHMrX+/DMifhX2vb081xbm0s9sZH mib0fDRiW0EL75WUrBvfmIo4P6lq0ic+WO0ZWZ8D8u+hNI7/c8FRPA77w+chdZzE UNDIwkYV33dYEKHCTqgO3B6LmvhzAMLUTNWy7hxZ7MgeWCKtOCauLjv6EqU11gPw tc5/24EPJ5Rau0RWMcN9eJrYwG62vPk+uinTSI6AUMf/cUl/7nrsHyBW2HJN+hJ/ KjRxJq02GMx1+LsJkMOlHg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352539; x=1773359739; bh=7 EkI+1dYSsaNPhaQL4RFoi/L2xXEeUvFR4/hMXQ6Tv8=; b=uCftpOHJU6GQPgjyP BqLIbZVvlgXlUB00MfOPgAaUi6FoFzPi9wFTBubNPoKakH+qqHCAOZOlPS/LAOUy 2/3De6yOkuPvYWRD68s+R8O8NOgbqOF81JlMqBfjjNF1p0HfN7PxORtuutOGgl9h uZ1t6widneeTd+8IGNXM/3F5qx8YOdgd4tNglwZJ+Rzk/id4c6PbCQxG8mGaTQ5U tKJ0yapFVfywZIR6KJRe0o9D6eR1gitNNNnyItQ78W5P9/nxAFKWWaudljMP03sa j2NvKpJYMrCX1uXLOSrf6IaPTyPZe2mcHof6Yt4e2dWNk77qwKbPdbVaRlkN4WxB 0dF8g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejleduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:55:26 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 42/53] fuse: don't d_drop() before d_splice_alias() Date: Fri, 13 Mar 2026 08:12:29 +1100 Message-ID: <20260312214330.3885211-43-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown create_new_entry() is used to finalise the creation of various objects (mknod, mkdir, symlink etc). It currently uses d_drop() which will be a problem for a proposed new locking scheme. d_splice_alias() now works on hashed dentries so the d_drop() isn't needed. Drop it. Signed-off-by: NeilBrown --- fs/fuse/dir.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 7ac6b232ef12..a659877b520a 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1020,7 +1020,6 @@ static struct dentry *create_new_entry(struct mnt_idm= ap *idmap, struct fuse_moun } kfree(forget); =20 - d_drop(entry); d =3D d_splice_alias(inode, entry); if (IS_ERR(d)) return d; --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B156F381B18; Thu, 12 Mar 2026 21:55:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352559; cv=none; b=qZHKE4HgzTd5o7iT3GzB4MPTb1Dot86DO1qcf3JH7NzQq33Y/ZzBdmgP5aAmAzf4WfhFG5sFY5l44W58SFF+QvZ4IGgmH8iJXzcCZ0fmhWbT8+gPtZIq+Y/w7cxy+01XnSgQnrRGMDnt2sk9jYyDuhpKVd4rhGL7LpYEPjAHAqY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352559; c=relaxed/simple; bh=FOzJwtw0hHbMUJM8s+KVybcLkR+QYGVmqbEOpwq9XZQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nAX5th8uMb9k9QHZTsXXPwlULS4r8A98ckxTLCqPvWFieuccGh5MJet6nkkxgruy8tFsZKvuphrCFg2z6oyu+nFmliIwRMY+lXY/0ZlyfLsQO15hD8wCfeDbsfz0Gon5QqDEKAYuqq0Ap9xINyHEzxzg2M5Clcpti9tcSCR4wPY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=V8DLV4wc; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=4sXEIXuX; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="V8DLV4wc"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="4sXEIXuX" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailflow.stl.internal (Postfix) with ESMTP id 0347F1301BBC; Thu, 12 Mar 2026 17:55:56 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Thu, 12 Mar 2026 17:55:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352556; x=1773359756; bh=I6CnyQAkwuxPKlDMQnXc9c5lwIeZ633Jm64d8FHO8OQ=; b= V8DLV4wcDGzhYebZPH4WK6E6cnXp1js2ckOETA/mb3gtKYUj8AtiU53pW8X5+uwx xh/Uo66CpTtUtZ4jmkXHAQhGC4g6P4sRJXtaWRNrdNLwnuZ5n5RNAsWDL4ky8tBQ w/VWSQ8ARbp+TTDBFg1VsxOtUfZiPyg4tlmEPKgESKCF4WIdXQ7cNpBcnaZg18/r NbDqlQl08OCTnlmB7CBOXZ+sKDVWJoDSNdAUKfQorFSUOlBf2VJ63I8JUboZYz4y sYVGOC28gblJ6pAGHKCTtDhMiB3lAojFXsfrVjP9t/rpcJ8NBgxsTkxpogTSS/Jk NyUn2RHykhm1Zeb6v7POLQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352556; x=1773359756; bh=I 6CnyQAkwuxPKlDMQnXc9c5lwIeZ633Jm64d8FHO8OQ=; b=4sXEIXuXZzpHdzsHY PI2r+pAeLO3D1p9t181hTerhmfrg1ujOX7AFVzgJlZAcUkevJbGyuacKaowYC42F kdrHTycOi5y9e88M4rq8+FOkXdbfBVGkRwOttka4u9t3gG9suHxbCZlzQ4HZf/fX cMzdXresl/Tkvk+CBFO67YH8oWWSjLVZfiA8dtQvrx+Pl1/0kBZJlHs++PpApXtf RkpDy4SrMA7h42gvYoK3MPokpoC5AnexXDVLyOxJsVhsRP4aCVl63NbiK/xmBzYP UsHcxRBRy/yDgJXHMafRUDiKl/NYzkWF4nJppx9bDb/T5j5kpS9zlYtGSAwheDR+ c8bMg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejleduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:55:43 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 43/53] fuse: Use d_alloc_noblock() in fuse_direntplus_link() Date: Fri, 13 Mar 2026 08:12:30 +1100 Message-ID: <20260312214330.3885211-44-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown fuse uses the results of readdir to prime the dcache. Using d_alloc_parallel() can block if there is a concurrent lookup. Blocking in that case is pointless as the lookup will add info to the dcache and there is no value in the readdir waiting to see if it should add the info too. Also this call to d_alloc_parallel() is made while the parent directory is locked. A proposed change to locking will lock the parent later, after d_alloc_parallel(). This means it won't be safe to wait in d_alloc_parallel() while holding the directory lock. So change to use d_alloc_noblock(), and use try_lookup_noperm() rather than full_name_hash and d_lookup. Signed-off-by: NeilBrown --- fs/fuse/readdir.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/fs/fuse/readdir.c b/fs/fuse/readdir.c index f588252891af..400a1a24f659 100644 --- a/fs/fuse/readdir.c +++ b/fs/fuse/readdir.c @@ -12,6 +12,7 @@ #include #include #include +#include =20 static bool fuse_use_readdirplus(struct inode *dir, struct dir_context *ct= x) { @@ -192,14 +193,18 @@ static int fuse_direntplus_link(struct file *file, fc =3D get_fuse_conn(dir); epoch =3D atomic_read(&fc->epoch); =20 - name.hash =3D full_name_hash(parent, name.name, name.len); - dentry =3D d_lookup(parent, &name); + dentry =3D try_lookup_noperm(&name, parent); if (!dentry) { retry: - dentry =3D d_alloc_parallel(parent, &name); - if (IS_ERR(dentry)) - return PTR_ERR(dentry); + dentry =3D d_alloc_noblock(parent, &name); + } + if (IS_ERR(dentry)) { + if (PTR_ERR(dentry) =3D=3D -EWOULDBLOCK) + /* harmless */ + return 0; + return PTR_ERR(dentry); } + if (!d_in_lookup(dentry)) { struct fuse_inode *fi; inode =3D d_inode(dentry); --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76DD72BCF5D; Thu, 12 Mar 2026 21:56:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352577; cv=none; b=soGkQCqd46LS9wwr0cl95t4XhX7XYZ4qun79KK1qG6hz1GDVJcbYgz//xgdgRanNXwlS0EDCDy84bkb1oak7F1cDQ1dW26O855eIHs6TPOnG6O4EBjC9vrqx0AW5m22uHMtI+H+OGly5T9092wp+wUlfWiyqfpHYrbD5N/md3Ds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352577; c=relaxed/simple; bh=zdrLQMFqHsRTuC2aerhnQN2BiNDQvmEaUEJHJX5ny1c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jZpLCc/AP+WngKOu3M1He4MU083yNUsuk7Nfn5fUu+qyCdBFLYSl8t7vTyVE9TJcacVJ0++d/eGcmU+f0es+KnbXFmF1hSXz3InsDBfPs11bnNjGs3PrP0QGwx1U4WlatA0DBN8tyo7EbSxj/3a8ZDkOS1iyPl1w2KcWKM/Wnwk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=U98BFMAp; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Uq1hO5Ih; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="U98BFMAp"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Uq1hO5Ih" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailflow.stl.internal (Postfix) with ESMTP id 8DFA81301BBC; Thu, 12 Mar 2026 17:56:13 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Thu, 12 Mar 2026 17:56:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352573; x=1773359773; bh=hNooXh8tukAy53X73o1gk7dQ7zysETg4G5i0zUIVsso=; b= U98BFMApU8sYPYQ7CogFDzIo34fTbwL3/llQtmzYPZfV0pgMqsNO+ST5FrQoK5D4 MoEqSp37f3Ei/nvhh9gnzQ0Vj/dJ+HGBU1MPmSCSms/pLVOoHo3pYMHID/m1+mT6 9aGOMWmkzPKRnfmBMXDMCQwGUY3khdFrwEnVLosiNx0qu0sFoGPySVfbV3/3hJpW VyBVlf2kOBR/TXmXdeKGHAcYZkzvQi1I4xDgBdvOz8abEkZU06o2QQM70xCkKIH0 Nw0rDMrPWZhx2wVPJUKPNXNp6cRn7jvsDB+AcIp52fzIkt6gcOhQ2zcmMdBhejxQ zm50aAYFzBWFIWO7hUiU6w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352573; x=1773359773; bh=h NooXh8tukAy53X73o1gk7dQ7zysETg4G5i0zUIVsso=; b=Uq1hO5IhWegU28BI8 tdXhi/CPmkZ7mOz+LkShu1oU2Xm2IdFVdV4/D9Cyu9c1dhFr6h1RwH8jyC39NHe9 qWOS6s9Ci7FAcAYKjUGYJMM1qhTr7ZgUE8IQMq5yMA6kvK9cth7XAx8hSg8Hy/6O k8Gcv3JWxxdyfq6ZTwBlR8gmACl9067HX6Fr7XX0c1f2F9RYRFIRgdSedLKqQK4m bp2TDf5cQZsusRq5sp6pLqDfjaTZYakjOcWktAW4cJWMVPfXhQszFLr1NOsdh8dz p3Cb8COwX/iQRC5GlV6uaTyYfCvVeH10Fyw+vNSnfAsjFuzFbMTASPxaaKt8yEh3 en+RQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejleduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:56:00 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 44/53] hostfs: don't d_drop() before d_splice_alias() in hostfs_mkdir() Date: Fri, 13 Mar 2026 08:12:31 +1100 Message-ID: <20260312214330.3885211-45-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown hostfs_mkdir() uses d_drop() and d_splice_alias() to ensure it has the right dentry after a mkdir. d_drop() is no longer needed here and will cause problem for future changes to directory locking. So remove the d_drop(). Signed-off-by: NeilBrown --- fs/hostfs/hostfs_kern.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index abe86d72d9ef..f737f99710d5 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c @@ -700,7 +700,6 @@ static struct dentry *hostfs_mkdir(struct mnt_idmap *id= map, struct inode *ino, dentry =3D ERR_PTR(err); } else { inode =3D hostfs_iget(dentry->d_sb, file); - d_drop(dentry); dentry =3D d_splice_alias(inode, dentry); } __putname(file); --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55E742BCF5D; Thu, 12 Mar 2026 21:56:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352594; cv=none; b=lAFoLy4LHkA0PqKJY4cC0t0309GFAWPAmyb3nVjPOqRXUKJmuL76855sq/D3Ck9Q+tsBbIOJ4OD3WgkuSG12v7NWlgPHi0teuH1qN+33uVO5pz+2gG5k97/2mxt6rJ9frvDwjFiOWsW1V/YVFkBrBT51gS4miJtteKBJ9LA/+Nc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352594; c=relaxed/simple; bh=Ry03XapnV8ZPqRwD/otU1U6sq93iLJCjUmdAQ3JSF0k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bKI8N9HQvQFeI9jGLO+Rrc7tmWB+q8atmJ7L8sq3DkL40T+JqDNjwatgVyoTgdx2mEESTb2ENXtUPxk63o3685bwMoboWzV4cgCIDl7lmkn07+RmNtgfAg/EdilFIpjZlHstC3HcPa8kknPeg2vL25aFST7AYtO+MQhwdv9434c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=BjVQ7Tij; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=YpiNzHFW; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="BjVQ7Tij"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="YpiNzHFW" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailflow.stl.internal (Postfix) with ESMTP id 84D321301BBF; Thu, 12 Mar 2026 17:56:30 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Thu, 12 Mar 2026 17:56:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352590; x=1773359790; bh=V1Hs5eklgfQn0H62/n/RsRquBHKKGkv3SWjXFgqWxeg=; b= BjVQ7Tij/z0cXHesrQNauBD40mf05TL+Wj6m1LoIvu1L/NzpAqGZ5cLMMYGVnhHH 5qpQy4Dpm9bq8Pb3bQ7SLoPEAN90xLCEzbpDBw32FsuGAR+9EIQaGhiqQ98SwOaT QOjIC4JQ26O0nUw/gfHxixp9O2LeLOAfcv7ko1la8I/jwje3ZAcm/+yUWtQegekd SEaAK9AahEsg1k6Lo05tjFqkn7nUv2p2kEM2DQJCJhauy4winthpmj9pCKsDjw+g LbL1Ut73HTaiBOaqfNeCA2hdtVcLqDwM9vhFb2A/Gp+vNDKEnvCIcGUBnuRQC5w4 c1vlq/YTLJZHkxtZdNo3ow== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352590; x=1773359790; bh=V 1Hs5eklgfQn0H62/n/RsRquBHKKGkv3SWjXFgqWxeg=; b=YpiNzHFW7/D9ZPSMi cZJKUNBZwgvwypUiNaP/NJM1ssRQhwagO51x7MSYiJEweucl/LQJMa2SKCpn9TMY zKHk3Y1z+6lpK6TbV+SLBojRbVgzqxTumBjH8yjZlwb/Pw05pMeeuDj3VQASKNMH JI1m/tgCDLltyQqPzDgUlE9fDYaQup9pOGAFgK5F8pGZ2h+PJQKg0JYnhCf6Anpd cMP+lNg8R98vHR1s3CC4zCU3o+z2qTy8ZvFno6N0EEpF2DC7MXEjoQhGkqR0/QDv RkF1A/8dkZ52tjjo3Ye102S9dNRb2q+2o8wsWe6EZ9KjKj0zQND+rl+xPCwoT4um OVbAw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejleduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:56:17 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 45/53] efivarfs: use d_alloc_name() Date: Fri, 13 Mar 2026 08:12:32 +1100 Message-ID: <20260312214330.3885211-46-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown efivarfs() is one of the few remaining users of d_alloc(). Other similar filesystems use d_alloc_name() in the same circumstances. Now that d_alloc_name() supports ->d_hash (providing that it never fails), change efivarfs to use that. Signed-off-by: NeilBrown --- fs/efivarfs/super.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c index 1c5224cf183e..232d9757804c 100644 --- a/fs/efivarfs/super.c +++ b/fs/efivarfs/super.c @@ -189,26 +189,6 @@ static const struct dentry_operations efivarfs_d_ops = =3D { .d_hash =3D efivarfs_d_hash, }; =20 -static struct dentry *efivarfs_alloc_dentry(struct dentry *parent, char *n= ame) -{ - struct dentry *d; - struct qstr q; - int err; - - q.name =3D name; - q.len =3D strlen(name); - - err =3D efivarfs_d_hash(parent, &q); - if (err) - return ERR_PTR(err); - - d =3D d_alloc(parent, &q); - if (d) - return d; - - return ERR_PTR(-ENOMEM); -} - bool efivarfs_variable_is_present(efi_char16_t *variable_name, efi_guid_t *vendor, void *data) { @@ -263,9 +243,9 @@ static int efivarfs_create_dentry(struct super_block *s= b, efi_char16_t *name16, memcpy(entry->var.VariableName, name16, name_size); memcpy(&(entry->var.VendorGuid), &vendor, sizeof(efi_guid_t)); =20 - dentry =3D efivarfs_alloc_dentry(root, name); - if (IS_ERR(dentry)) { - err =3D PTR_ERR(dentry); + dentry =3D d_alloc_name(root, name); + if (!dentry) { + err =3D -ENOMEM; goto fail_inode; } =20 --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8412F317142; Thu, 12 Mar 2026 21:56:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352610; cv=none; b=IOW8MaDXJhNTCwtsMpSK9RKDR8LzLp+z17tSoNVTNjanjxdKjxVFKQVJRUZ4WYRXnGmC3zbLwkct8Qu+M7h+Fa1BqRS5GtrP5GcTS48s0XeL8IIje0OT/xBbPkU7zRDuCDQRMbnUdLzMUwTaY5ZHsd/Lj/HKpoPVUUEjrOE09zQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352610; c=relaxed/simple; bh=qepEFLlJxKxGECKoKiRMdWLTH8oH6zcVxSk9a5QLego=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rS1tOE3ovHZXKv5rUL//k6YlMqkarbRu/nB8dlePF/KWZeO8i2sdHpS6Qio4SQUWfqkHJ2TWPG0bW4M8GzeK5MGtcdpW+Nit/xSdrVC7zvBdmPCjTG48pfwJIQsht8qOb8y/C9MwqpI7mmC1Gn0FAHO8pzw35eXboNc+TVoqZ5w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=We4QHEc5; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=dJKk8gs7; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="We4QHEc5"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="dJKk8gs7" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailflow.stl.internal (Postfix) with ESMTP id 6A68B1301B63; Thu, 12 Mar 2026 17:56:47 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Thu, 12 Mar 2026 17:56:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352607; x=1773359807; bh=Gqr5GRMgf06YnKH/0CimKgertEevcw92OqmrRngbywk=; b= We4QHEc5TNY1r6emZ7SsqEkPBAFl7fjcHi6srpfWQ1jfp9RJyRfEF8fnUh1L1DCn NUV0TnodOWGmPyjahfVZyst7SyBFImTOBbu5reeCNuxZa9HRPVB4nYbPa9eKOqKj CPhvVoePIv8KrFKC9jWx48sJ90oGywC9Kg3zkO5a5jeQQfPK+hJjBscSS6duK7Cb 4Pu+8L4kIn61BbJxZZaydewbyuURl9IDnc5JFrYPrp1xqGiRHGGd6dO+zw/46d9v FWLsgwMkK6Rw70z4NcymA80fUToAHDfDhkXCxQcBYAwiDj6lNIFttjsKy3vYkGwg nbi7TF6fILEzY76fZqID3A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352607; x=1773359807; bh=G qr5GRMgf06YnKH/0CimKgertEevcw92OqmrRngbywk=; b=dJKk8gs7CF4KRCcfh 89WVjnhITgi2+635oEUJk+087w20YQpJyBQQRSv6sMvRFBFpbSYz45v1LYD7YSEF k5RjCZgWsz/jDYeuZ1/RmyGF7eTyz8EUQ+zX4XOys/kG00CKqN3XP/Hhwoh55q5p PBoqLjFiU/UtroUW0Z+Eqx5GO4FSz7jp/i1vGOgYuK+F9VG42MXubrcWhALXIcE/ 03DnMHBjvq88RBcy+yoHWGYj8PbashFFwXz6e3vWCTpBOCgBfX3IhkxEH5nO4Y9U amCTP9WGxg1h6I4qU4J31S/WBH+GxRhVgrevtJSzFc1T2ODHmcXC3fIdvp2qeyWc 4WATg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejleduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgepfeenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:56:33 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 46/53] Remove references to d_add() in documentation and comments. Date: Fri, 13 Mar 2026 08:12:33 +1100 Message-ID: <20260312214330.3885211-47-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown It is planned to remove d_add(), so remove all references in documentation and comments. Signed-off-by: NeilBrown --- Documentation/filesystems/nfs/exporting.rst | 10 ++-------- Documentation/filesystems/vfs.rst | 4 ++-- fs/afs/dir.c | 5 +++-- fs/dcache.c | 2 +- fs/ocfs2/namei.c | 2 +- fs/xfs/xfs_iops.c | 6 +++--- 6 files changed, 12 insertions(+), 17 deletions(-) diff --git a/Documentation/filesystems/nfs/exporting.rst b/Documentation/fi= lesystems/nfs/exporting.rst index a01d9b9b5bc3..ccaacdc72576 100644 --- a/Documentation/filesystems/nfs/exporting.rst +++ b/Documentation/filesystems/nfs/exporting.rst @@ -101,14 +101,8 @@ Filesystem Issues For a filesystem to be exportable it must: =20 1. provide the filehandle fragment routines described below. - 2. make sure that d_splice_alias is used rather than d_add - when ->lookup finds an inode for a given parent and name. - - If inode is NULL, d_splice_alias(inode, dentry) is equivalent to:: - - d_add(dentry, inode), NULL - - Similarly, d_splice_alias(ERR_PTR(err), dentry) =3D ERR_PTR(err) + 2. Use d_splice_alias() when ->lookup finds an inode for a given=20 + parent and name. =20 Typically the ->lookup routine will simply end with a:: =20 diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/= vfs.rst index d8df0a84cdba..26dec777ca5c 100644 --- a/Documentation/filesystems/vfs.rst +++ b/Documentation/filesystems/vfs.rst @@ -460,7 +460,7 @@ otherwise noted. ``lookup`` called when the VFS needs to look up an inode in a parent directory. The name to look for is found in the dentry. This - method must call d_add() to insert the found inode into the + method must call d_splice_alias() to insert the found inode into the dentry. The "i_count" field in the inode structure should be incremented. If the named inode does not exist a NULL inode should be inserted into the dentry (this is called a negative @@ -1433,7 +1433,7 @@ manipulate dentries: d_iput() method is called). If there are other references, then d_drop() is called instead =20 -``d_add`` +``d_splice_alias`` add a dentry to its parents hash list and then calls d_instantiate() =20 diff --git a/fs/afs/dir.c b/fs/afs/dir.c index b5c593f50079..f259ca2da383 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -960,8 +960,9 @@ static struct dentry *afs_lookup_atsys(struct inode *di= r, struct dentry *dentry, dput(ret); } =20 - /* We don't want to d_add() the @sys dentry here as we don't want to - * the cached dentry to hide changes to the sysnames list. + /* We don't want to d_splice_alias() the @sys dentry here as we + * don't want to the cached dentry to hide changes to the + * sysnames list. */ ret =3D NULL; out_s: diff --git a/fs/dcache.c b/fs/dcache.c index c48337d95f9a..9a6139013367 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -3323,7 +3323,7 @@ struct dentry *d_splice_alias_ops(struct inode *inode= , struct dentry *dentry, * @dentry must be negative and may be in-lookup or unhashed or hashed. * * If inode is a directory and has an IS_ROOT alias, then d_move that in - * place of the given dentry and return it, else simply d_add the inode + * place of the given dentry and return it, else simply __d_add the inode * to the dentry and return NULL. * * If a non-IS_ROOT directory is found, the filesystem is corrupt, and diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index 268b79339a51..0d3116142bd7 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c @@ -172,7 +172,7 @@ static struct dentry *ocfs2_lookup(struct inode *dir, s= truct dentry *dentry, ocfs2_dentry_attach_gen(dentry); =20 bail_unlock: - /* Don't drop the cluster lock until *after* the d_add -- + /* Don't drop the cluster lock until *after* the d_splice_alias -- * unlink on another node will message us to remove that * dentry under this lock so otherwise we can race this with * the downconvert thread and have a stale dentry. */ diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index ec19d3ec7cf0..2641061ba1db 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -356,9 +356,9 @@ xfs_vn_ci_lookup( if (unlikely(error !=3D -ENOENT)) return ERR_PTR(error); /* - * call d_add(dentry, NULL) here when d_drop_negative_children - * is called in xfs_vn_mknod (ie. allow negative dentries - * with CI filesystems). + * call d_splice_alias(NULL, dentry) here when + * d_drop_negative_children is called in xfs_vn_mknod + * (ie. allow negative dentries with CI filesystems). */ return NULL; } --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3715A381B18; Thu, 12 Mar 2026 21:57:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352627; cv=none; b=NkZva2mG1ggAJj2Q+tahvr1n7UBw16z1d51I+fZnYwVMQTzWLO89h+6AIy1yF/8T0TNBRQNExaFWHICrFUSzQ0xyDe4cUmpmNfyYGWch9LPLrQvY0tFliyuSVeNfZPK/1p2+KyrGVJuJaR2z+Aecn+LpPBpfP6190kpJFhAL99g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352627; c=relaxed/simple; bh=rTMUv2NqZ3FGQqb+0wk8UIV1lhSxIjtP4stcYt3+MG8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bJ7rqaFSf9+kcoKJz4ToayKXF7b8UyGOYxqTLvHobWB2uHhBDEUsf7s2gTRUNVemUVLvRlpuO/H5LjBL2yR8d40Wcwznqf1orobXDn2RyLwd+XDdtWyLZ1ASDvAYY8td5IR/OuEah/H5c9o6UH28ddVPHzcwuj1eldcY7QVcZ0M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=BW9wEqW3; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=dpUIJhtE; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="BW9wEqW3"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="dpUIJhtE" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailflow.stl.internal (Postfix) with ESMTP id 8997E1300F6C; Thu, 12 Mar 2026 17:57:04 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Thu, 12 Mar 2026 17:57:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352624; x=1773359824; bh=4l/tn7wsmdY2E32uQtjREu4g7D5gEVnge4bbDSwghlw=; b= BW9wEqW3sDh/FtKsI2oZym4cN8gfqO7PI+1QZkzeYlyvzzvl6g5EeSeOVu2oQtk6 PwPCa0pocxA0zzebqej9hV8+MTj4mW3U1OzGT1coekfj64HMKjiyXojEgdUSfnKR Df6eFbO4K8hWvuP6o0waZ4SVFdfPcjZ7D+C0sJjdqiTmUTmlwI+pXNafNv00dWc+ O0BVOVD6z9gx+eoRdkYV7FRCKsnyeYvYtoaEJmptNiWxetbag5RW+Ctd2uja0vfe v/0ZReqHwz02Av+es2ehMtnHwBvblWlCyOd+zaOQ8hfvOrqwfKTb6BsB9u6fjrkN H6TNzQH7wj5p2FUyypeOZA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352624; x=1773359824; bh=4 l/tn7wsmdY2E32uQtjREu4g7D5gEVnge4bbDSwghlw=; b=dpUIJhtEj1cBj3j9H unyZT0sMz9m0PJa4w9ml8U0zTMyPTdFWoMrhP+PqHlnb46PZTAI4xBzf/94OZ8au HMMYdpzclow79eg8cITbo/HF3XL3lV3pJvLrnH+UHhYGWNABwaDUEiiSyBi+p058 AIT72AIiSjFv8C24PGRRqioFgMW/bXDjAmwY1r7O83Dgv8bls44ABJ3Gy3mhaPVZ p5sA4LBrZzneMleY4pIfAQbq2VSFXST6n79auOxftmCpBxOkbEmLk++Su9Eqt6tE 9xo9Ukyjllk9zko/7dVAbA5+W8pX2MGic1YtvXJIew/ovNUl8pHZGrIke+e8ed4X zHmhQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejledvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:56:51 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 47/53] VFS: make d_alloc() local to VFS. Date: Fri, 13 Mar 2026 08:12:34 +1100 Message-ID: <20260312214330.3885211-48-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown d_alloc() is not useful. d_alloc_name() is a better interface for those cases where it is safe to allocate a dentry without synchronisation with the VFS, and d_alloc_parallel() or d_alloc_noblock() shoudl be used when synchronisation is needed. Signed-off-by: NeilBrown --- Documentation/filesystems/porting.rst | 8 ++++++++ fs/dcache.c | 1 - fs/internal.h | 1 + include/linux/dcache.h | 1 - 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesyst= ems/porting.rst index 6a507c508ccf..4712403fd98e 100644 --- a/Documentation/filesystems/porting.rst +++ b/Documentation/filesystems/porting.rst @@ -1381,3 +1381,11 @@ longer available. Use start_renaming() or similar. =20 d_alloc_parallel() no longer requires a waitqueue_head. It uses one from an internal table when needed. + +--- + +**mandatory** + +d_alloc() is no longer exported as its use can be racy. Use d_alloc_name() +when object creation is controlled separately from standard filesystem int= erface, +and d_alloc_parallel() or d_alloc_noblock() when standard interfaces can b= e used. diff --git a/fs/dcache.c b/fs/dcache.c index 9a6139013367..23f04fa05778 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1830,7 +1830,6 @@ struct dentry *d_alloc(struct dentry * parent, const = struct qstr *name) =20 return dentry; } -EXPORT_SYMBOL(d_alloc); =20 /** * d_duplicate: duplicate a dentry for combined atomic operation diff --git a/fs/internal.h b/fs/internal.h index cbc384a1aa09..9c637e2d18ef 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -223,6 +223,7 @@ bool sync_lazytime(struct inode *inode); /* * dcache.c */ +struct dentry *d_alloc(struct dentry * parent, const struct qstr *name); extern int d_set_mounted(struct dentry *dentry); extern long prune_dcache_sb(struct super_block *sb, struct shrink_control = *sc); extern struct dentry *d_alloc_cursor(struct dentry *); diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 3b12577ddfbb..18242f9598dc 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -242,7 +242,6 @@ extern void d_drop(struct dentry *dentry); extern void d_delete(struct dentry *); =20 /* allocate/de-allocate */ -extern struct dentry * d_alloc(struct dentry *, const struct qstr *); extern struct dentry * d_alloc_anon(struct super_block *); extern struct dentry * d_alloc_parallel(struct dentry *, const struct qstr= *); extern struct dentry * d_alloc_noblock(struct dentry *, struct qstr *); --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EAE0317142; Thu, 12 Mar 2026 21:57:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352645; cv=none; b=oXWepgmAkobNzBgNGc3AwyYX3QtuZdemYA259c70/CvVW7xu1SL2M06XCC7ZBAjW18SodblLKusvWaCScZwZTP7tM2TlcE2ly4lMQrQDzQjr1xWg3qKgnaHNLIH9tEYq9ZJaKRthsWvhIP1PUduyY+nPMs593B24pvd/ZOqRu7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352645; c=relaxed/simple; bh=sJlA18OTmCW0Nza7hJ61Fmatr582H1VHa/YPsfzcAXs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hAp3DHT5zd9or4OeJqxLovqN8obX6gLUBQOafethIyNs4JiP9sjDXl7zW8sUoLuNtImB8l54WyCA7QiMvANqQZZC/sxFXtnalJ9NLvJJCZ0DvKwpQmap2XPat+ovr1ACiI2wDg/osVesSWrk6fvOQ7VdK/EPwNvm1kdzxgyQ8+8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=nvIfh2aV; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=xlwDjQbH; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="nvIfh2aV"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="xlwDjQbH" Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailflow.stl.internal (Postfix) with ESMTP id 8380A1301B63; Thu, 12 Mar 2026 17:57:21 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-10.internal (MEProxy); Thu, 12 Mar 2026 17:57:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352641; x=1773359841; bh=TcDuCufZRxJixrcfGFygV+aETR7o0fZBVzJe26rF96E=; b= nvIfh2aV2uCnP5fbNBD0+p+cy5dGDLvwuz7s3Y2ug0pE9ASziUJZDIeLE56guz56 /o5mTdgRuBry13nfhP1Q6ljFE8dK90mkT3TGfExLnEDQmbbJ4Dd5dIswurNNrHRG qGYhyGNzBYe1eg7Wv4tqzkAxFgmyldVz0qJd1mhHWbQli6lUFt9JSJiI5gyfnnfm 57b4oV9ELFNsGFG3SMNAeCDK4TTz5aO3+SYbXmhxZKK0+IiiAUY8/N6+jkCPR+pd 4dpuFNZj/O88RcKYROJtoFUZ9hP5f5ew2YzSgcaYhUFxonj7LcTlhEjqBbo59CfP 1Bx00rDdV5Kc8MhWJ7JNLw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352641; x=1773359841; bh=T cDuCufZRxJixrcfGFygV+aETR7o0fZBVzJe26rF96E=; b=xlwDjQbH9C1hyWYTk qKwHe5IPsQr+iN4dxQjz1i3OO4hnW9JvPTqO9DlXAuYx/EU4usiTZf+yBPoL8+fp v/v6ZaEjHOByIDbkNYrbdJWbNWeuewez+R4OXr/Xw9Qyo+x/FkLR79SrLLtJK3d3 3mf0I+ElHTZ5v25Gr2YAJD3rYwupgT1B6fSTpAvQYmWkEZXCpYWUVl/GMo584Do+ OCWpoJvv3lLzJ5rwqiPmcnhbTPLew/JpKRHjScaMdrDKoT/wZLzFfO4XO/ABZ5D/ u0cy237zNWkEclRAhZkLsXOULDttuM2SX9t6Y/c5mpNLkRskDDrpctYmuSOGGgpj IdArg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejledvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:57:07 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 48/53] VFS: remove d_add() Date: Fri, 13 Mar 2026 08:12:35 +1100 Message-ID: <20260312214330.3885211-49-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown d_add() has been supplanted by d_splice_alias(), d_make_persistent() and others. It is no longer used and can be discarded Signed-off-by: NeilBrown --- fs/dcache.c | 19 ------------------- include/linux/dcache.h | 2 -- 2 files changed, 21 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 23f04fa05778..4ebbbcc5aec4 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2979,25 +2979,6 @@ static inline void __d_add(struct dentry *dentry, st= ruct inode *inode, spin_unlock(&inode->i_lock); } =20 -/** - * d_add - add dentry to hash queues - * @entry: dentry to add - * @inode: The inode to attach to this dentry - * - * This adds the entry to the hash queues and initializes @inode. - * The entry was actually filled in earlier during d_alloc(). - */ - -void d_add(struct dentry *entry, struct inode *inode) -{ - if (inode) { - security_d_instantiate(entry, inode); - spin_lock(&inode->i_lock); - } - __d_add(entry, inode, NULL); -} -EXPORT_SYMBOL(d_add); - struct dentry *d_make_persistent(struct dentry *dentry, struct inode *inod= e) { WARN_ON(!hlist_unhashed(&dentry->d_u.d_alias)); diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 18242f9598dc..31b4a831ecdb 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -282,8 +282,6 @@ extern int path_has_submounts(const struct path *); */ extern void d_rehash(struct dentry *); =20 -extern void d_add(struct dentry *, struct inode *); - /* used for rename() and baskets */ extern void d_move(struct dentry *, struct dentry *); extern void d_exchange(struct dentry *, struct dentry *); --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DAE1317142; Thu, 12 Mar 2026 21:57:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352661; cv=none; b=A9Yzkqj8U+sMzn9UMBBHBaK1Tt9M7PZQQ9+RkYe3OcHE5O3qKo5qx/J4hdPpQDd+aJHzOWAjXFik1zONXjnr+co2WBcd6zR4i7nogsw2RmTlvZ4EVal3FWUkWWKR9tJVW8v5S8zq+P8bFpWQMFnDkfgjRvOwHKRmgvb82zaviw4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352661; c=relaxed/simple; bh=IvIgaj6RGP4Mope0MBBjyMqWcWrdMOteV8lrKz+ETTU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mKXCvKH/LvA/nVvYYieTbByeWLVMCni3oXPyUyz0qEtHfVLPKRV5YH/UzYC42+gnw/hpBUPBOXvea0QLMddEzpxRQ+DPgMeHWJg1TcUscQ754ZeyuDmaFSgtDuHEsjMK2jezbv1SpJm4ARYtMfLTX3q3mYFhopZtuCamIbNB3O8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=H/xdszBd; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=UIuUs5vU; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="H/xdszBd"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="UIuUs5vU" Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailflow.stl.internal (Postfix) with ESMTP id A5ED31301B5F; Thu, 12 Mar 2026 17:57:38 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Thu, 12 Mar 2026 17:57:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352658; x=1773359858; bh=WHdWWLZAUXsN0K/gS8foO1rQ+cBpiHFflrFfn6k5mho=; b= H/xdszBdpajXQlqvP2h9f8bRrmPuJ0E3HbSIi1+FvDbmXu5Tffa39rTheWtfGwZR 07K9XTAAEu7QaoJDNNdeV8FPwp7VsZ05tBCbGNERpgIPXvnUh4Dh11eHvup8m6vs E5AWfQHX37M7Oed9OovK3Y5b84TTp6vRaxqOKav5UXzJr4jRcIi0QkXwPhN4kZYV LZoFa/W1oz8zPHi+tqAL3COCNVGwcsFSYb9+rQJTG37CHQI159wRjqpP0tBXNsNq WKVSfQ7Vrk7fhCT55o9UbvASICeM8pa8jCAA7V/OugQhNLLKoEUUVDh26eeB6pU0 w+PQtmIUZsNeWl/pHFJh2w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352658; x=1773359858; bh=W HdWWLZAUXsN0K/gS8foO1rQ+cBpiHFflrFfn6k5mho=; b=UIuUs5vUUmD7NwmW0 yb8NDgNHItXo1Ks/l/WxZ+fc3iPeAPnbXAz/dyah4o+3nxPXgyyTjMIsM+QVnZP+ YrT1OE6Q7kMuq0FQpMmfD5M3YNYv+ja9g16SXRCe54Y8qn2v2Rv3Fx3JjasZy4Wg UEOHHaKmxENT6dRF9frTgZLL7RQ62rZhSzqZV+3ehBY2yK051jf/wLAtOKbzZxck oOCPIJW9D0oqj7rnHP94IfAhWhex0ZcyYxBDYhqGoYVxAV21pRS44vfgPWtBBbbw 4XQOqgI+qyun3wABEJ24wxhbpqXk5pq7ME0lbxnSNrBtvCLwBnmyKv5pz1oNHiw7 QHz7Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejledvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:57:25 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 49/53] VFS: remove d_rehash() Date: Fri, 13 Mar 2026 08:12:36 +1100 Message-ID: <20260312214330.3885211-50-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown d_rehash() is no longer used. Is existence implies that it might be safe to unhash and rehash ad dentry, and with proposed locking changes that will no longer be the case. So remove it. Signed-off-by: NeilBrown --- Documentation/filesystems/porting.rst | 7 +++++++ fs/dcache.c | 15 --------------- include/linux/dcache.h | 5 ----- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesyst= ems/porting.rst index 4712403fd98e..154a38cd7801 100644 --- a/Documentation/filesystems/porting.rst +++ b/Documentation/filesystems/porting.rst @@ -1389,3 +1389,10 @@ from an internal table when needed. d_alloc() is no longer exported as its use can be racy. Use d_alloc_name() when object creation is controlled separately from standard filesystem int= erface, and d_alloc_parallel() or d_alloc_noblock() when standard interfaces can b= e used. + +--- +**mandatory** + +d_rehash() is gone. It should never be needed. Only unhash a dentry if +you really don't want it. + diff --git a/fs/dcache.c b/fs/dcache.c index 4ebbbcc5aec4..abb96ad8e015 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2627,21 +2627,6 @@ static void __d_rehash(struct dentry *entry) hlist_bl_unlock(b); } =20 -/** - * d_rehash - add an entry back to the hash - * @entry: dentry to add to the hash - * - * Adds a dentry to the hash according to its name. - */ -=20 -void d_rehash(struct dentry * entry) -{ - spin_lock(&entry->d_lock); - __d_rehash(entry); - spin_unlock(&entry->d_lock); -} -EXPORT_SYMBOL(d_rehash); - #define PAR_LOOKUP_WQ_BITS 8 #define PAR_LOOKUP_WQS (1 << PAR_LOOKUP_WQ_BITS) static wait_queue_head_t par_wait_table[PAR_LOOKUP_WQS] __cacheline_aligne= d; diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 31b4a831ecdb..eb1a59b6fca7 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -277,11 +277,6 @@ extern struct dentry *d_find_alias_rcu(struct inode *); /* test whether we have any submounts in a subdir tree */ extern int path_has_submounts(const struct path *); =20 -/* - * This adds the entry to the hash queues. - */ -extern void d_rehash(struct dentry *); -=20 /* used for rename() and baskets */ extern void d_move(struct dentry *, struct dentry *); extern void d_exchange(struct dentry *, struct dentry *); --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47B042BCF5D; Thu, 12 Mar 2026 21:57:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352678; cv=none; b=qBIltq5UX5vO9nZOn2gmYzGn/ReD2cgw59u4Vw4fHcA8+hZay8I4EYmlokrZ/2mLspp+/h7Ykkz34K1j+Y3HXMAlPu7uUg7adk2iVtwBaGZMpCqYscjIP8YBZwNmobTjHFPIaKG13Snn4JUKdY73PqK+fm6uN7k+0rv7UhKo/Yw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352678; c=relaxed/simple; bh=zhOU+CUP9BDiz+mBL+6rvvcpWUBlfL5f4sGMgdReybg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d0kjDlRtdbszzPn1/xSM1cebsxNm22qesVOsVqmakIKi2BnyPXHDAeCbgWdUGsbLz42tcMiMirfv8pPb0H+kacIGCGH7Pi8rTmcd+zhILhBTbsmryMG42kkCHMY/W1x0zTuQfkQROsSafkgDPHFmvBQqPGcmDlqG2KL0qEXIXzk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=OmN1n9vT; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=DUkArunM; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="OmN1n9vT"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="DUkArunM" Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailflow.stl.internal (Postfix) with ESMTP id 9E9601300F6C; Thu, 12 Mar 2026 17:57:55 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Thu, 12 Mar 2026 17:57:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352675; x=1773359875; bh=tG1sAZ33EfRbToxRaM5utlCqwlH2sGHBZL6Q+fSZ/kg=; b= OmN1n9vTcFKpHoHUGImFy0CQZvz9KEtReJX8p0OX7kUzjl9V1nlaH0yIJxxNJ5o5 oET4VMjoMdSHj7IP5T4w/Rg6YRHXE0F+yv/zv6JIVNaEu04OcGt8i2Z31ixKUARE DgWSGk08+PgsvbboVZfumYegJ49ceyganU4rmEo80NNQt8dBC4CP9Wg3fGyUFm/H JqPNMalfP80ve+bbpg9QT7R10mOUfPal3L+Ic8nXjpuv3ShR8ZVXFaW54uMweLe0 Uq9Qii9ZXDmV3HkZ8LfHyMvZo42uRI7668NHYPRCfw63wFbH2Rx07hB+CGfTU/+0 5h1RkHy0wyR2U7RjIeMU+g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352675; x=1773359875; bh=t G1sAZ33EfRbToxRaM5utlCqwlH2sGHBZL6Q+fSZ/kg=; b=DUkArunM0luViPOSC jYYHJCnZBtZFu1yArXIwY0hvu6BErdZBDdHUc16HB0A4qYJKkcPzwpLxrDs9bVos bzYgAA+8UttTRhFKZ0bpoi8CaHHQoxiV1ip3XmTGLLS3OhflYcg/lSPRa3aw9Esw 9Dby830jyY6S1LECOhApUa2X7BsIoOuRyilaw6sD+gyYb3+jHWgRcHxC9iAw/Z2u IRdPeUpUN5OYAHfWgBBL/r028pjWmk4Ha2AjbAGHczLxiNwGIUOrONuduvNIGDUf DAhRMe7hKq4+w9i2cCgr2MKWCq0AYV+anj+y7k2zwww+ByYy121ZFJq9XFjo8x6e Ofj3w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejledvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:57:42 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 50/53] VFS: remove lookup_one() and lookup_noperm() Date: Fri, 13 Mar 2026 08:12:37 +1100 Message-ID: <20260312214330.3885211-51-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown These are no longer used, so remove them. Signed-off-by: NeilBrown --- Documentation/filesystems/porting.rst | 7 +++ fs/ecryptfs/inode.c | 2 +- fs/namei.c | 61 ++------------------------- include/linux/namei.h | 2 - 4 files changed, 12 insertions(+), 60 deletions(-) diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesyst= ems/porting.rst index 154a38cd7801..7e83bd3c5a12 100644 --- a/Documentation/filesystems/porting.rst +++ b/Documentation/filesystems/porting.rst @@ -1396,3 +1396,10 @@ and d_alloc_parallel() or d_alloc_noblock() when sta= ndard interfaces can be used d_rehash() is gone. It should never be needed. Only unhash a dentry if you really don't want it. =20 +--- + +** mandatory** + +lookup_one() and lookup_noperm() are no longer available. Use +start_creating() or similar instead. + diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index beb9e2c8b8b3..a7a596d51d67 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c @@ -414,7 +414,7 @@ static struct dentry *ecryptfs_lookup(struct inode *ecr= yptfs_dir_inode, =20 lower_dentry =3D lookup_noperm_unlocked(&qname, lower_dir_dentry); if (IS_ERR(lower_dentry)) { - ecryptfs_printk(KERN_DEBUG, "%s: lookup_noperm() returned " + ecryptfs_printk(KERN_DEBUG, "%s: lookup_noperm_unlocked() returned " "[%ld] on lower_dentry =3D [%s]\n", __func__, PTR_ERR(lower_dentry), qname.name); diff --git a/fs/namei.c b/fs/namei.c index eed388ee8a30..cb80490a869f 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3148,59 +3148,6 @@ struct dentry *try_lookup_noperm(struct qstr *name, = struct dentry *base) } EXPORT_SYMBOL(try_lookup_noperm); =20 -/** - * lookup_noperm - filesystem helper to lookup single pathname component - * @name: qstr storing pathname component to lookup - * @base: base directory to lookup from - * - * Note that this routine is purely a helper for filesystem usage and shou= ld - * not be called by generic code. It does no permission checking. - * - * The caller must hold base->i_rwsem. - */ -struct dentry *lookup_noperm(struct qstr *name, struct dentry *base) -{ - struct dentry *dentry; - int err; - - WARN_ON_ONCE(!inode_is_locked(base->d_inode)); - - err =3D lookup_noperm_common(name, base); - if (err) - return ERR_PTR(err); - - dentry =3D lookup_dcache(name, base, 0); - return dentry ? dentry : __lookup_slow(name, base, 0); -} -EXPORT_SYMBOL(lookup_noperm); - -/** - * lookup_one - lookup single pathname component - * @idmap: idmap of the mount the lookup is performed from - * @name: qstr holding pathname component to lookup - * @base: base directory to lookup from - * - * This can be used for in-kernel filesystem clients such as file servers. - * - * The caller must hold base->i_rwsem. - */ -struct dentry *lookup_one(struct mnt_idmap *idmap, struct qstr *name, - struct dentry *base) -{ - struct dentry *dentry; - int err; - - WARN_ON_ONCE(!inode_is_locked(base->d_inode)); - - err =3D lookup_one_common(idmap, name, base); - if (err) - return ERR_PTR(err); - - dentry =3D lookup_dcache(name, base, 0); - return dentry ? dentry : __lookup_slow(name, base, 0); -} -EXPORT_SYMBOL(lookup_one); - /** * lookup_one_unlocked - lookup single pathname component * @idmap: idmap of the mount the lookup is performed from @@ -3209,8 +3156,8 @@ EXPORT_SYMBOL(lookup_one); * * This can be used for in-kernel filesystem clients such as file servers. * - * Unlike lookup_one, it should be called without the parent - * i_rwsem held, and will take the i_rwsem itself if necessary. + * It should be called without the parent i_rwsem held, and will take + * the i_rwsem itself if necessary. * * Returns: - A dentry, possibly negative, or * - same errors as try_lookup_noperm() or @@ -3322,8 +3269,8 @@ EXPORT_SYMBOL(lookup_one_positive_unlocked); * Note that this routine is purely a helper for filesystem usage and shou= ld * not be called by generic code. It does no permission checking. * - * Unlike lookup_noperm(), it should be called without the parent - * i_rwsem held, and will take the i_rwsem itself if necessary. + * This should be called without the parent i_rwsem held, and will take + * the i_rwsem itself if necessary. * * Unlike try_lookup_noperm() it *does* revalidate the dentry if it already * existed. diff --git a/include/linux/namei.h b/include/linux/namei.h index b3346a513d8f..cb79e84c718d 100644 --- a/include/linux/namei.h +++ b/include/linux/namei.h @@ -74,10 +74,8 @@ int vfs_path_lookup(struct dentry *, struct vfsmount *, = const char *, unsigned int, struct path *); =20 extern struct dentry *try_lookup_noperm(struct qstr *, struct dentry *); -extern struct dentry *lookup_noperm(struct qstr *, struct dentry *); extern struct dentry *lookup_noperm_unlocked(struct qstr *, struct dentry = *); extern struct dentry *lookup_noperm_positive_unlocked(struct qstr *, struc= t dentry *); -struct dentry *lookup_one(struct mnt_idmap *, struct qstr *, struct dentry= *); struct dentry *lookup_one_unlocked(struct mnt_idmap *idmap, struct qstr *name, struct dentry *base); struct dentry *lookup_one_positive_unlocked(struct mnt_idmap *idmap, --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFCD63AB290; Thu, 12 Mar 2026 21:58:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352696; cv=none; b=JD7A2qxXcbMqBtQTRlZIvUtQWRWfw8K/h/9bt/We5EhKaVFJ6NgTpLusix5JDw/hPEQ6f1a7fQI0EsMnTx2GSbg1U4ZxbcKNQTeOvhiVymH1KofNHmFuDrrbeHHjYCMBcreiYlthtqUfYlekc2L2DTMul8lvGvNZZBrTrogobvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352696; c=relaxed/simple; bh=PDfaEKR3ToWZipBTJ7awOf9nXE0QxmMtFDzDKxbjUmQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kqumXwgi9n7PbrqwTfTGXuce8ko6ljK3NvDPGin1XM1mdOj2O9E+LXJkl5wJIEyeWgHwx7WknvxpV+STnfw5JtO+KVI6g7vkTVKo5o+23P6SRV/VO3Ofq68kbtWe2zDIN3MOoPfW1KevKpGKQ440gLbv0fzFAlKHtBkUTQ2nqCE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=Aiv/eft0; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=1OKI1aeP; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="Aiv/eft0"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="1OKI1aeP" Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailflow.stl.internal (Postfix) with ESMTP id 531271301B68; Thu, 12 Mar 2026 17:58:12 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-12.internal (MEProxy); Thu, 12 Mar 2026 17:58:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352692; x=1773359892; bh=MUCVEDpSf+0EP+yvqNrKKgbgS6k/EkMfChZKLZ22YF8=; b= Aiv/eft0lgPfT980cKxeTnbansdx69JMDdu3/JvECSezFjIw35T8po0J7Dr8uNz3 sIBBHBdSe4MXUrEF8Fj06jbhW2EE7JC8gaPZzvxL4boq4YxDZ+CRXvvNlgYjU+ad zVo48RhaQGZQOjrYGJTHjDPxeGvcjtjerjOc4eh0NjzqVTlyohkpdmmv2NUqgUY0 kGTPr9S74jE/j+NCuYF03/ks4uS34m9TEH/qtCulLr0zXqcwhZT0jqA18NZMxYk8 7Q7QidM3FocAj62Z/Xs8FMUmSkMlrAh0Tu4ZwGqs+fXuxjjYBw4q/KLFBSxgulO/ O8xZvAKjbOCAu8Ctbd/xlw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352692; x=1773359892; bh=M UCVEDpSf+0EP+yvqNrKKgbgS6k/EkMfChZKLZ22YF8=; b=1OKI1aeP/URdJ6EVy Z+vyP9J8PKZrd0kY//3qj71VewKCNrnBkJOvFWrxGJymoeibivc952VMmJ0Wmphn GdXCcWC2chTiQ8YEYimV8Wfe46qK2KFxr0eSSwm2kf+ajXccqEga9+LHL5oUW84X yEB8WJoc/CtgIS9uwc4JfckT9M7HIIj9BkYyKEc7UKLYbnFaA3YX1pZd7rtnIM7X 0CSikuFS9fiJ8+Et3mu0UkfKU4IGmFqiDYedmOmjR/0tGilyq8lfTDvk4GLhoa0C FKHKzDyWUSwTK3s6Ka962SMkXym18zo7X8d44IXEmqoskkODbePuGhcnghfwNyOh 65kZw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejledvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnefuuh gsshhtuchvrghrshculdehtddmnecujfgurhephffvvefufffkofgjfhhrggfgsedtkeer tdertddtnecuhfhrohhmpefpvghilheurhhofihnuceonhgvihhlsgesohifnhhmrghilh drnhgvtheqnecuggftrfgrthhtvghrnhepveevkeffudeuvefhieeghffgudektdelkeej iedtjedugfeukedvkeffvdefvddunecuvehluhhsthgvrhfuihiivgepudenucfrrghrrg hmpehmrghilhhfrhhomhepnhgvihhlsgesohifnhhmrghilhdrnhgvthdpnhgspghrtghp thhtohephedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehvihhrohesiigvnh hivhdrlhhinhhugidrohhrghdruhhkpdhrtghpthhtoheplhhinhhugidqgihfshesvhhg vghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhunhhiohhnfhhsse hvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqthhrrggtvgdq khgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugi dqnhhfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhk vghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqd hfshguvghvvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhu gidqvgigthegsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugi dqvghfihesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:57:59 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 51/53] VFS: use d_alloc_parallel() in lookup_one_qstr_excl(). Date: Fri, 13 Mar 2026 08:12:38 +1100 Message-ID: <20260312214330.3885211-52-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown lookup_one_qstr_excl() is used for lookups prior to directory modifications (other than open(O_CREATE)), whether create, remove, or rename. A future patch will lift lookup out of the i_rwsem lock that protects the directory during these operations (only taking a shared lock if the target name is not yet in the dcache). To prepare for this change and particularly to allow lookup to always be done outside the parent i_rwsem, change lookup_one_qstr_excl() to use d_alloc_parallel(). For the target of create and rename some filesystems skip the preliminary lookup and combine it with the main operation. This is only safe if the operation has exclusive access to the dentry. Currently this is guaranteed by an exclusive lock on the directory. d_alloc_parallel() provides alternate exclusive access (in the case where the name isn't in the dcache and ->lookup will be called). As a result of this change, ->lookup is now only ever called with a d_in_lookup() dentry. Consequently we can remove the d_in_lookup() check from d_add_ci() which is only used in ->lookup. If LOOKUP_EXCL or LOOKUP_RENAME_TARGET is passed, the caller must ensure d_lookup_done() is called at an appropriate time, and must not assume that it can test for positive or negative dentries without confirming that the dentry is no longer d_in_lookup() - unless it is filesystem code acting on itself and *knows* that ->lookup() always completes the lookup (currently true for all filesystems other than NFS). This is all handled in start_creating() and end_dirop() and friends. Note that as lookup_one_qstr_excl() is called with an exclusive lock on the directory, d_alloc_parallel() cannot race with another thread and cannot return a non-in-lookup dentry. However that is expected to change so that case is handled with this patch. Signed-off-by: NeilBrown --- Documentation/filesystems/porting.rst | 14 ++++++++++ fs/dcache.c | 16 +++-------- fs/namei.c | 38 ++++++++++++++++++++------- 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesyst= ems/porting.rst index 7e83bd3c5a12..5ddc5ecfcc64 100644 --- a/Documentation/filesystems/porting.rst +++ b/Documentation/filesystems/porting.rst @@ -1403,3 +1403,17 @@ you really don't want it. lookup_one() and lookup_noperm() are no longer available. Use start_creating() or similar instead. =20 + +--- + +**mandatory** + +All start_creating and start_renaming functions may return a +d_in_lookup() dentry if passed "O_CREATE|O_EXCL" or "O_RENAME_TARGET". +end_dirop() calls the necessary d_lookup_done(). If the caller +*knows* which filesystem is being used, it may know that this is not +possible. Otherwise it must be careful testing if the dentry is +positive or negative as the lookup may not have been performed yet. + +inode_operations.lookup() is now only ever called with a d_in_lookup() +dentry. diff --git a/fs/dcache.c b/fs/dcache.c index abb96ad8e015..f573716d1a04 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2261,18 +2261,10 @@ struct dentry *d_add_ci(struct dentry *dentry, stru= ct inode *inode, inode_unlock_shared(d_inode(dentry->d_parent)); else inode_unlock(d_inode(dentry->d_parent)); - if (d_in_lookup(dentry)) { - found =3D d_alloc_parallel(dentry->d_parent, name); - if (IS_ERR(found) || !d_in_lookup(found)) { - iput(inode); - return found; - } - } else { - found =3D d_alloc(dentry->d_parent, name); - if (!found) { - iput(inode); - return ERR_PTR(-ENOMEM); - } + found =3D d_alloc_parallel(dentry->d_parent, name); + if (IS_ERR(found) || !d_in_lookup(found)) { + iput(inode); + return found; } if (shared) inode_lock_shared(d_inode(dentry->d_parent)); diff --git a/fs/namei.c b/fs/namei.c index cb80490a869f..bba419f2fc53 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1774,13 +1774,14 @@ static struct dentry *lookup_dcache(const struct qs= tr *name, } =20 /* - * Parent directory has inode locked exclusive. This is one - * and only case when ->lookup() gets called on non in-lookup - * dentries - as the matter of fact, this only gets called - * when directory is guaranteed to have no in-lookup children - * at all. - * Will return -ENOENT if name isn't found and LOOKUP_CREATE wasn't passed. - * Will return -EEXIST if name is found and LOOKUP_EXCL was passed. + * Parent directory has inode locked. + * If Lookup_EXCL or LOOKUP_RENAME_TARGET is set + * d_lookup_done() must be called before the dentry is dput() + * If the dentry is not d_in_lookup(): + * Will return -ENOENT if name isn't found and LOOKUP_CREATE wasn't pass= ed. + * Will return -EEXIST if name is found and LOOKUP_EXCL was passed. + * If it is d_in_lookup() then these conditions can only be checked by the + * file system when carrying out the intent (create or rename). */ static struct dentry *lookup_one_qstr_excl(const struct qstr *name, struct dentry *base, unsigned int flags) @@ -1798,18 +1799,27 @@ static struct dentry *lookup_one_qstr_excl(const st= ruct qstr *name, if (unlikely(IS_DEADDIR(dir))) return ERR_PTR(-ENOENT); =20 - dentry =3D d_alloc(base, name); - if (unlikely(!dentry)) - return ERR_PTR(-ENOMEM); + dentry =3D d_alloc_parallel(base, name); + if (unlikely(IS_ERR(dentry))) + return dentry; + if (unlikely(!d_in_lookup(dentry))) + /* Raced with another thread which did the lookup */ + goto found; =20 old =3D dir->i_op->lookup(dir, dentry, flags); if (unlikely(old)) { + d_lookup_done(dentry); dput(dentry); dentry =3D old; } found: if (IS_ERR(dentry)) return dentry; + if (d_in_lookup(dentry)) + /* We cannot check for errors - the caller will have to + * wait for any create-etc attempt to get relevant errors. + */ + return dentry; if (d_is_negative(dentry) && !(flags & LOOKUP_CREATE)) { dput(dentry); return ERR_PTR(-ENOENT); @@ -2921,6 +2931,8 @@ static struct dentry *__start_dirop(struct dentry *pa= rent, struct qstr *name, * The lookup is performed and necessary locks are taken so that, on succe= ss, * the returned dentry can be operated on safely. * The qstr must already have the hash value calculated. + * The dentry may be d_in_lookup() if %LOOKUP_EXCL or %LOOKUP_RENAME_TARGET + * is given, depending on the filesystem. * * Returns: a locked dentry, or an error. * @@ -2942,6 +2954,7 @@ void end_dirop(struct dentry *de) { if (!IS_ERR(de)) { inode_unlock(de->d_parent->d_inode); + d_lookup_done(de); dput(de); } } @@ -3854,8 +3867,10 @@ __start_renaming(struct renamedata *rd, int lookup_f= lags, return 0; =20 out_dput_d2: + d_lookup_done(d2); dput(d2); out_dput_d1: + d_lookup_done(d1); dput(d1); out_unlock: unlock_rename(rd->old_parent, rd->new_parent); @@ -3950,6 +3965,7 @@ __start_renaming_dentry(struct renamedata *rd, int lo= okup_flags, return 0; =20 out_dput_d2: + d_lookup_done(d2); dput(d2); out_unlock: unlock_rename(old_dentry->d_parent, rd->new_parent); @@ -4059,6 +4075,8 @@ EXPORT_SYMBOL(start_renaming_two_dentries); =20 void end_renaming(struct renamedata *rd) { + d_lookup_done(rd->old_dentry); + d_lookup_done(rd->new_dentry); unlock_rename(rd->old_parent, rd->new_parent); dput(rd->old_dentry); dput(rd->new_dentry); --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 425E534A797; Thu, 12 Mar 2026 21:58:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352713; cv=none; b=Xih5iItiq46g5beVbKcRdndH58wA7zPNUJiKZNrJmKruVyPn2U6lC47Q7r0Q46cUrxhs9A/OGuPej7419nWkDYz+nRflLAItEOlvj9vKU/swxAkCaLz8Dp1tBXiF4uZv5WKuSbYGCpqIYfcPJ2RvUEKh2Byy60GjRdgLxm/4rB4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352713; c=relaxed/simple; bh=1JkkAedomWBG14G0WAqvfZiAthqy/JF/uu16ADzus+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nKClF/lPsAmEGh9OIqDY4oHVLGofE6kPQDWaZ5j3aTXQQwk28Zo9Ejc+j4eIgjgnGOBa2fnjYVSfU2gikDI2wzK1FZwRcFk7II7mZvlDUTpPNtWkE/JdRkWnDLrUEenxZo2JmTB99Uu0tbz7cvkvxnKGvxYKj4ycRe+sY2AGsuA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=WfHfWNbc; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Qx5rCR2g; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="WfHfWNbc"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Qx5rCR2g" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailflow.stl.internal (Postfix) with ESMTP id 6F3A01301B63; Thu, 12 Mar 2026 17:58:29 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Thu, 12 Mar 2026 17:58:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352709; x=1773359909; bh=1h/4KUNGDnlL7CBwVpO5v6kJjyfz+9NwtNaAhRC9U10=; b= WfHfWNbch9UGB+eGabQxTdEvIDD4DFelol7k3LjdQO/lb65xfuejEmzAoM8pvQ4+ gJ4ol9X9HCBFTIzeKB0Viue1L3jG1Q9bqBwZUTphx4m6U3Rk2ls8GfzEdN0PiZi5 LCTknHndu4dqomidg/k3sGUcGTijbG2dTWjKHVNypIRljDAxdhO3oxfrhMJkCel/ D96BUDM2dcr86sPQiHqSYInXl70rtCkrmk8TxgB7ddCaXEgipNdaZIjXJPrb/0fJ BpP944NRphZdvubke4smP5FoL2inwaqZC6E92n9ErQLi+cdxDBeLIX0EUFb3yR9T sC3KzRrjSgOF44kCJiHBIA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352709; x=1773359909; bh=1 h/4KUNGDnlL7CBwVpO5v6kJjyfz+9NwtNaAhRC9U10=; b=Qx5rCR2gTxh9pg1aW AjDwaxfHDw0YiqmAUCgdlStHI0PQga3+vcnB8gfVa/y4ZBpWzH0QrLbujnOmZKv8 6tBLD2DKb69VB5WgrYmfGt41UvEtR9qwufkNY6SmUVXS1uuj8MG8L6/WcUbufqDc tGCfJnZa7u52el6AobUREmziO6p1gxAhhfQlvnqIsQf2Ry0YMLdAYgehYR7OvjBg Hf7z6Fv/FTfS3TEpRoly9oXmw9v58aAJTrvP/BMYbLSbx0Zd0jSOWF8jkC76ErM+ pvhKfqXWeCDyRvi7kvD8qfxdIcxMmWn10jVuo8IUlE8Mq9uzo+hkJ6Se7a+KyFPv Jtq8g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejledvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:58:15 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 52/53] VFS: lift d_alloc_parallel above inode_lock Date: Fri, 13 Mar 2026 08:12:39 +1100 Message-ID: <20260312214330.3885211-53-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown d_alloc_parallel() can block waiting on a d_in_lookup() dentry so it is important to order it consistently with other blocking locks such as inode_lock(). Currenty d_alloc_parallel() is ordered after inode_lock(): it can be called while the inode is locked, and so the inode cannot be locked while a d_in_lookup() dentry is held. This patch reverses that order. d_alloc_parallel() must now be called *before* locking the directory, and must not be called afterwards. This allows directory locking to be moved closer to the filesystem operations, and ultimately into those operations. lookup_one_qstr_excl() is now called without an lock held, exclusive or otherwise, so the "_excl" is dropped - it is now lookup_one_qstr(). As a lock is taken *after* lookup, start_dirop() and start_renaming() must ensure that if the dentry isn't d_in_lookup() that after the lock is taken the parent is still correct and the dentry is still hashed. lookup_one_qstr() and lookup_slow() don't need to re-check the parent as the dentry is always d_in_lookup() so parent cannot change. The locking in lookup_slow() is moved into __lookup_slow() immediately before/after ->lookup, and lookup_slow() just sets the task state for waiting. Parent locking is removed from open_last_lookups() and performed in lookup_open(). A shared lock is taken if ->lookup() needs to be called. An exclusive lock is taken separately if ->create() needs to be called - with checks that the dentry hasn't become positive. If ->atomic_open is needed we take exclusive or shared parent lock as appropriate and check for a positive dentry or DEAD parent. The fsnotify_create() call is kept inside the locked region in lookup_open(). I don't know if this is important. Signed-off-by: NeilBrown --- fs/namei.c | 239 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 154 insertions(+), 85 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index bba419f2fc53..3d213070a515 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1773,8 +1773,19 @@ static struct dentry *lookup_dcache(const struct qst= r *name, return dentry; } =20 +static inline bool inode_lock_shared_state(struct inode *inode, unsigned i= nt state) +{ + if (state =3D=3D TASK_KILLABLE) { + if (down_read_killable(&inode->i_rwsem) !=3D 0) { + return false; + } + } else { + inode_lock_shared(inode); + } + return true; +} + /* - * Parent directory has inode locked. * If Lookup_EXCL or LOOKUP_RENAME_TARGET is set * d_lookup_done() must be called before the dentry is dput() * If the dentry is not d_in_lookup(): @@ -1783,8 +1794,9 @@ static struct dentry *lookup_dcache(const struct qstr= *name, * If it is d_in_lookup() then these conditions can only be checked by the * file system when carrying out the intent (create or rename). */ -static struct dentry *lookup_one_qstr_excl(const struct qstr *name, - struct dentry *base, unsigned int flags) +static struct dentry *lookup_one_qstr(const struct qstr *name, + struct dentry *base, unsigned int flags, + unsigned int state) { struct dentry *dentry; struct dentry *old; @@ -1806,7 +1818,16 @@ static struct dentry *lookup_one_qstr_excl(const str= uct qstr *name, /* Raced with another thread which did the lookup */ goto found; =20 - old =3D dir->i_op->lookup(dir, dentry, flags); + if (!inode_lock_shared_state(dir, state)) { + d_lookup_done(dentry); + dput(dentry); + return ERR_PTR(-EINTR); + } + if (unlikely(IS_DEADDIR(dir))) + old =3D ERR_PTR(-ENOENT); + else + old =3D dir->i_op->lookup(dir, dentry, flags | LOOKUP_SHARED); + inode_unlock_shared(dir); if (unlikely(old)) { d_lookup_done(dentry); dput(dentry); @@ -1897,7 +1918,8 @@ static struct dentry *lookup_fast(struct nameidata *n= d) /* Fast lookup failed, do it the slow way */ static struct dentry *__lookup_slow(const struct qstr *name, struct dentry *dir, - unsigned int flags) + unsigned int flags, + unsigned int state) { struct dentry *dentry, *old; struct inode *inode =3D dir->d_inode; @@ -1920,8 +1942,17 @@ static struct dentry *__lookup_slow(const struct qst= r *name, dput(dentry); dentry =3D ERR_PTR(error); } + } else if (!inode_lock_shared_state(inode, state)) { + d_lookup_done(dentry); + dput(dentry); + return ERR_PTR(-EINTR); } else { - old =3D inode->i_op->lookup(inode, dentry, flags); + if (unlikely(IS_DEADDIR(inode))) + old =3D ERR_PTR(-ENOENT); + else + old =3D inode->i_op->lookup(inode, dentry, + flags | LOOKUP_SHARED); + inode_unlock_shared(inode); d_lookup_done(dentry); if (unlikely(old)) { dput(dentry); @@ -1935,26 +1966,14 @@ static noinline struct dentry *lookup_slow(const st= ruct qstr *name, struct dentry *dir, unsigned int flags) { - struct inode *inode =3D dir->d_inode; - struct dentry *res; - inode_lock_shared(inode); - res =3D __lookup_slow(name, dir, flags | LOOKUP_SHARED); - inode_unlock_shared(inode); - return res; + return __lookup_slow(name, dir, flags | LOOKUP_SHARED, TASK_NORMAL); } =20 static struct dentry *lookup_slow_killable(const struct qstr *name, struct dentry *dir, unsigned int flags) { - struct inode *inode =3D dir->d_inode; - struct dentry *res; - - if (inode_lock_shared_killable(inode)) - return ERR_PTR(-EINTR); - res =3D __lookup_slow(name, dir, flags | LOOKUP_SHARED); - inode_unlock_shared(inode); - return res; + return __lookup_slow(name, dir, flags | LOOKUP_SHARED, TASK_KILLABLE); } =20 static inline int may_lookup(struct mnt_idmap *idmap, @@ -2908,18 +2927,26 @@ static struct dentry *__start_dirop(struct dentry *= parent, struct qstr *name, struct dentry *dentry; struct inode *dir =3D d_inode(parent); =20 - if (state =3D=3D TASK_KILLABLE) { - int ret =3D down_write_killable_nested(&dir->i_rwsem, - I_MUTEX_PARENT); - if (ret) - return ERR_PTR(ret); - } else { - inode_lock_nested(dir, I_MUTEX_PARENT); - } - dentry =3D lookup_one_qstr_excl(name, parent, lookup_flags); - if (IS_ERR(dentry)) + while(1) { + dentry =3D lookup_one_qstr(name, parent, lookup_flags, state); + if (IS_ERR(dentry)) + return dentry; + if (state =3D=3D TASK_KILLABLE) { + if (down_write_killable_nested(&dir->i_rwsem, I_MUTEX_PARENT) !=3D 0) { + d_lookup_done(dentry); + dput(dentry); + return ERR_PTR(-EINTR); + } + } else { + inode_lock_nested(dir, I_MUTEX_PARENT); + } + if (d_in_lookup(dentry) || + (!d_unhashed(dentry) && dentry->d_parent =3D=3D parent)) + return dentry; inode_unlock(dir); - return dentry; + d_lookup_done(dentry); + dput(dentry); + } } =20 /** @@ -3830,26 +3857,37 @@ __start_renaming(struct renamedata *rd, int lookup_= flags, if (rd->flags & RENAME_NOREPLACE) target_flags |=3D LOOKUP_EXCL; =20 - trap =3D lock_rename(rd->old_parent, rd->new_parent); - if (IS_ERR(trap)) - return PTR_ERR(trap); - - d1 =3D lookup_one_qstr_excl(old_last, rd->old_parent, - lookup_flags); +retry: + d1 =3D lookup_one_qstr(old_last, rd->old_parent, + lookup_flags, TASK_NORMAL); err =3D PTR_ERR(d1); if (IS_ERR(d1)) - goto out_unlock; + goto out_err; =20 - d2 =3D lookup_one_qstr_excl(new_last, rd->new_parent, - lookup_flags | target_flags); + d2 =3D lookup_one_qstr(new_last, rd->new_parent, + lookup_flags | target_flags, TASK_NORMAL); err =3D PTR_ERR(d2); if (IS_ERR(d2)) goto out_dput_d1; =20 + trap =3D lock_rename(rd->old_parent, rd->new_parent); + err =3D PTR_ERR(trap); + if (IS_ERR(trap)) + goto out_unlock; + + if (unlikely((!d_in_lookup(d1) && d_unhashed(d1)) || d1->d_parent !=3D rd= ->old_parent || + (!d_in_lookup(d2) && d_unhashed(d2)) || d2->d_parent !=3D rd->new_p= arent)) { + unlock_rename(rd->old_parent, rd->new_parent); + d_lookup_done(d1); dput(d1); + d_lookup_done(d2); dput(d2); + dput(trap); + goto retry; + } + if (d1 =3D=3D trap) { /* source is an ancestor of target */ err =3D -EINVAL; - goto out_dput_d2; + goto out_unlock; } =20 if (d2 =3D=3D trap) { @@ -3858,7 +3896,7 @@ __start_renaming(struct renamedata *rd, int lookup_fl= ags, err =3D -EINVAL; else err =3D -ENOTEMPTY; - goto out_dput_d2; + goto out_unlock; } =20 rd->old_dentry =3D d1; @@ -3866,14 +3904,14 @@ __start_renaming(struct renamedata *rd, int lookup_= flags, dget(rd->old_parent); return 0; =20 -out_dput_d2: +out_unlock: + unlock_rename(rd->old_parent, rd->new_parent); d_lookup_done(d2); dput(d2); out_dput_d1: d_lookup_done(d1); dput(d1); -out_unlock: - unlock_rename(rd->old_parent, rd->new_parent); +out_err: return err; } =20 @@ -3927,10 +3965,22 @@ __start_renaming_dentry(struct renamedata *rd, int = lookup_flags, if (rd->flags & RENAME_NOREPLACE) target_flags |=3D LOOKUP_EXCL; =20 - /* Already have the dentry - need to be sure to lock the correct parent */ +retry: + d2 =3D lookup_one_qstr(new_last, rd->new_parent, + lookup_flags | target_flags, TASK_NORMAL); + err =3D PTR_ERR(d2); + if (IS_ERR(d2)) + goto out_unlock; + + /* + * Already have the old_dentry - need to be sure to lock + * the correct parent + */ trap =3D lock_rename_child(old_dentry, rd->new_parent); + err =3D PTR_ERR(trap); if (IS_ERR(trap)) - return PTR_ERR(trap); + goto out_dput_d2; + if (d_unhashed(old_dentry) || (rd->old_parent && rd->old_parent !=3D old_dentry->d_parent)) { /* dentry was removed, or moved and explicit parent requested */ @@ -3938,16 +3988,19 @@ __start_renaming_dentry(struct renamedata *rd, int = lookup_flags, goto out_unlock; } =20 - d2 =3D lookup_one_qstr_excl(new_last, rd->new_parent, - lookup_flags | target_flags); - err =3D PTR_ERR(d2); - if (IS_ERR(d2)) - goto out_unlock; + if (unlikely((!d_in_lookup(d2) && d_unhashed(d2)) || + d2->d_parent !=3D rd->new_parent)) { + /* d2 was moved/removed before lock - repeat lookup */ + unlock_rename(old_dentry->d_parent, rd->new_parent); + d_lookup_done(d2); dput(d2); + dput(trap); + goto retry; + } =20 if (old_dentry =3D=3D trap) { /* source is an ancestor of target */ err =3D -EINVAL; - goto out_dput_d2; + goto out_unlock; } =20 if (d2 =3D=3D trap) { @@ -3956,7 +4009,7 @@ __start_renaming_dentry(struct renamedata *rd, int lo= okup_flags, err =3D -EINVAL; else err =3D -ENOTEMPTY; - goto out_dput_d2; + goto out_unlock; } =20 rd->old_dentry =3D dget(old_dentry); @@ -3964,11 +4017,11 @@ __start_renaming_dentry(struct renamedata *rd, int = lookup_flags, rd->old_parent =3D dget(old_dentry->d_parent); return 0; =20 +out_unlock: + unlock_rename(old_dentry->d_parent, rd->new_parent); out_dput_d2: d_lookup_done(d2); dput(d2); -out_unlock: - unlock_rename(old_dentry->d_parent, rd->new_parent); return err; } =20 @@ -4319,8 +4372,19 @@ static struct dentry *atomic_open(const struct path = *path, struct dentry *dentry =20 file->__f_path.dentry =3D DENTRY_NOT_SET; file->__f_path.mnt =3D path->mnt; - error =3D dir->i_op->atomic_open(dir, dentry, file, - open_to_namei_flags(open_flag), mode); + + if (open_flag & O_CREAT) + inode_lock(dir); + else + inode_lock_shared(dir); + if (dentry->d_inode) + error =3D finish_no_open(file, NULL); + else if (unlikely(IS_DEADDIR(dir))) + error =3D -ENOENT; + else + error =3D dir->i_op->atomic_open(dir, dentry, file, + open_to_namei_flags(open_flag), + mode); d_lookup_done(dentry); if (!error) { if (file->f_mode & FMODE_OPENED) { @@ -4339,6 +4403,13 @@ static struct dentry *atomic_open(const struct path = *path, struct dentry *dentry error =3D -ENOENT; } } + if (!error && (file->f_mode & FMODE_CREATED)) + fsnotify_create(dir, dentry); + if (open_flag & O_CREAT) + inode_unlock(dir); + else + inode_unlock_shared(dir); + if (error) { dput(dentry); dentry =3D ERR_PTR(error); @@ -4372,10 +4443,6 @@ static struct dentry *lookup_open(struct nameidata *= nd, struct file *file, struct dentry *dentry; int error, create_error =3D 0; umode_t mode =3D op->mode; - unsigned int shared_flag =3D (op->open_flag & O_CREAT) ? 0 : LOOKUP_SHARE= D; - - if (unlikely(IS_DEADDIR(dir_inode))) - return ERR_PTR(-ENOENT); =20 file->f_mode &=3D ~FMODE_CREATED; dentry =3D d_lookup(dir, &nd->last); @@ -4420,7 +4487,7 @@ static struct dentry *lookup_open(struct nameidata *n= d, struct file *file, if (open_flag & O_CREAT) { if (open_flag & O_EXCL) open_flag &=3D ~O_TRUNC; - mode =3D vfs_prepare_mode(idmap, dir->d_inode, mode, mode, mode); + mode =3D vfs_prepare_mode(idmap, dir_inode, mode, mode, mode); if (likely(got_write)) create_error =3D may_o_create(idmap, &nd->path, dentry, mode); @@ -4439,8 +4506,15 @@ static struct dentry *lookup_open(struct nameidata *= nd, struct file *file, } =20 if (d_in_lookup(dentry)) { - struct dentry *res =3D dir_inode->i_op->lookup(dir_inode, dentry, - nd->flags | shared_flag); + struct dentry *res; + + inode_lock_shared(dir_inode); + if (IS_DEADDIR(dir_inode)) + res =3D ERR_PTR(-ENOENT); + else + res =3D dir_inode->i_op->lookup(dir_inode, dentry, + nd->flags | LOOKUP_SHARED); + inode_unlock_shared(dir_inode); d_lookup_done(dentry); if (unlikely(res)) { if (IS_ERR(res)) { @@ -4459,15 +4533,22 @@ static struct dentry *lookup_open(struct nameidata = *nd, struct file *file, if (error) goto out_dput; =20 - file->f_mode |=3D FMODE_CREATED; - audit_inode_child(dir_inode, dentry, AUDIT_TYPE_CHILD_CREATE); - if (!dir_inode->i_op->create) { - error =3D -EACCES; - goto out_dput; - } + inode_lock(dir_inode); + if (!dentry->d_inode && !unlikely(IS_DEADDIR(dir_inode))) { + file->f_mode |=3D FMODE_CREATED; + audit_inode_child(dir_inode, dentry, AUDIT_TYPE_CHILD_CREATE); + if (!dir_inode->i_op->create) { + error =3D -EACCES; + goto out_dput; + } =20 - error =3D dir_inode->i_op->create(idmap, dir_inode, dentry, - mode, open_flag & O_EXCL); + error =3D dir_inode->i_op->create(idmap, dir_inode, dentry, + mode, open_flag & O_EXCL); + if (!error) + fsnotify_create(dir_inode, dentry); + } else if (!dentry->d_inode) + error =3D -ENOENT; + inode_unlock(dir_inode); if (error) goto out_dput; } @@ -4522,7 +4603,6 @@ static const char *open_last_lookups(struct nameidata= *nd, struct file *file, const struct open_flags *op) { struct delegated_inode delegated_inode =3D { }; - struct dentry *dir =3D nd->path.dentry; int open_flag =3D op->open_flag; bool got_write =3D false; struct dentry *dentry; @@ -4562,22 +4642,11 @@ static const char *open_last_lookups(struct nameida= ta *nd, * dropping this one anyway. */ } - if (open_flag & O_CREAT) - inode_lock(dir->d_inode); - else - inode_lock_shared(dir->d_inode); dentry =3D lookup_open(nd, file, op, got_write, &delegated_inode); if (!IS_ERR(dentry)) { - if (file->f_mode & FMODE_CREATED) - fsnotify_create(dir->d_inode, dentry); if (file->f_mode & FMODE_OPENED) fsnotify_open(file); } - if (open_flag & O_CREAT) - inode_unlock(dir->d_inode); - else - inode_unlock_shared(dir->d_inode); - if (got_write) mnt_drop_write(nd->path.mnt); =20 --=20 2.50.0.107.gf914562f5916.dirty From nobody Tue Apr 7 14:39:35 2026 Received: from flow-b6-smtp.messagingengine.com (flow-b6-smtp.messagingengine.com [202.12.124.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1883B3B0AC3; Thu, 12 Mar 2026 21:58:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352730; cv=none; b=sRITVV3t4lyVcazicXpR1awjN2tuFhEHfkb5c11UVzL/t1lHgbQZI116EOrPFT3lxzoN8iWrunGLzZCNlHiL/CReHNIY88QeMnZXqXverrS8iFNylfmxSSfF4T4QQSzywkLyFwep45hzDEbyuIY4d0FFAmiFGmIcapJ/Yti2ME0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773352730; c=relaxed/simple; bh=UmfJbnuU/Yo/a8QU+2YFRiWg5kbx4wC2VnpwUVdazVw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hDqY6QdrwaePmeIh0NSczvXxM0KAVlMcXAa4h9lgYz7SP8uH81BWR3+50508hO09CyXciFBcPEJxgjHcS8uleJwCtoh2yESNAyykPMY2930tPuLPHby7yDLCJ6Vl4HCqW8a5h4sjscobNfhW3y9giTUvvBmzP3s0Il7mWCSoGUk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=blzcrDgL; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=ixHPrpEO; arc=none smtp.client-ip=202.12.124.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="blzcrDgL"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="ixHPrpEO" Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailflow.stl.internal (Postfix) with ESMTP id 4DDDD1301B67; Thu, 12 Mar 2026 17:58:46 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-10.internal (MEProxy); Thu, 12 Mar 2026 17:58:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm1; t=1773352726; x=1773359926; bh=2wACx9EwCsU2MDL/6t9ARpFPHpQPm8JZgOjdNVtpbNE=; b= blzcrDgLn4ZT1/j/qNPwj10MGyDDKhidDzBQXDLYeoY4Yltme0biw2IT9ktAbaOb N7qFTQgNbIDpTUtHqfGoyMmpUnkIB5afxID4LfkxBWIe/3ZjfNoJeD8//kPAuxN+ gG7mt8T+9KsDqj6oOqhnO7tq1PyR3O3qlNuDj4XyU8/suvadyNcwIMrRH79WoZyr oaxRL1ArA2O4uHcrh9ILrwXJWcm6ni4lXh4xLKgPm1bNw/98wN/aUlWXDActEM1M 44KhqBaswgoORV7MrH5Sl9r6bWdoAtxSBWWS8K5XiUC97v+bt+lYIP/MePsALlc1 0G9KqiqnN4hwv+H1715/Vw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773352726; x=1773359926; bh=2 wACx9EwCsU2MDL/6t9ARpFPHpQPm8JZgOjdNVtpbNE=; b=ixHPrpEOU9DFEicZZ zRVVExlYGJIKXL1t1vKaHDUivTDQpq17RVcDlcnpcX+oEEwR4o6fk1VFpaf7ELpu qPcrp1pU+E9aBsRq6LqGRwEyfCxFOAG/eZBuveJEVZ604l67sEjztB/T1VzgaPNq m1SQq5YT9ScU672gnZ9KQZAxk1dZBg6iIh/thQcnTYmFTZUE8fOl96euvWClr0Sk Jw4UArEOMp9nx8kYqCM/xH1Gu6MmI3GoPxnw+0BPKXleygi8xEj4rpevltF2XXQx AycZ8p2EmhSDx22kqIc0KRGYEOLQglNymJH4IFUMck56rrI6KAzuPWriwWjrqJO4 3dPjg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeejledvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohephedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtoheplhhinhhugidqgihfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpd hrtghpthhtoheplhhinhhugidqthhrrggtvgdqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrh hnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvgigthegsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlh drohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 17:58:32 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Carlos Maiolino , Miklos Szeredi , Amir Goldstein , Jan Harkes , Hugh Dickins , Baolin Wang , David Howells , Marc Dionne , Steve French , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Andreas Hindborg , Breno Leitao , "Theodore Ts'o" , Andreas Dilger , Steven Rostedt , Masami Hiramatsu , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , Tyler Hicks , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeremy Kerr , Ard Biesheuvel Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, coda@cs.cmu.edu, linux-mm@kvack.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 53/53] VFS: remove LOOKUP_SHARED Date: Fri, 13 Mar 2026 08:12:40 +1100 Message-ID: <20260312214330.3885211-54-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260312214330.3885211-1-neilb@ownmail.net> References: <20260312214330.3885211-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown ->lookup is now always called with a shared lock and LOOKUP_SHARED set, so we can discard that flag and remove the code for when it wasn't set. Signed-off-by: NeilBrown --- fs/afs/dir.c | 10 ++-------- fs/dcache.c | 13 +++---------- fs/namei.c | 10 +++++----- fs/xfs/xfs_iops.c | 3 +-- include/linux/dcache.h | 3 +-- include/linux/namei.h | 3 +-- 6 files changed, 13 insertions(+), 29 deletions(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index f259ca2da383..29e39aeaf654 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -938,10 +938,7 @@ static struct dentry *afs_lookup_atsys(struct inode *d= ir, struct dentry *dentry, /* Calling d_alloc_parallel() while holding parent locked is undesirable. * We don't really need the lock any more. */ - if (flags & LOOKUP_SHARED) - inode_unlock_shared(dir); - else - inode_unlock(dir); + inode_unlock_shared(dir); for (i =3D 0; i < subs->nr; i++) { name =3D subs->subs[i]; len =3D dentry->d_name.len - 4 + strlen(name); @@ -966,10 +963,7 @@ static struct dentry *afs_lookup_atsys(struct inode *d= ir, struct dentry *dentry, */ ret =3D NULL; out_s: - if (flags & LOOKUP_SHARED) - inode_lock_shared(dir); - else - inode_lock_nested(dir, I_MUTEX_PARENT); + inode_lock_shared(dir); afs_put_sysnames(subs); kfree(buf); out_p: diff --git a/fs/dcache.c b/fs/dcache.c index f573716d1a04..2d694e14bd22 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2224,7 +2224,6 @@ EXPORT_SYMBOL(d_obtain_root); * @dentry: the negative dentry that was passed to the parent's lookup func * @inode: the inode case-insensitive lookup has found * @name: the case-exact name to be associated with the returned dentry - * @bool: %true if lookup was performed with LOOKUP_SHARED * * This is to avoid filling the dcache with case-insensitive names to the * same inode, only the actual correct case is stored in the dcache for @@ -2237,7 +2236,7 @@ EXPORT_SYMBOL(d_obtain_root); * the exact case, and return the spliced entry. */ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, - struct qstr *name, bool shared) + struct qstr *name) { struct dentry *found, *res; =20 @@ -2257,19 +2256,13 @@ struct dentry *d_add_ci(struct dentry *dentry, stru= ct inode *inode, * d_in_lookup() (so ->d_parent is stable) and we are near the * end ->lookup() and will shortly drop the lock anyway. */ - if (shared) - inode_unlock_shared(d_inode(dentry->d_parent)); - else - inode_unlock(d_inode(dentry->d_parent)); + inode_unlock_shared(d_inode(dentry->d_parent)); found =3D d_alloc_parallel(dentry->d_parent, name); if (IS_ERR(found) || !d_in_lookup(found)) { iput(inode); return found; } - if (shared) - inode_lock_shared(d_inode(dentry->d_parent)); - else - inode_lock_nested(d_inode(dentry->d_parent), I_MUTEX_PARENT); + inode_lock_shared(d_inode(dentry->d_parent)); res =3D d_splice_alias(inode, found); if (res) { d_lookup_done(found); diff --git a/fs/namei.c b/fs/namei.c index 3d213070a515..9e2ac3077f72 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1826,7 +1826,7 @@ static struct dentry *lookup_one_qstr(const struct qs= tr *name, if (unlikely(IS_DEADDIR(dir))) old =3D ERR_PTR(-ENOENT); else - old =3D dir->i_op->lookup(dir, dentry, flags | LOOKUP_SHARED); + old =3D dir->i_op->lookup(dir, dentry, flags); inode_unlock_shared(dir); if (unlikely(old)) { d_lookup_done(dentry); @@ -1951,7 +1951,7 @@ static struct dentry *__lookup_slow(const struct qstr= *name, old =3D ERR_PTR(-ENOENT); else old =3D inode->i_op->lookup(inode, dentry, - flags | LOOKUP_SHARED); + flags); inode_unlock_shared(inode); d_lookup_done(dentry); if (unlikely(old)) { @@ -1966,14 +1966,14 @@ static noinline struct dentry *lookup_slow(const st= ruct qstr *name, struct dentry *dir, unsigned int flags) { - return __lookup_slow(name, dir, flags | LOOKUP_SHARED, TASK_NORMAL); + return __lookup_slow(name, dir, flags, TASK_NORMAL); } =20 static struct dentry *lookup_slow_killable(const struct qstr *name, struct dentry *dir, unsigned int flags) { - return __lookup_slow(name, dir, flags | LOOKUP_SHARED, TASK_KILLABLE); + return __lookup_slow(name, dir, flags, TASK_KILLABLE); } =20 static inline int may_lookup(struct mnt_idmap *idmap, @@ -4513,7 +4513,7 @@ static struct dentry *lookup_open(struct nameidata *n= d, struct file *file, res =3D ERR_PTR(-ENOENT); else res =3D dir_inode->i_op->lookup(dir_inode, dentry, - nd->flags | LOOKUP_SHARED); + nd->flags); inode_unlock_shared(dir_inode); d_lookup_done(dentry); if (unlikely(res)) { diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 2641061ba1db..cfd1cb42a29f 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -35,7 +35,6 @@ #include #include #include -#include // for LOOKUP_SHARED =20 /* * Directories have different lock order w.r.t. mmap_lock compared to regu= lar @@ -370,7 +369,7 @@ xfs_vn_ci_lookup( /* else case-insensitive match... */ dname.name =3D ci_name.name; dname.len =3D ci_name.len; - dentry =3D d_add_ci(dentry, VFS_I(ip), &dname, !!(flags & LOOKUP_SHARED)); + dentry =3D d_add_ci(dentry, VFS_I(ip), &dname); kfree(ci_name.name); return dentry; } diff --git a/include/linux/dcache.h b/include/linux/dcache.h index eb1a59b6fca7..74607dbcb7f0 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -250,8 +250,7 @@ struct dentry *d_duplicate(struct dentry *dentry); /* weird procfs mess; *NOT* exported */ extern struct dentry * d_splice_alias_ops(struct inode *, struct dentry *, const struct dentry_operations *); -extern struct dentry * d_add_ci(struct dentry *, struct inode *, struct qs= tr *, - bool); +extern struct dentry * d_add_ci(struct dentry *, struct inode *, struct qs= tr *); extern bool d_same_name(const struct dentry *dentry, const struct dentry *= parent, const struct qstr *name); extern struct dentry *d_find_any_alias(struct inode *inode); diff --git a/include/linux/namei.h b/include/linux/namei.h index cb79e84c718d..643d862a7fda 100644 --- a/include/linux/namei.h +++ b/include/linux/namei.h @@ -37,9 +37,8 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT}; #define LOOKUP_CREATE BIT(17) /* ... in object creation */ #define LOOKUP_EXCL BIT(18) /* ... in target must not exist */ #define LOOKUP_RENAME_TARGET BIT(19) /* ... in destination of rename() */ -#define LOOKUP_SHARED BIT(20) /* Parent lock is held shared */ =20 -/* 3 spare bits for intent */ +/* 4 spare bits for intent */ =20 /* Scoping flags for lookup. */ #define LOOKUP_NO_SYMLINKS BIT(24) /* No symlink crossing. */ --=20 2.50.0.107.gf914562f5916.dirty