From 8e70975f905935df2a68fb242570056035a52948 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Tue, 9 Jun 2015 16:39:25 -0700 Subject: [PATCH] Wait interruptibly in prefetch thread The Linux kernel watchdog will automatically dump a backtrace for any process while sleeps for over 120s in an uninterruptible state. The solution is for the prefetch thread to sleep in an interruptible state. The way the existing code was written this is safe because when woken it will always reevaluate its conditional. As a general rule it is preferable to sleep in an interruptible when possible. Signed-off-by: Brian Behlendorf Closes #3450 Closes #3402 --- module/zfs/dmu_traverse.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/module/zfs/dmu_traverse.c b/module/zfs/dmu_traverse.c index 6c69a2339..44b23280d 100644 --- a/module/zfs/dmu_traverse.c +++ b/module/zfs/dmu_traverse.c @@ -250,7 +250,7 @@ traverse_visitbp(traverse_data_t *td, const dnode_phys_t *dnp, mutex_enter(&pd->pd_mtx); ASSERT(pd->pd_bytes_fetched >= 0); while (pd->pd_bytes_fetched < size && !pd->pd_exited) - cv_wait(&pd->pd_cv, &pd->pd_mtx); + cv_wait_sig(&pd->pd_cv, &pd->pd_mtx); pd->pd_bytes_fetched -= size; cv_broadcast(&pd->pd_cv); mutex_exit(&pd->pd_mtx); @@ -459,7 +459,7 @@ traverse_prefetcher(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, mutex_enter(&pfd->pd_mtx); while (!pfd->pd_cancel && pfd->pd_bytes_fetched >= zfs_pd_bytes_max) - cv_wait(&pfd->pd_cv, &pfd->pd_mtx); + cv_wait_sig(&pfd->pd_cv, &pfd->pd_mtx); pfd->pd_bytes_fetched += BP_GET_LSIZE(bp); cv_broadcast(&pfd->pd_cv); mutex_exit(&pfd->pd_mtx); @@ -571,7 +571,7 @@ traverse_impl(spa_t *spa, dsl_dataset_t *ds, uint64_t objset, blkptr_t *rootbp, pd->pd_cancel = B_TRUE; cv_broadcast(&pd->pd_cv); while (!pd->pd_exited) - cv_wait(&pd->pd_cv, &pd->pd_mtx); + cv_wait_sig(&pd->pd_cv, &pd->pd_mtx); mutex_exit(&pd->pd_mtx); mutex_destroy(&pd->pd_mtx);