diff options
| author | Li Lingfeng <[email protected]> | 2024-12-27 08:33:53 +0000 |
|---|---|---|
| committer | Chuck Lever <[email protected]> | 2025-03-10 13:10:53 +0000 |
| commit | fc2a169c56de0860ea7599ea6f67ad5fc451bde1 (patch) | |
| tree | ce09624664788beadb2c71a3da3e41633f6e0d7d /net/sunrpc/cache.c | |
| parent | Linux 6.14-rc6 (diff) | |
| download | kernel-fc2a169c56de0860ea7599ea6f67ad5fc451bde1.tar.gz kernel-fc2a169c56de0860ea7599ea6f67ad5fc451bde1.zip | |
sunrpc: clean cache_detail immediately when flush is written frequently
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 <[email protected]>
Signed-off-by: Chuck Lever <[email protected]>
Diffstat (limited to 'net/sunrpc/cache.c')
| -rw-r--r-- | net/sunrpc/cache.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 7ce5e28a6c03..004cdb59f010 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -1536,9 +1536,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; |
