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