Skip to content

Commit d386515

Browse files
dennisszhoukdave
authored andcommitted
btrfs: zstd: ensure reclaim timer is properly cleaned up
The timer function, zstd_reclaim_timer_fn(), reschedules itself under certain conditions. When cleaning up, take the lock and remove all workspaces. This prevents the timer from rearming itself. Lastly, switch to del_timer_sync() to ensure that the timer function can't trigger as we're unloading. Signed-off-by: Dennis Zhou <dennis@kernel.org> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 7503b83 commit d386515

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/btrfs/zstd.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ static void zstd_cleanup_workspace_manager(void)
195195
struct workspace *workspace;
196196
int i;
197197

198-
del_timer(&wsm.timer);
199-
198+
spin_lock(&wsm.lock);
200199
for (i = 0; i < ZSTD_BTRFS_MAX_LEVEL; i++) {
201200
while (!list_empty(&wsm.idle_ws[i])) {
202201
workspace = container_of(wsm.idle_ws[i].next,
@@ -206,6 +205,9 @@ static void zstd_cleanup_workspace_manager(void)
206205
wsm.ops->free_workspace(&workspace->list);
207206
}
208207
}
208+
spin_unlock(&wsm.lock);
209+
210+
del_timer_sync(&wsm.timer);
209211
}
210212

211213
/*

0 commit comments

Comments
 (0)