Skip to content

Commit 967ef51

Browse files
jmaggard10masoncl
authored andcommitted
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 <[email protected]> Signed-off-by: Chris Mason <[email protected]>
1 parent 036a934 commit 967ef51

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/btrfs/qgroup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,9 +993,10 @@ int btrfs_quota_disable(struct btrfs_trans_handle *trans,
993993
mutex_lock(&fs_info->qgroup_ioctl_lock);
994994
if (!fs_info->quota_root)
995995
goto out;
996-
spin_lock(&fs_info->qgroup_lock);
997996
fs_info->quota_enabled = 0;
998997
fs_info->pending_quota_state = 0;
998+
btrfs_qgroup_wait_for_completion(fs_info);
999+
spin_lock(&fs_info->qgroup_lock);
9991000
quota_root = fs_info->quota_root;
10001001
fs_info->quota_root = NULL;
10011002
fs_info->qgroup_flags &= ~BTRFS_QGROUP_STATUS_FLAG_ON;

0 commit comments

Comments
 (0)