mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Logan Gunthorpe <logang@deltatee.com>
To: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org,
	Song Liu <song@kernel.org>
Cc: Shaohua Li <shli@kernel.org>,
	Guoqing Jiang <guoqing.jiang@linux.dev>,
	Stephen Bates <sbates@raithlin.com>,
	Martin Oliveira <Martin.Oliveira@eideticom.com>,
	David Sloan <David.Sloan@eideticom.com>,
	Logan Gunthorpe <logang@deltatee.com>
Subject: [PATCH v1 7/8] md/raid5: Check all disks in a stripe_head for reshape progress
Date: Thu,  7 Apr 2022 10:45:10 -0600	[thread overview]
Message-ID: <20220407164511.8472-8-logang@deltatee.com> (raw)
In-Reply-To: <20220407164511.8472-1-logang@deltatee.com>

When testing if a previous stripe has had reshape expand past it, use
the earliest or latest logical sector in all the disks for that stripe
head. This will allow adding multiple disks at a time in a subesquent
patch.

To do this cleaner, refactor the check into a helper function called
stripe_ahead_of_reshape().

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
---
 drivers/md/raid5.c | 47 +++++++++++++++++++++++++++++++---------------
 1 file changed, 32 insertions(+), 15 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 52227dd91e89..1ddce09970fa 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5764,6 +5764,33 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi)
 	bio_endio(bi);
 }
 
+static bool stripe_ahead_of_reshape(struct mddev *mddev, struct r5conf *conf,
+				    struct stripe_head *sh)
+{
+	sector_t max_sector = 0, min_sector = MaxSector;
+	int dd_idx, ret = 0;
+
+	for (dd_idx = 0; dd_idx < sh->disks; dd_idx++) {
+		if (dd_idx == sh->pd_idx)
+			continue;
+
+		min_sector = min(min_sector, sh->dev[dd_idx].sector);
+		max_sector = min(max_sector, sh->dev[dd_idx].sector);
+	}
+
+	spin_lock_irq(&conf->device_lock);
+
+	if (mddev->reshape_backwards
+	    ? max_sector >= conf->reshape_progress
+	    : min_sector < conf->reshape_progress)
+		/* mismatch, need to try again */
+		ret = 1;
+
+	spin_unlock_irq(&conf->device_lock);
+
+	return ret;
+}
+
 static bool raid5_make_request(struct mddev *mddev, struct bio * bi)
 {
 	struct stripe_head *batch_last = NULL;
@@ -5877,28 +5904,18 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi)
 			break;
 		}
 
-		if (unlikely(previous)) {
+		if (unlikely(previous) &&
+		    stripe_ahead_of_reshape(mddev, conf, sh)) {
 			/*
-			 * Expansion might have moved on while waiting for a
-			 * stripe, so we must do the range check again.
+			 * Expansion moved on while waiting for a stripe.
 			 * Expansion could still move past after this
 			 * test, but as we are holding a reference to
 			 * 'sh', we know that if that happens,
 			 *  STRIPE_EXPANDING will get set and the expansion
 			 * won't proceed until we finish with the stripe.
 			 */
-			int must_retry = 0;
-			spin_lock_irq(&conf->device_lock);
-			if (mddev->reshape_backwards
-			    ? logical_sector >= conf->reshape_progress
-			    : logical_sector < conf->reshape_progress)
-				/* mismatch, need to try again */
-				must_retry = 1;
-			spin_unlock_irq(&conf->device_lock);
-			if (must_retry) {
-				raid5_release_stripe(sh);
-				goto schedule_and_retry;
-			}
+			raid5_release_stripe(sh);
+			goto schedule_and_retry;
 		}
 		if (read_seqcount_retry(&conf->gen_lock, seq)) {
 			/* Might have got the wrong stripe_head by accident */
-- 
2.30.2


  parent reply	other threads:[~2022-04-07 16:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-07 16:45 [PATCH v1 0/8] Improve Raid5 Lock Contention Logan Gunthorpe
2022-04-07 16:45 ` [PATCH v1 1/8] md/raid5: Refactor raid5_make_request loop Logan Gunthorpe
2022-04-08  5:58   ` Christoph Hellwig
2022-04-07 16:45 ` [PATCH v1 2/8] md/raid5: Move stripe_add_to_batch_list() call out of add_stripe_bio() Logan Gunthorpe
2022-04-08  6:00   ` Christoph Hellwig
2022-04-07 16:45 ` [PATCH v1 3/8] md/raid5: Move common stripe count increment code into __find_stripe() Logan Gunthorpe
2022-04-08  6:01   ` Christoph Hellwig
2022-04-07 16:45 ` [PATCH v1 4/8] md/raid5: Make common label for schedule/retry in raid5_make_request() Logan Gunthorpe
2022-04-08  6:03   ` Christoph Hellwig
2022-04-07 16:45 ` [PATCH v1 5/8] md/raid5: Keep a reference to last stripe_head for batch Logan Gunthorpe
2022-04-07 16:45 ` [PATCH v1 6/8] md/raid5: Refactor add_stripe_bio() Logan Gunthorpe
2022-04-08  6:05   ` Christoph Hellwig
2022-04-07 16:45 ` Logan Gunthorpe [this message]
2022-04-07 16:45 ` [PATCH v1 8/8] md/raid5: Pivot raid5_make_request() Logan Gunthorpe

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=20220407164511.8472-8-logang@deltatee.com \
    --to=logang@deltatee.com \
    --cc=David.Sloan@eideticom.com \
    --cc=Martin.Oliveira@eideticom.com \
    --cc=guoqing.jiang@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=sbates@raithlin.com \
    --cc=shli@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®