Lines Matching refs:wsm
85 static struct zstd_workspace_manager wsm; variable
108 spin_lock_bh(&wsm.lock); in zstd_reclaim_timer_fn()
110 if (list_empty(&wsm.lru_list)) { in zstd_reclaim_timer_fn()
111 spin_unlock_bh(&wsm.lock); in zstd_reclaim_timer_fn()
115 list_for_each_prev_safe(pos, next, &wsm.lru_list) { in zstd_reclaim_timer_fn()
132 if (list_empty(&wsm.idle_ws[level - 1])) in zstd_reclaim_timer_fn()
133 clear_bit(level - 1, &wsm.active_map); in zstd_reclaim_timer_fn()
137 if (!list_empty(&wsm.lru_list)) in zstd_reclaim_timer_fn()
138 mod_timer(&wsm.timer, jiffies + ZSTD_BTRFS_RECLAIM_JIFFIES); in zstd_reclaim_timer_fn()
140 spin_unlock_bh(&wsm.lock); in zstd_reclaim_timer_fn()
177 wsm.ops = &btrfs_zstd_compress; in zstd_init_workspace_manager()
178 spin_lock_init(&wsm.lock); in zstd_init_workspace_manager()
179 init_waitqueue_head(&wsm.wait); in zstd_init_workspace_manager()
180 timer_setup(&wsm.timer, zstd_reclaim_timer_fn, 0); in zstd_init_workspace_manager()
182 INIT_LIST_HEAD(&wsm.lru_list); in zstd_init_workspace_manager()
184 INIT_LIST_HEAD(&wsm.idle_ws[i]); in zstd_init_workspace_manager()
191 set_bit(ZSTD_BTRFS_MAX_LEVEL - 1, &wsm.active_map); in zstd_init_workspace_manager()
192 list_add(ws, &wsm.idle_ws[ZSTD_BTRFS_MAX_LEVEL - 1]); in zstd_init_workspace_manager()
201 spin_lock_bh(&wsm.lock); in zstd_cleanup_workspace_manager()
203 while (!list_empty(&wsm.idle_ws[i])) { in zstd_cleanup_workspace_manager()
204 workspace = container_of(wsm.idle_ws[i].next, in zstd_cleanup_workspace_manager()
211 spin_unlock_bh(&wsm.lock); in zstd_cleanup_workspace_manager()
213 del_timer_sync(&wsm.timer); in zstd_cleanup_workspace_manager()
233 spin_lock_bh(&wsm.lock); in zstd_find_workspace()
234 for_each_set_bit_from(i, &wsm.active_map, ZSTD_BTRFS_MAX_LEVEL) { in zstd_find_workspace()
235 if (!list_empty(&wsm.idle_ws[i])) { in zstd_find_workspace()
236 ws = wsm.idle_ws[i].next; in zstd_find_workspace()
243 if (list_empty(&wsm.idle_ws[i])) in zstd_find_workspace()
244 clear_bit(i, &wsm.active_map); in zstd_find_workspace()
245 spin_unlock_bh(&wsm.lock); in zstd_find_workspace()
249 spin_unlock_bh(&wsm.lock); in zstd_find_workspace()
284 prepare_to_wait(&wsm.wait, &wait, TASK_UNINTERRUPTIBLE); in zstd_get_workspace()
286 finish_wait(&wsm.wait, &wait); in zstd_get_workspace()
308 spin_lock_bh(&wsm.lock); in zstd_put_workspace()
313 if (list_empty(&wsm.idle_ws[ZSTD_BTRFS_MAX_LEVEL - 1])) { in zstd_put_workspace()
317 list_add(&workspace->lru_list, &wsm.lru_list); in zstd_put_workspace()
318 if (!timer_pending(&wsm.timer)) in zstd_put_workspace()
319 mod_timer(&wsm.timer, in zstd_put_workspace()
324 set_bit(workspace->level - 1, &wsm.active_map); in zstd_put_workspace()
325 list_add(&workspace->list, &wsm.idle_ws[workspace->level - 1]); in zstd_put_workspace()
328 spin_unlock_bh(&wsm.lock); in zstd_put_workspace()
331 cond_wake_up(&wsm.wait); in zstd_put_workspace()