aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid5.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2011-01-30 19:57:43 -0500
committerNeilBrown <neilb@suse.de>2011-01-30 19:57:43 -0500
commit87a8dec91e15954f0cf86be6c21741d991d83621 (patch)
tree6719ef774c0e1a719b0365eae457c8ba4f130c70 /drivers/md/raid5.c
parentde171cb9a52598cc023adceafc6c166112401386 (diff)
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: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/raid5.c')
-rw-r--r--drivers/md/raid5.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 5044babfcda0..fa5519389a17 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5517,7 +5517,6 @@ static int raid5_start_reshape(mddev_t *mddev)
5517 raid5_conf_t *conf = mddev->private; 5517 raid5_conf_t *conf = mddev->private;
5518 mdk_rdev_t *rdev; 5518 mdk_rdev_t *rdev;
5519 int spares = 0; 5519 int spares = 0;
5520 int added_devices = 0;
5521 unsigned long flags; 5520 unsigned long flags;
5522 5521
5523 if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) 5522 if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery))
@@ -5571,34 +5570,36 @@ static int raid5_start_reshape(mddev_t *mddev)
5571 * to correctly record the "partially reconstructed" state of 5570 * to correctly record the "partially reconstructed" state of
5572 * such devices during the reshape and confusion could result. 5571 * such devices during the reshape and confusion could result.
5573 */ 5572 */
5574 if (mddev->delta_disks >= 0) 5573 if (mddev->delta_disks >= 0) {
5575 list_for_each_entry(rdev, &mddev->disks, same_set) 5574 int added_devices = 0;
5576 if (rdev->raid_disk < 0 && 5575 list_for_each_entry(rdev, &mddev->disks, same_set)
5577 !test_bit(Faulty, &rdev->flags)) { 5576 if (rdev->raid_disk < 0 &&
5578 if (raid5_add_disk(mddev, rdev) == 0) { 5577 !test_bit(Faulty, &rdev->flags)) {
5579 char nm[20]; 5578 if (raid5_add_disk(mddev, rdev) == 0) {
5580 if (rdev->raid_disk >= conf->previous_raid_disks) { 5579 char nm[20];
5581 set_bit(In_sync, &rdev->flags); 5580 if (rdev->raid_disk
5582 added_devices++; 5581 >= conf->previous_raid_disks) {
5582 set_bit(In_sync, &rdev->flags);
5583 added_devices++;
5584 } else
5585 rdev->recovery_offset = 0;
5586 sprintf(nm, "rd%d", rdev->raid_disk);
5587 if (sysfs_create_link(&mddev->kobj,
5588 &rdev->kobj, nm))
5589 /* Failure here is OK */;
5583 } else 5590 } else
5584 rdev->recovery_offset = 0; 5591 break;
5585 sprintf(nm, "rd%d", rdev->raid_disk); 5592 } else if (rdev->raid_disk >= conf->previous_raid_disks
5586 if (sysfs_create_link(&mddev->kobj, 5593 && !test_bit(Faulty, &rdev->flags)) {
5587 &rdev->kobj, nm)) 5594 /* This is a spare that was manually added */
5588 /* Failure here is OK */; 5595 set_bit(In_sync, &rdev->flags);
5589 } else 5596 added_devices++;
5590 break; 5597 }
5591 } else if (rdev->raid_disk >= conf->previous_raid_disks
5592 && !test_bit(Faulty, &rdev->flags)) {
5593 /* This is a spare that was manually added */
5594 set_bit(In_sync, &rdev->flags);
5595 added_devices++;
5596 }
5597 5598
5598 /* When a reshape changes the number of devices, ->degraded 5599 /* When a reshape changes the number of devices,
5599 * is measured against the larger of the pre and post number of 5600 * ->degraded is measured against the larger of the
5600 * devices.*/ 5601 * pre and post number of devices.
5601 if (mddev->delta_disks > 0) { 5602 */
5602 spin_lock_irqsave(&conf->device_lock, flags); 5603 spin_lock_irqsave(&conf->device_lock, flags);
5603 mddev->degraded += (conf->raid_disks - conf->previous_raid_disks) 5604 mddev->degraded += (conf->raid_disks - conf->previous_raid_disks)
5604 - added_devices; 5605 - added_devices;