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,13 +5570,15 @@ static int raid5_start_reshape(mddev_t *mddev) ...@@ -5571,13 +5570,15 @@ 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) {
int added_devices = 0;
list_for_each_entry(rdev, &mddev->disks, same_set) list_for_each_entry(rdev, &mddev->disks, same_set)
if (rdev->raid_disk < 0 && if (rdev->raid_disk < 0 &&
!test_bit(Faulty, &rdev->flags)) { !test_bit(Faulty, &rdev->flags)) {
if (raid5_add_disk(mddev, rdev) == 0) { if (raid5_add_disk(mddev, rdev) == 0) {
char nm[20]; char nm[20];
if (rdev->raid_disk >= conf->previous_raid_disks) { if (rdev->raid_disk
>= conf->previous_raid_disks) {
set_bit(In_sync, &rdev->flags); set_bit(In_sync, &rdev->flags);
added_devices++; added_devices++;
} else } else
...@@ -5595,10 +5596,10 @@ static int raid5_start_reshape(mddev_t *mddev) ...@@ -5595,10 +5596,10 @@ static int raid5_start_reshape(mddev_t *mddev)
added_devices++; 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