Lines Matching refs:wq
67 btrfs_workqueue_owner(const struct __btrfs_workqueue *wq) in btrfs_workqueue_owner() argument
69 return wq->fs_info; in btrfs_workqueue_owner()
75 return work->wq->fs_info; in btrfs_work_owner()
78 bool btrfs_workqueue_normal_congested(const struct btrfs_workqueue *wq) in btrfs_workqueue_normal_congested() argument
86 if (wq->normal->thresh == NO_THRESHOLD) in btrfs_workqueue_normal_congested()
89 return atomic_read(&wq->normal->pending) > wq->normal->thresh * 2; in btrfs_workqueue_normal_congested()
162 __btrfs_destroy_workqueue(struct __btrfs_workqueue *wq);
200 static inline void thresh_queue_hook(struct __btrfs_workqueue *wq) in thresh_queue_hook() argument
202 if (wq->thresh == NO_THRESHOLD) in thresh_queue_hook()
204 atomic_inc(&wq->pending); in thresh_queue_hook()
212 static inline void thresh_exec_hook(struct __btrfs_workqueue *wq) in thresh_exec_hook() argument
218 if (wq->thresh == NO_THRESHOLD) in thresh_exec_hook()
221 atomic_dec(&wq->pending); in thresh_exec_hook()
222 spin_lock(&wq->thres_lock); in thresh_exec_hook()
227 wq->count++; in thresh_exec_hook()
228 wq->count %= (wq->thresh / 4); in thresh_exec_hook()
229 if (!wq->count) in thresh_exec_hook()
231 new_current_active = wq->current_active; in thresh_exec_hook()
237 pending = atomic_read(&wq->pending); in thresh_exec_hook()
238 if (pending > wq->thresh) in thresh_exec_hook()
240 if (pending < wq->thresh / 2) in thresh_exec_hook()
242 new_current_active = clamp_val(new_current_active, 1, wq->limit_active); in thresh_exec_hook()
243 if (new_current_active != wq->current_active) { in thresh_exec_hook()
245 wq->current_active = new_current_active; in thresh_exec_hook()
248 spin_unlock(&wq->thres_lock); in thresh_exec_hook()
251 workqueue_set_max_active(wq->normal_wq, wq->current_active); in thresh_exec_hook()
255 static void run_ordered_work(struct __btrfs_workqueue *wq) in run_ordered_work() argument
257 struct list_head *list = &wq->ordered_list; in run_ordered_work()
259 spinlock_t *lock = &wq->list_lock; in run_ordered_work()
297 trace_btrfs_all_work_done(wq->fs_info, wtag); in run_ordered_work()
304 struct __btrfs_workqueue *wq; in normal_work_helper() local
318 wq = work->wq; in normal_work_helper()
323 thresh_exec_hook(wq); in normal_work_helper()
327 run_ordered_work(wq); in normal_work_helper()
330 trace_btrfs_all_work_done(wq->fs_info, wtag); in normal_work_helper()
346 static inline void __btrfs_queue_work(struct __btrfs_workqueue *wq, in __btrfs_queue_work() argument
351 work->wq = wq; in __btrfs_queue_work()
352 thresh_queue_hook(wq); in __btrfs_queue_work()
354 spin_lock_irqsave(&wq->list_lock, flags); in __btrfs_queue_work()
355 list_add_tail(&work->ordered_list, &wq->ordered_list); in __btrfs_queue_work()
356 spin_unlock_irqrestore(&wq->list_lock, flags); in __btrfs_queue_work()
359 queue_work(wq->normal_wq, &work->normal_work); in __btrfs_queue_work()
362 void btrfs_queue_work(struct btrfs_workqueue *wq, in btrfs_queue_work() argument
367 if (test_bit(WORK_HIGH_PRIO_BIT, &work->flags) && wq->high) in btrfs_queue_work()
368 dest_wq = wq->high; in btrfs_queue_work()
370 dest_wq = wq->normal; in btrfs_queue_work()
375 __btrfs_destroy_workqueue(struct __btrfs_workqueue *wq) in __btrfs_destroy_workqueue() argument
377 destroy_workqueue(wq->normal_wq); in __btrfs_destroy_workqueue()
378 trace_btrfs_workqueue_destroy(wq); in __btrfs_destroy_workqueue()
379 kfree(wq); in __btrfs_destroy_workqueue()
382 void btrfs_destroy_workqueue(struct btrfs_workqueue *wq) in btrfs_destroy_workqueue() argument
384 if (!wq) in btrfs_destroy_workqueue()
386 if (wq->high) in btrfs_destroy_workqueue()
387 __btrfs_destroy_workqueue(wq->high); in btrfs_destroy_workqueue()
388 __btrfs_destroy_workqueue(wq->normal); in btrfs_destroy_workqueue()
389 kfree(wq); in btrfs_destroy_workqueue()
392 void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int limit_active) in btrfs_workqueue_set_max() argument
394 if (!wq) in btrfs_workqueue_set_max()
396 wq->normal->limit_active = limit_active; in btrfs_workqueue_set_max()
397 if (wq->high) in btrfs_workqueue_set_max()
398 wq->high->limit_active = limit_active; in btrfs_workqueue_set_max()