All of lore.kernel.org
 help / color / mirror / Atom feed
From: Song Liu <song@kernel.org>
To: Xiao Ni <xni@redhat.com>
Cc: linux-raid <linux-raid@vger.kernel.org>,
	Nigel Croxon <ncroxon@redhat.com>
Subject: Re: [PATCH 1/2] super1.0 calculates max sectors in a wrong way
Date: Mon, 27 Jul 2020 10:33:56 -0700	[thread overview]
Message-ID: <CAPhsuW7WY7kQ77BKBqev2CVFPS63C7u0HtBqkB49XtbRCysWmg@mail.gmail.com> (raw)
In-Reply-To: <1593503737-5067-2-git-send-email-xni@redhat.com>

On Tue, Jun 30, 2020 at 12:55 AM Xiao Ni <xni@redhat.com> wrote:
>
> One super1.0 raid array wants to grow size, it needs to check the device max usable
> size. If the requested size is bigger than max usable size, it will return an error.
>
> Now it uses rdev->sectors for max usable size. If one disk is 500G and the raid device
> only uses the 100GB of this disk. rdev->sectors can't tell the real max usable size.
> The max usable size should be dev_size-(superblock_size+bitmap_size+badblock_size).
>
> Signed-off-by: Xiao Ni <xni@redhat.com>

Thanks for the fix!

> ---
>  drivers/md/md.c | 26 +++++++++++++++++++++++---
>  1 file changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index f567f53..d2c5984 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -2183,10 +2183,30 @@ super_1_rdev_size_change(struct md_rdev *rdev, sector_t num_sectors)
>                 return 0;
>         } else {
>                 /* minor version 0; superblock after data */
> -               sector_t sb_start;
> -               sb_start = (i_size_read(rdev->bdev->bd_inode) >> 9) - 8*2;
> +               sector_t sb_start, bm_space;
> +               sector_t dev_size = i_size_read(rdev->bdev->bd_inode) >> 9;
> +
> +               /* 8K is for superblock */
> +               sb_start = dev_size - 8*2;
>                 sb_start &= ~(sector_t)(4*2 - 1);
> -               max_sectors = rdev->sectors + sb_start - rdev->sb_start;
> +
> +               /* if the device is bigger than 8Gig, save 64k for bitmap usage,
> +                * if bigger than 200Gig, save 128k
> +                */
> +               if (dev_size < 64*2)
> +                       bm_space = 0;
> +               else if (dev_size - 64*2 >= 200*1024*1024*2)
> +                       bm_space = 128*2;
> +               else if (dev_size - 4*2 > 8*1024*1024*2)
> +                       bm_space = 64*2;
> +               else
> +                       bm_space = 4*2;

Could you explain the handling of bitmap space?

Thanks,
Song

  reply	other threads:[~2020-07-27 17:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-30  7:55 [PATCH 0/2] Can't grow size twice for a super1.0 array Xiao Ni
2020-06-30  7:55 ` [PATCH 1/2] super1.0 calculates max sectors in a wrong way Xiao Ni
2020-07-27 17:33   ` Song Liu [this message]
2020-07-28  1:18     ` Xiao Ni
2020-07-29  0:43       ` Song Liu
2020-07-29  1:13         ` Xiao Ni
2020-07-29  2:51           ` Song Liu
2020-06-30  7:55 ` [PATCH 2/2] Don't need to reset superblock start address for super1.0 Xiao Ni

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=CAPhsuW7WY7kQ77BKBqev2CVFPS63C7u0HtBqkB49XtbRCysWmg@mail.gmail.com \
    --to=song@kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=ncroxon@redhat.com \
    --cc=xni@redhat.com \
    /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.