Skip to content

Commit bd72717

Browse files
josefbacikkdave
authored andcommitted
btrfs: handle logged extent failure properly
If we're allocating a logged extent we attempt to insert an extent record for the file extent directly. We increase space_info->bytes_reserved, because the extent entry addition will call btrfs_update_block_group(), which will convert the ->bytes_reserved to ->bytes_used. However if we fail at any point while inserting the extent entry we will bail and leave space on ->bytes_reserved, which will trigger a WARN_ON() on umount. Fix this by pinning the space if we fail to insert, which is what happens in every other failure case that involves adding the extent entry. CC: [email protected] # 5.4+ Reviewed-by: Johannes Thumshirn <[email protected]> Reviewed-by: Nikolay Borisov <[email protected]> Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 1e90315 commit bd72717

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/btrfs/extent-tree.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4430,6 +4430,8 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans,
44304430

44314431
ret = alloc_reserved_file_extent(trans, 0, root_objectid, 0, owner,
44324432
offset, ins, 1);
4433+
if (ret)
4434+
btrfs_pin_extent(fs_info, ins->objectid, ins->offset, 1);
44334435
btrfs_put_block_group(block_group);
44344436
return ret;
44354437
}

0 commit comments

Comments
 (0)