Skip to contentSkip to conversation

Btrfs: fix transaction handle leak in balance

PATCH In review [email protected] 2 participants 2 messages Dec 10, 2015 – Dec 11, 2015 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs: fix transaction handle leak in balance

From: Filipe Manana <[email protected]>

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")
---
 fs/btrfs/volumes.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/volumes.c +1 -2
index 3e55e07..f5e5e20 100644
@@ -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;
 		}
 
Signature · 1 line
2.1.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · On Thu, Dec 10, 2015 at 11:16:27AM +0000, [email protected] wrote:

From: Filipe Manana <[email protected]>

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.

Looks good.

Thanks,

-liubo

Quoted 32 lines
Fixes 2c9fe8355258 ("btrfs: Fix lost-data-profile caused by balance bg")
---
 fs/btrfs/volumes.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/volumes.c +1 -2
index 3e55e07..f5e5e20 100644
@@ -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;
 		}
 
Signature · 6 lines
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html