From: Christopher Unkel <cunkel@drivescale.com>
To: linux-raid@vger.kernel.org, Song Liu <song@kernel.org>,
Christoph Hellwig <hch@infradead.org>
Cc: linux-kernel@vger.kernel.org, Christopher Unkel <cunkel@drivescale.com>
Subject: [PATCH 3/3] md: reuse sb length-checking logic
Date: Thu, 29 Oct 2020 13:13:58 -0700 [thread overview]
Message-ID: <20201029201358.29181-4-cunkel@drivescale.com> (raw)
In-Reply-To: <20201029201358.29181-1-cunkel@drivescale.com>
The logic in super_1_load() to check the length of the superblock
against (new_)data_offset has the same purpose as the newly-created
super_1_sb_length_ok(). The latter is also more complete in that it
check for overlap between the superblock write and the bitmap.
Signed-off-by: Christopher Unkel <cunkel@drivescale.com>
---
This series replaces the first patch of the previous series
(https://lkml.org/lkml/2020/10/22/1058), with the following changes:
1. Creates a helper function super_1_sb_length_ok().
2. Fixes operator placement style violation.
3. Covers case in super_1_sync().
4. Refactors duplicate logic.
5. Covers a case in existing code where aligned superblock could
run into bitmap.
drivers/md/md.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 802a9a256fe5..3b7bf14922ac 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1768,13 +1768,8 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
super_1_set_rdev_sb_size(rdev, le32_to_cpu(sb->max_dev), minor_version);
-
- if (minor_version
- && rdev->data_offset < sb_start + (rdev->sb_size/512))
- return -EINVAL;
- if (minor_version
- && rdev->new_data_offset < sb_start + (rdev->sb_size/512))
- return -EINVAL;
+ if (!super_1_sb_length_ok(rdev, minor_version, rdev->sb_size))
+ return -EINVAL;
if (sb->level == cpu_to_le32(LEVEL_MULTIPATH))
rdev->desc_nr = -1;
--
2.17.1
next prev parent reply other threads:[~2020-10-29 20:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-29 20:13 [PATCH v2 0/3] md superblock write alignment on 512e devices Christopher Unkel
2020-10-29 20:13 ` [PATCH v2 1/3] md: factor out repeated sb alignment logic Christopher Unkel
2020-10-29 20:13 ` [PATCH 2/3] md: align superblock writes to physical blocks Christopher Unkel
2020-11-02 8:02 ` Xiao Ni
2020-10-29 20:13 ` Christopher Unkel [this message]
2020-11-02 7:42 ` [PATCH v2 0/3] md superblock write alignment on 512e devices Xiao Ni
2020-11-03 20:12 ` Chris Unkel
2020-11-05 3:29 ` 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=20201029201358.29181-4-cunkel@drivescale.com \
--to=cunkel@drivescale.com \
--cc=hch@infradead.org \
--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
all inboxes | Powered by JetHome®