aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/md.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r--drivers/md/md.c52
1 files changed, 3 insertions, 49 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index d9cce54cc2d5..0f11fd1417ab 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -440,18 +440,6 @@ static inline sector_t calc_dev_sboffset(struct block_device *bdev)
440 return MD_NEW_SIZE_SECTORS(num_sectors); 440 return MD_NEW_SIZE_SECTORS(num_sectors);
441} 441}
442 442
443static sector_t calc_num_sectors(mdk_rdev_t *rdev, unsigned chunk_size)
444{
445 sector_t num_sectors = rdev->sb_start;
446
447 if (chunk_size) {
448 unsigned chunk_sects = chunk_size>>9;
449 sector_div(num_sectors, chunk_sects);
450 num_sectors *= chunk_sects;
451 }
452 return num_sectors;
453}
454
455static int alloc_disk_sb(mdk_rdev_t * rdev) 443static int alloc_disk_sb(mdk_rdev_t * rdev)
456{ 444{
457 if (rdev->sb_page) 445 if (rdev->sb_page)
@@ -839,7 +827,7 @@ static int super_90_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version
839 else 827 else
840 ret = 0; 828 ret = 0;
841 } 829 }
842 rdev->sectors = calc_num_sectors(rdev, sb->chunk_size); 830 rdev->sectors = rdev->sb_start;
843 831
844 if (rdev->sectors < sb->size * 2 && sb->level > 1) 832 if (rdev->sectors < sb->size * 2 && sb->level > 1)
845 /* "this cannot possibly happen" ... */ 833 /* "this cannot possibly happen" ... */
@@ -1251,13 +1239,6 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
1251 if (rdev->sectors < le64_to_cpu(sb->data_size)) 1239 if (rdev->sectors < le64_to_cpu(sb->data_size))
1252 return -EINVAL; 1240 return -EINVAL;
1253 rdev->sectors = le64_to_cpu(sb->data_size); 1241 rdev->sectors = le64_to_cpu(sb->data_size);
1254 if (le32_to_cpu(sb->chunksize)) {
1255 int chunk_sects = le32_to_cpu(sb->chunksize);
1256 sector_t chunks = rdev->sectors;
1257 sector_div(chunks, chunk_sects);
1258 rdev->sectors = chunks * chunk_sects;
1259 }
1260
1261 if (le64_to_cpu(sb->size) > rdev->sectors) 1242 if (le64_to_cpu(sb->size) > rdev->sectors)
1262 return -EINVAL; 1243 return -EINVAL;
1263 return ret; 1244 return ret;
@@ -3983,11 +3964,9 @@ static int start_dirty_degraded;
3983static int do_md_run(mddev_t * mddev) 3964static int do_md_run(mddev_t * mddev)
3984{ 3965{
3985 int err; 3966 int err;
3986 int chunk_size;
3987 mdk_rdev_t *rdev; 3967 mdk_rdev_t *rdev;
3988 struct gendisk *disk; 3968 struct gendisk *disk;
3989 struct mdk_personality *pers; 3969 struct mdk_personality *pers;
3990 char b[BDEVNAME_SIZE];
3991 3970
3992 if (list_empty(&mddev->disks)) 3971 if (list_empty(&mddev->disks))
3993 /* cannot run an array with no devices.. */ 3972 /* cannot run an array with no devices.. */
@@ -4005,30 +3984,6 @@ static int do_md_run(mddev_t * mddev)
4005 analyze_sbs(mddev); 3984 analyze_sbs(mddev);
4006 } 3985 }
4007 3986
4008 chunk_size = mddev->chunk_sectors << 9;
4009
4010 if (chunk_size) {
4011 if (chunk_size > MAX_CHUNK_SIZE) {
4012 printk(KERN_ERR "too big chunk_size: %d > %d\n",
4013 chunk_size, MAX_CHUNK_SIZE);
4014 return -EINVAL;
4015 }
4016 /* devices must have minimum size of one chunk */
4017 list_for_each_entry(rdev, &mddev->disks, same_set) {
4018 if (test_bit(Faulty, &rdev->flags))
4019 continue;
4020 if (rdev->sectors < chunk_size / 512) {
4021 printk(KERN_WARNING
4022 "md: Dev %s smaller than chunk_size:"
4023 " %llu < %d\n",
4024 bdevname(rdev->bdev,b),
4025 (unsigned long long)rdev->sectors,
4026 chunk_size / 512);
4027 return -EINVAL;
4028 }
4029 }
4030 }
4031
4032 if (mddev->level != LEVEL_NONE) 3987 if (mddev->level != LEVEL_NONE)
4033 request_module("md-level-%d", mddev->level); 3988 request_module("md-level-%d", mddev->level);
4034 else if (mddev->clevel[0]) 3989 else if (mddev->clevel[0])
@@ -4842,8 +4797,7 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
4842 rdev->sb_start = rdev->bdev->bd_inode->i_size / 512; 4797 rdev->sb_start = rdev->bdev->bd_inode->i_size / 512;
4843 } else 4798 } else
4844 rdev->sb_start = calc_dev_sboffset(rdev->bdev); 4799 rdev->sb_start = calc_dev_sboffset(rdev->bdev);
4845 rdev->sectors = calc_num_sectors(rdev, 4800 rdev->sectors = rdev->sb_start;
4846 mddev->chunk_sectors << 9);
4847 4801
4848 err = bind_rdev_to_array(rdev, mddev); 4802 err = bind_rdev_to_array(rdev, mddev);
4849 if (err) { 4803 if (err) {
@@ -4913,7 +4867,7 @@ static int hot_add_disk(mddev_t * mddev, dev_t dev)
4913 else 4867 else
4914 rdev->sb_start = rdev->bdev->bd_inode->i_size / 512; 4868 rdev->sb_start = rdev->bdev->bd_inode->i_size / 512;
4915 4869
4916 rdev->sectors = calc_num_sectors(rdev, mddev->chunk_sectors << 9); 4870 rdev->sectors = rdev->sb_start;
4917 4871
4918 if (test_bit(Faulty, &rdev->flags)) { 4872 if (test_bit(Faulty, &rdev->flags)) {
4919 printk(KERN_WARNING 4873 printk(KERN_WARNING