From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Cc: <dsterba@suse.cz>
Subject: [PATCH v2 1/6] btrfs-progs: Cleanup open-coded btrfs_chunk_item_size
Date: Wed, 31 May 2017 13:56:05 +0800 [thread overview]
Message-ID: <20170531055610.11606-2-quwenruo@cn.fujitsu.com> (raw)
In-Reply-To: <20170531055610.11606-1-quwenruo@cn.fujitsu.com>
In btrfs_check_chunk_valid() we calculates chunk item using open code.
use btrfs_chunk_item_size() to replace them.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
volumes.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/volumes.c b/volumes.c
index b350e259..62e23aee 100644
--- a/volumes.c
+++ b/volumes.c
@@ -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;
}
--
2.13.0
next prev parent reply other threads:[~2017-05-31 5:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-31 5:56 [PATCH v2 0/6] Lowmem mode check check fix for mulit-device Qu Wenruo
2017-05-31 5:56 ` Qu Wenruo [this message]
2017-05-31 5:56 ` [PATCH v2 2/6] btrfs-progs: Enhance chunk item validation check Qu Wenruo
2017-05-31 5:56 ` [PATCH v2 3/6] btrfs-progs: check: Reuse btrfs_check_chunk_valid in lowmem mode Qu Wenruo
2017-05-31 5:56 ` [PATCH v2 4/6] btrfs-progs: Introduce function to get correct stripe length Qu Wenruo
2017-05-31 5:56 ` [PATCH v2 5/6] btrfs-progs: lowmem check: Fix false alert on missing chunk or dev extent Qu Wenruo
2017-05-31 5:56 ` [PATCH v2 6/6] btrfs-progs: test: Introduce functions to prepare and cleanup loop device Qu Wenruo
2017-06-02 14:05 ` David Sterba
2017-06-02 13:53 ` [PATCH v2 0/6] Lowmem mode check check fix for mulit-device David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170531055610.11606-2-quwenruo@cn.fujitsu.com \
--to=quwenruo@cn.fujitsu.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.