diff options
-rw-r--r-- | fs/btrfs/async-thread.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c index 6ea5cd0a595f..73df627ab8ab 100644 --- a/fs/btrfs/async-thread.c +++ b/fs/btrfs/async-thread.c | |||
@@ -74,7 +74,12 @@ static void check_idle_worker(struct btrfs_worker_thread *worker) | |||
74 | unsigned long flags; | 74 | unsigned long flags; |
75 | spin_lock_irqsave(&worker->workers->lock, flags); | 75 | spin_lock_irqsave(&worker->workers->lock, flags); |
76 | worker->idle = 1; | 76 | worker->idle = 1; |
77 | list_move(&worker->worker_list, &worker->workers->idle_list); | 77 | |
78 | /* the list may be empty if the worker is just starting */ | ||
79 | if (!list_empty(&worker->worker_list)) { | ||
80 | list_move(&worker->worker_list, | ||
81 | &worker->workers->idle_list); | ||
82 | } | ||
78 | spin_unlock_irqrestore(&worker->workers->lock, flags); | 83 | spin_unlock_irqrestore(&worker->workers->lock, flags); |
79 | } | 84 | } |
80 | } | 85 | } |
@@ -90,8 +95,11 @@ static void check_busy_worker(struct btrfs_worker_thread *worker) | |||
90 | unsigned long flags; | 95 | unsigned long flags; |
91 | spin_lock_irqsave(&worker->workers->lock, flags); | 96 | spin_lock_irqsave(&worker->workers->lock, flags); |
92 | worker->idle = 0; | 97 | worker->idle = 0; |
93 | list_move_tail(&worker->worker_list, | 98 | |
94 | &worker->workers->worker_list); | 99 | if (!list_empty(&worker->worker_list)) { |
100 | list_move_tail(&worker->worker_list, | ||
101 | &worker->workers->worker_list); | ||
102 | } | ||
95 | spin_unlock_irqrestore(&worker->workers->lock, flags); | 103 | spin_unlock_irqrestore(&worker->workers->lock, flags); |
96 | } | 104 | } |
97 | } | 105 | } |