From: Xiao Ni <xni@redhat.com>
To: song@kernel.org
Cc: yukuai1@huaweicloud.com, bmarzins@redhat.com, heinzm@redhat.com,
snitzer@kernel.org, ncroxon@redhat.com,
linux-raid@vger.kernel.org, dm-devel@lists.linux.dev
Subject: [PATCH 6/6] md/raid5: Don't check crossing reshape when reshape hasn't started
Date: Thu, 29 Feb 2024 23:49:41 +0800 [thread overview]
Message-ID: <20240229154941.99557-7-xni@redhat.com> (raw)
In-Reply-To: <20240229154941.99557-1-xni@redhat.com>
stripe_ahead_of_reshape is used to check if a stripe region cross the
reshape position. So first, change the function name to
stripe_across_reshape to describe the usage of this function.
For reshape backwards, it starts reshape from the end of array and conf->
reshape_progress is init to raid5_size. During reshape, if previous is true
(set in make_stripe_request) and max_sector >= conf->reshape_progress, ios
should wait until reshape window moves forward. But ios don't need to wait
if max_sector is raid5_size.
And put the conditions into the function directly to make understand the
codes easily.
This can be reproduced easily by lvm2 test shell/lvconvert-raid-reshape.sh
For dm raid reshape, before starting sync thread, it needs to reload table
some times. In one time dm raid uses MD_RECOVERY_WAIT to delay reshape and
it doesn't start sync thread this time. Then one io comes in and it waits
because stripe_ahead_of_reshape returns true because it's a backward
reshape and max_sectors > conf->reshape_progress. But the reshape hasn't
started. So skip this check when reshape_progress is raid5_size
Fixes: 486f60558607 ("md/raid5: Check all disks in a stripe_head for reshape progress")
Signed-off-by: Xiao Ni <xni@redhat.com>
---
drivers/md/raid5.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 8497880135ee..965991a3104f 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5832,17 +5832,12 @@ static bool ahead_of_reshape(struct mddev *mddev, sector_t sector,
sector >= reshape_sector;
}
-static bool range_ahead_of_reshape(struct mddev *mddev, sector_t min,
- sector_t max, sector_t reshape_sector)
-{
- return mddev->reshape_backwards ? max < reshape_sector :
- min >= reshape_sector;
-}
-
-static bool stripe_ahead_of_reshape(struct mddev *mddev, struct r5conf *conf,
+static sector_t raid5_size(struct mddev *mddev, sector_t sectors, int raid_disks);
+static bool stripe_across_reshape(struct mddev *mddev, struct r5conf *conf,
struct stripe_head *sh)
{
sector_t max_sector = 0, min_sector = MaxSector;
+ sector_t reshape_pos = 0;
bool ret = false;
int dd_idx;
@@ -5856,9 +5851,12 @@ static bool stripe_ahead_of_reshape(struct mddev *mddev, struct r5conf *conf,
spin_lock_irq(&conf->device_lock);
- if (!range_ahead_of_reshape(mddev, min_sector, max_sector,
- conf->reshape_progress))
- /* mismatch, need to try again */
+ reshape_pos = conf->reshape_progress;
+ if (mddev->reshape_backwards) {
+ if (max_sector >= reshape_pos &&
+ reshape_pos != raid5_size(mddev, 0, 0))
+ ret = true;
+ } else if (min_sector < reshape_pos)
ret = true;
spin_unlock_irq(&conf->device_lock);
@@ -5969,7 +5967,7 @@ static enum stripe_result make_stripe_request(struct mddev *mddev,
}
if (unlikely(previous) &&
- stripe_ahead_of_reshape(mddev, conf, sh)) {
+ stripe_across_reshape(mddev, conf, sh)) {
/*
* Expansion moved on while waiting for a stripe.
* Expansion could still move past after this
--
2.32.0 (Apple Git-132)
next prev parent reply other threads:[~2024-02-29 15:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-29 15:49 [PATCH 0/6] Fix dmraid regression bugs Xiao Ni
2024-02-29 15:49 ` [PATCH 1/6] md: Revert "md: Don't register sync_thread for reshape directly" Xiao Ni
2024-03-01 2:38 ` Yu Kuai
2024-03-01 4:41 ` Xiao Ni
2024-02-29 15:49 ` [PATCH 2/6] md: Revert "md: Make sure md_do_sync() will set MD_RECOVERY_DONE" Xiao Ni
2024-02-29 22:53 ` Song Liu
2024-02-29 23:45 ` Song Liu
2024-03-01 0:49 ` Xiao Ni
2024-03-01 1:11 ` Song Liu
2024-02-29 15:49 ` [PATCH 3/6] md: Revert "md: Don't ignore suspended array in md_check_recovery()" Xiao Ni
2024-02-29 15:49 ` [PATCH 4/6] dm-raid/md: Clear MD_RECOVERY_WAIT when stopping dmraid Xiao Ni
2024-03-01 2:44 ` Yu Kuai
2024-03-01 4:19 ` Xiao Ni
2024-02-29 15:49 ` [PATCH 5/6] md: Set MD_RECOVERY_FROZEN before stop sync thread Xiao Ni
2024-02-29 15:49 ` Xiao Ni [this message]
2024-02-29 19:39 ` [PATCH 0/6] Fix dmraid regression bugs Christoph Hellwig
2024-02-29 19:45 ` Song Liu
2024-03-01 2:12 ` Yu Kuai
2024-03-01 2:22 ` 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=20240229154941.99557-7-xni@redhat.com \
--to=xni@redhat.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=heinzm@redhat.com \
--cc=linux-raid@vger.kernel.org \
--cc=ncroxon@redhat.com \
--cc=snitzer@kernel.org \
--cc=song@kernel.org \
--cc=yukuai1@huaweicloud.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 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).