public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs/async-thread.c: decrease workers->num_workers only on worker can be freed in btrfs_stop_workers
@ 2012-03-16  3:04 Wang Sheng-Hui
  0 siblings, 0 replies; only message in thread
From: Wang Sheng-Hui @ 2012-03-16  3:04 UTC (permalink / raw)
  To: Chris Mason, linux-btrfs, linux-kernel

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.


Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
---
 fs/btrfs/async-thread.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index 0cc20b3..5a7d756 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -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
-- 
1.7.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-03-16  3:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-16  3:04 [PATCH] btrfs/async-thread.c: decrease workers->num_workers only on worker can be freed in btrfs_stop_workers Wang Sheng-Hui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox