aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/async-thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/async-thread.c')
-rw-r--r--fs/btrfs/async-thread.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index 2a5f383c3636..a709585e2c97 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -32,7 +32,7 @@
32#define NO_THRESHOLD (-1) 32#define NO_THRESHOLD (-1)
33#define DFT_THRESHOLD (32) 33#define DFT_THRESHOLD (32)
34 34
35struct __btrfs_workqueue_struct { 35struct __btrfs_workqueue {
36 struct workqueue_struct *normal_wq; 36 struct workqueue_struct *normal_wq;
37 /* List head pointing to ordered work list */ 37 /* List head pointing to ordered work list */
38 struct list_head ordered_list; 38 struct list_head ordered_list;
@@ -49,15 +49,15 @@ struct __btrfs_workqueue_struct {
49 spinlock_t thres_lock; 49 spinlock_t thres_lock;
50}; 50};
51 51
52struct btrfs_workqueue_struct { 52struct btrfs_workqueue {
53 struct __btrfs_workqueue_struct *normal; 53 struct __btrfs_workqueue *normal;
54 struct __btrfs_workqueue_struct *high; 54 struct __btrfs_workqueue *high;
55}; 55};
56 56
57static inline struct __btrfs_workqueue_struct 57static inline struct __btrfs_workqueue
58*__btrfs_alloc_workqueue(char *name, int flags, int max_active, int thresh) 58*__btrfs_alloc_workqueue(char *name, int flags, int max_active, int thresh)
59{ 59{
60 struct __btrfs_workqueue_struct *ret = kzalloc(sizeof(*ret), GFP_NOFS); 60 struct __btrfs_workqueue *ret = kzalloc(sizeof(*ret), GFP_NOFS);
61 61
62 if (unlikely(!ret)) 62 if (unlikely(!ret))
63 return NULL; 63 return NULL;
@@ -95,14 +95,14 @@ static inline struct __btrfs_workqueue_struct
95} 95}
96 96
97static inline void 97static inline void
98__btrfs_destroy_workqueue(struct __btrfs_workqueue_struct *wq); 98__btrfs_destroy_workqueue(struct __btrfs_workqueue *wq);
99 99
100struct btrfs_workqueue_struct *btrfs_alloc_workqueue(char *name, 100struct btrfs_workqueue *btrfs_alloc_workqueue(char *name,
101 int flags, 101 int flags,
102 int max_active, 102 int max_active,
103 int thresh) 103 int thresh)
104{ 104{
105 struct btrfs_workqueue_struct *ret = kzalloc(sizeof(*ret), GFP_NOFS); 105 struct btrfs_workqueue *ret = kzalloc(sizeof(*ret), GFP_NOFS);
106 106
107 if (unlikely(!ret)) 107 if (unlikely(!ret))
108 return NULL; 108 return NULL;
@@ -131,7 +131,7 @@ struct btrfs_workqueue_struct *btrfs_alloc_workqueue(char *name,
131 * This hook WILL be called in IRQ handler context, 131 * This hook WILL be called in IRQ handler context,
132 * so workqueue_set_max_active MUST NOT be called in this hook 132 * so workqueue_set_max_active MUST NOT be called in this hook
133 */ 133 */
134static inline void thresh_queue_hook(struct __btrfs_workqueue_struct *wq) 134static inline void thresh_queue_hook(struct __btrfs_workqueue *wq)
135{ 135{
136 if (wq->thresh == NO_THRESHOLD) 136 if (wq->thresh == NO_THRESHOLD)
137 return; 137 return;
@@ -143,7 +143,7 @@ static inline void thresh_queue_hook(struct __btrfs_workqueue_struct *wq)
143 * This hook is called in kthread content. 143 * This hook is called in kthread content.
144 * So workqueue_set_max_active is called here. 144 * So workqueue_set_max_active is called here.
145 */ 145 */
146static inline void thresh_exec_hook(struct __btrfs_workqueue_struct *wq) 146static inline void thresh_exec_hook(struct __btrfs_workqueue *wq)
147{ 147{
148 int new_max_active; 148 int new_max_active;
149 long pending; 149 long pending;
@@ -186,10 +186,10 @@ out:
186 } 186 }
187} 187}
188 188
189static void run_ordered_work(struct __btrfs_workqueue_struct *wq) 189static void run_ordered_work(struct __btrfs_workqueue *wq)
190{ 190{
191 struct list_head *list = &wq->ordered_list; 191 struct list_head *list = &wq->ordered_list;
192 struct btrfs_work_struct *work; 192 struct btrfs_work *work;
193 spinlock_t *lock = &wq->list_lock; 193 spinlock_t *lock = &wq->list_lock;
194 unsigned long flags; 194 unsigned long flags;
195 195
@@ -197,7 +197,7 @@ static void run_ordered_work(struct __btrfs_workqueue_struct *wq)
197 spin_lock_irqsave(lock, flags); 197 spin_lock_irqsave(lock, flags);
198 if (list_empty(list)) 198 if (list_empty(list))
199 break; 199 break;
200 work = list_entry(list->next, struct btrfs_work_struct, 200 work = list_entry(list->next, struct btrfs_work,
201 ordered_list); 201 ordered_list);
202 if (!test_bit(WORK_DONE_BIT, &work->flags)) 202 if (!test_bit(WORK_DONE_BIT, &work->flags))
203 break; 203 break;
@@ -229,11 +229,11 @@ static void run_ordered_work(struct __btrfs_workqueue_struct *wq)
229 229
230static void normal_work_helper(struct work_struct *arg) 230static void normal_work_helper(struct work_struct *arg)
231{ 231{
232 struct btrfs_work_struct *work; 232 struct btrfs_work *work;
233 struct __btrfs_workqueue_struct *wq; 233 struct __btrfs_workqueue *wq;
234 int need_order = 0; 234 int need_order = 0;
235 235
236 work = container_of(arg, struct btrfs_work_struct, normal_work); 236 work = container_of(arg, struct btrfs_work, normal_work);
237 /* 237 /*
238 * We should not touch things inside work in the following cases: 238 * We should not touch things inside work in the following cases:
239 * 1) after work->func() if it has no ordered_free 239 * 1) after work->func() if it has no ordered_free
@@ -254,10 +254,10 @@ static void normal_work_helper(struct work_struct *arg)
254 } 254 }
255} 255}
256 256
257void btrfs_init_work(struct btrfs_work_struct *work, 257void btrfs_init_work(struct btrfs_work *work,
258 void (*func)(struct btrfs_work_struct *), 258 void (*func)(struct btrfs_work *),
259 void (*ordered_func)(struct btrfs_work_struct *), 259 void (*ordered_func)(struct btrfs_work *),
260 void (*ordered_free)(struct btrfs_work_struct *)) 260 void (*ordered_free)(struct btrfs_work *))
261{ 261{
262 work->func = func; 262 work->func = func;
263 work->ordered_func = ordered_func; 263 work->ordered_func = ordered_func;
@@ -267,8 +267,8 @@ void btrfs_init_work(struct btrfs_work_struct *work,
267 work->flags = 0; 267 work->flags = 0;
268} 268}
269 269
270static inline void __btrfs_queue_work(struct __btrfs_workqueue_struct *wq, 270static inline void __btrfs_queue_work(struct __btrfs_workqueue *wq,
271 struct btrfs_work_struct *work) 271 struct btrfs_work *work)
272{ 272{
273 unsigned long flags; 273 unsigned long flags;
274 274
@@ -282,10 +282,10 @@ static inline void __btrfs_queue_work(struct __btrfs_workqueue_struct *wq,
282 queue_work(wq->normal_wq, &work->normal_work); 282 queue_work(wq->normal_wq, &work->normal_work);
283} 283}
284 284
285void btrfs_queue_work(struct btrfs_workqueue_struct *wq, 285void btrfs_queue_work(struct btrfs_workqueue *wq,
286 struct btrfs_work_struct *work) 286 struct btrfs_work *work)
287{ 287{
288 struct __btrfs_workqueue_struct *dest_wq; 288 struct __btrfs_workqueue *dest_wq;
289 289
290 if (test_bit(WORK_HIGH_PRIO_BIT, &work->flags) && wq->high) 290 if (test_bit(WORK_HIGH_PRIO_BIT, &work->flags) && wq->high)
291 dest_wq = wq->high; 291 dest_wq = wq->high;
@@ -295,13 +295,13 @@ void btrfs_queue_work(struct btrfs_workqueue_struct *wq,
295} 295}
296 296
297static inline void 297static inline void
298__btrfs_destroy_workqueue(struct __btrfs_workqueue_struct *wq) 298__btrfs_destroy_workqueue(struct __btrfs_workqueue *wq)
299{ 299{
300 destroy_workqueue(wq->normal_wq); 300 destroy_workqueue(wq->normal_wq);
301 kfree(wq); 301 kfree(wq);
302} 302}
303 303
304void btrfs_destroy_workqueue(struct btrfs_workqueue_struct *wq) 304void btrfs_destroy_workqueue(struct btrfs_workqueue *wq)
305{ 305{
306 if (!wq) 306 if (!wq)
307 return; 307 return;
@@ -310,14 +310,14 @@ void btrfs_destroy_workqueue(struct btrfs_workqueue_struct *wq)
310 __btrfs_destroy_workqueue(wq->normal); 310 __btrfs_destroy_workqueue(wq->normal);
311} 311}
312 312
313void btrfs_workqueue_set_max(struct btrfs_workqueue_struct *wq, int max) 313void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max)
314{ 314{
315 wq->normal->max_active = max; 315 wq->normal->max_active = max;
316 if (wq->high) 316 if (wq->high)
317 wq->high->max_active = max; 317 wq->high->max_active = max;
318} 318}
319 319
320void btrfs_set_work_high_priority(struct btrfs_work_struct *work) 320void btrfs_set_work_high_priority(struct btrfs_work *work)
321{ 321{
322 set_bit(WORK_HIGH_PRIO_BIT, &work->flags); 322 set_bit(WORK_HIGH_PRIO_BIT, &work->flags);
323} 323}