From 9db3b475c0513782004b4e60a457590f5bc62b5c Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Mon, 28 Jun 2021 13:44:59 -0700 Subject: [PATCH] Stop log merge work earlier during unmount The forest log merge work calls into the client to send commit requests to the server. The forest is usually destroyed relatively late in the sequence and can still be running after the client is destroyed. Adding a _forest_stop call lets us stop the log merging work before the client is destroyed. Signed-off-by: Zach Brown --- kmod/src/forest.c | 15 ++++++++++----- kmod/src/forest.h | 1 + kmod/src/super.c | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/kmod/src/forest.c b/kmod/src/forest.c index 37be80a0..a2f555d0 100644 --- a/kmod/src/forest.c +++ b/kmod/src/forest.c @@ -758,6 +758,16 @@ out: return 0; } +void scoutfs_forest_stop(struct super_block *sb) +{ + DECLARE_FOREST_INFO(sb, finf); + + if (finf && finf->workq) { + cancel_delayed_work_sync(&finf->log_merge_dwork); + destroy_workqueue(finf->workq); + } +} + void scoutfs_forest_destroy(struct super_block *sb) { struct scoutfs_sb_info *sbi = SCOUTFS_SB(sb); @@ -766,11 +776,6 @@ void scoutfs_forest_destroy(struct super_block *sb) if (finf) { scoutfs_block_put(sb, finf->srch_bl); - if (finf->workq) { - cancel_delayed_work_sync(&finf->log_merge_dwork); - destroy_workqueue(finf->workq); - } - kfree(finf); sbi->forest_info = NULL; } diff --git a/kmod/src/forest.h b/kmod/src/forest.h index 3ca50670..7bd4609e 100644 --- a/kmod/src/forest.h +++ b/kmod/src/forest.h @@ -39,6 +39,7 @@ void scoutfs_forest_get_btrees(struct super_block *sb, struct scoutfs_log_trees *lt); int scoutfs_forest_setup(struct super_block *sb); +void scoutfs_forest_stop(struct super_block *sb); void scoutfs_forest_destroy(struct super_block *sb); #endif diff --git a/kmod/src/super.c b/kmod/src/super.c index a1862bdf..65224dff 100644 --- a/kmod/src/super.c +++ b/kmod/src/super.c @@ -248,6 +248,7 @@ static void scoutfs_put_super(struct super_block *sb) trace_scoutfs_put_super(sb); scoutfs_inode_stop(sb); + scoutfs_forest_stop(sb); scoutfs_srch_destroy(sb); scoutfs_lock_shutdown(sb);