Lines Matching refs:wq
57 btrfs_workqueue_owner(const struct __btrfs_workqueue *wq) in btrfs_workqueue_owner() argument
59 return wq->fs_info; in btrfs_workqueue_owner()
65 return work->wq->fs_info; in btrfs_work_owner()
68 bool btrfs_workqueue_normal_congested(const struct btrfs_workqueue *wq) in btrfs_workqueue_normal_congested() argument
76 if (wq->normal->thresh == NO_THRESHOLD) in btrfs_workqueue_normal_congested()
79 return atomic_read(&wq->normal->pending) > wq->normal->thresh * 2; in btrfs_workqueue_normal_congested()
129 __btrfs_destroy_workqueue(struct __btrfs_workqueue *wq);
167 static inline void thresh_queue_hook(struct __btrfs_workqueue *wq) in thresh_queue_hook() argument
169 if (wq->thresh == NO_THRESHOLD) in thresh_queue_hook()
171 atomic_inc(&wq->pending); in thresh_queue_hook()
179 static inline void thresh_exec_hook(struct __btrfs_workqueue *wq) in thresh_exec_hook() argument
185 if (wq->thresh == NO_THRESHOLD) in thresh_exec_hook()
188 atomic_dec(&wq->pending); in thresh_exec_hook()
189 spin_lock(&wq->thres_lock); in thresh_exec_hook()
194 wq->count++; in thresh_exec_hook()
195 wq->count %= (wq->thresh / 4); in thresh_exec_hook()
196 if (!wq->count) in thresh_exec_hook()
198 new_current_active = wq->current_active; in thresh_exec_hook()
204 pending = atomic_read(&wq->pending); in thresh_exec_hook()
205 if (pending > wq->thresh) in thresh_exec_hook()
207 if (pending < wq->thresh / 2) in thresh_exec_hook()
209 new_current_active = clamp_val(new_current_active, 1, wq->limit_active); in thresh_exec_hook()
210 if (new_current_active != wq->current_active) { in thresh_exec_hook()
212 wq->current_active = new_current_active; in thresh_exec_hook()
215 spin_unlock(&wq->thres_lock); in thresh_exec_hook()
218 workqueue_set_max_active(wq->normal_wq, wq->current_active); in thresh_exec_hook()
222 static void run_ordered_work(struct __btrfs_workqueue *wq, in run_ordered_work() argument
225 struct list_head *list = &wq->ordered_list; in run_ordered_work()
227 spinlock_t *lock = &wq->list_lock; in run_ordered_work()
290 trace_btrfs_all_work_done(wq->fs_info, wtag); in run_ordered_work()
298 trace_btrfs_all_work_done(wq->fs_info, wtag); in run_ordered_work()
306 struct __btrfs_workqueue *wq; in btrfs_work_helper() local
320 wq = work->wq; in btrfs_work_helper()
325 thresh_exec_hook(wq); in btrfs_work_helper()
329 run_ordered_work(wq, work); in btrfs_work_helper()
332 trace_btrfs_all_work_done(wq->fs_info, wtag); in btrfs_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()