lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu,  3 Aug 2023 21:24:23 +0800
From:   Yu Kuai <yukuai1@...weicloud.com>
To:     song@...nel.org, xni@...hat.com
Cc:     linux-raid@...r.kernel.org, linux-kernel@...r.kernel.org,
        yukuai3@...wei.com, yukuai1@...weicloud.com, yi.zhang@...wei.com,
        yangerkun@...wei.com
Subject: [PATCH -next 10/13] md: cleanup remove_and_add_spares()

From: Yu Kuai <yukuai3@...wei.com>

Now that remove_and_add_spares() is only called from daemon thread, and
the second parameter is always NULL, remove the second parameter.

Signed-off-by: Yu Kuai <yukuai3@...wei.com>
---
 drivers/md/md.c | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 1dc26bb1e096..e64d1d0b4c5c 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -86,8 +86,6 @@ static struct workqueue_struct *md_misc_wq;
 struct workqueue_struct *md_bitmap_wq;
 
 static bool hot_remove_rdev(struct md_rdev *rdev);
-static int remove_and_add_spares(struct mddev *mddev,
-				 struct md_rdev *this);
 static void mddev_detach(struct mddev *mddev);
 static void export_rdev(struct md_rdev *rdev, struct mddev *mddev);
 static void md_wakeup_thread_directly(struct md_thread __rcu *thread);
@@ -9232,36 +9230,26 @@ static bool hot_add_rdev(struct md_rdev *rdev)
 	return true;
 }
 
-static int remove_and_add_spares(struct mddev *mddev,
-				 struct md_rdev *this)
+static int remove_and_add_spares(struct mddev *mddev)
 {
 	struct md_rdev *rdev;
 	int spares = 0;
 	int removed = 0;
 
-	if (this && test_bit(MD_RECOVERY_RUNNING, &mddev->recovery))
-		/* Mustn't remove devices when resync thread is running */
-		return 0;
-
 	rdev_for_each(rdev, mddev)
-		if ((this == NULL || rdev == this) && hot_remove_rdev(rdev))
+		if (hot_remove_rdev(rdev))
 			removed++;
 
 	if (removed && mddev->kobj.sd)
 		sysfs_notify_dirent_safe(mddev->sysfs_degraded);
 
-	if (this && removed)
-		goto no_add;
-
 	rdev_for_each(rdev, mddev) {
-		if (this && this != rdev)
-			continue;
 		if (rdev_is_spare(rdev))
 			spares++;
 		if (hot_add_rdev(rdev) && !test_bit(Journal, &rdev->flags))
 			spares++;
 	}
-no_add:
+
 	if (removed)
 		set_bit(MD_SB_CHANGE_DEVS, &mddev->sb_flags);
 	return spares;
@@ -9381,7 +9369,7 @@ void md_check_recovery(struct mddev *mddev)
 			 * As we only add devices that are already in-sync,
 			 * we can activate the spares immediately.
 			 */
-			remove_and_add_spares(mddev, NULL);
+			remove_and_add_spares(mddev);
 			/* There is no thread, but we need to call
 			 * ->spare_active and clear saved_raid_disk
 			 */
@@ -9462,7 +9450,7 @@ void md_check_recovery(struct mddev *mddev)
 				goto not_running;
 			set_bit(MD_RECOVERY_RESHAPE, &mddev->recovery);
 			clear_bit(MD_RECOVERY_RECOVER, &mddev->recovery);
-		} else if ((spares = remove_and_add_spares(mddev, NULL))) {
+		} else if ((spares = remove_and_add_spares(mddev))) {
 			clear_bit(MD_RECOVERY_SYNC, &mddev->recovery);
 			clear_bit(MD_RECOVERY_CHECK, &mddev->recovery);
 			clear_bit(MD_RECOVERY_REQUESTED, &mddev->recovery);
-- 
2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ