diff mbox series

[3/3] btrfs: free qgroup metadata without holding the fs roots lock

Message ID 216b5bd4a975fc9dd462e3f9ce6af8b66a16d039.1657097693.git.fdmanana@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs: fix a couple sleeps while holding a spinlock | expand

Commit Message

Filipe Manana July 6, 2022, 9:09 a.m. UTC
From: Filipe Manana <fdmanana@suse.com>

At commit_fs_roots(), we are freeing the per transaction qgroup metadata
while holding the fs roots lock, which is not necessary as it does not
change anything in the root itself or the fs roots XArray. So change
that to be done without holding that lock.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/transaction.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 1283be132776..e014b5d8a813 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1447,8 +1447,8 @@  static noinline int commit_fs_roots(struct btrfs_trans_handle *trans)
 					&root->root_key, &root->root_item);
 		if (ret)
 			return ret;
-		mutex_lock(&fs_info->fs_roots_mutex);
 		btrfs_qgroup_free_meta_all_pertrans(root);
+		mutex_lock(&fs_info->fs_roots_mutex);
 	}
 	mutex_unlock(&fs_info->fs_roots_mutex);
 	return 0;