Commit d3865159 authored by Dennis Zhou's avatar Dennis Zhou Committed by David Sterba
Browse files

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: default avatarDennis Zhou <dennis@kernel.org>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 7503b83d
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -195,8 +195,7 @@ static void zstd_cleanup_workspace_manager(void)
	struct workspace *workspace;
	int i;

	del_timer(&wsm.timer);

	spin_lock(&wsm.lock);
	for (i = 0; i < ZSTD_BTRFS_MAX_LEVEL; i++) {
		while (!list_empty(&wsm.idle_ws[i])) {
			workspace = container_of(wsm.idle_ws[i].next,
@@ -206,6 +205,9 @@ static void zstd_cleanup_workspace_manager(void)
			wsm.ops->free_workspace(&workspace->list);
		}
	}
	spin_unlock(&wsm.lock);

	del_timer_sync(&wsm.timer);
}

/*