From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-a5-smtp.messagingengine.com (fhigh-a5-smtp.messagingengine.com [103.168.172.156]) (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 7523D23EAB3; Mon, 27 Apr 2026 04:08:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.156 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777262890; cv=none; b=lAEqbbqN6ja0Gjyz2I/5IkqBnvjLhW2yK4aJDgD80i97JN+LJB1hhb7wwIjgjGc+v6gdzWNzACxtb3oUtzUaX22MytRZR05duQlSdggerOXAEtsw6M7VI3QmJ0TIWwS4fM/6i2XcUW9Y1OJ4o8z/V1FuwwlMz03+mKkx8vm7bac= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777262890; c=relaxed/simple; bh=JM9LLqSf9XLlCtfxMB7Z+hQXEmomGURwLcnDXDC0yHY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sHUxp7QlBG4woY/Drl12+K4Pogg+dYmvLMek/I91PstVSAtvXQ4/zvH21vBUAO7nFL4bU4pl9vJzpNiTlzqeo4sxO3yQ9gSKluuAYd/6f5Lx+tUqUHKpR2eTMTwIDp+EVkogg2lh210++blOchPTUaxnBPsSGR52ksHLagj3Lc4= 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=XW8oWgK1; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=c78zhWhA; arc=none smtp.client-ip=103.168.172.156 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="XW8oWgK1"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="c78zhWhA" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id C112D14000B0; Mon, 27 Apr 2026 00:08:08 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Mon, 27 Apr 2026 00:08:08 -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=1777262888; x=1777349288; bh=As30Bn0VYVoxaWKi4m0aODUf1VutcCrIZEa7WHHt+uk=; b= XW8oWgK1KBqGQrsKFk9tG7WREvUEjFyiWui/Nsi0mgFW9Jn4inCszfn51AhD0bZM Lf5d7j0GEBgVCKii0Yrh9fnegRMbHH+gvyraiC/oPzbAg0sPFdCRsPZkfXmIlYGP Oyo833zp74YwCV6WUXlFfHqp1p+MAgBBCLN8ZVq9VrKVryieq7j8MkZqX2/l54SY Z8QbiWKQ+3mCcTsVOhdYDJimpMyhE0BHQSZCx0go+jaM1s1VLLo+lS6m5/bqevsM CBW6FZrmSP1vh70SAGXhZM+M4Zv5ZnZ2OnmMGqcwRDYyzW0n1anU7wkYgnFK97hr EVNr3FTVO1/454K+tAzAqA== 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=1777262888; x=1777349288; bh=A s30Bn0VYVoxaWKi4m0aODUf1VutcCrIZEa7WHHt+uk=; b=c78zhWhAgOoFgytQY MKEDCwK6jeLoETuGUGZrrxYCw4HGzGMcJ8Cvk3bsk78Of77wiiYZi8DszoyTdYCe 0n9h1qvoxAQmxCdjZ9ESo508iyd3/hNKUV1rPLqMY9+Ryo5AbCTjCnQajqajluzZ nO73dW0PXe8EkPx/Spcy/nLI+vSdGWUC6gq+VG2Nh/6FCiWnA2WmoOSmjTCK8Luk 8FPneu/GxvN9qMPaMbrLpCZRnb12dKZx+6PnEuzZLjhz9TNHP6trrSgbsPx/lThE UDRXxCESfkf5ueAJ0PPn8HSpe10Xh6Ak/xqskOQ8BIDFjQS6P3BI2W202NN9VJ6j 8G24w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdejjeeikecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefhvfevufffkffojghfrhgggfestdekredtredttdenucfhrhhomheppfgvihhluehr ohifnhcuoehnvghilhgssehofihnmhgrihhlrdhnvghtqeenucggtffrrghtthgvrhhnpe evveekffduueevhfeigefhgfdukedtleekjeeitdejudfgueekvdekffdvfedvudenucev lhhushhtvghrufhiiigvpeeinecurfgrrhgrmhepmhgrihhlfhhrohhmpehnvghilhgsse hofihnmhgrihhlrdhnvghtpdhnsggprhgtphhtthhopeduiedpmhhouggvpehsmhhtphho uhhtpdhrtghpthhtohepvhhirhhoseiivghnihhvrdhlihhnuhigrdhorhhgrdhukhdprh gtphhtthhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhg pdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprh gtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdp rhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrhhnvghlrdhorh hgpdhrtghpthhtoheplhhinhhugidqvghfihesvhhgvghrrdhkvghrnhgvlhdrohhrghdp rhgtphhtthhopehmihhklhhoshesshiivghrvgguihdrhhhupdhrtghpthhtohepjhgrtg hksehsuhhsvgdrtgiipdhrtghpthhtohepjhhksehoiihlrggsshdrohhrgh X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 27 Apr 2026 00:08:04 -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 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.org Subject: [PATCH v3 14/19] nfs: use d_splice_alias() in nfs_link() Date: Mon, 27 Apr 2026 14:01:32 +1000 Message-ID: <20260427040517.828226-15-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260427040517.828226-1-neilb@ownmail.net> References: <20260427040517.828226-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-unionfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: NeilBrown When filename_linkat() calls filename_create() which ultimately calls ->lookup, the flags LOOKUP_CREATE|LOOKUP_EXCL are passed. nfs_lookup() treats this as an exclusive create (which it is) and skips the ->lookup, leaving the dentry unchanged. Currently that means nfs_link() can get a hashed dentry (if the name was already in the cache) or an unhashed dentry (if it wasn't). As none of d_add(), d_instantiate(), d_splice_alias() could handle both of these, nfs_link() calls d_drop() and then then d_add(). Recent changes to d_splice_alias() mean that it *can* work with either hashed or unhashed dentries. Future changes to locking mean that it will be unsafe to d_drop() a dentry while an operation (in this case "link()") is still ongoing. So change to use d_splice_alias(), and not to d_drop() until an error is detected (as in that case was can't be sure what is actually on the server). Also update the comment for nfs_is_exclusive_create() to note that link(), mkdir(), mknod(), symlink() all appear as exclusive creates. Those other than link() already used d_splice_alias() via nfs_add_or_obtain(). Signed-off-by: NeilBrown --- fs/nfs/dir.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 0791fc2d161b..2c1315a02e52 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1570,6 +1570,9 @@ static int nfs_check_verifier(struct inode *dir, struct dentry *dentry, /* * Use intent information to check whether or not we're going to do * an O_EXCL create using this path component. + * Note that link(), mkdir(), mknod(), symlink() all appear as + * exclusive creation. Regular file creation could be distinguished + * with LOOKUP_OPEN. */ static int nfs_is_exclusive_create(struct inode *dir, unsigned int flags) { @@ -2676,14 +2679,15 @@ nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) old_dentry, dentry); trace_nfs_link_enter(inode, dir, dentry); - d_drop(dentry); if (S_ISREG(inode->i_mode)) nfs_sync_inode(inode); error = NFS_PROTO(dir)->link(inode, dir, &dentry->d_name); if (error == 0) { nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); ihold(inode); - d_add(dentry, inode); + d_splice_alias(inode, dentry); + } else { + d_drop(dentry); } trace_nfs_link_exit(inode, dir, dentry, error); return error; -- 2.50.0.107.gf914562f5916.dirty