int (*validate_super)(mddev_t *mddev, mdk_rdev_t *rdev);
void (*sync_super)(mddev_t *mddev, mdk_rdev_t *rdev);
unsigned long long (*rdev_size_change)(mdk_rdev_t *rdev,
- unsigned long long size);
+ sector_t num_sectors);
};
/*
* rdev_size_change for 0.90.0
*/
static unsigned long long
-super_90_rdev_size_change(mdk_rdev_t *rdev, unsigned long long size)
+super_90_rdev_size_change(mdk_rdev_t *rdev, sector_t num_sectors)
{
- if (size && size < rdev->mddev->size)
+ if (num_sectors && num_sectors < rdev->mddev->size * 2)
return 0; /* component must fit device */
- size *= 2; /* convert to sectors */
if (rdev->mddev->bitmap_offset)
return 0; /* can't move bitmap */
rdev->sb_start = calc_dev_sboffset(rdev->bdev);
- if (!size || size > rdev->sb_start)
- size = rdev->sb_start;
+ if (!num_sectors || num_sectors > rdev->sb_start)
+ num_sectors = rdev->sb_start;
md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size,
rdev->sb_page);
md_super_wait(rdev->mddev);
- return size/2; /* kB for sysfs */
+ return num_sectors / 2; /* kB for sysfs */
}
}
static unsigned long long
-super_1_rdev_size_change(mdk_rdev_t *rdev, unsigned long long size)
+super_1_rdev_size_change(mdk_rdev_t *rdev, sector_t num_sectors)
{
struct mdp_superblock_1 *sb;
- unsigned long long max_size;
- if (size && size < rdev->mddev->size)
+ sector_t max_sectors;
+ if (num_sectors && num_sectors < rdev->mddev->size * 2)
return 0; /* component must fit device */
- size *= 2; /* convert to sectors */
if (rdev->sb_start < rdev->data_offset) {
/* minor versions 1 and 2; superblock before data */
- max_size = (rdev->bdev->bd_inode->i_size >> 9);
- max_size -= rdev->data_offset;
- if (!size || size > max_size)
- size = max_size;
+ max_sectors = rdev->bdev->bd_inode->i_size >> 9;
+ max_sectors -= rdev->data_offset;
+ if (!num_sectors || num_sectors > max_sectors)
+ num_sectors = max_sectors;
} else if (rdev->mddev->bitmap_offset) {
/* minor version 0 with bitmap we can't move */
return 0;
sector_t sb_start;
sb_start = (rdev->bdev->bd_inode->i_size >> 9) - 8*2;
sb_start &= ~(sector_t)(4*2 - 1);
- max_size = rdev->size*2 + sb_start - rdev->sb_start;
- if (!size || size > max_size)
- size = max_size;
+ max_sectors = rdev->size * 2 + sb_start - rdev->sb_start;
+ if (!num_sectors || num_sectors > max_sectors)
+ num_sectors = max_sectors;
rdev->sb_start = sb_start;
}
sb = (struct mdp_superblock_1 *) page_address(rdev->sb_page);
- sb->data_size = cpu_to_le64(size);
+ sb->data_size = cpu_to_le64(num_sectors);
sb->super_offset = rdev->sb_start;
sb->sb_csum = calc_sb_1_csum(sb);
md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size,
rdev->sb_page);
md_super_wait(rdev->mddev);
- return size/2; /* kB for sysfs */
+ return num_sectors / 2; /* kB for sysfs */
}
static struct super_type super_types[] = {
if (my_mddev->pers && rdev->raid_disk >= 0) {
if (my_mddev->persistent) {
size = super_types[my_mddev->major_version].
- rdev_size_change(rdev, size);
+ rdev_size_change(rdev, size * 2);
if (!size)
return -EBUSY;
} else if (!size) {