lkml.org 
[lkml]   [2023]   [Aug]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH -next 09/13] md: convert to use hot_add_rdev() to hot add one rdev
Date
From: Yu Kuai <yukuai3@huawei.com>

Replace remove_and_add_spares() with hot_add_rdev() in
check_sb_changes(), also handle the case that hot add rdev failed.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index de7399769c8d..1dc26bb1e096 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -9773,13 +9773,20 @@ static void check_sb_changes(struct mddev *mddev, struct md_rdev *rdev)
!(le32_to_cpu(sb->feature_map) &
MD_FEATURE_RESHAPE_ACTIVE)) {
rdev2->saved_raid_disk = role;
- ret = remove_and_add_spares(mddev, rdev2);
- pr_info("Activated spare: %pg\n",
- rdev2->bdev);
- /* wakeup mddev->thread here, so array could
- * perform resync with the new activated disk */
- set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
- md_wakeup_thread(mddev->thread);
+ if (!test_bit(MD_RECOVERY_RUNNING,
+ &mddev->recovery) &&
+ hot_add_rdev(rdev2)) {
+ pr_info("Activated spare: %pg\n",
+ rdev2->bdev);
+ /*
+ * wakeup mddev->thread here, so array
+ * could perform resync with the new
+ * activated disk.
+ */
+ set_bit(MD_RECOVERY_NEEDED,
+ &mddev->recovery);
+ md_wakeup_thread(mddev->thread);
+ }
}
/* device faulty
* We just want to do the minimum to mark the disk
--
2.39.2
\
 
 \ /
  Last update: 2023-08-03 15:29    [W:0.306 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site