From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=103.168.172.153 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795578426; b=lmzxlMVeSqa4ATR7J729IV4WFUSnNyJiGJHK2JfrfCFpd0XwrEvxLprpPJgrdGdb12v5 XH2NQaI0Cl3jJ/j7kVgzBQDrpi8QtnyNwiv2MSDFKqMjjSnBfmbb/rbhvzcLv0Dihz3dy GDR2915gR92Jyl4BBsaA/LY/Ed5ki/d9HAKwWIu2NBCshJhu+vEpck+anMKP6jZc1/z/v CFFoZQq1yNX3HD0JDA8gM3n4wpVv4dJucVvSy2QINqKSSzt4NkrWOek8mG04L+Tx7w1M0 VZz08ysvvkr/M2Ra6ggPe1DahkLPLhZpm/tMyH0hopcoUFV/cDKbe05e7qadOm4vPPw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795578426; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:Reply-To:MIME-Version:Content-Transfer-Encoding; bh=7GW90Xebke1BO6VVD+3Eb+D/Pr8y2bvy00kHZFBZIWY=; b=Ahold1W3lgY6b292e1MLOvdUQmLdS1aZxTufLaQ6QgvVkUo6znpmXrjE4h6X/135VcuP lMKIHNSLlZ3+10yTiDLdZU0xSPwiBOHwCUhA2aeJhPyqCSGCuPe5BPNzCdvTJpQQID4Fd 9kY5i5thN+WsdjGkJdFnJUP6M5InuS5x2JKrlqtAewnSg8cTM8QPqxqe9if0+mF0UoNMj EOjfMH2uVOipaJd8mf/xiofpYSXb2GCiwS73a5zhrVQLhcCI2WGy5o0CLHYqmEDCPi3SR r43pyxIq9TpXayj00G+0uEehULT9a3LZZi8jpkx+veFw7iNgLeOv8FL/eFozodQlOYg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass header.d=ownmail.net header.i=@ownmail.net header.a=rsa-sha256 header.s=fm3 header.b=MrF6e9+Z; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=TiS5M1sX; arc=none smtp.remote-ip=103.168.172.153 Received: from fhigh-a2-smtp.messagingengine.com (fhigh-a2-smtp.messagingengine.com [103.168.172.153]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABAE1606A323 for ; Wed, 25 Nov 2026 03:47:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org ABAE1606A323 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, unprotected) header.d=ownmail.net header.i=@ownmail.net header.a=rsa-sha256 header.s=fm3 header.b=MrF6e9+Z; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=TiS5M1sX Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfhigh.phl.internal (Postfix) with ESMTP id E1FCF1400366 for ; Tue, 24 Nov 2026 22:47:04 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-12.internal (MEProxy); Tue, 24 Nov 2026 22:47:04 -0500 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=fm3; t=1795578424; x=1795664824; bh=7GW90Xebke1BO6VVD+3Eb+D/Pr8y2bvy00kHZFBZIWY=; b= MrF6e9+ZMBTZn/E8MbMazi5xiWgag5leKJkWRE3yJiRs3KF0cDsEu8CLxxqy4du+ B5SPDpYwQkJZdR4omxRqKsYznywT9axCihKe2BmV3UuArLInERHrvbdwh1LIGEI7 FBbWtRhIzFq51gfx1aubPoAFYLa8GrVUymBFV7SX2O8QY3Q2TwNEajuCriDn16Vm UeA9IxU9PFJB2hgx2vOzDp9vpKyTvfQ3VXpsbZUN6fLFySDSR+cs9McAUZQlZYOo 0mxbpH9b8rugf0nvbmZzd874I7vEeSdbyAg51DQc3oyK/bKCnn6oAcy0ar4iL0nF OeKDVR44R14Fz8zRZ7/W/Q== 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=fm3; t=1795578424; x=1795664824; bh=7 GW90Xebke1BO6VVD+3Eb+D/Pr8y2bvy00kHZFBZIWY=; b=TiS5M1sXCm2z71YAv Rdi4q4SlJ7G6TVuL0xFGepax6Nb2Mh9/d1bErQT4vC7QKmW6PbPvWERrwDxPob8V I0VKLE+YhaZVRaPsm4VqUSynbziVM/qtO2knxlakeOqvP5HyXMUzsp5bkH8fh26C IqCFItT8+GG08H2NLrdwBui15uXc/neWHa55XkiIaJGmjj6Cn5xkK+A27mTk3TuM s5T8Zo1de3O1JIN1tL6cqV4ElIdm73nRmd8DmcrFwuNp0niSRL/XdpkzpLgyAdAP 1bWIHFgZc9peeQEj7amO2Dr7pyNHPEOui66ykO/7/Fg4X/LS+719EYToLSbxXgHl R+x2A== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=ownmail.net a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1795578424; d=ownmail.net; mf=PG5laWxiQG93bm1haWwubmV0Pg==; rt=PGxpbnV4LWtlcm5lbEB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:RYHEDMq5cSCy1LuH7i77MRFe1/JWdMXz41KFSKHveMXpT78 miegfELDp13Peyhet2x7fZgxEm3KV5jjDaKgXm4FVdasrXWhtGslJJYTOHnUi935 4jW/gqHQyKvtR+Gsr2WcPPKjOZrgvsTFqqkB53VptOQH0BDpHTYehfgb51XttzHJ C/V/CKX+bob0HXuIxx5wf7qoaCn8xTKoBsSdxzwpesmrp9UHwpb/4UHAJNu1Co+6 oIkG1adNcyCiy6dQ8xS6sIuyShvWg6NMyhaZe+sPF0Xn3x1DJYWOpyCOwFi8yz1t tJhczxhu4O06YmlnEkBmNMSSDm3ExJARIaAuKvg==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-transfer-encoding,date,feedback-id,from, in-reply-to,message-id,mime-version,references,reply-to,subject, to; Message-Instance: m=1; h=sha256:pLgtTQtuzOUYUx84zLKxXDCEnsf79PIXIsM+V8REFpk=:rKFIY2igCQNYJ/8KN9XbK5tFVEJagzy3L1EzWAznAQk=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTE4HtNMS82oETeKxjFsMonchsNmutSXRF8P4Wz/gL5NuR+PmnhI7BdBjNpxinbAbR gE9fr8C0GNc0SnxE2B+IXDaaoddndfcEJfJtcWeI4ytNiRF08hWb9RlxFjA1qgM4oFyoJi /AdIhJNfEVO0oVTJtQVCvv+X67aNRews2LQwnM5uAbOmmoGahsFhP1aXSbisfk+ds7cJJ0 OsFbDOPt7ZICh4tniydbOvMlt1+f+7jVXUCHPaOJHWPFgfTUvPivbmMoJSDdfil0VmV1q/ 2QMjPNE1ltm0/CAvjxy3k0MqWfenoOEUWjyOM0HmgbohwH+N/2hScfzSSITnIBzePDS5oC YFHOQAnyEuAqnfgBtSnnYtOgAjzsJ1IwaGTozxClzxjIqWdOYHSG2ZsI/tZG4wAeX3eMfc uJ/8/Rcsdctsd3B45F/OegSCjYq/aOokBPrWswWQE/p5+P4uAExV5ufFMfgf2APnWeThom amUcpiyHxktVYgGYGNuRcWn2NXITXMXNo13y5gmT2jl+YvZrz9VOZhwDLVNHmWqit/cdsW G1FIxC2vMuUI2zWvy702UXXJotPnVh2hCwxYjLg69wHIC4s3wx67DJLjXEbBdBMAgkBthE aatYGNh8qBvSofBxsnjcg2GXutvcXGcrdWMNPpZ9x1pgi3lPC8HzTx5+SqWg X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 24 Nov 2026 22:47:00 -0500 (EST) From: NeilBrown To: Alexander Viro , Christian Brauner Cc: David Howells , Marc Dionne , Jan Harkes , coda@cs.cmu.edu, Jan Kara , Richard Weinberger , Anton Ivanov , Johannes Berg , Jeff Layton , Amir Goldstein , linux-kernel@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-fsdevel@vger.kernel.org, linux-um@lists.infradead.org, linux-afs@lists.infradead.org Subject: [PATCH v3 09/11] VFS: drop parent lock across d_alloc_parallel() in d_add_ci() Date: Wed, 25 Nov 2026 14:16:47 +1100 Message-ID: <20261125034543.4084039-10-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20261125034543.4084039-1-neilb@ownmail.net> References: <20261125034543.4084039-1-neilb@ownmail.net> Reply-To: NeilBrown X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: NeilBrown A proposed change will invert the lock ordering between d_alloc_parallel() and inode_lock() on the parent. When that happens it will not be safe to call d_alloc_parallel() while holding the parent lock - even shared. It is already *safe* to call d_alloc_parallel() without holding the parent lock - providing any filesystem that does so doesn't d_drop or d_hash in the middle of an operation. Those filesystems which use d_add_ci() don't d_drop(). We don't need to keep the parent lock held when d_add_ci() is run - the VFS doesn't need it as dentry is exclusively held due to DCACHE_PAR_LOOKUP and the filesystem has finished its work. So drop and reclaim the lock to avoid future deadlock. Signed-off-by: NeilBrown --- fs/dcache.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 2ad39c1515b7..ed957f090247 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2472,17 +2472,30 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, iput(inode); return found; } + /* + * We are holding parent lock and mustn't wait + * for a d_in_lookup() dentry. We can safely drop the + * parent lock and reclaim it as we have exclusive + * access to dentry as it is d_in_lookup() (so + * ->d_parent is stable) and we are near the end + * ->lookup() and will shortly drop the lock anyway. + * We cannot retake the lock while the new dentry is in-lookup + */ + inode_unlock_shared(d_inode(dentry->d_parent)); found = d_alloc_parallel(dentry->d_parent, name); if (IS_ERR(found) || !d_in_lookup(found)) { iput(inode); - return found; + goto out_relock; } res = d_splice_alias(inode, found); if (res) { d_lookup_done(found); dput(found); - return res; + found = res; } +out_relock: + d_lookup_done(dentry); + inode_lock_shared(d_inode(dentry->d_parent)); return found; } EXPORT_SYMBOL(d_add_ci); -- 2.50.0.107.gf914562f5916.dirty