This is a note to let you know that I've just added the patch titled btrfs: zoned: fix wrong mutex unlock on failure to allocate log root tree to the 5.12-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: btrfs-zoned-fix-wrong-mutex-unlock-on-failure-to-allocate-log-root-tree.patch and it can be found in the queue-5.12 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From ea32af47f00a046a1f953370514d6d946efe0152 Mon Sep 17 00:00:00 2001 From: Filipe Manana <fdmanana@xxxxxxxx> Date: Wed, 7 Jul 2021 12:23:45 +0100 Subject: btrfs: zoned: fix wrong mutex unlock on failure to allocate log root tree From: Filipe Manana <fdmanana@xxxxxxxx> commit ea32af47f00a046a1f953370514d6d946efe0152 upstream. When syncing the log, if we fail to allocate the root node for the log root tree: 1) We are unlocking fs_info->tree_log_mutex, but at this point we have not yet locked this mutex; 2) We have locked fs_info->tree_root->log_mutex, but we end up not unlocking it; So fix this by unlocking fs_info->tree_root->log_mutex instead of fs_info->tree_log_mutex. Fixes: e75f9fd194090e ("btrfs: zoned: move log tree node allocation out of log_root_tree->log_mutex") CC: stable@xxxxxxxxxxxxxxx # 5.13+ Reviewed-by: Nikolay Borisov <nborisov@xxxxxxxx> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@xxxxxxx> Signed-off-by: Filipe Manana <fdmanana@xxxxxxxx> Signed-off-by: David Sterba <dsterba@xxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/btrfs/tree-log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -3173,7 +3173,7 @@ int btrfs_sync_log(struct btrfs_trans_ha if (!log_root_tree->node) { ret = btrfs_alloc_log_tree_node(trans, log_root_tree); if (ret) { - mutex_unlock(&fs_info->tree_log_mutex); + mutex_unlock(&fs_info->tree_root->log_mutex); goto out; } } Patches currently in stable-queue which might be from fdmanana@xxxxxxxx are queue-5.12/btrfs-fix-deadlock-with-concurrent-chunk-allocations-involving-system-chunks.patch queue-5.12/btrfs-zoned-fix-wrong-mutex-unlock-on-failure-to-allocate-log-root-tree.patch queue-5.12/btrfs-rework-chunk-allocation-to-avoid-exhaustion-of-the-system-chunk-array.patch