Skip to contentSkip to conversation

btrfs/async-thread.c: decrease workers->num_workers only on worker can be freed in btrfs_stop_workers

PATCH New Wang Sheng-Hui 1 participant 1 message Mar 16, 2012 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs/async-thread.c: decrease workers->num_workers only on worker can be freed in btrfs_stop_workers

If the worker cannot be freed, decrease workers->num_workers can corrupt the statistics. The workers->num_workers should be decreased only when the worker can be stopped and freed in btrfs_stop_workers.

---
 fs/btrfs/async-thread.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/btrfs/async-thread.c +1 -1
index 0cc20b3..5a7d756 100644
@@ -413,9 +413,9 @@ int btrfs_stop_workers(struct btrfs_workers *workers)
 				    worker_list);
 
 		atomic_inc(&worker->refs);
-		workers->num_workers -= 1;
 		if (!list_empty(&worker->worker_list)) {
 			list_del_init(&worker->worker_list);
+			workers->num_workers--;
 			put_worker(worker);
 			can_stop = 1;
 		} else
Signature · 1 line
1.7.1