aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/md/md.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 19f646a76402..3276edde7576 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -347,10 +347,11 @@ static struct mdk_personality *find_pers(int level, char *clevel)
347 return NULL; 347 return NULL;
348} 348}
349 349
350/* return the offset of the super block in 512byte sectors */
350static inline sector_t calc_dev_sboffset(struct block_device *bdev) 351static inline sector_t calc_dev_sboffset(struct block_device *bdev)
351{ 352{
352 sector_t size = bdev->bd_inode->i_size >> BLOCK_SIZE_BITS; 353 sector_t num_sectors = bdev->bd_inode->i_size / 512;
353 return MD_NEW_SIZE_BLOCKS(size); 354 return MD_NEW_SIZE_SECTORS(num_sectors);
354} 355}
355 356
356static sector_t calc_num_sectors(mdk_rdev_t *rdev, unsigned chunk_size) 357static sector_t calc_num_sectors(mdk_rdev_t *rdev, unsigned chunk_size)
@@ -673,7 +674,7 @@ static int super_90_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version
673 * 674 *
674 * It also happens to be a multiple of 4Kb. 675 * It also happens to be a multiple of 4Kb.
675 */ 676 */
676 sb_offset = calc_dev_sboffset(rdev->bdev); 677 sb_offset = calc_dev_sboffset(rdev->bdev) / 2;
677 rdev->sb_offset = sb_offset; 678 rdev->sb_offset = sb_offset;
678 679
679 ret = read_disk_sb(rdev, MD_SB_BYTES); 680 ret = read_disk_sb(rdev, MD_SB_BYTES);
@@ -1006,7 +1007,7 @@ super_90_rdev_size_change(mdk_rdev_t *rdev, unsigned long long size)
1006 size *= 2; /* convert to sectors */ 1007 size *= 2; /* convert to sectors */
1007 if (rdev->mddev->bitmap_offset) 1008 if (rdev->mddev->bitmap_offset)
1008 return 0; /* can't move bitmap */ 1009 return 0; /* can't move bitmap */
1009 rdev->sb_offset = calc_dev_sboffset(rdev->bdev); 1010 rdev->sb_offset = calc_dev_sboffset(rdev->bdev) / 2;
1010 if (!size || size > rdev->sb_offset*2) 1011 if (!size || size > rdev->sb_offset*2)
1011 size = rdev->sb_offset*2; 1012 size = rdev->sb_offset*2;
1012 md_super_write(rdev->mddev, rdev, rdev->sb_offset << 1, rdev->sb_size, 1013 md_super_write(rdev->mddev, rdev, rdev->sb_offset << 1, rdev->sb_size,
@@ -4356,7 +4357,7 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
4356 printk(KERN_INFO "md: nonpersistent superblock ...\n"); 4357 printk(KERN_INFO "md: nonpersistent superblock ...\n");
4357 rdev->sb_offset = rdev->bdev->bd_inode->i_size >> BLOCK_SIZE_BITS; 4358 rdev->sb_offset = rdev->bdev->bd_inode->i_size >> BLOCK_SIZE_BITS;
4358 } else 4359 } else
4359 rdev->sb_offset = calc_dev_sboffset(rdev->bdev); 4360 rdev->sb_offset = calc_dev_sboffset(rdev->bdev) / 2;
4360 rdev->size = calc_num_sectors(rdev, mddev->chunk_size) / 2; 4361 rdev->size = calc_num_sectors(rdev, mddev->chunk_size) / 2;
4361 4362
4362 err = bind_rdev_to_array(rdev, mddev); 4363 err = bind_rdev_to_array(rdev, mddev);
@@ -4423,7 +4424,7 @@ static int hot_add_disk(mddev_t * mddev, dev_t dev)
4423 } 4424 }
4424 4425
4425 if (mddev->persistent) 4426 if (mddev->persistent)
4426 rdev->sb_offset = calc_dev_sboffset(rdev->bdev); 4427 rdev->sb_offset = calc_dev_sboffset(rdev->bdev) / 2;
4427 else 4428 else
4428 rdev->sb_offset = 4429 rdev->sb_offset =
4429 rdev->bdev->bd_inode->i_size >> BLOCK_SIZE_BITS; 4430 rdev->bdev->bd_inode->i_size >> BLOCK_SIZE_BITS;