btrfs-progs: properly initialize extent generation in __btrfs_record_file_extent()
[BUG] When using mkfs.btrfs --rootdir option, the data extents generated will have 0 as their generation in extent tree: # mkdir /tmp/rootdir # xfs_io -f -c "pwrite 0 16k" /tmp/rootdir/foobar # mkfs.btrfs -f --rootdir /tmp/rootdir $dev # btrfs ins dump-tree -t extent $dev btrfs-progs v5.19.1 extent tree key (EXTENT_TREE ROOT_ITEM 0) leaf 30474240 items 13 free space 15536 generation 7 owner EXTENT_TREE leaf 30474240 flags 0x1(WRITTEN) backref revision 1 fs uuid c1f05988-49f9-4dd4-8489-b90d60f522ee chunk uuid 40f81603-fe75-4f58-aa9e-e74e28df8523 item 0 key (13631488 EXTENT_ITEM 16384) itemoff 16230 itemsize 53 refs 1 gen 0 flags DATA <<< Generation is 0 ... [CAUSE] In __btrfs_record_file_extent() we just set the extent generation to 0. [FIX] Use trans->transid to properly fill extent generation. Now after mkfs, the first data extent backref looks like this: item 0 key (13631488 EXTENT_ITEM 16384) itemoff 16230 itemsize 53 refs 1 gen 7 flags DATA ... Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
ccb2d4aa45
commit
dad9db45bb
|
@ -3582,7 +3582,7 @@ static int __btrfs_record_file_extent(struct btrfs_trans_handle *trans,
|
|||
struct btrfs_extent_item);
|
||||
|
||||
btrfs_set_extent_refs(leaf, ei, 0);
|
||||
btrfs_set_extent_generation(leaf, ei, 0);
|
||||
btrfs_set_extent_generation(leaf, ei, trans->transid);
|
||||
btrfs_set_extent_flags(leaf, ei,
|
||||
BTRFS_EXTENT_FLAG_DATA);
|
||||
btrfs_mark_buffer_dirty(leaf);
|
||||
|
|
Loading…
Reference in New Issue