From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 F1D611AF0A5; Tue, 15 Oct 2024 12:53:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728996838; cv=none; b=aNLBSIAF1/7hJVgxBtbi8iuJ/Op2BNf5bNMJJTw6LMPGEmSBP4CQbUlCMs7RZx5/u/8wl8CdLnT9JOG/9xio0S/1kv/2frfB/6CdEaYBopklMkTrH7mQh5GmN7XYoKt7jF5MZKLTACakjari7eTIzY4KEwIH4vGl56SHxuR9Hb8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728996838; c=relaxed/simple; bh=yKMgN4SkwV9VILyGt/GDItqFw+wXpRGNcfWA3nvDYDY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PcNU5cNnUflQRmhXtpZv57Sl0rVCAe8oa9x92cUvE1zBFnGJQMpK4qhlbzrB2SOA/Xb2+JTvIaTpqo16IulhEluf3yoyq45nBheHopS6duwI1H/YjGdcpnWEYHelH+pF9v6sswhKIIHyRsKq4Kw41M12bGNF65I1jkeAWBSdKtM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=v0CBN6XT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="v0CBN6XT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5ED5EC4CECE; Tue, 15 Oct 2024 12:53:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728996837; bh=yKMgN4SkwV9VILyGt/GDItqFw+wXpRGNcfWA3nvDYDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v0CBN6XTKeXuU8mQpadMet4NmZQUzKwL27TMaBp7UjjEaRn16g6tiiGJ6w6mgUVHQ DV0fC0p1PMNHsNhUfFhPrZ3Y9rDnD2/qjGa9ZDC70vuWweq0jstnlx2DaP3zo3J/Ks JDaCjCfDOOeZSxoNadh1C/QN4v5GIEvQ5p2+Z2fE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Trond Myklebust , Jeff Layton , Anna Schumaker , Sasha Levin Subject: [PATCH 5.10 014/518] NFS: Avoid unnecessary rescanning of the per-server delegation list Date: Tue, 15 Oct 2024 14:38:38 +0200 Message-ID: <20241015123917.384254786@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241015123916.821186887@linuxfoundation.org> References: <20241015123916.821186887@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Trond Myklebust [ Upstream commit f92214e4c312f6ea9d78650cc6291d200f17abb6 ] If the call to nfs_delegation_grab_inode() fails, we will not have dropped any locks that require us to rescan the list. Signed-off-by: Trond Myklebust Reviewed-by: Jeff Layton Signed-off-by: Anna Schumaker Signed-off-by: Sasha Levin --- fs/nfs/delegation.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 1eb6c7a142ff..c15188d0b6b3 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -609,6 +609,9 @@ static int nfs_server_return_marked_delegations(struct nfs_server *server, prev = delegation; continue; } + inode = nfs_delegation_grab_inode(delegation); + if (inode == NULL) + continue; if (prev) { struct inode *tmp = nfs_delegation_grab_inode(prev); @@ -619,12 +622,6 @@ static int nfs_server_return_marked_delegations(struct nfs_server *server, } } - inode = nfs_delegation_grab_inode(delegation); - if (inode == NULL) { - rcu_read_unlock(); - iput(to_put); - goto restart; - } delegation = nfs_start_delegation_return_locked(NFS_I(inode)); rcu_read_unlock(); @@ -1140,7 +1137,6 @@ static int nfs_server_reap_unclaimed_delegations(struct nfs_server *server, struct inode *inode; restart: rcu_read_lock(); -restart_locked: list_for_each_entry_rcu(delegation, &server->delegations, super_list) { if (test_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags) || @@ -1151,7 +1147,7 @@ static int nfs_server_reap_unclaimed_delegations(struct nfs_server *server, continue; inode = nfs_delegation_grab_inode(delegation); if (inode == NULL) - goto restart_locked; + continue; delegation = nfs_start_delegation_return_locked(NFS_I(inode)); rcu_read_unlock(); if (delegation != NULL) { @@ -1272,7 +1268,6 @@ static int nfs_server_reap_expired_delegations(struct nfs_server *server, nfs4_stateid stateid; restart: rcu_read_lock(); -restart_locked: list_for_each_entry_rcu(delegation, &server->delegations, super_list) { if (test_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags) || @@ -1283,7 +1278,7 @@ static int nfs_server_reap_expired_delegations(struct nfs_server *server, continue; inode = nfs_delegation_grab_inode(delegation); if (inode == NULL) - goto restart_locked; + continue; spin_lock(&delegation->lock); cred = get_cred_rcu(delegation->cred); nfs4_stateid_copy(&stateid, &delegation->stateid); -- 2.43.0