Skip to content

Commit 5150bf1

Browse files
fdmananakdave
authored andcommitted
btrfs: fix memory leak of transaction when deleting unused block group
When cleaning pinned extents right before deleting an unused block group, we check if there's still a previous transaction running and if so we increment its reference count before using it for cleaning pinned ranges in its pinned extents iotree. However we ended up never decrementing the reference count after using the transaction, resulting in a memory leak. Fix it by decrementing the reference count. Fixes: fe119a6 ("btrfs: switch to per-transaction pinned extents") Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 317ddf3 commit 5150bf1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/btrfs/block-group.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,11 +1288,15 @@ static bool clean_pinned_extents(struct btrfs_trans_handle *trans,
12881288
if (ret)
12891289
goto err;
12901290
mutex_unlock(&fs_info->unused_bg_unpin_mutex);
1291+
if (prev_trans)
1292+
btrfs_put_transaction(prev_trans);
12911293

12921294
return true;
12931295

12941296
err:
12951297
mutex_unlock(&fs_info->unused_bg_unpin_mutex);
1298+
if (prev_trans)
1299+
btrfs_put_transaction(prev_trans);
12961300
btrfs_dec_block_group_ro(bg);
12971301
return false;
12981302
}

0 commit comments

Comments
 (0)