Thread (17 messages) 17 messages, 3 authors, 2023-08-15
STALE1063d

[PATCH -next 09/13] md: convert to use hot_add_rdev() to hot add one rdev

From: Yu Kuai <hidden>
Date: 2023-08-03 13:28:32
Also in: lkml
Subsystem: software raid (multiple disks) support, the rest · Maintainers: Song Liu, Yu Kuai, Linus Torvalds

From: Yu Kuai <redacted>

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 <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help