All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: qgroup: fix quota disable during rescan
@ 2015-11-06 18:36 Justin Maggard
  2015-11-07 15:01 ` Filipe Manana
  2015-11-19 13:08 ` David Sterba
  0 siblings, 2 replies; 6+ messages in thread
From: Justin Maggard @ 2015-11-06 18:36 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Justin Maggard

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 <jmaggard@netgear.com>
---
 fs/btrfs/qgroup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 75c0249..a7cf504 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;
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-11-19 15:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-06 18:36 [PATCH] btrfs: qgroup: fix quota disable during rescan Justin Maggard
2015-11-07 15:01 ` Filipe Manana
2015-11-19 13:08 ` David Sterba
2015-11-19 13:16   ` Filipe Manana
2015-11-19 13:20     ` David Sterba
2015-11-19 15:01       ` Chris Mason

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.