Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 243A9280332 for ; Wed, 7 Jan 2026 07:28:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767770897; cv=none; b=orMsPP1L9PiXLMYD1f2iJ/DcXYTS3TQQQQQ6leDxC0r/KZYwS5kO4tKP2qaXEUL8Y7/tzQfZlYfvybZBM6C7KJo1v8wpoHEEGC4Y0dWm6CuUQNr16IBVpoeRqeEFiJi31vnZywIt7tOR7vbARAYxGFo5TWutSeiWDWN9ZmCewHA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767770897; c=relaxed/simple; bh=flU3GauvlQ6EwG7uHSGRzVN+UkFNRe7OndK8ercjFzE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RRuptF5lZt2R6AIb3QJw0lQAeGeT5nrbWttQfsj6R64NxDCWE2lutMmWiWTNJm0tBP4LyEQ1M5hBo+/VSpw/W9fIKbXrUQbBPPfdqOOvog4b2aiMbvTr4IIvqP7LXE2J6Px8cSFrcSdKUlhrFQ3oQPH4likyALG1VfFb9nLjnDY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=dllUSKZk; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="dllUSKZk" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=C9V4AqoH893EcmxxBgVz71lLnnKCpqTMA956yiGcZCE=; b=dllUSKZkmAicA0cCquOS6eVd+m 9mQoWDavkj9mMak/Mu8VxMj2o/3D4IpCgDOFVOxEdDjjM/tasbyHyvil/1vTX3wGECM0viN0P2AdG cQGQpIvlDcRNDE1Qa2cs5dVPzTnRlENbiDO3VPu8awX42hdZrqSwvyPOmZ2U41iTbVswgIGg4RcZG 2YcRw/rRDbb0vTkzdAcAADnMvvFviY5EG8bYiiOPGGX8GRdjWxaLVl6wgzWhGo/HJJUarqeLwvAd0 lupUbVvap6sn0IEhITgAJw1+u/+tf9Avll1HHKxgRfICl6DPEYpJcaIdWluwt6CHOMQBe17NRTmxn 4ObSRxkw==; Received: from 2a02-8389-2341-5b80-d601-7564-c2e0-491c.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:d601:7564:c2e0:491c] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vdNxn-0000000EHnG-0BwX; Wed, 07 Jan 2026 07:28:15 +0000 From: Christoph Hellwig To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 14/24] NFS: return bool from nfs_detach_delegation{,_locked} Date: Wed, 7 Jan 2026 08:27:05 +0100 Message-ID: <20260107072720.1744129-15-hch@lst.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260107072720.1744129-1-hch@lst.de> References: <20260107072720.1744129-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html nfs_detach_delegation always returns either the passed in delegation or NULL, simplify this to a bool return. Signed-off-by: Christoph Hellwig --- fs/nfs/delegation.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 5141f6e5def1..6946b48584f8 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -345,7 +345,7 @@ static void nfs_abort_delegation_return(struct nfs_delegation *delegation, spin_unlock(&delegation->lock); } -static struct nfs_delegation * +static bool nfs_detach_delegation_locked(struct nfs_inode *nfsi, struct nfs_delegation *delegation, struct nfs_client *clp) @@ -356,13 +356,13 @@ nfs_detach_delegation_locked(struct nfs_inode *nfsi, trace_nfs4_detach_delegation(&nfsi->vfs_inode, delegation->type); - if (deleg_cur == NULL || delegation != deleg_cur) - return NULL; + if (delegation != deleg_cur) + return false; spin_lock(&delegation->lock); if (!delegation->inode) { spin_unlock(&delegation->lock); - return NULL; + return false; } hlist_del_init_rcu(&delegation->hash); list_del_rcu(&delegation->super_list); @@ -370,19 +370,20 @@ nfs_detach_delegation_locked(struct nfs_inode *nfsi, rcu_assign_pointer(nfsi->delegation, NULL); spin_unlock(&delegation->lock); clear_bit(NFS_INO_REQ_DIR_DELEG, &nfsi->flags); - return delegation; + return true; } -static struct nfs_delegation *nfs_detach_delegation(struct nfs_inode *nfsi, +static bool nfs_detach_delegation(struct nfs_inode *nfsi, struct nfs_delegation *delegation, struct nfs_server *server) { struct nfs_client *clp = server->nfs_client; + bool ret; spin_lock(&clp->cl_lock); - delegation = nfs_detach_delegation_locked(nfsi, delegation, clp); + ret = nfs_detach_delegation_locked(nfsi, delegation, clp); spin_unlock(&clp->cl_lock); - return delegation; + return ret; } static void @@ -492,9 +493,9 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, &old_delegation->flags)) goto out; } - freeme = nfs_detach_delegation_locked(nfsi, old_delegation, clp); - if (freeme == NULL) + if (!nfs_detach_delegation_locked(nfsi, old_delegation, clp)) goto out; + freeme = old_delegation; add_new: /* * If we didn't revalidate the change attribute before setting @@ -732,8 +733,8 @@ void nfs_inode_evict_delegation(struct inode *inode) rcu_read_lock(); delegation = rcu_dereference(nfsi->delegation); - if (delegation) - delegation = nfs_detach_delegation(nfsi, delegation, server); + if (delegation && !nfs_detach_delegation(nfsi, delegation, server)) + delegation = NULL; rcu_read_unlock(); if (!delegation) @@ -1240,7 +1241,7 @@ static int nfs_server_reap_unclaimed_delegations(struct nfs_server *server, rcu_read_unlock(); if (delegation != NULL) { if (nfs_detach_delegation(NFS_I(inode), delegation, - server) != NULL) { + server)) { nfs_mark_delegation_revoked(server, delegation); nfs_put_delegation(delegation); } -- 2.47.3