mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yu Kuai <yukuai@kernel.org>
To: corbet@lwn.net, agk@redhat.co, snitzer@kernel.org,
	mpatocka@redhat.com, hch@lst.de, song@kernel.org, hare@suse.de
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	dm-devel@lists.linux.dev, linux-raid@vger.kernel.org,
	yukuai3@huawei.com, yangerkun@huawei.com, yi.zhang@huawei.com,
	johnny.chenyi@huawei.com, Xiao Ni <xni@redhat.com>
Subject: [PATCH v4 02/11] md: factor out a helper raid_is_456()
Date: Tue, 22 Jul 2025 01:15:48 +0800	[thread overview]
Message-ID: <20250721171557.34587-3-yukuai@kernel.org> (raw)
In-Reply-To: <20250721171557.34587-1-yukuai@kernel.org>

From: Yu Kuai <yukuai3@huawei.com>

There are no functional changes, the helper will be used by llbitmap in
following patches.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Xiao Ni <xni@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
---
 drivers/md/md.c | 9 +--------
 drivers/md/md.h | 6 ++++++
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index c4ef23ade9e2..1db7af64184d 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -9050,19 +9050,12 @@ static sector_t md_sync_position(struct mddev *mddev, enum sync_action action)
 
 static bool sync_io_within_limit(struct mddev *mddev)
 {
-	int io_sectors;
-
 	/*
 	 * For raid456, sync IO is stripe(4k) per IO, for other levels, it's
 	 * RESYNC_PAGES(64k) per IO.
 	 */
-	if (mddev->level == 4 || mddev->level == 5 || mddev->level == 6)
-		io_sectors = 8;
-	else
-		io_sectors = 128;
-
 	return atomic_read(&mddev->recovery_active) <
-		io_sectors * sync_io_depth(mddev);
+	       (raid_is_456(mddev) ? 8 : 128) * sync_io_depth(mddev);
 }
 
 #define SYNC_MARKS	10
diff --git a/drivers/md/md.h b/drivers/md/md.h
index 9e37c6c18722..72bce59376d7 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -1033,6 +1033,12 @@ static inline bool mddev_is_dm(struct mddev *mddev)
 	return !mddev->gendisk;
 }
 
+static inline bool raid_is_456(struct mddev *mddev)
+{
+	return mddev->level == ID_RAID4 || mddev->level == ID_RAID5 ||
+	       mddev->level == ID_RAID6;
+}
+
 static inline void mddev_trace_remap(struct mddev *mddev, struct bio *bio,
 		sector_t sector)
 {
-- 
2.43.0


  parent reply	other threads:[~2025-07-21 17:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-21 17:15 [PATCH v4 00/11] md/llbitmap: md/md-llbitmap: introduce a new lockless bitmap Yu Kuai
2025-07-21 17:15 ` [PATCH v4 01/11] md: add a new parameter 'offset' to md_super_write() Yu Kuai
2025-07-21 17:15 ` Yu Kuai [this message]
2025-07-21 17:15 ` [PATCH v4 03/11] md/md-bitmap: support discard for bitmap ops Yu Kuai
2025-07-21 17:15 ` [PATCH v4 04/11] md: add a new mddev field 'bitmap_id' Yu Kuai
2025-07-21 17:15 ` [PATCH v4 05/11] md/md-bitmap: add a new sysfs api bitmap_type Yu Kuai
2025-07-21 17:15 ` [PATCH v4 06/11] md/md-bitmap: delay registration of bitmap_ops until creating bitmap Yu Kuai
2025-07-22  6:07   ` Hannes Reinecke
2025-07-21 17:15 ` [PATCH v4 07/11] md/md-bitmap: add a new method skip_sync_blocks() in bitmap_operations Yu Kuai
2025-07-21 17:15 ` [PATCH v4 08/11] md/md-bitmap: add a new method blocks_synced() " Yu Kuai
2025-07-21 17:15 ` [PATCH v4 09/11] md: add a new recovery_flag MD_RECOVERY_LAZY_RECOVER Yu Kuai
2025-07-21 17:15 ` [PATCH v4 10/11] md/md-bitmap: make method bitmap_ops->daemon_work optional Yu Kuai
2025-07-21 17:15 ` [PATCH v4 11/11] md/md-llbitmap: introduce new lockless bitmap Yu Kuai
2025-08-01  2:00   ` Yu Kuai
2025-07-22  8:29 ` [PATCH v4 00/11] md/llbitmap: md/md-llbitmap: introduce a " Li Nan

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=20250721171557.34587-3-yukuai@kernel.org \
    --to=yukuai@kernel.org \
    --cc=agk@redhat.co \
    --cc=corbet@lwn.net \
    --cc=dm-devel@lists.linux.dev \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=johnny.chenyi@huawei.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=snitzer@kernel.org \
    --cc=song@kernel.org \
    --cc=xni@redhat.com \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --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

all inboxes | Powered by JetHome®