Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 165899
b: refs/heads/master
c: 6e74057
h: refs/heads/master
i:
  165897: dbe4d6a
  165895: 6291dcb
v: v3
  • Loading branch information
Chris Mason committed Sep 16, 2009
1 parent 82a0cf1 commit b99cf3f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 627e421a3f35ad6b52dc58982fb6f8a97c30dcd7
refs/heads/master: 6e74057c4686dc12ea767b4bdc50a63876056e1c
16 changes: 10 additions & 6 deletions trunk/fs/btrfs/async-thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ static int try_worker_shutdown(struct btrfs_worker_thread *worker)
!worker->working &&
!list_empty(&worker->worker_list) &&
list_empty(&worker->prio_pending) &&
list_empty(&worker->pending)) {
list_empty(&worker->pending) &&
atomic_read(&worker->num_pending) == 0) {
freeit = 1;
list_del_init(&worker->worker_list);
worker->workers->num_workers--;
Expand Down Expand Up @@ -485,7 +486,6 @@ static struct btrfs_worker_thread *next_worker(struct btrfs_workers *workers)
*/
next = workers->worker_list.next;
worker = list_entry(next, struct btrfs_worker_thread, worker_list);
atomic_inc(&worker->num_pending);
worker->sequence++;

if (worker->sequence % workers->idle_thresh == 0)
Expand Down Expand Up @@ -521,8 +521,7 @@ static struct btrfs_worker_thread *find_worker(struct btrfs_workers *workers)
goto again;
}
}
spin_unlock_irqrestore(&workers->lock, flags);
return worker;
goto found;

fallback:
fallback = NULL;
Expand All @@ -537,6 +536,12 @@ static struct btrfs_worker_thread *find_worker(struct btrfs_workers *workers)
BUG_ON(!fallback);
worker = list_entry(fallback,
struct btrfs_worker_thread, worker_list);
found:
/*
* this makes sure the worker doesn't exit before it is placed
* onto a busy/idle list
*/
atomic_inc(&worker->num_pending);
spin_unlock_irqrestore(&workers->lock, flags);
return worker;
}
Expand Down Expand Up @@ -569,7 +574,7 @@ int btrfs_requeue_work(struct btrfs_work *work)
spin_lock(&worker->workers->lock);
worker->idle = 0;
list_move_tail(&worker->worker_list,
&worker->workers->worker_list);
&worker->workers->worker_list);
spin_unlock(&worker->workers->lock);
}
if (!worker->working) {
Expand Down Expand Up @@ -627,7 +632,6 @@ int btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work)
list_add_tail(&work->list, &worker->prio_pending);
else
list_add_tail(&work->list, &worker->pending);
atomic_inc(&worker->num_pending);
check_busy_worker(worker);

/*
Expand Down

0 comments on commit b99cf3f

Please sign in to comment.