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 5B7634C6E; Mon, 23 Jun 2025 13:31:46 +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=1750685506; cv=none; b=JrNSy9F5r7GqjmzX4Yp3U3suhxMIEgN/0/GZbNpPpKQP3OBPwYADCokIA3eulHf6CU6FvbHbASXjJzzL5oKUcrtDRXb6c3iK/jPHqAcp10AjZ5f3jHAEaJbScj0JzimyQUiSKcNyLV4CngHp6pogaj0Xu1YnrVbADh5nsXd5kTg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750685506; c=relaxed/simple; bh=whkuWnHhng1PHEIgW51OiCMk8TEg1xkAEMP39MZGMDE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pZyuCMyANXsudK3/xN2bSyCp66f3AAxk6m4HetcftvGP8a2ONkGAWLQQ932a5FElANK3DFaQOd/XZ8Ssz8p6JQwmJ1UcFR/mQccrAVQbin7k9AhrOHP2DazLaK0/zPpUh0WLkQz89Qb1OvQsljoXFfpgCV22/x6wJBEVVgjDLxw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=RYsmsBuM; 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="RYsmsBuM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E21E9C4CEF2; Mon, 23 Jun 2025 13:31:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750685506; bh=whkuWnHhng1PHEIgW51OiCMk8TEg1xkAEMP39MZGMDE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RYsmsBuMDIpzO95BOaHJJNmJ7J3Y56EOLXiOdUaU7Ma+ZsDPnlEKhhXBFf/x4DrhQ YEcc3rg9QN19zkDSEQFmlAqgBtlxsFrIqrL8RFZlGuxkt4tild5sNaBEV+lP9RHbPu GH+i2iKXn82UyzCvWaMqMo9rXVsV1eEX4ipLOs5c= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Long Li , Chuck Lever , Sasha Levin Subject: [PATCH 6.15 240/592] sunrpc: update nextcheck time when adding new cache entries Date: Mon, 23 Jun 2025 15:03:18 +0200 Message-ID: <20250623130705.999524487@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250623130700.210182694@linuxfoundation.org> References: <20250623130700.210182694@linuxfoundation.org> User-Agent: quilt/0.68 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 6.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Long Li [ 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 Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin --- net/sunrpc/cache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 7ce5e28a6c031..bbaa77d7bbc81 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -135,6 +135,8 @@ static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail, hlist_add_head_rcu(&new->cache_list, head); detail->entries++; + if (detail->nextcheck > new->expiry_time) + detail->nextcheck = new->expiry_time + 1; cache_get(new); spin_unlock(&detail->hash_lock); -- 2.39.5