Lines Matching refs:wq
50 struct btrfs_fs_info * __pure btrfs_workqueue_owner(const struct btrfs_workqueue *wq) in btrfs_workqueue_owner() argument
52 return wq->fs_info; in btrfs_workqueue_owner()
57 return work->wq->fs_info; in btrfs_work_owner()
60 bool btrfs_workqueue_normal_congested(const struct btrfs_workqueue *wq) in btrfs_workqueue_normal_congested() argument
68 if (wq->thresh == NO_THRESHOLD) in btrfs_workqueue_normal_congested()
71 return atomic_read(&wq->pending) > wq->thresh * 2; in btrfs_workqueue_normal_congested()
121 static inline void thresh_queue_hook(struct btrfs_workqueue *wq) in thresh_queue_hook() argument
123 if (wq->thresh == NO_THRESHOLD) in thresh_queue_hook()
125 atomic_inc(&wq->pending); in thresh_queue_hook()
133 static inline void thresh_exec_hook(struct btrfs_workqueue *wq) in thresh_exec_hook() argument
139 if (wq->thresh == NO_THRESHOLD) in thresh_exec_hook()
142 atomic_dec(&wq->pending); in thresh_exec_hook()
143 spin_lock(&wq->thres_lock); in thresh_exec_hook()
148 wq->count++; in thresh_exec_hook()
149 wq->count %= (wq->thresh / 4); in thresh_exec_hook()
150 if (!wq->count) in thresh_exec_hook()
152 new_current_active = wq->current_active; in thresh_exec_hook()
158 pending = atomic_read(&wq->pending); in thresh_exec_hook()
159 if (pending > wq->thresh) in thresh_exec_hook()
161 if (pending < wq->thresh / 2) in thresh_exec_hook()
163 new_current_active = clamp_val(new_current_active, 1, wq->limit_active); in thresh_exec_hook()
164 if (new_current_active != wq->current_active) { in thresh_exec_hook()
166 wq->current_active = new_current_active; in thresh_exec_hook()
169 spin_unlock(&wq->thres_lock); in thresh_exec_hook()
172 workqueue_set_max_active(wq->normal_wq, wq->current_active); in thresh_exec_hook()
176 static void run_ordered_work(struct btrfs_workqueue *wq, in run_ordered_work() argument
179 struct list_head *list = &wq->ordered_list; in run_ordered_work()
181 spinlock_t *lock = &wq->list_lock; in run_ordered_work()
248 trace_btrfs_all_work_done(wq->fs_info, work); in run_ordered_work()
256 trace_btrfs_all_work_done(wq->fs_info, self); in run_ordered_work()
264 struct btrfs_workqueue *wq = work->wq; in btrfs_work_helper() local
279 thresh_exec_hook(wq); in btrfs_work_helper()
290 run_ordered_work(wq, work); in btrfs_work_helper()
293 trace_btrfs_all_work_done(wq->fs_info, work); in btrfs_work_helper()
308 void btrfs_queue_work(struct btrfs_workqueue *wq, struct btrfs_work *work) in btrfs_queue_work() argument
312 work->wq = wq; in btrfs_queue_work()
313 thresh_queue_hook(wq); in btrfs_queue_work()
315 spin_lock_irqsave(&wq->list_lock, flags); in btrfs_queue_work()
316 list_add_tail(&work->ordered_list, &wq->ordered_list); in btrfs_queue_work()
317 spin_unlock_irqrestore(&wq->list_lock, flags); in btrfs_queue_work()
320 queue_work(wq->normal_wq, &work->normal_work); in btrfs_queue_work()
323 void btrfs_destroy_workqueue(struct btrfs_workqueue *wq) in btrfs_destroy_workqueue() argument
325 if (!wq) in btrfs_destroy_workqueue()
327 destroy_workqueue(wq->normal_wq); in btrfs_destroy_workqueue()
328 trace_btrfs_workqueue_destroy(wq); in btrfs_destroy_workqueue()
329 kfree(wq); in btrfs_destroy_workqueue()
332 void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int limit_active) in btrfs_workqueue_set_max() argument
334 if (wq) in btrfs_workqueue_set_max()
335 wq->limit_active = limit_active; in btrfs_workqueue_set_max()
338 void btrfs_flush_workqueue(struct btrfs_workqueue *wq) in btrfs_flush_workqueue() argument
340 flush_workqueue(wq->normal_wq); in btrfs_flush_workqueue()