Commit 6b965620 authored by NeilBrown's avatar NeilBrown

md: provide appropriate return value for spare_active functions.

md_check_recovery expects ->spare_active to return 'true' if any
spares were activated, but none of them do, so the consequent change
in 'degraded' is not notified through sysfs.

So count the number of spares activated, subtract it from 'degraded'
just once, and return it.
Reported-by: default avatarAdrian Drzewiecki <adriand@vmware.com>
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent e6ffbcb6
...@@ -1120,6 +1120,8 @@ static int raid1_spare_active(mddev_t *mddev) ...@@ -1120,6 +1120,8 @@ static int raid1_spare_active(mddev_t *mddev)
{ {
int i; int i;
conf_t *conf = mddev->private; conf_t *conf = mddev->private;
int count = 0;
unsigned long flags;
/* /*
* Find all failed disks within the RAID1 configuration * Find all failed disks within the RAID1 configuration
...@@ -1131,16 +1133,16 @@ static int raid1_spare_active(mddev_t *mddev) ...@@ -1131,16 +1133,16 @@ static int raid1_spare_active(mddev_t *mddev)
if (rdev if (rdev
&& !test_bit(Faulty, &rdev->flags) && !test_bit(Faulty, &rdev->flags)
&& !test_and_set_bit(In_sync, &rdev->flags)) { && !test_and_set_bit(In_sync, &rdev->flags)) {
unsigned long flags; count++;
spin_lock_irqsave(&conf->device_lock, flags);
mddev->degraded--;
spin_unlock_irqrestore(&conf->device_lock, flags);
sysfs_notify_dirent(rdev->sysfs_state); sysfs_notify_dirent(rdev->sysfs_state);
} }
} }
spin_lock_irqsave(&conf->device_lock, flags);
mddev->degraded -= count;
spin_unlock_irqrestore(&conf->device_lock, flags);
print_conf(conf); print_conf(conf);
return 0; return count;
} }
......
...@@ -1116,6 +1116,8 @@ static int raid10_spare_active(mddev_t *mddev) ...@@ -1116,6 +1116,8 @@ static int raid10_spare_active(mddev_t *mddev)
int i; int i;
conf_t *conf = mddev->private; conf_t *conf = mddev->private;
mirror_info_t *tmp; mirror_info_t *tmp;
int count = 0;
unsigned long flags;
/* /*
* Find all non-in_sync disks within the RAID10 configuration * Find all non-in_sync disks within the RAID10 configuration
...@@ -1126,16 +1128,16 @@ static int raid10_spare_active(mddev_t *mddev) ...@@ -1126,16 +1128,16 @@ static int raid10_spare_active(mddev_t *mddev)
if (tmp->rdev if (tmp->rdev
&& !test_bit(Faulty, &tmp->rdev->flags) && !test_bit(Faulty, &tmp->rdev->flags)
&& !test_and_set_bit(In_sync, &tmp->rdev->flags)) { && !test_and_set_bit(In_sync, &tmp->rdev->flags)) {
unsigned long flags; count++;
spin_lock_irqsave(&conf->device_lock, flags);
mddev->degraded--;
spin_unlock_irqrestore(&conf->device_lock, flags);
sysfs_notify_dirent(tmp->rdev->sysfs_state); sysfs_notify_dirent(tmp->rdev->sysfs_state);
} }
} }
spin_lock_irqsave(&conf->device_lock, flags);
mddev->degraded -= count;
spin_unlock_irqrestore(&conf->device_lock, flags);
print_conf(conf); print_conf(conf);
return 0; return count;
} }
......
...@@ -5330,6 +5330,8 @@ static int raid5_spare_active(mddev_t *mddev) ...@@ -5330,6 +5330,8 @@ static int raid5_spare_active(mddev_t *mddev)
int i; int i;
raid5_conf_t *conf = mddev->private; raid5_conf_t *conf = mddev->private;
struct disk_info *tmp; struct disk_info *tmp;
int count = 0;
unsigned long flags;
for (i = 0; i < conf->raid_disks; i++) { for (i = 0; i < conf->raid_disks; i++) {
tmp = conf->disks + i; tmp = conf->disks + i;
...@@ -5337,15 +5339,15 @@ static int raid5_spare_active(mddev_t *mddev) ...@@ -5337,15 +5339,15 @@ static int raid5_spare_active(mddev_t *mddev)
&& tmp->rdev->recovery_offset == MaxSector && tmp->rdev->recovery_offset == MaxSector
&& !test_bit(Faulty, &tmp->rdev->flags) && !test_bit(Faulty, &tmp->rdev->flags)
&& !test_and_set_bit(In_sync, &tmp->rdev->flags)) { && !test_and_set_bit(In_sync, &tmp->rdev->flags)) {
unsigned long flags; count++;
spin_lock_irqsave(&conf->device_lock, flags);
mddev->degraded--;
spin_unlock_irqrestore(&conf->device_lock, flags);
sysfs_notify_dirent(tmp->rdev->sysfs_state); sysfs_notify_dirent(tmp->rdev->sysfs_state);
} }
} }
spin_lock_irqsave(&conf->device_lock, flags);
mddev->degraded -= count;
spin_unlock_irqrestore(&conf->device_lock, flags);
print_raid5_conf(conf); print_raid5_conf(conf);
return 0; return count;
} }
static int raid5_remove_disk(mddev_t *mddev, int number) static int raid5_remove_disk(mddev_t *mddev, int number)
......
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