aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid10.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-07-21 13:29:12 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-21 13:29:12 -0400
commit8a392625b665c676a77c62f8608d10ff430bcb83 (patch)
tree4000a65d61baed73200e47f91dea5263ed16edd0 /drivers/md/raid10.c
parent519f0141f1c42e2b8b59c7dea005cbf6095358e8 (diff)
parent4b80991c6cb9efa607bc4fd6f3ecdf5511c31bb0 (diff)
Merge branch 'for-linus' of git://neil.brown.name/md
* 'for-linus' of git://neil.brown.name/md: (52 commits) md: Protect access to mddev->disks list using RCU md: only count actual openers as access which prevent a 'stop' md: linear: Make array_size sector-based and rename it to array_sectors. md: Make mddev->array_size sector-based. md: Make super_type->rdev_size_change() take sector-based sizes. md: Fix check for overlapping devices. md: Tidy up rdev_size_store a bit: md: Remove some unused macros. md: Turn rdev->sb_offset into a sector-based quantity. md: Make calc_dev_sboffset() return a sector count. md: Replace calc_dev_size() by calc_num_sectors(). md: Make update_size() take the number of sectors. md: Better control of when do_md_stop is allowed to stop the array. md: get_disk_info(): Don't convert between signed and unsigned and back. md: Simplify restart_array(). md: alloc_disk_sb(): Return proper error value. md: Simplify sb_equal(). md: Simplify uuid_equal(). md: sb_equal(): Fix misleading printk. md: Fix a typo in the comment to cmd_match(). ...
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;