* [PATCH] sunrpc: clean cache_detail immediately when flush is written frequently
@ 2024-12-27 8:33 Li Lingfeng
2025-01-08 18:51 ` cel
0 siblings, 1 reply; 2+ messages in thread
From: Li Lingfeng @ 2024-12-27 8:33 UTC (permalink / raw)
To: trondmy, anna, chuck.lever, jlayton, neilb, okorniev, Dai.Ngo,
tom, davem, edumazet, kuba, pabeni, horms
Cc: linux-nfs, netdev, linux-kernel, liujian56, yukuai1, houtao1,
yi.zhang, yangerkun, lilingfeng, lilingfeng3
We will write /proc/net/rpc/xxx/flush if we want to clean cache_detail.
This updates nextcheck to the current time and calls cache_flush -->
cache_clean to clean cache_detail.
If we write this interface again within one second, it will only increase
flush_time and nextcheck without actually cleaning cache_detail.
Therefore, if we keep writing this interface repeatedly within one second,
flush_time and nextcheck will keep increasing, even far exceeding the
current time, making it impossible to clear cache_detail through the flush
interface or cache_cleaner.
If someone frequently calls the flush interface, we should immediately
clean the corresponding cache_detail instead of continuously accumulating
nextcheck.
Signed-off-by: Li Lingfeng <lilingfeng3@huawei.com>
---
net/sunrpc/cache.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 059f6ef1ad18..73668df0450b 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -1531,9 +1531,13 @@ static ssize_t write_flush(struct file *file, const char __user *buf,
* or by one second if it has already reached the current time.
* Newly added cache entries will always have ->last_refresh greater
* that ->flush_time, so they don't get flushed prematurely.
+ *
+ * If someone frequently calls the flush interface, we should
+ * immediately clean the corresponding cache_detail instead of
+ * continuously accumulating nextcheck.
*/
- if (cd->flush_time >= now)
+ if (cd->flush_time >= now && cd->flush_time < (now + 5))
now = cd->flush_time + 1;
cd->flush_time = now;
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] sunrpc: clean cache_detail immediately when flush is written frequently
2024-12-27 8:33 [PATCH] sunrpc: clean cache_detail immediately when flush is written frequently Li Lingfeng
@ 2025-01-08 18:51 ` cel
0 siblings, 0 replies; 2+ messages in thread
From: cel @ 2025-01-08 18:51 UTC (permalink / raw)
To: trondmy, anna, jlayton, neilb, okorniev, Dai.Ngo, tom, davem,
edumazet, kuba, pabeni, horms, Li Lingfeng
Cc: Chuck Lever, linux-nfs, netdev, linux-kernel, liujian56, yukuai1,
houtao1, yi.zhang, yangerkun, lilingfeng
From: Chuck Lever <chuck.lever@oracle.com>
On Fri, 27 Dec 2024 16:33:53 +0800, Li Lingfeng wrote:
> We will write /proc/net/rpc/xxx/flush if we want to clean cache_detail.
> This updates nextcheck to the current time and calls cache_flush -->
> cache_clean to clean cache_detail.
> If we write this interface again within one second, it will only increase
> flush_time and nextcheck without actually cleaning cache_detail.
> Therefore, if we keep writing this interface repeatedly within one second,
> flush_time and nextcheck will keep increasing, even far exceeding the
> current time, making it impossible to clear cache_detail through the flush
> interface or cache_cleaner.
> If someone frequently calls the flush interface, we should immediately
> clean the corresponding cache_detail instead of continuously accumulating
> nextcheck.
>
> [...]
Applied to nfsd-testing, thanks!
[1/1] sunrpc: clean cache_detail immediately when flush is written frequently
commit: 33c4c54ed3b912edca4c2cd9ae3dd0492ab9fc4c
--
Chuck Lever
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-08 18:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-27 8:33 [PATCH] sunrpc: clean cache_detail immediately when flush is written frequently Li Lingfeng
2025-01-08 18:51 ` cel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox