path: root/check
diff options
authorQu Wenruo <>2018-06-06 15:27:13 +0800
committerDavid Sterba <>2018-08-06 15:00:34 +0200
commit3c042605db2238c09f56c197a58624d4e10c5d2e (patch)
tree16d840e1e8f861cb26e369a0e76b78e2ba599a53 /check
parent90b677a2d7e6b14e3047b5ac8625269378c1198f (diff)
btrfs-progs: Get rid of the confusing btrfs_file_extent_inline_len()
[BUG] If one uncompressed inline extent has incorrect ram_bytes, neither btrfs check nor dump-tree could detect such corruption. [CAUSE] Every caller tries to read inline extent ram_bytes is using btrfs_file_extent_inline_len(), other than directly calling btrfs_file_extent_ram_bytes(). For compressed extent, it's just calling btrfs_file_extent_ram_bytes(). However for uncompressed extent, it falls back to btrfs_file_extent_inline_item_len(), makes us unable to detect anything wrong in ram_bytes. [FIX] Just get rid of such confusing btrfs_file_extent_inline_len() function. Reported-by: Steve Leung <> Tested-by: Steve Leung <> Signed-off-by: Qu Wenruo <> Signed-off-by: David Sterba <>
Diffstat (limited to 'check')
2 files changed, 2 insertions, 2 deletions
diff --git a/check/main.c b/check/main.c
index c25c50ef..22700018 100644
--- a/check/main.c
+++ b/check/main.c
@@ -1472,7 +1472,7 @@ static int process_file_extent(struct btrfs_root *root,
u8 compression = btrfs_file_extent_compression(eb, fi);
struct btrfs_item *item = btrfs_item_nr(slot);
- num_bytes = btrfs_file_extent_inline_len(eb, slot, fi);
+ num_bytes = btrfs_file_extent_ram_bytes(eb, fi);
if (num_bytes == 0)
rec->errors |= I_ERR_BAD_FILE_EXTENT;
if (compression) {
diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
index 66da4531..3a749784 100644
--- a/check/mode-lowmem.c
+++ b/check/mode-lowmem.c
@@ -1776,7 +1776,7 @@ static int check_file_extent(struct btrfs_root *root, struct btrfs_key *fkey,
u32 item_inline_len;
item_inline_len = btrfs_file_extent_inline_item_len(node, e);
- extent_num_bytes = btrfs_file_extent_inline_len(node, slot, fi);
+ extent_num_bytes = btrfs_file_extent_ram_bytes(node, fi);
compressed = btrfs_file_extent_compression(node, fi);
if (extent_num_bytes == 0) {