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

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;
+	}
+
 	if (sb->level == cpu_to_le32(LEVEL_MULTIPATH))
 		rdev->desc_nr = -1;
 	else
-- 
2.17.1


  reply	other threads:[~2020-10-23  3:31 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 ` Christopher Unkel [this message]
2020-10-23  5:46   ` [PATCH 1/3] md: align superblock writes to physical blocks Song Liu
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=20201023033130.11354-2-cunkel@drivescale.com \
    --to=cunkel@drivescale.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=song@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).