summaryrefslogtreecommitdiff
path: root/cmds-check.c
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2017-02-21 16:34:30 +0800
committerDavid Sterba <dsterba@suse.com>2017-03-08 13:00:48 +0100
commit4a749360cdb55d196750bd7ea3591a3db7f90843 (patch)
tree4b70a9912d02dab5b5c99330d3b081e5aef6f0c9 /cmds-check.c
parenteec058075f8b90d5cfc98a003c0533b5bfc81ac0 (diff)
btrfs-progs: check: lowmem: Fix extent item size false alert
If one extent item has no inline ref, btrfs lowmem mode check can give false alert without outputting any error message. The problem is lowmem mode always assumes that extent item has inline refs, and when it encounters such case it flags the extent item has wrong size, but doesn't output the error message. Although we already have such image submitted, at the commit time due to another bug in cmds-check return value, it doesn't detect it until that bug is fixed. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'cmds-check.c')
-rw-r--r--cmds-check.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/cmds-check.c b/cmds-check.c
index 1f751575..29c532b9 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -10743,13 +10743,20 @@ static int check_extent_item(struct btrfs_fs_info *fs_info,
}
end = (unsigned long)ei + item_size;
- if (ptr >= end) {
+next:
+ /* Reached extent item end normally */
+ if (ptr == end)
+ goto out;
+
+ /* Beyond extent item end, wrong item size */
+ if (ptr > end) {
err |= ITEM_SIZE_MISMATCH;
+ error("extent item at bytenr %llu slot %d has wrong size",
+ eb->start, slot);
goto out;
}
/* Now check every backref in this extent item */
-next:
iref = (struct btrfs_extent_inline_ref *)ptr;
type = btrfs_extent_inline_ref_type(eb, iref);
offset = btrfs_extent_inline_ref_offset(eb, iref);
@@ -10786,8 +10793,7 @@ next:
}
ptr += btrfs_extent_inline_ref_size(type);
- if (ptr < end)
- goto next;
+ goto next;
out:
return err;