aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2016-11-23 21:09:04 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-01-06 04:40:10 -0500
commit1a5ec7dd17a98547618ea7b0ef3bbeb3837a7c49 (patch)
tree62a436be168751b4980a20ed0cc0d7163bbe0b37
parenta1e0e0476afb2471f9cee0a995206b053a8241f8 (diff)
Btrfs: fix qgroup rescan worker initialization
commit 8d9eddad19467b008e0c881bc3133d7da94b7ec1 upstream. We were setting the qgroup_rescan_running flag to true only after the rescan worker started (which is a task run by a queue). So if a user space task starts a rescan and immediately after asks to wait for the rescan worker to finish, this second call might happen before the rescan worker task starts running, in which case the rescan wait ioctl returns immediatley, not waiting for the rescan worker to finish. This was making the fstest btrfs/022 fail very often. Fixes: d2c609b834d6 (btrfs: properly track when rescan worker is running) Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/btrfs/qgroup.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 11f4fffe503e..dfd99867ff4d 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -2335,10 +2335,6 @@ static void btrfs_qgroup_rescan_worker(struct btrfs_work *work)
2335 int err = -ENOMEM; 2335 int err = -ENOMEM;
2336 int ret = 0; 2336 int ret = 0;
2337 2337
2338 mutex_lock(&fs_info->qgroup_rescan_lock);
2339 fs_info->qgroup_rescan_running = true;
2340 mutex_unlock(&fs_info->qgroup_rescan_lock);
2341
2342 path = btrfs_alloc_path(); 2338 path = btrfs_alloc_path();
2343 if (!path) 2339 if (!path)
2344 goto out; 2340 goto out;
@@ -2449,6 +2445,7 @@ qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid,
2449 sizeof(fs_info->qgroup_rescan_progress)); 2445 sizeof(fs_info->qgroup_rescan_progress));
2450 fs_info->qgroup_rescan_progress.objectid = progress_objectid; 2446 fs_info->qgroup_rescan_progress.objectid = progress_objectid;
2451 init_completion(&fs_info->qgroup_rescan_completion); 2447 init_completion(&fs_info->qgroup_rescan_completion);
2448 fs_info->qgroup_rescan_running = true;
2452 2449
2453 spin_unlock(&fs_info->qgroup_lock); 2450 spin_unlock(&fs_info->qgroup_lock);
2454 mutex_unlock(&fs_info->qgroup_rescan_lock); 2451 mutex_unlock(&fs_info->qgroup_rescan_lock);