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.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index 5f2f5a8c2289..958cd8b5f0d7 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -48,6 +48,7 @@ struct btrfs_worker_thread {
48 48
49 /* number of things on the pending list */ 49 /* number of things on the pending list */
50 atomic_t num_pending; 50 atomic_t num_pending;
51 unsigned long sequence;
51 52
52 /* protects the pending list. */ 53 /* protects the pending list. */
53 spinlock_t lock; 54 spinlock_t lock;
@@ -197,6 +198,7 @@ int btrfs_start_workers(struct btrfs_workers *workers, int num_workers)
197 198
198 spin_lock_irq(&workers->lock); 199 spin_lock_irq(&workers->lock);
199 list_add_tail(&worker->worker_list, &workers->idle_list); 200 list_add_tail(&worker->worker_list, &workers->idle_list);
201 worker->idle = 1;
200 workers->num_workers++; 202 workers->num_workers++;
201 spin_unlock_irq(&workers->lock); 203 spin_unlock_irq(&workers->lock);
202 } 204 }
@@ -238,7 +240,10 @@ static struct btrfs_worker_thread *next_worker(struct btrfs_workers *workers)
238 */ 240 */
239 next = workers->worker_list.next; 241 next = workers->worker_list.next;
240 worker = list_entry(next, struct btrfs_worker_thread, worker_list); 242 worker = list_entry(next, struct btrfs_worker_thread, worker_list);
241 list_move_tail(next, &workers->worker_list); 243 atomic_inc(&worker->num_pending);
244 worker->sequence++;
245 if (worker->sequence % 4 == 0)
246 list_move_tail(next, &workers->worker_list);
242 return worker; 247 return worker;
243} 248}
244 249