Skip to content

Commit 896c8b9

Browse files
adam900710kdave
authored andcommitted
btrfs: fix the ram_bytes assignment for truncated ordered extents
[HICCUP] After adding extra checks on btrfs_file_extent_item::ram_bytes to tree-checker, running fsstress leads to tree-checker warning at write time, as we created file extent items with an invalid ram_bytes. All those offending file extents have offset 0, and ram_bytes matching num_bytes, and smaller than disk_num_bytes. This would also trigger the recently enhanced btrfs-check, which catches such mismatches and report them as minor errors. [CAUSE] When a folio/page is invalidated and it is part of a submitted OE, we mark the OE truncated just to the beginning of the folio/page. And for truncated OE, we insert the file extent item with incorrect value for ram_bytes (using num_bytes instead of the usual value). This is not a big deal for end users, as we do not utilize the ram_bytes field for regular non-compressed extents. This mismatch is just a small violation against on-disk format. [FIX] Fix it by removing the override on btrfs_file_extent_item::ram_bytes. Reviewed-by: Filipe Manana <[email protected]> Signed-off-by: Qu Wenruo <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 1b87d26 commit 896c8b9

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

fs/btrfs/inode.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2960,10 +2960,8 @@ static int insert_ordered_extent_file_extent(struct btrfs_trans_handle *trans,
29602960
btrfs_set_stack_file_extent_disk_num_bytes(&stack_fi,
29612961
oe->disk_num_bytes);
29622962
btrfs_set_stack_file_extent_offset(&stack_fi, oe->offset);
2963-
if (test_bit(BTRFS_ORDERED_TRUNCATED, &oe->flags)) {
2963+
if (test_bit(BTRFS_ORDERED_TRUNCATED, &oe->flags))
29642964
num_bytes = oe->truncated_len;
2965-
ram_bytes = num_bytes;
2966-
}
29672965
btrfs_set_stack_file_extent_num_bytes(&stack_fi, num_bytes);
29682966
btrfs_set_stack_file_extent_ram_bytes(&stack_fi, ram_bytes);
29692967
btrfs_set_stack_file_extent_compression(&stack_fi, oe->compress_type);

0 commit comments

Comments
 (0)