Btrfs: fix transaction handle leak in balance
authorFilipe Manana <fdmanana@suse.com>
Thu, 10 Dec 2015 11:08:59 +0000 (11:08 +0000)
committerFilipe Manana <fdmanana@suse.com>
Thu, 10 Dec 2015 11:23:24 +0000 (11:23 +0000)
If we fail to allocate a new data chunk, we were jumping to the error path
without release the transaction handle we got before. Fix this by always
releasing it before doing the jump.

Fixes: 2c9fe8355258 ("btrfs: Fix lost-data-profile caused by balance bg")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
fs/btrfs/volumes.c

index 750285e4f274503ad0e34451c90b1b6c5a484fe5..86124cde907a8cc695230376e7e50b0bf0f6be1d 100644 (file)
@@ -3548,12 +3548,11 @@ again:
 
                        ret = btrfs_force_chunk_alloc(trans, chunk_root,
                                                      BTRFS_BLOCK_GROUP_DATA);
+                       btrfs_end_transaction(trans, chunk_root);
                        if (ret < 0) {
                                mutex_unlock(&fs_info->delete_unused_bgs_mutex);
                                goto error;
                        }
-
-                       btrfs_end_transaction(trans, chunk_root);
                        chunk_reserved = 1;
                }