Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH] btrfs: free qgroup configuration when quota enable fails
@ 2026-08-14 11:22 Guanjie Chen
  2026-08-14 11:49 ` Qu Wenruo
  0 siblings, 1 reply; 8+ messages in thread
From: Guanjie Chen @ 2026-08-14 11:22 UTC (permalink / raw)
  To: linux-btrfs; +Cc: clm, dsterba, fdmanana, linux-kernel, Guanjie Chen

Quota enable adds qgroups to fs_info->qgroup_tree before the operation is
guaranteed to succeed.  On failure, the current error path removes only the
sysfs entries, leaving the qgroups and their relations in memory.

Use btrfs_free_qgroup_config() instead.  It is the existing qgroup teardown
helper and removes the in-memory qgroups, their relations and the sysfs
entries.

This is safe because the failure cleanup runs with qgroup_ioctl_lock held
and before quota_root is published or quota accounting is enabled.  Qgroups
already added to the tree are freed by btrfs_free_qgroup_config(), while an
untransferred preallocation and quota_root are still released by the
existing cleanup code.  Transaction handling is unchanged.

Signed-off-by: Guanjie Chen <jk.chen1095@gmail.com>
---
 fs/btrfs/qgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -1292,7 +1292,7 @@ out_free_root:
 		btrfs_put_root(quota_root);
 out:
 	if (ret)
-		btrfs_sysfs_del_qgroups(fs_info);
+		btrfs_free_qgroup_config(fs_info);
 	mutex_unlock(&fs_info->qgroup_ioctl_lock);
 	if (ret && trans)
 		btrfs_end_transaction(trans);
-- 
2.43.0


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

end of thread, other threads:[~2026-08-15  9:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <d239645a-b291-4fe9-b256-f0be849c875a@suse.com@suse.com>
2026-08-15  9:00 ` [PATCH] btrfs: free qgroup configuration when quota enable fails Guanjie Chen
2026-08-15  9:08   ` Qu Wenruo
2026-08-14 11:22 Guanjie Chen
2026-08-14 11:49 ` Qu Wenruo
2026-08-14 12:30   ` Guanjie Chen
2026-08-14 22:13     ` Qu Wenruo
2026-08-15  6:44       ` Guanjie Chen
2026-08-15  8:03         ` Qu Wenruo

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