diff options
author | Dan Williams <dan.j.williams@intel.com> | 2009-03-17 21:10:40 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2009-03-30 23:57:49 -0400 |
commit | 80c3a6ce4ba4470379b9e6a4d9bcd9d2ee26ae03 (patch) | |
tree | de88622f05a7e681ac7bff7714e8f2d8953b66ac /drivers/md/raid1.c | |
parent | 93ed05e2a56b5ee06c0100a169433b11c4aa5d0b (diff) |
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/raid1.c')
-rw-r--r-- | drivers/md/raid1.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 7eaca3209364..a2a83b0d5a95 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -1922,6 +1922,14 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i | |||
1922 | return nr_sectors; | 1922 | return nr_sectors; |
1923 | } | 1923 | } |
1924 | 1924 | ||
1925 | static sector_t raid1_size(mddev_t *mddev, sector_t sectors, int raid_disks) | ||
1926 | { | ||
1927 | if (sectors) | ||
1928 | return sectors; | ||
1929 | |||
1930 | return mddev->dev_sectors; | ||
1931 | } | ||
1932 | |||
1925 | static int run(mddev_t *mddev) | 1933 | static int run(mddev_t *mddev) |
1926 | { | 1934 | { |
1927 | conf_t *conf; | 1935 | conf_t *conf; |
@@ -2051,7 +2059,7 @@ static int run(mddev_t *mddev) | |||
2051 | /* | 2059 | /* |
2052 | * Ok, everything is just fine now | 2060 | * Ok, everything is just fine now |
2053 | */ | 2061 | */ |
2054 | mddev->array_sectors = mddev->dev_sectors; | 2062 | mddev->array_sectors = raid1_size(mddev, 0, 0); |
2055 | 2063 | ||
2056 | mddev->queue->unplug_fn = raid1_unplug; | 2064 | mddev->queue->unplug_fn = raid1_unplug; |
2057 | mddev->queue->backing_dev_info.congested_fn = raid1_congested; | 2065 | mddev->queue->backing_dev_info.congested_fn = raid1_congested; |
@@ -2116,7 +2124,7 @@ static int raid1_resize(mddev_t *mddev, sector_t sectors) | |||
2116 | * any io in the removed space completes, but it hardly seems | 2124 | * any io in the removed space completes, but it hardly seems |
2117 | * worth it. | 2125 | * worth it. |
2118 | */ | 2126 | */ |
2119 | mddev->array_sectors = sectors; | 2127 | mddev->array_sectors = raid1_size(mddev, sectors, 0); |
2120 | set_capacity(mddev->gendisk, mddev->array_sectors); | 2128 | set_capacity(mddev->gendisk, mddev->array_sectors); |
2121 | mddev->changed = 1; | 2129 | mddev->changed = 1; |
2122 | if (mddev->array_sectors > mddev->dev_sectors && | 2130 | if (mddev->array_sectors > mddev->dev_sectors && |
@@ -2270,6 +2278,7 @@ static struct mdk_personality raid1_personality = | |||
2270 | .spare_active = raid1_spare_active, | 2278 | .spare_active = raid1_spare_active, |
2271 | .sync_request = sync_request, | 2279 | .sync_request = sync_request, |
2272 | .resize = raid1_resize, | 2280 | .resize = raid1_resize, |
2281 | .size = raid1_size, | ||
2273 | .check_reshape = raid1_reshape, | 2282 | .check_reshape = raid1_reshape, |
2274 | .quiesce = raid1_quiesce, | 2283 | .quiesce = raid1_quiesce, |
2275 | }; | 2284 | }; |