From f493a4b9866dfeee7d6daa8d339aaae6ab6852a5 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Mon, 26 Oct 2020 21:45:41 -0400 Subject: [PATCH] Yield periodically when rebuilding L2ARC. L2ARC devices of several terabytes filled with 4KB blocks may take 15 minutes to rebuild. Due to the way L2ARC log reading is implemented it is quite likely that for all that time rebuild thread will never sleep. At least on FreeBSD kernel threads have absolute priority and can not be preempted by threads with lower priorities. If some thread is also bound to that specific CPU it may not get any CPU time for all the 15 minutes. Signed-off-by: Alexander Motin --- module/zfs/arc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 1e3d47693d37..72a71bafd2f1 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -9893,6 +9893,7 @@ l2arc_rebuild(l2arc_dev_t *dev) !dev->l2ad_first) goto out; + cond_resched(); for (;;) { mutex_enter(&l2arc_rebuild_thr_lock); if (dev->l2ad_rebuild_cancel) {