diff options
Diffstat (limited to 'drivers/md/raid1.c')
-rw-r--r-- | drivers/md/raid1.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index c610b947218a..03a5ab705c20 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -1100,11 +1100,16 @@ static int raid1_spare_active(mddev_t *mddev) | |||
1100 | static int raid1_add_disk(mddev_t *mddev, mdk_rdev_t *rdev) | 1100 | static int raid1_add_disk(mddev_t *mddev, mdk_rdev_t *rdev) |
1101 | { | 1101 | { |
1102 | conf_t *conf = mddev->private; | 1102 | conf_t *conf = mddev->private; |
1103 | int found = 0; | 1103 | int err = -EEXIST; |
1104 | int mirror = 0; | 1104 | int mirror = 0; |
1105 | mirror_info_t *p; | 1105 | mirror_info_t *p; |
1106 | int first = 0; | ||
1107 | int last = mddev->raid_disks - 1; | ||
1106 | 1108 | ||
1107 | for (mirror=0; mirror < mddev->raid_disks; mirror++) | 1109 | if (rdev->raid_disk >= 0) |
1110 | first = last = rdev->raid_disk; | ||
1111 | |||
1112 | for (mirror = first; mirror <= last; mirror++) | ||
1108 | if ( !(p=conf->mirrors+mirror)->rdev) { | 1113 | if ( !(p=conf->mirrors+mirror)->rdev) { |
1109 | 1114 | ||
1110 | blk_queue_stack_limits(mddev->queue, | 1115 | blk_queue_stack_limits(mddev->queue, |
@@ -1119,7 +1124,7 @@ static int raid1_add_disk(mddev_t *mddev, mdk_rdev_t *rdev) | |||
1119 | 1124 | ||
1120 | p->head_position = 0; | 1125 | p->head_position = 0; |
1121 | rdev->raid_disk = mirror; | 1126 | rdev->raid_disk = mirror; |
1122 | found = 1; | 1127 | err = 0; |
1123 | /* As all devices are equivalent, we don't need a full recovery | 1128 | /* As all devices are equivalent, we don't need a full recovery |
1124 | * if this was recently any drive of the array | 1129 | * if this was recently any drive of the array |
1125 | */ | 1130 | */ |
@@ -1130,7 +1135,7 @@ static int raid1_add_disk(mddev_t *mddev, mdk_rdev_t *rdev) | |||
1130 | } | 1135 | } |
1131 | 1136 | ||
1132 | print_conf(conf); | 1137 | print_conf(conf); |
1133 | return found; | 1138 | return err; |
1134 | } | 1139 | } |
1135 | 1140 | ||
1136 | static int raid1_remove_disk(mddev_t *mddev, int number) | 1141 | static int raid1_remove_disk(mddev_t *mddev, int number) |
@@ -2038,7 +2043,7 @@ static int run(mddev_t *mddev) | |||
2038 | /* | 2043 | /* |
2039 | * Ok, everything is just fine now | 2044 | * Ok, everything is just fine now |
2040 | */ | 2045 | */ |
2041 | mddev->array_size = mddev->size; | 2046 | mddev->array_sectors = mddev->size * 2; |
2042 | 2047 | ||
2043 | mddev->queue->unplug_fn = raid1_unplug; | 2048 | mddev->queue->unplug_fn = raid1_unplug; |
2044 | mddev->queue->backing_dev_info.congested_fn = raid1_congested; | 2049 | mddev->queue->backing_dev_info.congested_fn = raid1_congested; |
@@ -2100,14 +2105,15 @@ static int raid1_resize(mddev_t *mddev, sector_t sectors) | |||
2100 | * any io in the removed space completes, but it hardly seems | 2105 | * any io in the removed space completes, but it hardly seems |
2101 | * worth it. | 2106 | * worth it. |
2102 | */ | 2107 | */ |
2103 | mddev->array_size = sectors>>1; | 2108 | mddev->array_sectors = sectors; |
2104 | set_capacity(mddev->gendisk, mddev->array_size << 1); | 2109 | set_capacity(mddev->gendisk, mddev->array_sectors); |
2105 | mddev->changed = 1; | 2110 | mddev->changed = 1; |
2106 | if (mddev->array_size > mddev->size && mddev->recovery_cp == MaxSector) { | 2111 | if (mddev->array_sectors / 2 > mddev->size && |
2112 | mddev->recovery_cp == MaxSector) { | ||
2107 | mddev->recovery_cp = mddev->size << 1; | 2113 | mddev->recovery_cp = mddev->size << 1; |
2108 | set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); | 2114 | set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); |
2109 | } | 2115 | } |
2110 | mddev->size = mddev->array_size; | 2116 | mddev->size = mddev->array_sectors / 2; |
2111 | mddev->resync_max_sectors = sectors; | 2117 | mddev->resync_max_sectors = sectors; |
2112 | return 0; | 2118 | return 0; |
2113 | } | 2119 | } |
@@ -2131,7 +2137,7 @@ static int raid1_reshape(mddev_t *mddev) | |||
2131 | conf_t *conf = mddev_to_conf(mddev); | 2137 | conf_t *conf = mddev_to_conf(mddev); |
2132 | int cnt, raid_disks; | 2138 | int cnt, raid_disks; |
2133 | unsigned long flags; | 2139 | unsigned long flags; |
2134 | int d, d2; | 2140 | int d, d2, err; |
2135 | 2141 | ||
2136 | /* Cannot change chunk_size, layout, or level */ | 2142 | /* Cannot change chunk_size, layout, or level */ |
2137 | if (mddev->chunk_size != mddev->new_chunk || | 2143 | if (mddev->chunk_size != mddev->new_chunk || |
@@ -2143,7 +2149,9 @@ static int raid1_reshape(mddev_t *mddev) | |||
2143 | return -EINVAL; | 2149 | return -EINVAL; |
2144 | } | 2150 | } |
2145 | 2151 | ||
2146 | md_allow_write(mddev); | 2152 | err = md_allow_write(mddev); |
2153 | if (err) | ||
2154 | return err; | ||
2147 | 2155 | ||
2148 | raid_disks = mddev->raid_disks + mddev->delta_disks; | 2156 | raid_disks = mddev->raid_disks + mddev->delta_disks; |
2149 | 2157 | ||