Skip to content

Commit 1432189

Browse files
maharmstoneadam900710
authored andcommitted
btrfs-progs: fix corruption when doing mkfs.btrfs with -O ^no-holes
Commit 44b83ff introduces a bug: when we encountered a hole in the source file, we're creating a explicit file extent. But as we're zero-initializing the struct btrfs_file_extent_item, we're setting its type to BTRFS_FILE_EXTENT_INLINE. Fix this by forcing it to be BTRFS_FILE_EXTENT_REG. Signed-off-by: Mark Harmstone <mark@harmstone.com>
1 parent f82b83e commit 1432189

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

mkfs/rootdir.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,7 @@ static int add_file_item_extent(struct btrfs_trans_handle *trans,
819819
*/
820820
const u64 length = min_t(u64, next - file_pos, SZ_1G);
821821

822+
btrfs_set_stack_file_extent_type(&stack_fi, BTRFS_FILE_EXTENT_REG);
822823
btrfs_set_stack_file_extent_num_bytes(&stack_fi, length);
823824
btrfs_set_stack_file_extent_ram_bytes(&stack_fi, length);
824825
ret = btrfs_insert_file_extent(trans, root, objectid, file_pos, &stack_fi);

0 commit comments

Comments
 (0)