Skip to content

Commit fc2a169

Browse files
Li Lingfengchucklever
authored andcommitted
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]>
1 parent 80e54e8 commit fc2a169

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

net/sunrpc/cache.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1536,9 +1536,13 @@ static ssize_t write_flush(struct file *file, const char __user *buf,
15361536
* or by one second if it has already reached the current time.
15371537
* Newly added cache entries will always have ->last_refresh greater
15381538
* that ->flush_time, so they don't get flushed prematurely.
1539+
*
1540+
* If someone frequently calls the flush interface, we should
1541+
* immediately clean the corresponding cache_detail instead of
1542+
* continuously accumulating nextcheck.
15391543
*/
15401544

1541-
if (cd->flush_time >= now)
1545+
if (cd->flush_time >= now && cd->flush_time < (now + 5))
15421546
now = cd->flush_time + 1;
15431547

15441548
cd->flush_time = now;

0 commit comments

Comments
 (0)