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