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.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index a2813fa06b7c..df13a17a9627 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -655,7 +655,7 @@ struct super_type {
655 int (*validate_super)(mddev_t *mddev, mdk_rdev_t *rdev); 655 int (*validate_super)(mddev_t *mddev, mdk_rdev_t *rdev);
656 void (*sync_super)(mddev_t *mddev, mdk_rdev_t *rdev); 656 void (*sync_super)(mddev_t *mddev, mdk_rdev_t *rdev);
657 unsigned long long (*rdev_size_change)(mdk_rdev_t *rdev, 657 unsigned long long (*rdev_size_change)(mdk_rdev_t *rdev,
658 unsigned long long size); 658 sector_t num_sectors);
659}; 659};
660 660
661/* 661/*
@@ -998,20 +998,19 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev)
998 * rdev_size_change for 0.90.0 998 * rdev_size_change for 0.90.0
999 */ 999 */
1000static unsigned long long 1000static unsigned long long
1001super_90_rdev_size_change(mdk_rdev_t *rdev, unsigned long long size) 1001super_90_rdev_size_change(mdk_rdev_t *rdev, sector_t num_sectors)
1002{ 1002{
1003 if (size && size < rdev->mddev->size) 1003 if (num_sectors && num_sectors < rdev->mddev->size * 2)
1004 return 0; /* component must fit device */ 1004 return 0; /* component must fit device */
1005 size *= 2; /* convert to sectors */
1006 if (rdev->mddev->bitmap_offset) 1005 if (rdev->mddev->bitmap_offset)
1007 return 0; /* can't move bitmap */ 1006 return 0; /* can't move bitmap */
1008 rdev->sb_start = calc_dev_sboffset(rdev->bdev); 1007 rdev->sb_start = calc_dev_sboffset(rdev->bdev);
1009 if (!size || size > rdev->sb_start) 1008 if (!num_sectors || num_sectors > rdev->sb_start)
1010 size = rdev->sb_start; 1009 num_sectors = rdev->sb_start;
1011 md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size, 1010 md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size,
1012 rdev->sb_page); 1011 rdev->sb_page);
1013 md_super_wait(rdev->mddev); 1012 md_super_wait(rdev->mddev);
1014 return size/2; /* kB for sysfs */ 1013 return num_sectors / 2; /* kB for sysfs */
1015} 1014}
1016 1015
1017 1016
@@ -1339,19 +1338,18 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1339} 1338}
1340 1339
1341static unsigned long long 1340static unsigned long long
1342super_1_rdev_size_change(mdk_rdev_t *rdev, unsigned long long size) 1341super_1_rdev_size_change(mdk_rdev_t *rdev, sector_t num_sectors)
1343{ 1342{
1344 struct mdp_superblock_1 *sb; 1343 struct mdp_superblock_1 *sb;
1345 unsigned long long max_size; 1344 sector_t max_sectors;
1346 if (size && size < rdev->mddev->size) 1345 if (num_sectors && num_sectors < rdev->mddev->size * 2)
1347 return 0; /* component must fit device */ 1346 return 0; /* component must fit device */
1348 size *= 2; /* convert to sectors */
1349 if (rdev->sb_start < rdev->data_offset) { 1347 if (rdev->sb_start < rdev->data_offset) {
1350 /* minor versions 1 and 2; superblock before data */ 1348 /* minor versions 1 and 2; superblock before data */
1351 max_size = (rdev->bdev->bd_inode->i_size >> 9); 1349 max_sectors = rdev->bdev->bd_inode->i_size >> 9;
1352 max_size -= rdev->data_offset; 1350 max_sectors -= rdev->data_offset;
1353 if (!size || size > max_size) 1351 if (!num_sectors || num_sectors > max_sectors)
1354 size = max_size; 1352 num_sectors = max_sectors;
1355 } else if (rdev->mddev->bitmap_offset) { 1353 } else if (rdev->mddev->bitmap_offset) {
1356 /* minor version 0 with bitmap we can't move */ 1354 /* minor version 0 with bitmap we can't move */
1357 return 0; 1355 return 0;
@@ -1360,19 +1358,19 @@ super_1_rdev_size_change(mdk_rdev_t *rdev, unsigned long long size)
1360 sector_t sb_start; 1358 sector_t sb_start;
1361 sb_start = (rdev->bdev->bd_inode->i_size >> 9) - 8*2; 1359 sb_start = (rdev->bdev->bd_inode->i_size >> 9) - 8*2;
1362 sb_start &= ~(sector_t)(4*2 - 1); 1360 sb_start &= ~(sector_t)(4*2 - 1);
1363 max_size = rdev->size*2 + sb_start - rdev->sb_start; 1361 max_sectors = rdev->size * 2 + sb_start - rdev->sb_start;
1364 if (!size || size > max_size) 1362 if (!num_sectors || num_sectors > max_sectors)
1365 size = max_size; 1363 num_sectors = max_sectors;
1366 rdev->sb_start = sb_start; 1364 rdev->sb_start = sb_start;
1367 } 1365 }
1368 sb = (struct mdp_superblock_1 *) page_address(rdev->sb_page); 1366 sb = (struct mdp_superblock_1 *) page_address(rdev->sb_page);
1369 sb->data_size = cpu_to_le64(size); 1367 sb->data_size = cpu_to_le64(num_sectors);
1370 sb->super_offset = rdev->sb_start; 1368 sb->super_offset = rdev->sb_start;
1371 sb->sb_csum = calc_sb_1_csum(sb); 1369 sb->sb_csum = calc_sb_1_csum(sb);
1372 md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size, 1370 md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size,
1373 rdev->sb_page); 1371 rdev->sb_page);
1374 md_super_wait(rdev->mddev); 1372 md_super_wait(rdev->mddev);
1375 return size/2; /* kB for sysfs */ 1373 return num_sectors / 2; /* kB for sysfs */
1376} 1374}
1377 1375
1378static struct super_type super_types[] = { 1376static struct super_type super_types[] = {
@@ -2112,7 +2110,7 @@ rdev_size_store(mdk_rdev_t *rdev, const char *buf, size_t len)
2112 if (my_mddev->pers && rdev->raid_disk >= 0) { 2110 if (my_mddev->pers && rdev->raid_disk >= 0) {
2113 if (my_mddev->persistent) { 2111 if (my_mddev->persistent) {
2114 size = super_types[my_mddev->major_version]. 2112 size = super_types[my_mddev->major_version].
2115 rdev_size_change(rdev, size); 2113 rdev_size_change(rdev, size * 2);
2116 if (!size) 2114 if (!size)
2117 return -EBUSY; 2115 return -EBUSY;
2118 } else if (!size) { 2116 } else if (!size) {