]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
sunrpc: update nextcheck time when adding new cache entries
authorLong Li <leo.lilong@huawei.com>
Sat, 1 Mar 2025 06:48:35 +0000 (14:48 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2025 10:05:28 +0000 (11:05 +0100)
commitfbee3fe40ca289090eb22562831012bcecfd7494
tree166084e57104112092da4eee89a872e1ee14efeb
parent767e4d5300ea50cd4569af05236627500d5f8035
sunrpc: update nextcheck time when adding new cache entries

[ Upstream commit 5ca00634c8bbb2979c73465588f486b9632f5ed5 ]

The cache_detail structure uses a "nextcheck" field to control hash table
scanning intervals. When a table scan begins, nextcheck is set to current
time plus 1800 seconds. During scanning, if cache_detail is not empty and
a cache entry's expiry time is earlier than the current nextcheck, the
nextcheck is updated to that expiry time.

This mechanism ensures that:
1) Empty cache_details are scanned every 1800 seconds to avoid unnecessary
   scans
2) Non-empty cache_details are scanned based on the earliest expiry time
   found

However, when adding a new cache entry to an empty cache_detail, the
nextcheck time was not being updated, remaining at 1800 seconds. This
could delay cache cleanup for up to 1800 seconds, potentially blocking
threads(such as nfsd) that are waiting for cache cleanup.

Fix this by updating the nextcheck time whenever a new cache entry is
added.

Signed-off-by: Long Li <leo.lilong@huawei.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/sunrpc/cache.c