[PATCH] nfsd: add scheduling point in nfsd_file_gc()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Under a high NFSv3 load with lots of different file being accessed The
list_lru of garbage-collectable files can become quite long.

Asking lisT_lru_scan() to scan the whole list can result in a long
period during which a spinlock is held and no scheduling is possible.
This is impolite.

So only ask list_lru_scan() to scan 1024 entries at a time, and repeat
if necessary - calling cond_resched() each time.

Signed-off-by: NeilBrown <neilb@xxxxxxx>
---
 fs/nfsd/filecache.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
index a1cdba42c4fa..e99a86798e86 100644
--- a/fs/nfsd/filecache.c
+++ b/fs/nfsd/filecache.c
@@ -543,11 +543,18 @@ nfsd_file_gc(void)
 {
 	LIST_HEAD(dispose);
 	unsigned long ret;
-
-	ret = list_lru_walk(&nfsd_file_lru, nfsd_file_lru_cb,
-			    &dispose, list_lru_count(&nfsd_file_lru));
-	trace_nfsd_file_gc_removed(ret, list_lru_count(&nfsd_file_lru));
-	nfsd_file_dispose_list_delayed(&dispose);
+	unsigned long cnt = list_lru_count(&nfsd_file_lru);
+
+	while (cnt > 0) {
+		unsigned long num_to_scan = min(cnt, 1024UL);
+		ret = list_lru_walk(&nfsd_file_lru, nfsd_file_lru_cb,
+				    &dispose, num_to_scan);
+		trace_nfsd_file_gc_removed(ret, list_lru_count(&nfsd_file_lru));
+		nfsd_file_dispose_list_delayed(&dispose);
+		cnt -= num_to_scan;
+		if (cnt)
+			cond_resched();
+	}
 }
 
 static void
-- 
2.47.1





[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux