diff options
author | Dennis Zhou <dennis@kernel.org> | 2019-02-22 14:53:48 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2019-02-27 11:45:04 -0500 |
commit | d3865159ac7823f645d313fdbac0b256ac01eeb9 (patch) | |
tree | 5d2b928fde2612ef2f0210a7decca42396892356 | |
parent | 7503b83d80f0a3da5dead1293f5454206e7f9db6 (diff) |
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>
-rw-r--r-- | fs/btrfs/zstd.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/btrfs/zstd.c b/fs/btrfs/zstd.c index 3e418a3aeb11..6b9e29d050f3 100644 --- a/fs/btrfs/zstd.c +++ b/fs/btrfs/zstd.c | |||
@@ -195,8 +195,7 @@ static void zstd_cleanup_workspace_manager(void) | |||
195 | struct workspace *workspace; | 195 | struct workspace *workspace; |
196 | int i; | 196 | int i; |
197 | 197 | ||
198 | del_timer(&wsm.timer); | 198 | spin_lock(&wsm.lock); |
199 | |||
200 | for (i = 0; i < ZSTD_BTRFS_MAX_LEVEL; i++) { | 199 | for (i = 0; i < ZSTD_BTRFS_MAX_LEVEL; i++) { |
201 | while (!list_empty(&wsm.idle_ws[i])) { | 200 | while (!list_empty(&wsm.idle_ws[i])) { |
202 | workspace = container_of(wsm.idle_ws[i].next, | 201 | workspace = container_of(wsm.idle_ws[i].next, |
@@ -206,6 +205,9 @@ static void zstd_cleanup_workspace_manager(void) | |||
206 | wsm.ops->free_workspace(&workspace->list); | 205 | wsm.ops->free_workspace(&workspace->list); |
207 | } | 206 | } |
208 | } | 207 | } |
208 | spin_unlock(&wsm.lock); | ||
209 | |||
210 | del_timer_sync(&wsm.timer); | ||
209 | } | 211 | } |
210 | 212 | ||
211 | /* | 213 | /* |