From: Yu Kuai <yukuai1@huaweicloud.com>
To: hch@lst.de, corbet@lwn.net, song@kernel.org, yukuai3@huawei.com,
agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com,
linan122@huawei.com, xni@redhat.com, hare@suse.de
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-raid@vger.kernel.org, dm-devel@lists.linux.dev,
yukuai1@huaweicloud.com, yi.zhang@huawei.com,
yangerkun@huawei.com, johnny.chenyi@huawei.com
Subject: [PATCH v5 09/11] md: add a new recovery_flag MD_RECOVERY_LAZY_RECOVER
Date: Fri, 1 Aug 2025 15:03:44 +0800 [thread overview]
Message-ID: <20250801070346.4127558-10-yukuai1@huaweicloud.com> (raw)
In-Reply-To: <20250801070346.4127558-1-yukuai1@huaweicloud.com>
From: Yu Kuai <yukuai3@huawei.com>
This flag is used by llbitmap in later patches to skip raid456 initial
recover and delay building initial xor data to first write.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Li Nan <linan122@huawei.com>
---
drivers/md/md.c | 14 +++++++++++++-
drivers/md/md.h | 2 ++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 2dc8234d19f5..69bf55d4a422 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -9165,6 +9165,14 @@ static sector_t md_sync_position(struct mddev *mddev, enum sync_action action)
start = rdev->recovery_offset;
rcu_read_unlock();
+ /*
+ * If there are no spares, and raid456 lazy initial recover is
+ * requested.
+ */
+ if (test_bit(MD_RECOVERY_LAZY_RECOVER, &mddev->recovery) &&
+ start == MaxSector)
+ start = 0;
+
/* If there is a bitmap, we need to make sure all
* writes that started before we added a spare
* complete before we start doing a recovery.
@@ -9724,6 +9732,7 @@ static bool md_choose_sync_action(struct mddev *mddev, int *spares)
set_bit(MD_RECOVERY_RESHAPE, &mddev->recovery);
clear_bit(MD_RECOVERY_RECOVER, &mddev->recovery);
+ clear_bit(MD_RECOVERY_LAZY_RECOVER, &mddev->recovery);
return true;
}
@@ -9732,6 +9741,7 @@ static bool md_choose_sync_action(struct mddev *mddev, int *spares)
remove_spares(mddev, NULL);
set_bit(MD_RECOVERY_SYNC, &mddev->recovery);
clear_bit(MD_RECOVERY_RECOVER, &mddev->recovery);
+ clear_bit(MD_RECOVERY_LAZY_RECOVER, &mddev->recovery);
return true;
}
@@ -9741,7 +9751,7 @@ static bool md_choose_sync_action(struct mddev *mddev, int *spares)
* re-add.
*/
*spares = remove_and_add_spares(mddev, NULL);
- if (*spares) {
+ if (*spares || test_bit(MD_RECOVERY_LAZY_RECOVER, &mddev->recovery)) {
clear_bit(MD_RECOVERY_SYNC, &mddev->recovery);
clear_bit(MD_RECOVERY_CHECK, &mddev->recovery);
clear_bit(MD_RECOVERY_REQUESTED, &mddev->recovery);
@@ -9954,6 +9964,7 @@ void md_check_recovery(struct mddev *mddev)
}
clear_bit(MD_RECOVERY_RECOVER, &mddev->recovery);
+ clear_bit(MD_RECOVERY_LAZY_RECOVER, &mddev->recovery);
clear_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
clear_bit(MD_SB_CHANGE_PENDING, &mddev->sb_flags);
@@ -10064,6 +10075,7 @@ void md_reap_sync_thread(struct mddev *mddev)
clear_bit(MD_RECOVERY_RESHAPE, &mddev->recovery);
clear_bit(MD_RECOVERY_REQUESTED, &mddev->recovery);
clear_bit(MD_RECOVERY_CHECK, &mddev->recovery);
+ clear_bit(MD_RECOVERY_LAZY_RECOVER, &mddev->recovery);
/*
* We call mddev->cluster_ops->update_size here because sync_size could
* be changed by md_update_sb, and MD_RECOVERY_RESHAPE is cleared,
diff --git a/drivers/md/md.h b/drivers/md/md.h
index 4fa5a3e68a0c..7b6357879a84 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -667,6 +667,8 @@ enum recovery_flags {
MD_RECOVERY_RESHAPE,
/* remote node is running resync thread */
MD_RESYNCING_REMOTE,
+ /* raid456 lazy initial recover */
+ MD_RECOVERY_LAZY_RECOVER,
};
enum md_ro_state {
--
2.39.2
next prev parent reply other threads:[~2025-08-01 7:30 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-01 7:03 [PATCH v5 00/11] md/llbitmap: md/md-llbitmap: introduce a new lockless bitmap Yu Kuai
2025-08-01 7:03 ` [PATCH v5 01/11] md: add a new parameter 'offset' to md_super_write() Yu Kuai
2025-08-01 7:03 ` [PATCH v5 02/11] md: factor out a helper raid_is_456() Yu Kuai
2025-08-01 7:03 ` [PATCH v5 03/11] md/md-bitmap: support discard for bitmap ops Yu Kuai
2025-08-01 7:03 ` [PATCH v5 04/11] md: add a new mddev field 'bitmap_id' Yu Kuai
2025-08-01 7:03 ` [PATCH v5 05/11] md/md-bitmap: add a new sysfs api bitmap_type Yu Kuai
2025-08-01 7:03 ` [PATCH v5 06/11] md/md-bitmap: delay registration of bitmap_ops until creating bitmap Yu Kuai
2025-08-01 7:03 ` [PATCH v5 07/11] md/md-bitmap: add a new method skip_sync_blocks() in bitmap_operations Yu Kuai
2025-08-01 7:03 ` [PATCH v5 08/11] md/md-bitmap: add a new method blocks_synced() " Yu Kuai
2025-08-04 9:15 ` Xiao Ni
2025-08-05 1:15 ` Yu Kuai
2025-08-01 7:03 ` Yu Kuai [this message]
2025-08-01 7:03 ` [PATCH v5 10/11] md/md-bitmap: make method bitmap_ops->daemon_work optional Yu Kuai
2025-08-01 7:03 ` [PATCH v5 11/11] md/md-llbitmap: introduce new lockless bitmap Yu Kuai
2025-08-03 9:48 ` Li Nan
2025-08-03 10:33 ` Yu Kuai
2025-08-07 3:57 ` Xiao Ni
2025-08-08 6:17 ` 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=20250801070346.4127558-10-yukuai1@huaweicloud.com \
--to=yukuai1@huaweicloud.com \
--cc=agk@redhat.com \
--cc=corbet@lwn.net \
--cc=dm-devel@lists.linux.dev \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=johnny.chenyi@huawei.com \
--cc=linan122@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;
as well as URLs for NNTP newsgroup(s).