From nobody Tue Apr 7 16:16:41 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