From: Justin Maggard Date: Fri, 6 Nov 2015 18:36:42 +0000 (-0800) Subject: btrfs: qgroup: fix quota disable during rescan X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=882f290d4af174b408bffc4a832d30d0cea93499;p=linux btrfs: qgroup: fix quota disable during rescan There's a race condition that leads to a NULL pointer dereference if you disable quotas while a quota rescan is running. To fix this, we just need to wait for the quota rescan worker to actually exit before tearing down the quota structures. Signed-off-by: Justin Maggard Signed-off-by: Chris Mason (cherry picked from commit 967ef5131e42d6e3bb216c44161d893048a49957) (cherry picked from commit 161f778b36a4308d697137c87f9ebeac8c5a71b7) --- diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 8a8202956576..ff646f587e77 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -993,9 +993,10 @@ int btrfs_quota_disable(struct btrfs_trans_handle *trans, mutex_lock(&fs_info->qgroup_ioctl_lock); if (!fs_info->quota_root) goto out; - spin_lock(&fs_info->qgroup_lock); fs_info->quota_enabled = 0; fs_info->pending_quota_state = 0; + btrfs_qgroup_wait_for_completion(fs_info); + spin_lock(&fs_info->qgroup_lock); quota_root = fs_info->quota_root; fs_info->quota_root = NULL; fs_info->qgroup_flags &= ~BTRFS_QGROUP_STATUS_FLAG_ON;