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