mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: <linan122@huawei.com>
To: <corbet@lwn.net>, <song@kernel.org>, <yukuai@fnnas.com>,
	<linan122@huawei.com>, <hare@suse.de>, <xni@redhat.com>
Cc: <linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-raid@vger.kernel.org>, <linan666@huaweicloud.com>,
	<yangerkun@huawei.com>, <yi.zhang@huawei.com>
Subject: [PATCH v7 3/4] md/raid0: Move queue limit setup before r0conf initialization
Date: Mon, 27 Oct 2025 15:29:14 +0800	[thread overview]
Message-ID: <20251027072915.3014463-4-linan122@huawei.com> (raw)
In-Reply-To: <20251027072915.3014463-1-linan122@huawei.com>

From: Li Nan <linan122@huawei.com>

Prepare for making logical blocksize configurable.

Move raid0_set_limits() before create_strip_zones(). It is safe as fields
modified in create_strip_zones() do not involve mddev configuration, and
rdev modifications there are not used in raid0_set_limits().

'blksize' in create_strip_zones() fetches mddev's logical block size. This
change has no impact until logical block size becomes configurable.

Signed-off-by: Li Nan <linan122@huawei.com>
---
 drivers/md/raid0.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index e443e478645a..49477b560cc9 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -68,7 +68,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 	struct strip_zone *zone;
 	int cnt;
 	struct r0conf *conf = kzalloc(sizeof(*conf), GFP_KERNEL);
-	unsigned blksize = 512;
+	unsigned int blksize = queue_logical_block_size(mddev->gendisk->queue);
 
 	*private_conf = ERR_PTR(-ENOMEM);
 	if (!conf)
@@ -405,6 +405,12 @@ static int raid0_run(struct mddev *mddev)
 	if (md_check_no_bitmap(mddev))
 		return -EINVAL;
 
+	if (!mddev_is_dm(mddev)) {
+		ret = raid0_set_limits(mddev);
+		if (ret)
+			return ret;
+	}
+
 	/* if private is not null, we are here after takeover */
 	if (mddev->private == NULL) {
 		ret = create_strip_zones(mddev, &conf);
@@ -413,11 +419,6 @@ static int raid0_run(struct mddev *mddev)
 		mddev->private = conf;
 	}
 	conf = mddev->private;
-	if (!mddev_is_dm(mddev)) {
-		ret = raid0_set_limits(mddev);
-		if (ret)
-			return ret;
-	}
 
 	/* calculate array device size */
 	md_set_array_sectors(mddev, raid0_size(mddev, 0, 0));
-- 
2.39.2


  parent reply	other threads:[~2025-10-27  7:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-27  7:29 [PATCH v7 0/4] make logical block size configurable linan122
2025-10-27  7:29 ` [PATCH v7 1/4] md: delete md_redundancy_group when array is becoming inactive linan122
2025-10-28 11:57   ` Yu Kuai
2025-10-27  7:29 ` [PATCH v7 2/4] md: init bioset in mddev_init linan122
2025-10-28 12:01   ` Yu Kuai
2025-10-29  2:35     ` Li Nan
2025-10-27  7:29 ` linan122 [this message]
2025-10-28 12:12   ` [PATCH v7 3/4] md/raid0: Move queue limit setup before r0conf initialization Yu Kuai
2025-10-29  2:37     ` Li Nan
2025-10-27  7:29 ` [PATCH v7 4/4] md: allow configuring logical block size linan122
2025-10-28 12:23   ` Yu Kuai

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=20251027072915.3014463-4-linan122@huawei.com \
    --to=linan122@huawei.com \
    --cc=corbet@lwn.net \
    --cc=hare@suse.de \
    --cc=linan666@huaweicloud.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=song@kernel.org \
    --cc=xni@redhat.com \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai@fnnas.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

all inboxes | Powered by JetHome®