aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/md/md.c29
-rw-r--r--drivers/md/md.h3
-rw-r--r--drivers/md/raid1.c4
-rw-r--r--drivers/md/raid5.c45
4 files changed, 43 insertions, 38 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index abcc0fef30e3..f996d8342a85 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -886,13 +886,13 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev)
886 mddev->delta_disks = sb->delta_disks; 886 mddev->delta_disks = sb->delta_disks;
887 mddev->new_level = sb->new_level; 887 mddev->new_level = sb->new_level;
888 mddev->new_layout = sb->new_layout; 888 mddev->new_layout = sb->new_layout;
889 mddev->new_chunk = sb->new_chunk; 889 mddev->new_chunk_sectors = sb->new_chunk >> 9;
890 } else { 890 } else {
891 mddev->reshape_position = MaxSector; 891 mddev->reshape_position = MaxSector;
892 mddev->delta_disks = 0; 892 mddev->delta_disks = 0;
893 mddev->new_level = mddev->level; 893 mddev->new_level = mddev->level;
894 mddev->new_layout = mddev->layout; 894 mddev->new_layout = mddev->layout;
895 mddev->new_chunk = mddev->chunk_sectors << 9; 895 mddev->new_chunk_sectors = mddev->chunk_sectors;
896 } 896 }
897 897
898 if (sb->state & (1<<MD_SB_CLEAN)) 898 if (sb->state & (1<<MD_SB_CLEAN))
@@ -1007,7 +1007,7 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1007 sb->new_level = mddev->new_level; 1007 sb->new_level = mddev->new_level;
1008 sb->delta_disks = mddev->delta_disks; 1008 sb->delta_disks = mddev->delta_disks;
1009 sb->new_layout = mddev->new_layout; 1009 sb->new_layout = mddev->new_layout;
1010 sb->new_chunk = mddev->new_chunk; 1010 sb->new_chunk = mddev->new_chunk_sectors << 9;
1011 } 1011 }
1012 mddev->minor_version = sb->minor_version; 1012 mddev->minor_version = sb->minor_version;
1013 if (mddev->in_sync) 1013 if (mddev->in_sync)
@@ -1304,13 +1304,13 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
1304 mddev->delta_disks = le32_to_cpu(sb->delta_disks); 1304 mddev->delta_disks = le32_to_cpu(sb->delta_disks);
1305 mddev->new_level = le32_to_cpu(sb->new_level); 1305 mddev->new_level = le32_to_cpu(sb->new_level);
1306 mddev->new_layout = le32_to_cpu(sb->new_layout); 1306 mddev->new_layout = le32_to_cpu(sb->new_layout);
1307 mddev->new_chunk = le32_to_cpu(sb->new_chunk)<<9; 1307 mddev->new_chunk_sectors = le32_to_cpu(sb->new_chunk);
1308 } else { 1308 } else {
1309 mddev->reshape_position = MaxSector; 1309 mddev->reshape_position = MaxSector;
1310 mddev->delta_disks = 0; 1310 mddev->delta_disks = 0;
1311 mddev->new_level = mddev->level; 1311 mddev->new_level = mddev->level;
1312 mddev->new_layout = mddev->layout; 1312 mddev->new_layout = mddev->layout;
1313 mddev->new_chunk = mddev->chunk_sectors << 9; 1313 mddev->new_chunk_sectors = mddev->chunk_sectors;
1314 } 1314 }
1315 1315
1316 } else if (mddev->pers == NULL) { 1316 } else if (mddev->pers == NULL) {
@@ -1409,7 +1409,7 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1409 sb->new_layout = cpu_to_le32(mddev->new_layout); 1409 sb->new_layout = cpu_to_le32(mddev->new_layout);
1410 sb->delta_disks = cpu_to_le32(mddev->delta_disks); 1410 sb->delta_disks = cpu_to_le32(mddev->delta_disks);
1411 sb->new_level = cpu_to_le32(mddev->new_level); 1411 sb->new_level = cpu_to_le32(mddev->new_level);
1412 sb->new_chunk = cpu_to_le32(mddev->new_chunk>>9); 1412 sb->new_chunk = cpu_to_le32(mddev->new_chunk_sectors);
1413 } 1413 }
1414 1414
1415 max_dev = 0; 1415 max_dev = 0;
@@ -2753,7 +2753,7 @@ level_store(mddev_t *mddev, const char *buf, size_t len)
2753 if (IS_ERR(priv)) { 2753 if (IS_ERR(priv)) {
2754 mddev->new_level = mddev->level; 2754 mddev->new_level = mddev->level;
2755 mddev->new_layout = mddev->layout; 2755 mddev->new_layout = mddev->layout;
2756 mddev->new_chunk = mddev->chunk_sectors << 9; 2756 mddev->new_chunk_sectors = mddev->chunk_sectors;
2757 mddev->raid_disks -= mddev->delta_disks; 2757 mddev->raid_disks -= mddev->delta_disks;
2758 mddev->delta_disks = 0; 2758 mddev->delta_disks = 0;
2759 module_put(pers->owner); 2759 module_put(pers->owner);
@@ -2771,7 +2771,7 @@ level_store(mddev_t *mddev, const char *buf, size_t len)
2771 strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel)); 2771 strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel));
2772 mddev->level = mddev->new_level; 2772 mddev->level = mddev->new_level;
2773 mddev->layout = mddev->new_layout; 2773 mddev->layout = mddev->new_layout;
2774 mddev->chunk_sectors = mddev->new_chunk >> 9; 2774 mddev->chunk_sectors = mddev->new_chunk_sectors;
2775 mddev->delta_disks = 0; 2775 mddev->delta_disks = 0;
2776 pers->run(mddev); 2776 pers->run(mddev);
2777 mddev_resume(mddev); 2777 mddev_resume(mddev);
@@ -2864,8 +2864,9 @@ static ssize_t
2864chunk_size_show(mddev_t *mddev, char *page) 2864chunk_size_show(mddev_t *mddev, char *page)
2865{ 2865{
2866 if (mddev->reshape_position != MaxSector && 2866 if (mddev->reshape_position != MaxSector &&
2867 mddev->chunk_sectors << 9 != mddev->new_chunk) 2867 mddev->chunk_sectors != mddev->new_chunk_sectors)
2868 return sprintf(page, "%d (%d)\n", mddev->new_chunk, 2868 return sprintf(page, "%d (%d)\n",
2869 mddev->new_chunk_sectors << 9,
2869 mddev->chunk_sectors << 9); 2870 mddev->chunk_sectors << 9);
2870 return sprintf(page, "%d\n", mddev->chunk_sectors << 9); 2871 return sprintf(page, "%d\n", mddev->chunk_sectors << 9);
2871} 2872}
@@ -2887,7 +2888,7 @@ chunk_size_store(mddev_t *mddev, const char *buf, size_t len)
2887 if (err) 2888 if (err)
2888 return err; 2889 return err;
2889 } else { 2890 } else {
2890 mddev->new_chunk = n; 2891 mddev->new_chunk_sectors = n >> 9;
2891 if (mddev->reshape_position == MaxSector) 2892 if (mddev->reshape_position == MaxSector)
2892 mddev->chunk_sectors = n >> 9; 2893 mddev->chunk_sectors = n >> 9;
2893 } 2894 }
@@ -3665,7 +3666,7 @@ reshape_position_store(mddev_t *mddev, const char *buf, size_t len)
3665 mddev->delta_disks = 0; 3666 mddev->delta_disks = 0;
3666 mddev->new_level = mddev->level; 3667 mddev->new_level = mddev->level;
3667 mddev->new_layout = mddev->layout; 3668 mddev->new_layout = mddev->layout;
3668 mddev->new_chunk = mddev->chunk_sectors << 9; 3669 mddev->new_chunk_sectors = mddev->chunk_sectors;
3669 return len; 3670 return len;
3670} 3671}
3671 3672
@@ -4414,7 +4415,7 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
4414 mddev->delta_disks = 0; 4415 mddev->delta_disks = 0;
4415 mddev->new_level = LEVEL_NONE; 4416 mddev->new_level = LEVEL_NONE;
4416 mddev->new_layout = 0; 4417 mddev->new_layout = 0;
4417 mddev->new_chunk = 0; 4418 mddev->new_chunk_sectors = 0;
4418 mddev->curr_resync = 0; 4419 mddev->curr_resync = 0;
4419 mddev->resync_mismatches = 0; 4420 mddev->resync_mismatches = 0;
4420 mddev->suspend_lo = mddev->suspend_hi = 0; 4421 mddev->suspend_lo = mddev->suspend_hi = 0;
@@ -5083,7 +5084,7 @@ static int set_array_info(mddev_t * mddev, mdu_array_info_t *info)
5083 get_random_bytes(mddev->uuid, 16); 5084 get_random_bytes(mddev->uuid, 16);
5084 5085
5085 mddev->new_level = mddev->level; 5086 mddev->new_level = mddev->level;
5086 mddev->new_chunk = mddev->chunk_sectors << 9; 5087 mddev->new_chunk_sectors = mddev->chunk_sectors;
5087 mddev->new_layout = mddev->layout; 5088 mddev->new_layout = mddev->layout;
5088 mddev->delta_disks = 0; 5089 mddev->delta_disks = 0;
5089 5090
diff --git a/drivers/md/md.h b/drivers/md/md.h
index 5d78830043d0..e0a2b8e3985d 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -166,7 +166,8 @@ struct mddev_s
166 * If reshape_position is MaxSector, then no reshape is happening (yet). 166 * If reshape_position is MaxSector, then no reshape is happening (yet).
167 */ 167 */
168 sector_t reshape_position; 168 sector_t reshape_position;
169 int delta_disks, new_level, new_layout, new_chunk; 169 int delta_disks, new_level, new_layout;
170 int new_chunk_sectors;
170 171
171 struct mdk_thread_s *thread; /* management thread */ 172 struct mdk_thread_s *thread; /* management thread */
172 struct mdk_thread_s *sync_thread; /* doing resync or reconstruct */ 173 struct mdk_thread_s *sync_thread; /* doing resync or reconstruct */
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 388635735ae5..12f8f34f17ae 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2161,10 +2161,10 @@ static int raid1_reshape(mddev_t *mddev)
2161 int d, d2, err; 2161 int d, d2, err;
2162 2162
2163 /* Cannot change chunk_size, layout, or level */ 2163 /* Cannot change chunk_size, layout, or level */
2164 if (mddev->chunk_sectors << 9 != mddev->new_chunk || 2164 if (mddev->chunk_sectors != mddev->new_chunk_sectors ||
2165 mddev->layout != mddev->new_layout || 2165 mddev->layout != mddev->new_layout ||
2166 mddev->level != mddev->new_level) { 2166 mddev->level != mddev->new_level) {
2167 mddev->new_chunk = mddev->chunk_sectors << 9; 2167 mddev->new_chunk_sectors = mddev->chunk_sectors;
2168 mddev->new_layout = mddev->layout; 2168 mddev->new_layout = mddev->layout;
2169 mddev->new_level = mddev->level; 2169 mddev->new_level = mddev->level;
2170 return -EINVAL; 2170 return -EINVAL;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 1e4fd5e8bfdd..bc3564cfbba0 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3358,8 +3358,8 @@ static int raid5_mergeable_bvec(struct request_queue *q,
3358 if ((bvm->bi_rw & 1) == WRITE) 3358 if ((bvm->bi_rw & 1) == WRITE)
3359 return biovec->bv_len; /* always allow writes to be mergeable */ 3359 return biovec->bv_len; /* always allow writes to be mergeable */
3360 3360
3361 if (mddev->new_chunk < mddev->chunk_sectors << 9) 3361 if (mddev->new_chunk_sectors < mddev->chunk_sectors)
3362 chunk_sectors = mddev->new_chunk >> 9; 3362 chunk_sectors = mddev->new_chunk_sectors;
3363 max = (chunk_sectors - ((sector & (chunk_sectors - 1)) + bio_sectors)) << 9; 3363 max = (chunk_sectors - ((sector & (chunk_sectors - 1)) + bio_sectors)) << 9;
3364 if (max < 0) max = 0; 3364 if (max < 0) max = 0;
3365 if (max <= biovec->bv_len && bio_sectors == 0) 3365 if (max <= biovec->bv_len && bio_sectors == 0)
@@ -3375,8 +3375,8 @@ static int in_chunk_boundary(mddev_t *mddev, struct bio *bio)
3375 unsigned int chunk_sectors = mddev->chunk_sectors; 3375 unsigned int chunk_sectors = mddev->chunk_sectors;
3376 unsigned int bio_sectors = bio->bi_size >> 9; 3376 unsigned int bio_sectors = bio->bi_size >> 9;
3377 3377
3378 if (mddev->new_chunk < mddev->chunk_sectors << 9) 3378 if (mddev->new_chunk_sectors < mddev->chunk_sectors)
3379 chunk_sectors = mddev->new_chunk >> 9; 3379 chunk_sectors = mddev->new_chunk_sectors;
3380 return chunk_sectors >= 3380 return chunk_sectors >=
3381 ((sector & (chunk_sectors - 1)) + bio_sectors); 3381 ((sector & (chunk_sectors - 1)) + bio_sectors);
3382} 3382}
@@ -3791,8 +3791,8 @@ static sector_t reshape_request(mddev_t *mddev, sector_t sector_nr, int *skipped
3791 * If old and new chunk sizes differ, we need to process the 3791 * If old and new chunk sizes differ, we need to process the
3792 * largest of these 3792 * largest of these
3793 */ 3793 */
3794 if (mddev->new_chunk > mddev->chunk_sectors << 9) 3794 if (mddev->new_chunk_sectors > mddev->chunk_sectors)
3795 reshape_sectors = mddev->new_chunk / 512; 3795 reshape_sectors = mddev->new_chunk_sectors;
3796 else 3796 else
3797 reshape_sectors = mddev->chunk_sectors; 3797 reshape_sectors = mddev->chunk_sectors;
3798 3798
@@ -4304,7 +4304,7 @@ raid5_size(mddev_t *mddev, sector_t sectors, int raid_disks)
4304 } 4304 }
4305 4305
4306 sectors &= ~((sector_t)mddev->chunk_sectors - 1); 4306 sectors &= ~((sector_t)mddev->chunk_sectors - 1);
4307 sectors &= ~((sector_t)mddev->new_chunk/512 - 1); 4307 sectors &= ~((sector_t)mddev->new_chunk_sectors - 1);
4308 return sectors * (raid_disks - conf->max_degraded); 4308 return sectors * (raid_disks - conf->max_degraded);
4309} 4309}
4310 4310
@@ -4336,10 +4336,11 @@ static raid5_conf_t *setup_conf(mddev_t *mddev)
4336 return ERR_PTR(-EINVAL); 4336 return ERR_PTR(-EINVAL);
4337 } 4337 }
4338 4338
4339 if (!mddev->new_chunk || mddev->new_chunk % PAGE_SIZE || 4339 if (!mddev->new_chunk_sectors ||
4340 !is_power_of_2(mddev->new_chunk)) { 4340 (mddev->new_chunk_sectors << 9) % PAGE_SIZE ||
4341 !is_power_of_2(mddev->new_chunk_sectors)) {
4341 printk(KERN_ERR "raid5: invalid chunk size %d for %s\n", 4342 printk(KERN_ERR "raid5: invalid chunk size %d for %s\n",
4342 mddev->new_chunk, mdname(mddev)); 4343 mddev->new_chunk_sectors << 9, mdname(mddev));
4343 return ERR_PTR(-EINVAL); 4344 return ERR_PTR(-EINVAL);
4344 } 4345 }
4345 4346
@@ -4402,7 +4403,7 @@ static raid5_conf_t *setup_conf(mddev_t *mddev)
4402 conf->fullsync = 1; 4403 conf->fullsync = 1;
4403 } 4404 }
4404 4405
4405 conf->chunk_size = mddev->new_chunk; 4406 conf->chunk_size = mddev->new_chunk_sectors << 9;
4406 conf->level = mddev->new_level; 4407 conf->level = mddev->new_level;
4407 if (conf->level == 6) 4408 if (conf->level == 6)
4408 conf->max_degraded = 2; 4409 conf->max_degraded = 2;
@@ -4476,7 +4477,7 @@ static int run(mddev_t *mddev)
4476 * geometry. 4477 * geometry.
4477 */ 4478 */
4478 here_new = mddev->reshape_position; 4479 here_new = mddev->reshape_position;
4479 if (sector_div(here_new, (mddev->new_chunk>>9)* 4480 if (sector_div(here_new, mddev->new_chunk_sectors *
4480 (mddev->raid_disks - max_degraded))) { 4481 (mddev->raid_disks - max_degraded))) {
4481 printk(KERN_ERR "raid5: reshape_position not " 4482 printk(KERN_ERR "raid5: reshape_position not "
4482 "on a stripe boundary\n"); 4483 "on a stripe boundary\n");
@@ -4499,7 +4500,7 @@ static int run(mddev_t *mddev)
4499 } else { 4500 } else {
4500 BUG_ON(mddev->level != mddev->new_level); 4501 BUG_ON(mddev->level != mddev->new_level);
4501 BUG_ON(mddev->layout != mddev->new_layout); 4502 BUG_ON(mddev->layout != mddev->new_layout);
4502 BUG_ON(mddev->chunk_sectors << 9 != mddev->new_chunk); 4503 BUG_ON(mddev->chunk_sectors != mddev->new_chunk_sectors);
4503 BUG_ON(mddev->delta_disks != 0); 4504 BUG_ON(mddev->delta_disks != 0);
4504 } 4505 }
4505 4506
@@ -4851,7 +4852,7 @@ static int raid5_check_reshape(mddev_t *mddev)
4851 4852
4852 if (mddev->delta_disks == 0 && 4853 if (mddev->delta_disks == 0 &&
4853 mddev->new_layout == mddev->layout && 4854 mddev->new_layout == mddev->layout &&
4854 mddev->new_chunk == mddev->chunk_sectors << 9) 4855 mddev->new_chunk_sectors == mddev->chunk_sectors)
4855 return -EINVAL; /* nothing to do */ 4856 return -EINVAL; /* nothing to do */
4856 if (mddev->bitmap) 4857 if (mddev->bitmap)
4857 /* Cannot grow a bitmap yet */ 4858 /* Cannot grow a bitmap yet */
@@ -4881,9 +4882,11 @@ static int raid5_check_reshape(mddev_t *mddev)
4881 */ 4882 */
4882 if (((mddev->chunk_sectors << 9) / STRIPE_SIZE) * 4 4883 if (((mddev->chunk_sectors << 9) / STRIPE_SIZE) * 4
4883 > conf->max_nr_stripes || 4884 > conf->max_nr_stripes ||
4884 (mddev->new_chunk / STRIPE_SIZE) * 4 > conf->max_nr_stripes) { 4885 ((mddev->new_chunk_sectors << 9) / STRIPE_SIZE) * 4
4886 > conf->max_nr_stripes) {
4885 printk(KERN_WARNING "raid5: reshape: not enough stripes. Needed %lu\n", 4887 printk(KERN_WARNING "raid5: reshape: not enough stripes. Needed %lu\n",
4886 (max(mddev->chunk_sectors << 9, mddev->new_chunk) 4888 (max(mddev->chunk_sectors << 9,
4889 mddev->new_chunk_sectors << 9)
4887 / STRIPE_SIZE)*4); 4890 / STRIPE_SIZE)*4);
4888 return -ENOSPC; 4891 return -ENOSPC;
4889 } 4892 }
@@ -4929,7 +4932,7 @@ static int raid5_start_reshape(mddev_t *mddev)
4929 conf->previous_raid_disks = conf->raid_disks; 4932 conf->previous_raid_disks = conf->raid_disks;
4930 conf->raid_disks += mddev->delta_disks; 4933 conf->raid_disks += mddev->delta_disks;
4931 conf->prev_chunk = conf->chunk_size; 4934 conf->prev_chunk = conf->chunk_size;
4932 conf->chunk_size = mddev->new_chunk; 4935 conf->chunk_size = mddev->new_chunk_sectors << 9;
4933 conf->prev_algo = conf->algorithm; 4936 conf->prev_algo = conf->algorithm;
4934 conf->algorithm = mddev->new_layout; 4937 conf->algorithm = mddev->new_layout;
4935 if (mddev->delta_disks < 0) 4938 if (mddev->delta_disks < 0)
@@ -5114,7 +5117,7 @@ static void *raid5_takeover_raid1(mddev_t *mddev)
5114 5117
5115 mddev->new_level = 5; 5118 mddev->new_level = 5;
5116 mddev->new_layout = ALGORITHM_LEFT_SYMMETRIC; 5119 mddev->new_layout = ALGORITHM_LEFT_SYMMETRIC;
5117 mddev->new_chunk = chunksect << 9; 5120 mddev->new_chunk_sectors = chunksect;
5118 5121
5119 return setup_conf(mddev); 5122 return setup_conf(mddev);
5120} 5123}
@@ -5185,7 +5188,7 @@ static int raid5_reconfig(mddev_t *mddev, int new_layout, int new_chunk)
5185 } 5188 }
5186 if (new_chunk > 0) { 5189 if (new_chunk > 0) {
5187 conf->chunk_size = new_chunk; 5190 conf->chunk_size = new_chunk;
5188 mddev->new_chunk = new_chunk; 5191 mddev->new_chunk_sectors = new_chunk >> 9;
5189 mddev->chunk_sectors = new_chunk >> 9; 5192 mddev->chunk_sectors = new_chunk >> 9;
5190 } 5193 }
5191 set_bit(MD_CHANGE_DEVS, &mddev->flags); 5194 set_bit(MD_CHANGE_DEVS, &mddev->flags);
@@ -5194,7 +5197,7 @@ static int raid5_reconfig(mddev_t *mddev, int new_layout, int new_chunk)
5194 if (new_layout >= 0) 5197 if (new_layout >= 0)
5195 mddev->new_layout = new_layout; 5198 mddev->new_layout = new_layout;
5196 if (new_chunk > 0) 5199 if (new_chunk > 0)
5197 mddev->new_chunk = new_chunk; 5200 mddev->new_chunk_sectors = new_chunk >> 9;
5198 } 5201 }
5199 return 0; 5202 return 0;
5200} 5203}
@@ -5219,7 +5222,7 @@ static int raid6_reconfig(mddev_t *mddev, int new_layout, int new_chunk)
5219 if (new_layout >= 0) 5222 if (new_layout >= 0)
5220 mddev->new_layout = new_layout; 5223 mddev->new_layout = new_layout;
5221 if (new_chunk > 0) 5224 if (new_chunk > 0)
5222 mddev->new_chunk = new_chunk; 5225 mddev->new_chunk_sectors = new_chunk >> 9;
5223 5226
5224 return 0; 5227 return 0;
5225} 5228}