diff options
Diffstat (limited to 'fs/btrfs/async-thread.c')
-rw-r--r-- | fs/btrfs/async-thread.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c index 5fb60ea7eee2..e0f071f6b5a7 100644 --- a/fs/btrfs/async-thread.c +++ b/fs/btrfs/async-thread.c | |||
@@ -34,6 +34,10 @@ | |||
34 | 34 | ||
35 | struct __btrfs_workqueue { | 35 | struct __btrfs_workqueue { |
36 | struct workqueue_struct *normal_wq; | 36 | struct workqueue_struct *normal_wq; |
37 | |||
38 | /* File system this workqueue services */ | ||
39 | struct btrfs_fs_info *fs_info; | ||
40 | |||
37 | /* List head pointing to ordered work list */ | 41 | /* List head pointing to ordered work list */ |
38 | struct list_head ordered_list; | 42 | struct list_head ordered_list; |
39 | 43 | ||
@@ -70,6 +74,18 @@ void btrfs_##name(struct work_struct *arg) \ | |||
70 | normal_work_helper(work); \ | 74 | normal_work_helper(work); \ |
71 | } | 75 | } |
72 | 76 | ||
77 | struct btrfs_fs_info * | ||
78 | btrfs_workqueue_owner(struct __btrfs_workqueue *wq) | ||
79 | { | ||
80 | return wq->fs_info; | ||
81 | } | ||
82 | |||
83 | struct btrfs_fs_info * | ||
84 | btrfs_work_owner(struct btrfs_work *work) | ||
85 | { | ||
86 | return work->wq->fs_info; | ||
87 | } | ||
88 | |||
73 | BTRFS_WORK_HELPER(worker_helper); | 89 | BTRFS_WORK_HELPER(worker_helper); |
74 | BTRFS_WORK_HELPER(delalloc_helper); | 90 | BTRFS_WORK_HELPER(delalloc_helper); |
75 | BTRFS_WORK_HELPER(flush_delalloc_helper); | 91 | BTRFS_WORK_HELPER(flush_delalloc_helper); |
@@ -94,14 +110,15 @@ BTRFS_WORK_HELPER(scrubnc_helper); | |||
94 | BTRFS_WORK_HELPER(scrubparity_helper); | 110 | BTRFS_WORK_HELPER(scrubparity_helper); |
95 | 111 | ||
96 | static struct __btrfs_workqueue * | 112 | static struct __btrfs_workqueue * |
97 | __btrfs_alloc_workqueue(const char *name, unsigned int flags, int limit_active, | 113 | __btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info, const char *name, |
98 | int thresh) | 114 | unsigned int flags, int limit_active, int thresh) |
99 | { | 115 | { |
100 | struct __btrfs_workqueue *ret = kzalloc(sizeof(*ret), GFP_KERNEL); | 116 | struct __btrfs_workqueue *ret = kzalloc(sizeof(*ret), GFP_KERNEL); |
101 | 117 | ||
102 | if (!ret) | 118 | if (!ret) |
103 | return NULL; | 119 | return NULL; |
104 | 120 | ||
121 | ret->fs_info = fs_info; | ||
105 | ret->limit_active = limit_active; | 122 | ret->limit_active = limit_active; |
106 | atomic_set(&ret->pending, 0); | 123 | atomic_set(&ret->pending, 0); |
107 | if (thresh == 0) | 124 | if (thresh == 0) |
@@ -143,7 +160,8 @@ __btrfs_alloc_workqueue(const char *name, unsigned int flags, int limit_active, | |||
143 | static inline void | 160 | static inline void |
144 | __btrfs_destroy_workqueue(struct __btrfs_workqueue *wq); | 161 | __btrfs_destroy_workqueue(struct __btrfs_workqueue *wq); |
145 | 162 | ||
146 | struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name, | 163 | struct btrfs_workqueue *btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info, |
164 | const char *name, | ||
147 | unsigned int flags, | 165 | unsigned int flags, |
148 | int limit_active, | 166 | int limit_active, |
149 | int thresh) | 167 | int thresh) |
@@ -153,7 +171,8 @@ struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name, | |||
153 | if (!ret) | 171 | if (!ret) |
154 | return NULL; | 172 | return NULL; |
155 | 173 | ||
156 | ret->normal = __btrfs_alloc_workqueue(name, flags & ~WQ_HIGHPRI, | 174 | ret->normal = __btrfs_alloc_workqueue(fs_info, name, |
175 | flags & ~WQ_HIGHPRI, | ||
157 | limit_active, thresh); | 176 | limit_active, thresh); |
158 | if (!ret->normal) { | 177 | if (!ret->normal) { |
159 | kfree(ret); | 178 | kfree(ret); |
@@ -161,8 +180,8 @@ struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name, | |||
161 | } | 180 | } |
162 | 181 | ||
163 | if (flags & WQ_HIGHPRI) { | 182 | if (flags & WQ_HIGHPRI) { |
164 | ret->high = __btrfs_alloc_workqueue(name, flags, limit_active, | 183 | ret->high = __btrfs_alloc_workqueue(fs_info, name, flags, |
165 | thresh); | 184 | limit_active, thresh); |
166 | if (!ret->high) { | 185 | if (!ret->high) { |
167 | __btrfs_destroy_workqueue(ret->normal); | 186 | __btrfs_destroy_workqueue(ret->normal); |
168 | kfree(ret); | 187 | kfree(ret); |