summaryrefslogtreecommitdiffstats
path: root/drivers/md/raid10.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2009-03-17 18:10:40 -0700
committerDan Williams <dan.j.williams@intel.com>2009-03-31 14:57:49 +1100
commit80c3a6ce4ba4470379b9e6a4d9bcd9d2ee26ae03 (patch)
treede88622f05a7e681ac7bff7714e8f2d8953b66ac /drivers/md/raid10.c
parent93ed05e2a56b5ee06c0100a169433b11c4aa5d0b (diff)
downloadop-kernel-dev-80c3a6ce4ba4470379b9e6a4d9bcd9d2ee26ae03.zip
op-kernel-dev-80c3a6ce4ba4470379b9e6a4d9bcd9d2ee26ae03.tar.gz
md: add 'size' as a personality method
In preparation for giving userspace control over ->array_sectors we need to be able to retrieve the 'default' size, and the 'anticipated' size when a reshape is requested. For personalities that do not reshape emit a warning if anything but the default size is requested. In the raid5 case we need to update ->previous_raid_disks to make the new 'default' size available. Reviewed-by: Andre Noll <maan@systemlinux.org> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/md/raid10.c')
-rw-r--r--drivers/md/raid10.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index c2059e2..5bf1b24 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -2023,6 +2023,25 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
goto skipped;
}
+static sector_t
+raid10_size(mddev_t *mddev, sector_t sectors, int raid_disks)
+{
+ sector_t size;
+ conf_t *conf = mddev_to_conf(mddev);
+
+ if (!raid_disks)
+ raid_disks = mddev->raid_disks;
+ if (!sectors)
+ sectors = mddev->dev_sectors;
+
+ size = sectors >> conf->chunk_shift;
+ sector_div(size, conf->far_copies);
+ size = size * raid_disks;
+ sector_div(size, conf->near_copies);
+
+ return size << conf->chunk_shift;
+}
+
static int run(mddev_t *mddev)
{
conf_t *conf;
@@ -2174,8 +2193,8 @@ static int run(mddev_t *mddev)
/*
* Ok, everything is just fine now
*/
- mddev->array_sectors = size << conf->chunk_shift;
- mddev->resync_max_sectors = size << conf->chunk_shift;
+ mddev->array_sectors = raid10_size(mddev, 0, 0);
+ mddev->resync_max_sectors = mddev->array_sectors;
mddev->queue->unplug_fn = raid10_unplug;
mddev->queue->backing_dev_info.congested_fn = raid10_congested;
@@ -2261,6 +2280,7 @@ static struct mdk_personality raid10_personality =
.spare_active = raid10_spare_active,
.sync_request = sync_request,
.quiesce = raid10_quiesce,
+ .size = raid10_size,
};
static int __init raid_init(void)
OpenPOWER on IntegriCloud