From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>, David Sterba <dsterba@suse.com>
Subject: Re: [PATCH] btrfs-progs: chunk-recovery: Fix a float point error
Date: Mon, 11 Jan 2016 10:15:08 +0800 [thread overview]
Message-ID: <5693102C.609@cn.fujitsu.com> (raw)
In-Reply-To: <1447915359-29707-1-git-send-email-quwenruo@cn.fujitsu.com>
Hi David,
Would you please consider merging this patch for v4.2 btrfs-progs?
Thanks,
Qu
Qu Wenruo wrote on 2015/11/19 14:42 +0800:
> Fix a zero division causing chunk-recovery fail.
>
> Also fix a typo "strpie_length" -> "stripe_length".
>
> Reported-by: Scotty Edmonds <scotty@scottyedmonds.com>
> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
> ---
> btrfsck.h | 17 +++++++++++++++++
> chunk-recover.c | 9 ++++++---
> 2 files changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/btrfsck.h b/btrfsck.h
> index 0882a38..e16f52f 100644
> --- a/btrfsck.h
> +++ b/btrfsck.h
> @@ -142,6 +142,23 @@ static inline unsigned long btrfs_chunk_record_size(int num_stripes)
> }
> void free_chunk_cache_tree(struct cache_tree *chunk_cache);
>
> +/*
> + * Function to check validation for num_stripes, or it can call
> + * float point error for 0 division
> + * return < 0 for invalid combination
> + * return 0 for valid combination
> + */
> +static inline int check_num_stripes(u64 type, int num_stripes)
> +{
> + if (num_stripes == 0)
> + return -1;
> + if (type & BTRFS_BLOCK_GROUP_RAID5 && num_stripes <= 1)
> + return -1;
> + if (type & BTRFS_BLOCK_GROUP_RAID6 && num_stripes <= 2)
> + return -1;
> + return 0;
> +}
> +
> u64 calc_stripe_length(u64 type, u64 length, int num_stripes);
> /* For block group tree */
> static inline void block_group_tree_init(struct block_group_tree *tree)
> diff --git a/chunk-recover.c b/chunk-recover.c
> index 0d4c8ff..85dc1bc 100644
> --- a/chunk-recover.c
> +++ b/chunk-recover.c
> @@ -1607,16 +1607,19 @@ static int btrfs_verify_device_extents(struct block_group_record *bg,
> struct list_head *devexts, int ndevexts)
> {
> struct device_extent_record *devext;
> - u64 strpie_length;
> + u64 stripe_length;
> int expected_num_stripes;
>
> expected_num_stripes = calc_num_stripes(bg->flags);
> if (expected_num_stripes && expected_num_stripes != ndevexts)
> return 1;
>
> - strpie_length = calc_stripe_length(bg->flags, bg->offset, ndevexts);
> + if (check_num_stripes(bg->flags, ndevexts) < 0)
> + return 1;
> +
> + stripe_length = calc_stripe_length(bg->flags, bg->offset, ndevexts);
> list_for_each_entry(devext, devexts, chunk_list) {
> - if (devext->length != strpie_length)
> + if (devext->length != stripe_length)
> return 1;
> }
> return 0;
>
next prev parent reply other threads:[~2016-01-11 2:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-19 6:42 [PATCH] btrfs-progs: chunk-recovery: Fix a float point error Qu Wenruo
2015-11-19 17:35 ` David Sterba
2016-01-11 2:15 ` Qu Wenruo [this message]
2016-01-11 9:14 ` David Sterba
2016-01-12 0:27 ` Qu Wenruo
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=5693102C.609@cn.fujitsu.com \
--to=quwenruo@cn.fujitsu.com \
--cc=dsterba@suse.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).