diff options
author | Qu Wenruo <quwenruo@cn.fujitsu.com> | 2017-05-15 16:27:38 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2017-07-03 13:35:10 +0200 |
commit | 8f41197b92d711a18e473e326bf576129051b7d5 (patch) | |
tree | 8993fa0bddbfef9e27bcecc6ce0941daeee1b4e6 /volumes.c | |
parent | cc5c10b675dd54156536e01653ce6081e9f57576 (diff) |
btrfs-progs: Cleanup open-coded btrfs_chunk_item_size
In btrfs_check_chunk_valid() we calculate chunk item using open code,
use an existing helper btrfs_chunk_item_size() instead.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'volumes.c')
-rw-r--r-- | volumes.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -1685,6 +1685,7 @@ int btrfs_check_chunk_valid(struct btrfs_root *root, u16 num_stripes; u16 sub_stripes; u64 type; + u32 chunk_ondisk_size; length = btrfs_chunk_length(leaf, chunk); stripe_len = btrfs_chunk_stripe_len(leaf, chunk); @@ -1724,16 +1725,16 @@ int btrfs_check_chunk_valid(struct btrfs_root *root, BTRFS_BLOCK_GROUP_PROFILE_MASK) & type); return -EIO; } + + chunk_ondisk_size = btrfs_chunk_item_size(num_stripes); /* * Btrfs_chunk contains at least one stripe, and for sys_chunk * it can't exceed the system chunk array size * For normal chunk, it should match its chunk item size. */ if (num_stripes < 1 || - (slot == -1 && sizeof(struct btrfs_stripe) * num_stripes > - BTRFS_SYSTEM_CHUNK_ARRAY_SIZE) || - (slot >= 0 && sizeof(struct btrfs_stripe) * (num_stripes - 1) > - btrfs_item_size_nr(leaf, slot))) { + (slot == -1 && chunk_ondisk_size > BTRFS_SYSTEM_CHUNK_ARRAY_SIZE) || + (slot >= 0 && chunk_ondisk_size > btrfs_item_size_nr(leaf, slot))) { error("invalid num_stripes: %u", num_stripes); return -EIO; } |