From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=202.12.124.146 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795988076; b=tl+ABWzoIKsOHSSNRs+HhBrxx45XHEDNyJXypJb6A2jqE+lePcCPZONvi0Iqd7AGpbCZ yyatNwkiA9o30rouOkwuJ0id4qvjDCXsrm881QHxtoACVuyGOPq7cmPxxCYiTVAGKjQgh 73l/uEQ+Bo+W/PhlAeVAWhJfw3Gd80MeGraIuIGcC9KWyVeXb9E6QMG+RrqM1a7jVIeLl IqtrFPqFUsMMoAhMHoLQ/udyYk+Wdg6510a9ecMPlkAiQ3k3AgYTwRSgKxSJ58iZ7k/P9 P782NejYK0mUD55JCCKKtrVQACZ4Gbe9VS+HlrACEdMUr3hXf/paNZ4ZH70rjzBFrKw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795988076; 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=n/4VZ7nVHNMeVsBo8A1rFyijwIjJDPxIuKDhcmNmX1g=; b=ArxgAftM7tOiuhaWC9uG+2IQCxJLvybhZBS7fRUMV6uXSYdJ6rUFr68yWq4m3o41J5/z O1CnDDOKfQndV8VwgjFe7vl7gpT6IH1TmgmybSNiBUuL23Efw21XUY1EYBoUR53Ys82EZ z92csMFAYjjKnhzFesHhJOJgiuBrVJHIDkk3zFji9hm2uNAkTw4c3XDGUBxXWks06gzIn Hl2w4RZHixEmSQzKrZq69GW1LLc8HtWJhSbvNomSZu+7kuvxgCLHjJer4TWVkUte5durl N9lHm1Z2zF3Yocf+Ahch1eqPTEPmkQCdQXdBk7o5b5sCypYavMWZNt5bJl5rRlD8sVw== 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=mWZ1H27r; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=gsKo+ow7; arc=none smtp.remote-ip=202.12.124.146 Received: from fout-b3-smtp.messagingengine.com (fout-b3-smtp.messagingengine.com [202.12.124.146]) (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 7C405606A31C for ; Sun, 29 Nov 2026 21:34:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7C405606A31C 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=mWZ1H27r; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=gsKo+ow7 Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfout.stl.internal (Postfix) with ESMTP id DE4241D0053F for ; Sun, 29 Nov 2026 16:34:34 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-11.internal (MEProxy); Sun, 29 Nov 2026 16:34:34 -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=1795988074; x=1796074474; bh=n/4VZ7nVHNMeVsBo8A1rFyijwIjJDPxIuKDhcmNmX1g=; b= mWZ1H27r3aPlgFYNuZyStwOi/GMEnoIlJRRD9UYDltxgF6NopkhPHocaPHYzifLw WjF45T150ba01ND0Iq7ruZ+GBeodj8D0ON6IGWnYWkZzgTO+VTyz25bp90dllrKp S02hNRps3NBuNRJ7TlAh96P4T9tflXhiAkUAoQKntHZEBXqc2IXdyQVFf5DNQW17 PTknMh2R8lUcAbCaWjaBmI8e3DEFsvW99hwLD4ttFlxmDVhQU+LP0/G6UuzADbay +Pkzqww8zP5che1uN9o5aJPNIFwH7zeVy53o3ztUu9DKPTnECFQb1nmYbVoTZimm UXvRw12/c8STMzIHPcNDsQ== 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=1795988074; x=1796074474; bh=n /4VZ7nVHNMeVsBo8A1rFyijwIjJDPxIuKDhcmNmX1g=; b=gsKo+ow7zpS619jAf ThX/2cZZIS5hbnrGhfH0BhfQAPDoo/5qtbAMvdZOPyBJftHCYXZfMcOYC/tbA9DX 9vLNP8tzBPNDLbysjjxkCVT3mFuoLkAP8o/1vthWAKoLWDyEcttySvNr2qefXwxk wxOmjrFdSNF0Q8Bt6q12za39uTCX6a+nlHmpA3Eg5H1wONLyzAtVbZFhWH/AKGlO h6ZJrqGVKHygtoCF7lIjLH0yG47zX9EIXg7sXAstIJ+PsIEwUOt3fUg4ULA8NGUm s/mmA+BQWfYXLYuzjZD85OYgB8DdmEsb3Mc597zkLbU+x6Tl+749kT45/eTVZttp 2eocA== 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=1795988074; d=ownmail.net; mf=PG5laWxiQG93bm1haWwubmV0Pg==; rt=PGxpbnV4LWtlcm5lbEB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:ghjGF9NdO08PrHqiIylsefdLTUOzGKPXw/cSR5DWwLFBqQa m28ltugiJRRNgN76tQFg74x2xb8AXjTcjfQ7fv/zDEfuyYAecQ2cQc0FQvWfWUgI AsVs4+XCBkFBRjqaDROkXYTtKEmAWJcQsGPYOXC5+VmkkxLOJvq4TiV6a3DcWRpq RrwcDe08e4B2SVHtGmdQRMsFaUbJYcbyhu5VzSniTDyMReq8tbhvMxB+5FE/Mi83 +sDNJsB5akazYalHPgsmHt/oyilbLUjFLe4CBYbTu70sXoxloqhp33P+IFIHhiUA JOZcRE9vul0xnz8KYhWG2vSVE8a7lQ5GF81m2oA==; 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:A9JoGhcYCGHBWFVa9I+WGDm4jHSSYu/XaavBZyAqHDw=:k+jQreKxUpf6fI/BL7k7NHY8HCtILR3ke4W3tmaNIuU=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTERuyqcLHBk8qrtJT0jNR2fvUsESQgJk9unHqY9jX9wE6FhL9iKDpYWVXOnP0mNCJ aVdYvG9YJa00KYx9biW/42BP6eXd6+ZTADzba4HSAvfKf6I5zI0YpzaxZ0Cp8TL3hTpIuP EtqvHWsdbKZnVNhdYZEbf+n96Q1VX9ODmGVpJyFotFMSR8iA6Meypg6ililxhrU5L37Enu YSYbVy9qd6HOKA5Icr/GC2TtrMKUsZ90Drnst1FhwNtEEe2sKXQdybIGMXZyRR2uVU619B gThw2TdBRih6yY8r+k24Pct3pGA/6+DkIG1e8oRFU+LkTcTUIbKJlknRS/Oiw2Zyc7uINE 7uqPk34FM0tZ3gs2dEt64CjWIw4GLhieCDX92E0RCTZcIBF4EhxIpOVjHI+vM6/N8IbufZ oDlV1FY/oC43ZlBTSxTUp/BbibhbbAdY5RIiZUmGu6qBu/fIOCIoBg/9KyaLwswhY0CTvo estiNPkeTy5TgzEW52jPIYlxLHOg+PALMDHUW0czfHEzCXOtS7xFo5Ctn4I2Cv1Pszp0UI /NK5mMfA6hAW4zlsbhS0Wx7UzzVm1lgkZexocXcY4A918mHfLh90CrN4eEcelktuGvkYaY TT5x+EWCVnVWOgwQsG86Lh4gmEHgVfAmU3PVRzze5l1WADTXQjGkk6vSsblA X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 29 Nov 2026 16:34:28 -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 v4 8/8] afs: lookup_atsys to drop and reclaim lock. Date: Mon, 30 Nov 2026 08:21:44 +1100 Message-ID: <20261129213259.2837044-9-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20261129213259.2837044-1-neilb@ownmail.net> References: <20261129213259.2837044-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 If afs is asked to lookup a name ending with @sys, it needs to look up a different name for which it might need to allocate 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 during this nested lookup. The original dentry will never be used - it is left unhashed and a dentry with the alternate name is returned. With this patch we unlock the directory and unlock (d_lookup_done) the dnetry early and reclaim the directory lock later. Then we use lookup_noperm_unlocked() for the nested lookup. Signed-off-by: NeilBrown --- fs/afs/dir.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index b40e02143224..b4f2bcdc35b3 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -913,7 +913,8 @@ 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 *dentry) +static struct dentry *afs_lookup_atsys(struct inode *dir, struct dentry *dentry, + unsigned int flags) { struct afs_sysnames *subs; struct afs_net *net = afs_i2net(dir); @@ -938,6 +939,18 @@ static struct dentry *afs_lookup_atsys(struct inode *dir, struct dentry *dentry) refcount_inc(&subs->usage); read_unlock(&net->sysnames_lock); + /* + * We need the directory to be unlocked so we can perform other lookups. + * We don't need the lock any more, we just need the name which we + * have taken a copy of. + * We won't be instantiating this dentry, so end lookup now. This + * makes it safe to take the parent lock in lookup_noperm_unlocked(). + */ + d_lookup_done(dentry); + if (flags & LOOKUP_SHARED) + inode_unlock_shared(dir); + else + inode_unlock(dir); for (i = 0; i < subs->nr; i++) { name = subs->subs[i]; len = dentry->d_name.len - 4 + strlen(name); @@ -947,7 +960,7 @@ static struct dentry *afs_lookup_atsys(struct inode *dir, struct dentry *dentry) } strcpy(p, name); - ret = lookup_noperm(&QSTR(buf), dentry->d_parent); + ret = lookup_noperm_unlocked(&QSTR(buf), dentry->d_parent); if (IS_ERR(ret) || d_is_positive(ret)) goto out_s; dput(ret); @@ -958,6 +971,10 @@ static struct dentry *afs_lookup_atsys(struct inode *dir, struct dentry *dentry) */ ret = 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: @@ -1003,7 +1020,7 @@ struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry, dentry->d_name.name[dentry->d_name.len - 3] == 's' && dentry->d_name.name[dentry->d_name.len - 2] == 'y' && dentry->d_name.name[dentry->d_name.len - 1] == 's') - return afs_lookup_atsys(dir, dentry); + return afs_lookup_atsys(dir, dentry, flags); afs_stat_v(dvnode, n_lookup); inode = afs_do_lookup(dir, dentry); -- 2.50.0.107.gf914562f5916.dirty