Skip to contentSkip to conversation

btrfs: fix transaction handle leaks in btrfs_last_identity_remap_gone()

PATCH In review Mark Harmstone 2 participants 2 messages Feb 19 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: fix transaction handle leaks in btrfs_last_identity_remap_gone()

btrfs_abort_transaction(), unlike btrfs_commit_transaction(), doesn't also free the transaction handle. Fix the instances in btrfs_last_identity_remap_gone() where we're also leaking the transaction on abort.

This fixes a bug introduced in "btrfs: handle deletions from remapped block group" in for-next.

---
 fs/btrfs/relocation.c | 3 +++
 1 file changed, 3 insertions(+)
fs/btrfs/relocation.c +3 -0
index 8a8a66112d42..f2abc5d625c1 100644
@@ -4715,6 +4715,7 @@ int btrfs_last_identity_remap_gone(struct btrfs_chunk_map *chunk_map,
 	ret = btrfs_remove_dev_extents(trans, chunk_map);
 	if (unlikely(ret)) {
 		btrfs_abort_transaction(trans, ret);
+		btrfs_end_transaction(trans);
 		return ret;
 	}
 
@@ -4724,6 +4725,7 @@ int btrfs_last_identity_remap_gone(struct btrfs_chunk_map *chunk_map,
 		if (unlikely(ret)) {
 			mutex_unlock(&trans->fs_info->chunk_mutex);
 			btrfs_abort_transaction(trans, ret);
+			btrfs_end_transaction(trans);
 			return ret;
 		}
 	}
@@ -4742,6 +4744,7 @@ int btrfs_last_identity_remap_gone(struct btrfs_chunk_map *chunk_map,
 	ret = remove_chunk_stripes(trans, chunk_map, path);
 	if (unlikely(ret)) {
 		btrfs_abort_transaction(trans, ret);
+		btrfs_end_transaction(trans);
 		return ret;
 	}
 
Signature · 1 line
2.52.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Mark Harmstone

btrfs_abort_transaction(), unlike btrfs_commit_transaction(), doesn't also free the transaction handle. Fix the instances in btrfs_last_identity_remap_gone() where we're also leaking the transaction on abort.

This fixes a bug introduced in "btrfs: handle deletions from remapped block group" in for-next.

In for-next and in Linus' tree already, commit 979e1dc3d69e4c825eec05d05d9567b251f6ec23.
Once you see David's pull request to Linus, you can assume the commit ID is stable and it will match the commit ID in Linus' tree once merged.

So we can, and should, add here:

Fixes 979e1dc3d69e ("btrfs: handle deletions from remapped block group")

With that added:

Thanks.

Quoted 40 lines
---
 fs/btrfs/relocation.c | 3 +++
 1 file changed, 3 insertions(+)
fs/btrfs/relocation.c +3 -1
index 8a8a66112d42..f2abc5d625c1 100644
@@ -4715,6 +4715,7 @@ int btrfs_last_identity_remap_gone(struct btrfs_chunk_map *chunk_map,
        ret = btrfs_remove_dev_extents(trans, chunk_map);
        if (unlikely(ret)) {
                btrfs_abort_transaction(trans, ret);
+               btrfs_end_transaction(trans);
                return ret;
        }
 
@@ -4724,6 +4725,7 @@ int btrfs_last_identity_remap_gone(struct btrfs_chunk_map *chunk_map,
                if (unlikely(ret)) {
                        mutex_unlock(&trans->fs_info->chunk_mutex);
                        btrfs_abort_transaction(trans, ret);
+                       btrfs_end_transaction(trans);
                        return ret;
                }
        }
@@ -4742,6 +4744,7 @@ int btrfs_last_identity_remap_gone(struct btrfs_chunk_map *chunk_map,
        ret = remove_chunk_stripes(trans, chunk_map, path);
        if (unlikely(ret)) {
                btrfs_abort_transaction(trans, ret);
+               btrfs_end_transaction(trans);
                return ret;
        }
 
--

2.52.0