aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid10.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/raid10.c')
-rw-r--r--drivers/md/raid10.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 22bb2b1b886d..159535d73567 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1114,24 +1114,30 @@ static int raid10_spare_active(mddev_t *mddev)
1114static int raid10_add_disk(mddev_t *mddev, mdk_rdev_t *rdev) 1114static int raid10_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
1115{ 1115{
1116 conf_t *conf = mddev->private; 1116 conf_t *conf = mddev->private;
1117 int found = 0; 1117 int err = -EEXIST;
1118 int mirror; 1118 int mirror;
1119 mirror_info_t *p; 1119 mirror_info_t *p;
1120 int first = 0;
1121 int last = mddev->raid_disks - 1;
1120 1122
1121 if (mddev->recovery_cp < MaxSector) 1123 if (mddev->recovery_cp < MaxSector)
1122 /* only hot-add to in-sync arrays, as recovery is 1124 /* only hot-add to in-sync arrays, as recovery is
1123 * very different from resync 1125 * very different from resync
1124 */ 1126 */
1125 return 0; 1127 return -EBUSY;
1126 if (!enough(conf)) 1128 if (!enough(conf))
1127 return 0; 1129 return -EINVAL;
1130
1131 if (rdev->raid_disk)
1132 first = last = rdev->raid_disk;
1128 1133
1129 if (rdev->saved_raid_disk >= 0 && 1134 if (rdev->saved_raid_disk >= 0 &&
1135 rdev->saved_raid_disk >= first &&
1130 conf->mirrors[rdev->saved_raid_disk].rdev == NULL) 1136 conf->mirrors[rdev->saved_raid_disk].rdev == NULL)
1131 mirror = rdev->saved_raid_disk; 1137 mirror = rdev->saved_raid_disk;
1132 else 1138 else
1133 mirror = 0; 1139 mirror = first;
1134 for ( ; mirror < mddev->raid_disks; mirror++) 1140 for ( ; mirror <= last ; mirror++)
1135 if ( !(p=conf->mirrors+mirror)->rdev) { 1141 if ( !(p=conf->mirrors+mirror)->rdev) {
1136 1142
1137 blk_queue_stack_limits(mddev->queue, 1143 blk_queue_stack_limits(mddev->queue,
@@ -1146,7 +1152,7 @@ static int raid10_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
1146 1152
1147 p->head_position = 0; 1153 p->head_position = 0;
1148 rdev->raid_disk = mirror; 1154 rdev->raid_disk = mirror;
1149 found = 1; 1155 err = 0;
1150 if (rdev->saved_raid_disk != mirror) 1156 if (rdev->saved_raid_disk != mirror)
1151 conf->fullsync = 1; 1157 conf->fullsync = 1;
1152 rcu_assign_pointer(p->rdev, rdev); 1158 rcu_assign_pointer(p->rdev, rdev);
@@ -1154,7 +1160,7 @@ static int raid10_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
1154 } 1160 }
1155 1161
1156 print_conf(conf); 1162 print_conf(conf);
1157 return found; 1163 return err;
1158} 1164}
1159 1165
1160static int raid10_remove_disk(mddev_t *mddev, int number) 1166static int raid10_remove_disk(mddev_t *mddev, int number)
@@ -2159,7 +2165,7 @@ static int run(mddev_t *mddev)
2159 /* 2165 /*
2160 * Ok, everything is just fine now 2166 * Ok, everything is just fine now
2161 */ 2167 */
2162 mddev->array_size = size << (conf->chunk_shift-1); 2168 mddev->array_sectors = size << conf->chunk_shift;
2163 mddev->resync_max_sectors = size << conf->chunk_shift; 2169 mddev->resync_max_sectors = size << conf->chunk_shift;
2164 2170
2165 mddev->queue->unplug_fn = raid10_unplug; 2171 mddev->queue->unplug_fn = raid10_unplug;