Commit 2910ff17 authored by Goldwyn Rodrigues's avatar Goldwyn Rodrigues

md: remove_and_add_spares() to activate specific rdev

remove_and_add_spares() checks for all devices to activate spare.
Change it to activate a specific device if a non-null rdev
argument is passed.

remove_and_add_spares() can be used to activate spares in
slot_store() as well.

For hot_remove_disk(), check if rdev->raid_disk == -1 before
calling remove_and_add_spares()
Signed-off-by: default avatarGoldwyn Rodrigues <rgoldwyn@suse.com>
parent b8ca846e
...@@ -2691,15 +2691,9 @@ slot_store(struct md_rdev *rdev, const char *buf, size_t len) ...@@ -2691,15 +2691,9 @@ slot_store(struct md_rdev *rdev, const char *buf, size_t len)
rdev->saved_raid_disk = -1; rdev->saved_raid_disk = -1;
clear_bit(In_sync, &rdev->flags); clear_bit(In_sync, &rdev->flags);
clear_bit(Bitmap_sync, &rdev->flags); clear_bit(Bitmap_sync, &rdev->flags);
err = rdev->mddev->pers-> remove_and_add_spares(rdev->mddev, rdev);
hot_add_disk(rdev->mddev, rdev); if (rdev->raid_disk == -1)
if (err) { return -EBUSY;
rdev->raid_disk = -1;
return err;
} else
sysfs_notify_dirent_safe(rdev->sysfs_state);
if (sysfs_link_rdev(rdev->mddev, rdev))
/* failure here is OK */;
/* don't wakeup anyone, leave that to userspace. */ /* don't wakeup anyone, leave that to userspace. */
} else { } else {
if (slot >= rdev->mddev->raid_disks && if (slot >= rdev->mddev->raid_disks &&
...@@ -6004,12 +5998,16 @@ static int hot_remove_disk(struct mddev *mddev, dev_t dev) ...@@ -6004,12 +5998,16 @@ static int hot_remove_disk(struct mddev *mddev, dev_t dev)
if (mddev_is_clustered(mddev)) if (mddev_is_clustered(mddev))
md_cluster_ops->metadata_update_start(mddev); md_cluster_ops->metadata_update_start(mddev);
if (rdev->raid_disk < 0)
goto kick_rdev;
clear_bit(Blocked, &rdev->flags); clear_bit(Blocked, &rdev->flags);
remove_and_add_spares(mddev, rdev); remove_and_add_spares(mddev, rdev);
if (rdev->raid_disk >= 0) if (rdev->raid_disk >= 0)
goto busy; goto busy;
kick_rdev:
if (mddev_is_clustered(mddev)) if (mddev_is_clustered(mddev))
md_cluster_ops->remove_disk(mddev, rdev); md_cluster_ops->remove_disk(mddev, rdev);
...@@ -6024,6 +6022,7 @@ static int hot_remove_disk(struct mddev *mddev, dev_t dev) ...@@ -6024,6 +6022,7 @@ static int hot_remove_disk(struct mddev *mddev, dev_t dev)
busy: busy:
if (mddev_is_clustered(mddev)) if (mddev_is_clustered(mddev))
md_cluster_ops->metadata_update_cancel(mddev); md_cluster_ops->metadata_update_cancel(mddev);
printk(KERN_WARNING "md: cannot remove active disk %s from %s ...\n", printk(KERN_WARNING "md: cannot remove active disk %s from %s ...\n",
bdevname(rdev->bdev,b), mdname(mddev)); bdevname(rdev->bdev,b), mdname(mddev));
return -EBUSY; return -EBUSY;
...@@ -8018,10 +8017,12 @@ static int remove_and_add_spares(struct mddev *mddev, ...@@ -8018,10 +8017,12 @@ static int remove_and_add_spares(struct mddev *mddev,
if (removed && mddev->kobj.sd) if (removed && mddev->kobj.sd)
sysfs_notify(&mddev->kobj, NULL, "degraded"); sysfs_notify(&mddev->kobj, NULL, "degraded");
if (this) if (this && removed)
goto no_add; goto no_add;
rdev_for_each(rdev, mddev) { rdev_for_each(rdev, mddev) {
if (this && this != rdev)
continue;
if (rdev->raid_disk >= 0 && if (rdev->raid_disk >= 0 &&
!test_bit(In_sync, &rdev->flags) && !test_bit(In_sync, &rdev->flags) &&
!test_bit(Faulty, &rdev->flags)) !test_bit(Faulty, &rdev->flags))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment