Skip to content

Commit 1b87d26

Browse files
adam900710kdave
authored andcommitted
btrfs: make validate_extent_map() catch ram_bytes mismatch
Previously validate_extent_map() is only to catch bugs related to extent_map member cleanups. But with recent btrfs-check enhancement to catch ram_bytes mismatch with disk_num_bytes, it would be much better to catch such extent maps earlier. So this patch adds extra ram_bytes validation for extent maps. Please note that, older filesystems with such mismatch won't trigger this error: - extent_map::ram_bytes is already fixed Previous patch has already fixed the ram_bytes for affected file extents. So this enhanced sanity check should not affect end users. Reviewed-by: Filipe Manana <[email protected]> Signed-off-by: Qu Wenruo <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 88e2e6d commit 1b87d26

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/btrfs/extent_map.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,11 @@ static void validate_extent_map(struct btrfs_fs_info *fs_info, struct extent_map
317317
if (em->offset + em->len > em->disk_num_bytes &&
318318
!extent_map_is_compressed(em))
319319
dump_extent_map(fs_info, "disk_num_bytes too small", em);
320+
if (!extent_map_is_compressed(em) &&
321+
em->ram_bytes != em->disk_num_bytes)
322+
dump_extent_map(fs_info,
323+
"ram_bytes mismatch with disk_num_bytes for non-compressed em",
324+
em);
320325
} else if (em->offset) {
321326
dump_extent_map(fs_info, "non-zero offset for hole/inline", em);
322327
}

0 commit comments

Comments
 (0)