DM-Devel Archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>, Mike Snitzer <snitzer@kernel.org>,
	Mikulas Patocka <mpatocka@redhat.com>, Song Liu <song@kernel.org>,
	Yu Kuai <yukuai3@huawei.com>
Cc: dm-devel@lists.linux.dev, linux-block@vger.kernel.org,
	linux-raid@vger.kernel.org
Subject: [PATCH 09/14] md/raid1: use the atomic queue limit update APIs
Date: Wed, 28 Feb 2024 14:56:48 -0800	[thread overview]
Message-ID: <20240228225653.947152-10-hch@lst.de> (raw)
In-Reply-To: <20240228225653.947152-1-hch@lst.de>

Build the queue limits outside the queue and apply them using
queue_limits_set.  To make the code more obvious also split the queue
limits handling into a separate helper function.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/md/raid1.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 3b1227f67a6d61..75329ab2dbd8de 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1782,10 +1782,9 @@ static int raid1_add_disk(struct mddev *mddev, struct md_rdev *rdev)
 	for (mirror = first; mirror <= last; mirror++) {
 		p = conf->mirrors + mirror;
 		if (!p->rdev) {
-			if (!mddev_is_dm(mddev))
-				disk_stack_limits(mddev->gendisk, rdev->bdev,
-						  rdev->data_offset << 9);
-
+			err = mddev_stack_new_rdev(mddev, rdev);
+			if (err)
+				return err;
 			p->head_position = 0;
 			rdev->raid_disk = mirror;
 			err = 0;
@@ -3077,12 +3076,21 @@ static struct r1conf *setup_conf(struct mddev *mddev)
 	return ERR_PTR(err);
 }
 
+static int raid1_set_limits(struct mddev *mddev)
+{
+	struct queue_limits lim;
+
+	blk_set_stacking_limits(&lim);
+	lim.max_write_zeroes_sectors = 0;
+	mddev_stack_rdev_limits(mddev, &lim);
+	return queue_limits_set(mddev->queue, &lim);
+}
+
 static void raid1_free(struct mddev *mddev, void *priv);
 static int raid1_run(struct mddev *mddev)
 {
 	struct r1conf *conf;
 	int i;
-	struct md_rdev *rdev;
 	int ret;
 
 	if (mddev->level != 1) {
@@ -3110,10 +3118,9 @@ static int raid1_run(struct mddev *mddev)
 		return PTR_ERR(conf);
 
 	if (!mddev_is_dm(mddev)) {
-		blk_queue_max_write_zeroes_sectors(mddev->queue, 0);
-		rdev_for_each(rdev, mddev)
-			disk_stack_limits(mddev->gendisk, rdev->bdev,
-					  rdev->data_offset << 9);
+		ret = raid1_set_limits(mddev);
+		if (ret)
+			goto abort;
 	}
 
 	mddev->degraded = 0;
-- 
2.39.2


  parent reply	other threads:[~2024-02-28 22:56 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-28 22:56 atomic queue limit updates for stackable devices v3 Christoph Hellwig
2024-02-28 22:56 ` [PATCH 01/14] block: add a queue_limits_set helper Christoph Hellwig
2024-02-28 22:56 ` [PATCH 02/14] block: add a queue_limits_stack_bdev helper Christoph Hellwig
2024-02-28 22:56 ` [PATCH 03/14] dm: use queue_limits_set Christoph Hellwig
2024-02-28 22:56 ` [PATCH 04/14] md: add a mddev_trace_remap helper Christoph Hellwig
2024-02-28 22:56 ` [PATCH 05/14] md: add a mddev_add_trace_msg helper Christoph Hellwig
2024-02-28 22:56 ` [PATCH 06/14] md: add a mddev_is_dm helper Christoph Hellwig
2024-02-28 22:56 ` [PATCH 07/14] md: add queue limit helpers Christoph Hellwig
2024-02-28 22:56 ` [PATCH 08/14] md/raid0: use the atomic queue limit update APIs Christoph Hellwig
2024-02-28 22:56 ` Christoph Hellwig [this message]
2024-02-28 22:56 ` [PATCH 10/14] md/raid5: " Christoph Hellwig
2024-02-28 22:56 ` [PATCH 11/14] md/raid10: " Christoph Hellwig
2024-02-28 22:56 ` [PATCH 12/14] md: don't initialize queue limits Christoph Hellwig
2024-02-28 22:56 ` [PATCH 13/14] md: remove mddev->queue Christoph Hellwig
2024-02-28 22:56 ` [PATCH 14/14] block: remove disk_stack_limits Christoph Hellwig
2024-02-29 19:40 ` atomic queue limit updates for stackable devices v3 Christoph Hellwig
2024-03-01 15:55 ` (subset) " Jens Axboe
2024-03-02  4:14   ` Song Liu

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=20240228225653.947152-10-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@lists.linux.dev \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=snitzer@kernel.org \
    --cc=song@kernel.org \
    --cc=yukuai3@huawei.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 read-only IMAP folder(s) and NNTP newsgroup(s).