linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Song Liu <song@kernel.org>
To: Christopher Unkel <cunkel@drivescale.com>
Cc: linux-raid <linux-raid@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] md: align superblock writes to physical blocks
Date: Thu, 22 Oct 2020 22:46:17 -0700	[thread overview]
Message-ID: <CAPhsuW50ON69Z=Wq30fEw0M2mGtXYKQCUNUbDS78AUe--nNZSg@mail.gmail.com> (raw)
In-Reply-To: <20201023033130.11354-2-cunkel@drivescale.com>

On Thu, Oct 22, 2020 at 8:31 PM Christopher Unkel <cunkel@drivescale.com> wrote:
>
> Writes of the md superblock are aligned to the logical blocks of the
> containing device, but no attempt is made to align them to physical
> block boundaries.  This means that on a "512e" device (4k physical, 512
> logical) every superblock update hits the 512-byte emulation and the
> possible associated performance penalty.
>
> Respect the physical block alignment when possible.
>
> Signed-off-by: Christopher Unkel <cunkel@drivescale.com>
> ---
>  drivers/md/md.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 98bac4f304ae..2b42850acfb3 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -1732,6 +1732,21 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
>             && rdev->new_data_offset < sb_start + (rdev->sb_size/512))
>                 return -EINVAL;
>
> +       /* Respect physical block size if feasible. */
> +       bmask = queue_physical_block_size(rdev->bdev->bd_disk->queue)-1;
> +       if (!((rdev->sb_start * 512) & bmask) && (rdev->sb_size & bmask)) {
> +               int candidate_size = (rdev->sb_size | bmask) + 1;
> +
> +               if (minor_version) {
> +                       int sectors = candidate_size / 512;
> +
> +                       if (rdev->data_offset >= sb_start + sectors
> +                           && rdev->new_data_offset >= sb_start + sectors)
> +                               rdev->sb_size = candidate_size;
> +               } else if (bmask <= 4095)
> +                       rdev->sb_size = candidate_size;
> +       }

In super_1_load() and super_1_sync(), we have

    bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;

I think we should replace it with queue_physical_block_size() so the logic is
cleaner. Would this work?

Thanks,
Song

  reply	other threads:[~2020-10-23  5:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-23  3:31 [PATCH 0/3] mdraid sb and bitmap write alignment on 512e drives Christopher Unkel
2020-10-23  3:31 ` [PATCH 1/3] md: align superblock writes to physical blocks Christopher Unkel
2020-10-23  5:46   ` Song Liu [this message]
2020-10-23  8:29   ` Christoph Hellwig
2020-10-23  3:31 ` [PATCH 2/3] md: factor sb write alignment check into function Christopher Unkel
2020-10-23  3:31 ` [PATCH 3/3] md: pad writes to end of bitmap to physical blocks Christopher Unkel
2020-10-23  5:41 ` [PATCH 0/3] mdraid sb and bitmap write alignment on 512e drives Song Liu
2020-10-23  7:03   ` Chris Unkel
2020-11-02  7:04 ` Xiao Ni
2020-11-02 18:59   ` Chris Unkel
2020-11-03  8:32     ` 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='CAPhsuW50ON69Z=Wq30fEw0M2mGtXYKQCUNUbDS78AUe--nNZSg@mail.gmail.com' \
    --to=song@kernel.org \
    --cc=cunkel@drivescale.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@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).