summaryrefslogtreecommitdiff
path: root/cmds-check.c
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2017-05-31 13:56:07 +0800
committerDavid Sterba <dsterba@suse.com>2017-07-03 13:35:11 +0200
commitd07f45bc25872acd9e88de9f6e3b2feeb8ad0423 (patch)
tree162ff242e0b7a8ec365ead93cf5b63a037fbe610 /cmds-check.c
parent383b2b9c562fc944c4c5733dcc2b0eaaea84d7b2 (diff)
btrfs-progs: check: Reuse btrfs_check_chunk_valid in lowmem mode
Before this patch, btrfs check lowmem mode manually checks found chunk item, even we already have the generic chunk validation checker, btrfs_check_chunk_valid(). This patch will use btrfs_check_chunk_valid() to replace open-coded chunk validation checker in check_chunk_item(). 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.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/cmds-check.c b/cmds-check.c
index 8a7efd95..de9f2709 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -11161,11 +11161,9 @@ static int check_chunk_item(struct btrfs_fs_info *fs_info,
struct btrfs_block_group_item *bi;
struct btrfs_block_group_item bg_item;
struct btrfs_dev_extent *ptr;
- u32 sectorsize = btrfs_super_sectorsize(fs_info->super_copy);
u64 length;
u64 chunk_end;
u64 type;
- u64 profile;
int num_stripes;
u64 offset;
u64 objectid;
@@ -11177,25 +11175,15 @@ static int check_chunk_item(struct btrfs_fs_info *fs_info,
chunk = btrfs_item_ptr(eb, slot, struct btrfs_chunk);
length = btrfs_chunk_length(eb, chunk);
chunk_end = chunk_key.offset + length;
- if (!IS_ALIGNED(length, sectorsize)) {
- error("chunk[%llu %llu) not aligned to %u",
- chunk_key.offset, chunk_end, sectorsize);
- err |= BYTES_UNALIGNED;
+ ret = btrfs_check_chunk_valid(extent_root, eb, chunk, slot,
+ chunk_key.offset);
+ if (ret < 0) {
+ error("chunk[%llu %llu) is invalid", chunk_key.offset,
+ chunk_end);
+ err |= BYTES_UNALIGNED | UNKNOWN_TYPE;
goto out;
}
-
type = btrfs_chunk_type(eb, chunk);
- profile = type & BTRFS_BLOCK_GROUP_PROFILE_MASK;
- if (!(type & BTRFS_BLOCK_GROUP_TYPE_MASK)) {
- error("chunk[%llu %llu) has no chunk type",
- chunk_key.offset, chunk_end);
- err |= UNKNOWN_TYPE;
- }
- if (profile && (profile & (profile - 1))) {
- error("chunk[%llu %llu) multiple profiles detected: %llx",
- chunk_key.offset, chunk_end, profile);
- err |= UNKNOWN_TYPE;
- }
bg_key.objectid = chunk_key.offset;
bg_key.type = BTRFS_BLOCK_GROUP_ITEM_KEY;