Commit 87a8dec9 authored by NeilBrown's avatar NeilBrown

md: simplify some 'if' conditionals in raid5_start_reshape.

There are two consecutive 'if' statements.

 if (mddev->delta_disks >= 0)
      ....
 if (mddev->delta_disks > 0)

The code in the second is equally valid if delta_disks == 0, and these
two statements are the only place that 'added_devices' is used.

So make them a single if statement, make added_devices a local
variable, and re-indent it all.

No functional change.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent de171cb9
...@@ -5517,7 +5517,6 @@ static int raid5_start_reshape(mddev_t *mddev) ...@@ -5517,7 +5517,6 @@ static int raid5_start_reshape(mddev_t *mddev)
raid5_conf_t *conf = mddev->private; raid5_conf_t *conf = mddev->private;
mdk_rdev_t *rdev; mdk_rdev_t *rdev;
int spares = 0; int spares = 0;
int added_devices = 0;
unsigned long flags; unsigned long flags;
if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery))
...@@ -5571,34 +5570,36 @@ static int raid5_start_reshape(mddev_t *mddev) ...@@ -5571,34 +5570,36 @@ static int raid5_start_reshape(mddev_t *mddev)
* to correctly record the "partially reconstructed" state of * to correctly record the "partially reconstructed" state of
* such devices during the reshape and confusion could result. * such devices during the reshape and confusion could result.
*/ */
if (mddev->delta_disks >= 0) if (mddev->delta_disks >= 0) {
list_for_each_entry(rdev, &mddev->disks, same_set) int added_devices = 0;
if (rdev->raid_disk < 0 && list_for_each_entry(rdev, &mddev->disks, same_set)
!test_bit(Faulty, &rdev->flags)) { if (rdev->raid_disk < 0 &&
if (raid5_add_disk(mddev, rdev) == 0) { !test_bit(Faulty, &rdev->flags)) {
char nm[20]; if (raid5_add_disk(mddev, rdev) == 0) {
if (rdev->raid_disk >= conf->previous_raid_disks) { char nm[20];
set_bit(In_sync, &rdev->flags); if (rdev->raid_disk
added_devices++; >= conf->previous_raid_disks) {
set_bit(In_sync, &rdev->flags);
added_devices++;
} else
rdev->recovery_offset = 0;
sprintf(nm, "rd%d", rdev->raid_disk);
if (sysfs_create_link(&mddev->kobj,
&rdev->kobj, nm))
/* Failure here is OK */;
} else } else
rdev->recovery_offset = 0; break;
sprintf(nm, "rd%d", rdev->raid_disk); } else if (rdev->raid_disk >= conf->previous_raid_disks
if (sysfs_create_link(&mddev->kobj, && !test_bit(Faulty, &rdev->flags)) {
&rdev->kobj, nm)) /* This is a spare that was manually added */
/* Failure here is OK */; set_bit(In_sync, &rdev->flags);
} else added_devices++;
break; }
} else if (rdev->raid_disk >= conf->previous_raid_disks
&& !test_bit(Faulty, &rdev->flags)) {
/* This is a spare that was manually added */
set_bit(In_sync, &rdev->flags);
added_devices++;
}
/* When a reshape changes the number of devices, ->degraded /* When a reshape changes the number of devices,
* is measured against the larger of the pre and post number of * ->degraded is measured against the larger of the
* devices.*/ * pre and post number of devices.
if (mddev->delta_disks > 0) { */
spin_lock_irqsave(&conf->device_lock, flags); spin_lock_irqsave(&conf->device_lock, flags);
mddev->degraded += (conf->raid_disks - conf->previous_raid_disks) mddev->degraded += (conf->raid_disks - conf->previous_raid_disks)
- added_devices; - added_devices;
......
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