Commit f233ea5c authored by Andre Noll's avatar Andre Noll Committed by NeilBrown

md: Make mddev->array_size sector-based.

This patch renames the array_size field of struct mddev_s to array_sectors
and converts all instances to use units of 512 byte sectors instead of 1k
blocks.
Signed-off-by: default avatarAndre Noll <maan@systemlinux.org>
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent 15f4a5fd
...@@ -297,7 +297,7 @@ static int run(mddev_t *mddev) ...@@ -297,7 +297,7 @@ static int run(mddev_t *mddev)
rdev_for_each(rdev, tmp, mddev) rdev_for_each(rdev, tmp, mddev)
conf->rdev = rdev; conf->rdev = rdev;
mddev->array_size = mddev->size; mddev->array_sectors = mddev->size * 2;
mddev->private = conf; mddev->private = conf;
reconfig(mddev, mddev->layout, -1); reconfig(mddev, mddev->layout, -1);
......
...@@ -256,7 +256,7 @@ static int linear_run (mddev_t *mddev) ...@@ -256,7 +256,7 @@ static int linear_run (mddev_t *mddev)
if (!conf) if (!conf)
return 1; return 1;
mddev->private = conf; mddev->private = conf;
mddev->array_size = conf->array_size; mddev->array_sectors = conf->array_size * 2;
blk_queue_merge_bvec(mddev->queue, linear_mergeable_bvec); blk_queue_merge_bvec(mddev->queue, linear_mergeable_bvec);
mddev->queue->unplug_fn = linear_unplug; mddev->queue->unplug_fn = linear_unplug;
...@@ -290,8 +290,8 @@ static int linear_add(mddev_t *mddev, mdk_rdev_t *rdev) ...@@ -290,8 +290,8 @@ static int linear_add(mddev_t *mddev, mdk_rdev_t *rdev)
newconf->prev = mddev_to_conf(mddev); newconf->prev = mddev_to_conf(mddev);
mddev->private = newconf; mddev->private = newconf;
mddev->raid_disks++; mddev->raid_disks++;
mddev->array_size = newconf->array_size; mddev->array_sectors = newconf->array_size * 2;
set_capacity(mddev->gendisk, mddev->array_size << 1); set_capacity(mddev->gendisk, mddev->array_sectors);
return 0; return 0;
} }
......
...@@ -3704,7 +3704,7 @@ static int do_md_run(mddev_t * mddev) ...@@ -3704,7 +3704,7 @@ static int do_md_run(mddev_t * mddev)
if (mddev->flags) if (mddev->flags)
md_update_sb(mddev, 0); md_update_sb(mddev, 0);
set_capacity(disk, mddev->array_size<<1); set_capacity(disk, mddev->array_sectors);
/* If we call blk_queue_make_request here, it will /* If we call blk_queue_make_request here, it will
* re-initialise max_sectors etc which may have been * re-initialise max_sectors etc which may have been
...@@ -3905,7 +3905,7 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open) ...@@ -3905,7 +3905,7 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
export_array(mddev); export_array(mddev);
mddev->array_size = 0; mddev->array_sectors = 0;
mddev->size = 0; mddev->size = 0;
mddev->raid_disks = 0; mddev->raid_disks = 0;
mddev->recovery_cp = 0; mddev->recovery_cp = 0;
...@@ -4644,7 +4644,8 @@ static int update_size(mddev_t *mddev, sector_t num_sectors) ...@@ -4644,7 +4644,8 @@ static int update_size(mddev_t *mddev, sector_t num_sectors)
bdev = bdget_disk(mddev->gendisk, 0); bdev = bdget_disk(mddev->gendisk, 0);
if (bdev) { if (bdev) {
mutex_lock(&bdev->bd_inode->i_mutex); mutex_lock(&bdev->bd_inode->i_mutex);
i_size_write(bdev->bd_inode, (loff_t)mddev->array_size << 10); i_size_write(bdev->bd_inode,
(loff_t)mddev->array_sectors << 9);
mutex_unlock(&bdev->bd_inode->i_mutex); mutex_unlock(&bdev->bd_inode->i_mutex);
bdput(bdev); bdput(bdev);
} }
...@@ -5391,10 +5392,11 @@ static int md_seq_show(struct seq_file *seq, void *v) ...@@ -5391,10 +5392,11 @@ static int md_seq_show(struct seq_file *seq, void *v)
if (!list_empty(&mddev->disks)) { if (!list_empty(&mddev->disks)) {
if (mddev->pers) if (mddev->pers)
seq_printf(seq, "\n %llu blocks", seq_printf(seq, "\n %llu blocks",
(unsigned long long)mddev->array_size); (unsigned long long)
mddev->array_sectors / 2);
else else
seq_printf(seq, "\n %llu blocks", seq_printf(seq, "\n %llu blocks",
(unsigned long long)size); (unsigned long long)size);
} }
if (mddev->persistent) { if (mddev->persistent) {
if (mddev->major_version != 0 || if (mddev->major_version != 0 ||
......
...@@ -504,7 +504,7 @@ static int multipath_run (mddev_t *mddev) ...@@ -504,7 +504,7 @@ static int multipath_run (mddev_t *mddev)
/* /*
* Ok, everything is just fine now * Ok, everything is just fine now
*/ */
mddev->array_size = mddev->size; mddev->array_sectors = mddev->size * 2;
mddev->queue->unplug_fn = multipath_unplug; mddev->queue->unplug_fn = multipath_unplug;
mddev->queue->backing_dev_info.congested_fn = multipath_congested; mddev->queue->backing_dev_info.congested_fn = multipath_congested;
......
...@@ -293,16 +293,16 @@ static int raid0_run (mddev_t *mddev) ...@@ -293,16 +293,16 @@ static int raid0_run (mddev_t *mddev)
goto out_free_conf; goto out_free_conf;
/* calculate array device size */ /* calculate array device size */
mddev->array_size = 0; mddev->array_sectors = 0;
rdev_for_each(rdev, tmp, mddev) rdev_for_each(rdev, tmp, mddev)
mddev->array_size += rdev->size; mddev->array_sectors += rdev->size * 2;
printk("raid0 : md_size is %llu blocks.\n", printk("raid0 : md_size is %llu blocks.\n",
(unsigned long long)mddev->array_size); (unsigned long long)mddev->array_sectors / 2);
printk("raid0 : conf->hash_spacing is %llu blocks.\n", printk("raid0 : conf->hash_spacing is %llu blocks.\n",
(unsigned long long)conf->hash_spacing); (unsigned long long)conf->hash_spacing);
{ {
sector_t s = mddev->array_size; sector_t s = mddev->array_sectors / 2;
sector_t space = conf->hash_spacing; sector_t space = conf->hash_spacing;
int round; int round;
conf->preshift = 0; conf->preshift = 0;
......
...@@ -2043,7 +2043,7 @@ static int run(mddev_t *mddev) ...@@ -2043,7 +2043,7 @@ static int run(mddev_t *mddev)
/* /*
* Ok, everything is just fine now * Ok, everything is just fine now
*/ */
mddev->array_size = mddev->size; mddev->array_sectors = mddev->size * 2;
mddev->queue->unplug_fn = raid1_unplug; mddev->queue->unplug_fn = raid1_unplug;
mddev->queue->backing_dev_info.congested_fn = raid1_congested; mddev->queue->backing_dev_info.congested_fn = raid1_congested;
...@@ -2105,14 +2105,15 @@ static int raid1_resize(mddev_t *mddev, sector_t sectors) ...@@ -2105,14 +2105,15 @@ static int raid1_resize(mddev_t *mddev, sector_t sectors)
* any io in the removed space completes, but it hardly seems * any io in the removed space completes, but it hardly seems
* worth it. * worth it.
*/ */
mddev->array_size = sectors>>1; mddev->array_sectors = sectors;
set_capacity(mddev->gendisk, mddev->array_size << 1); set_capacity(mddev->gendisk, mddev->array_sectors);
mddev->changed = 1; mddev->changed = 1;
if (mddev->array_size > mddev->size && mddev->recovery_cp == MaxSector) { if (mddev->array_sectors / 2 > mddev->size &&
mddev->recovery_cp == MaxSector) {
mddev->recovery_cp = mddev->size << 1; mddev->recovery_cp = mddev->size << 1;
set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
} }
mddev->size = mddev->array_size; mddev->size = mddev->array_sectors / 2;
mddev->resync_max_sectors = sectors; mddev->resync_max_sectors = sectors;
return 0; return 0;
} }
......
...@@ -2164,7 +2164,7 @@ static int run(mddev_t *mddev) ...@@ -2164,7 +2164,7 @@ static int run(mddev_t *mddev)
/* /*
* Ok, everything is just fine now * Ok, everything is just fine now
*/ */
mddev->array_size = size << (conf->chunk_shift-1); mddev->array_sectors = size << conf->chunk_shift;
mddev->resync_max_sectors = size << conf->chunk_shift; mddev->resync_max_sectors = size << conf->chunk_shift;
mddev->queue->unplug_fn = raid10_unplug; mddev->queue->unplug_fn = raid10_unplug;
......
...@@ -3540,7 +3540,7 @@ static sector_t reshape_request(mddev_t *mddev, sector_t sector_nr, int *skipped ...@@ -3540,7 +3540,7 @@ static sector_t reshape_request(mddev_t *mddev, sector_t sector_nr, int *skipped
j == raid6_next_disk(sh->pd_idx, sh->disks)) j == raid6_next_disk(sh->pd_idx, sh->disks))
continue; continue;
s = compute_blocknr(sh, j); s = compute_blocknr(sh, j);
if (s < (mddev->array_size<<1)) { if (s < mddev->array_sectors) {
skipped = 1; skipped = 1;
continue; continue;
} }
...@@ -4189,7 +4189,7 @@ static int run(mddev_t *mddev) ...@@ -4189,7 +4189,7 @@ static int run(mddev_t *mddev)
mddev->queue->backing_dev_info.congested_data = mddev; mddev->queue->backing_dev_info.congested_data = mddev;
mddev->queue->backing_dev_info.congested_fn = raid5_congested; mddev->queue->backing_dev_info.congested_fn = raid5_congested;
mddev->array_size = mddev->size * (conf->previous_raid_disks - mddev->array_sectors = 2 * mddev->size * (conf->previous_raid_disks -
conf->max_degraded); conf->max_degraded);
blk_queue_merge_bvec(mddev->queue, raid5_mergeable_bvec); blk_queue_merge_bvec(mddev->queue, raid5_mergeable_bvec);
...@@ -4413,8 +4413,9 @@ static int raid5_resize(mddev_t *mddev, sector_t sectors) ...@@ -4413,8 +4413,9 @@ static int raid5_resize(mddev_t *mddev, sector_t sectors)
raid5_conf_t *conf = mddev_to_conf(mddev); raid5_conf_t *conf = mddev_to_conf(mddev);
sectors &= ~((sector_t)mddev->chunk_size/512 - 1); sectors &= ~((sector_t)mddev->chunk_size/512 - 1);
mddev->array_size = (sectors * (mddev->raid_disks-conf->max_degraded))>>1; mddev->array_sectors = sectors * (mddev->raid_disks
set_capacity(mddev->gendisk, mddev->array_size << 1); - conf->max_degraded);
set_capacity(mddev->gendisk, mddev->array_sectors);
mddev->changed = 1; mddev->changed = 1;
if (sectors/2 > mddev->size && mddev->recovery_cp == MaxSector) { if (sectors/2 > mddev->size && mddev->recovery_cp == MaxSector) {
mddev->recovery_cp = mddev->size << 1; mddev->recovery_cp = mddev->size << 1;
...@@ -4547,15 +4548,16 @@ static void end_reshape(raid5_conf_t *conf) ...@@ -4547,15 +4548,16 @@ static void end_reshape(raid5_conf_t *conf)
struct block_device *bdev; struct block_device *bdev;
if (!test_bit(MD_RECOVERY_INTR, &conf->mddev->recovery)) { if (!test_bit(MD_RECOVERY_INTR, &conf->mddev->recovery)) {
conf->mddev->array_size = conf->mddev->size * conf->mddev->array_sectors = 2 * conf->mddev->size *
(conf->raid_disks - conf->max_degraded); (conf->raid_disks - conf->max_degraded);
set_capacity(conf->mddev->gendisk, conf->mddev->array_size << 1); set_capacity(conf->mddev->gendisk, conf->mddev->array_sectors);
conf->mddev->changed = 1; conf->mddev->changed = 1;
bdev = bdget_disk(conf->mddev->gendisk, 0); bdev = bdget_disk(conf->mddev->gendisk, 0);
if (bdev) { if (bdev) {
mutex_lock(&bdev->bd_inode->i_mutex); mutex_lock(&bdev->bd_inode->i_mutex);
i_size_write(bdev->bd_inode, (loff_t)conf->mddev->array_size << 10); i_size_write(bdev->bd_inode,
(loff_t)conf->mddev->array_sectors << 9);
mutex_unlock(&bdev->bd_inode->i_mutex); mutex_unlock(&bdev->bd_inode->i_mutex);
bdput(bdev); bdput(bdev);
} }
......
...@@ -150,7 +150,7 @@ struct mddev_s ...@@ -150,7 +150,7 @@ struct mddev_s
int raid_disks; int raid_disks;
int max_disks; int max_disks;
sector_t size; /* used size of component devices */ sector_t size; /* used size of component devices */
sector_t array_size; /* exported array size */ sector_t array_sectors; /* exported array size */
__u64 events; __u64 events;
char uuid[16]; char uuid[16];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment