From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-a3-smtp.messagingengine.com (fout-a3-smtp.messagingengine.com [103.168.172.146]) (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 7B2AA35E92B; Mon, 27 Apr 2026 03:38:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.146 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777261103; cv=none; b=Wd5WyW6WfXcVY7MBk9vZN8Mf3hjEwqB56/yFgMJdNEbDU7qPq10rs2BfW6NPF2BbBFoJisvOuyQgf5V1FbkIB6O3xLPm1Sz9TWhlMhHTyAxUj0z7MCQteNJRmPrgHDviJakvpBHbsi28ThhSNiL6trGhn/0Fdp6NTF0sKzn/ZY0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777261103; c=relaxed/simple; bh=WZ7UveSYOpovothb9tiW51mp2dtPIr+PjSBgGKNYxBk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZfelDsM/xlqvUAn+aEJ3SdkF4ZzNPnlVsOgd8gsL8/CJNvsjoWv4TM2RcM9NHAZqvzZ6E03iELPcMMEVI98uZekK5SQ+oRlIjnFc7SoWjB+yx9Yug2G3Wr4uIX8BprIg6T2xCvpu14r/c+sxm3o/WFXBWdA2KGGJg2SszaZu180= 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=r6/kzYCF; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=ngs6EhWZ; arc=none smtp.client-ip=103.168.172.146 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="r6/kzYCF"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="ngs6EhWZ" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id BFA70EC033E; Sun, 26 Apr 2026 23:38:21 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Sun, 26 Apr 2026 23:38:21 -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=fm2; t=1777261101; x=1777347501; bh=qNsDUPxIIaAA/63Z6to/nWQPQowfPrhVEFZuvx5A43o=; b= r6/kzYCFAquTeO1wlwvjKxCsUOW7TMSQNtGPG6AKh+5TIpty1dMOfRoHnPowMVBY 6LAJ4LRW5MJ1493OfTwiRePIZtXCe+4ozcHOecAA3SIKwkeVLSHMotLxccE55y8C QlDES/TEsl3lT1DhRBAHEEQv63ehnD0wYi3lE5nWCwr9Nt+qBhq4cX8VpGrei2LK GEM/Ee/3szdPdqRpJAQ3foU63YchCNm2YDdA6METDQ61tG+4/C9HGuiUsSoir9mH aAvlD30rL0vXFetx6uaGWsydkRtLKCfKOs24HjwaZa06teNd1CHMi93ZpjnNVJvW qeu1GUOXC64DdKyj56AA6w== 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=fm2; t=1777261101; x=1777347501; bh=q NsDUPxIIaAA/63Z6to/nWQPQowfPrhVEFZuvx5A43o=; b=ngs6EhWZRkMODM3Mn 13raWoG8isivHcdEpXwKHK0vh223CHClFEwU3f/H85d/o84sT8v2/5UdbrI6HYW8 y4vTyjut55NSo+JNFUSspcNSpUf5dM+hZezAIezhxCLJAJVxa2J917R4CjfM5lPD ct2jG8UoN5ELrk5jwNpS/UHMfSmwB5eXJ2Yg6UPVNlWMjDdsGHxMVSS3wuVw7bZp V+icccTGFs3WzMNjcYmfa1MKr87cauI2Jkl6TizcXjigBU7qSq8MDGUyyiCGMG2n rES4ZDapwky7qXfPbuC9Zwn6brsk0hkKZtFs4KYbtYSdKNzq1PDpxDpuM3iwXz+z wLvaQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdejjeeivdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefhvfevufffkffojghfrhgggfestdekredtredttdenucfhrhhomheppfgvihhluehr ohifnhcuoehnvghilhgssehofihnmhgrihhlrdhnvghtqeenucggtffrrghtthgvrhhnpe evveekffduueevhfeigefhgfdukedtleekjeeitdejudfgueekvdekffdvfedvudenucev lhhushhtvghrufhiiigvpeefnecurfgrrhgrmhepmhgrihhlfhhrohhmpehnvghilhgsse hofihnmhgrihhlrdhnvghtpdhnsggprhgtphhtthhopedujedpmhhouggvpehsmhhtphho uhhtpdhrtghpthhtohepvhhirhhoseiivghnihhvrdhlihhnuhigrdhorhhgrdhukhdprh gtphhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhg pdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprh gtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhg pdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprh gtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdprhgtphht thhopehmihhklhhoshesshiivghrvgguihdrhhhupdhrtghpthhtohepjhgrtghksehsuh hsvgdrtgiipdhrtghpthhtohepjhhksehoiihlrggsshdrohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 26 Apr 2026 23:38:17 -0400 (EDT) From: NeilBrown To: Linus Torvalds , Alexander Viro , Christian Brauner , Jan Kara , Jeff Layton , Trond Myklebust , Anna Schumaker , Miklos Szeredi , Amir Goldstein , Jeremy Kerr , Ard Biesheuvel , Christoph Hellwig Cc: linux-efi@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel Subject: [PATCH v2 18/19] nfs: use d_alloc_noblock() in silly-rename Date: Mon, 27 Apr 2026 13:29:51 +1000 Message-ID: <20260427033527.773006-19-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260427033527.773006-1-neilb@ownmail.net> References: <20260427033527.773006-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 | 51 ++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c index 43ea897943c0..1ac9bd2a63b2 100644 --- a/fs/nfs/unlink.c +++ b/fs/nfs/unlink.c @@ -445,7 +445,7 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry) static unsigned int sillycounter; unsigned char silly[SILLYNAME_LEN + 1]; unsigned long long fileid; - struct dentry *sdentry; + struct dentry *sdentry, *old; struct inode *inode = d_inode(dentry); struct rpc_task *task; int error = -EBUSY; @@ -462,26 +462,37 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry) fileid = NFS_FILEID(d_inode(dentry)); - sdentry = 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); + sdentry = d_alloc_noblock(dentry->d_parent, &QSTR(silly)); + if (sdentry == 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 = 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) != NULL); /* need negative lookup */ + goto newname; + } + /* This name isn't known locally - check on server */ + old = 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; + } ihold(inode); -- 2.50.0.107.gf914562f5916.dirty