diff options
Diffstat (limited to 'drivers/md/raid10.c')
-rw-r--r-- | drivers/md/raid10.c | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 7301631abe04..e293d92641ac 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
@@ -18,10 +18,13 @@ | |||
18 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include "dm-bio-list.h" | ||
22 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
23 | #include <linux/raid/raid10.h> | 22 | #include <linux/blkdev.h> |
24 | #include <linux/raid/bitmap.h> | 23 | #include <linux/seq_file.h> |
24 | #include "md.h" | ||
25 | #include "dm-bio-list.h" | ||
26 | #include "raid10.h" | ||
27 | #include "bitmap.h" | ||
25 | 28 | ||
26 | /* | 29 | /* |
27 | * RAID10 provides a combination of RAID0 and RAID1 functionality. | 30 | * RAID10 provides a combination of RAID0 and RAID1 functionality. |
@@ -1695,7 +1698,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i | |||
1695 | return 0; | 1698 | return 0; |
1696 | 1699 | ||
1697 | skipped: | 1700 | skipped: |
1698 | max_sector = mddev->size << 1; | 1701 | max_sector = mddev->dev_sectors; |
1699 | if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) | 1702 | if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) |
1700 | max_sector = mddev->resync_max_sectors; | 1703 | max_sector = mddev->resync_max_sectors; |
1701 | if (sector_nr >= max_sector) { | 1704 | if (sector_nr >= max_sector) { |
@@ -2020,6 +2023,25 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i | |||
2020 | goto skipped; | 2023 | goto skipped; |
2021 | } | 2024 | } |
2022 | 2025 | ||
2026 | static sector_t | ||
2027 | raid10_size(mddev_t *mddev, sector_t sectors, int raid_disks) | ||
2028 | { | ||
2029 | sector_t size; | ||
2030 | conf_t *conf = mddev_to_conf(mddev); | ||
2031 | |||
2032 | if (!raid_disks) | ||
2033 | raid_disks = mddev->raid_disks; | ||
2034 | if (!sectors) | ||
2035 | sectors = mddev->dev_sectors; | ||
2036 | |||
2037 | size = sectors >> conf->chunk_shift; | ||
2038 | sector_div(size, conf->far_copies); | ||
2039 | size = size * raid_disks; | ||
2040 | sector_div(size, conf->near_copies); | ||
2041 | |||
2042 | return size << conf->chunk_shift; | ||
2043 | } | ||
2044 | |||
2023 | static int run(mddev_t *mddev) | 2045 | static int run(mddev_t *mddev) |
2024 | { | 2046 | { |
2025 | conf_t *conf; | 2047 | conf_t *conf; |
@@ -2076,7 +2098,7 @@ static int run(mddev_t *mddev) | |||
2076 | conf->far_offset = fo; | 2098 | conf->far_offset = fo; |
2077 | conf->chunk_mask = (sector_t)(mddev->chunk_size>>9)-1; | 2099 | conf->chunk_mask = (sector_t)(mddev->chunk_size>>9)-1; |
2078 | conf->chunk_shift = ffz(~mddev->chunk_size) - 9; | 2100 | conf->chunk_shift = ffz(~mddev->chunk_size) - 9; |
2079 | size = mddev->size >> (conf->chunk_shift-1); | 2101 | size = mddev->dev_sectors >> conf->chunk_shift; |
2080 | sector_div(size, fc); | 2102 | sector_div(size, fc); |
2081 | size = size * conf->raid_disks; | 2103 | size = size * conf->raid_disks; |
2082 | sector_div(size, nc); | 2104 | sector_div(size, nc); |
@@ -2089,7 +2111,7 @@ static int run(mddev_t *mddev) | |||
2089 | */ | 2111 | */ |
2090 | stride += conf->raid_disks - 1; | 2112 | stride += conf->raid_disks - 1; |
2091 | sector_div(stride, conf->raid_disks); | 2113 | sector_div(stride, conf->raid_disks); |
2092 | mddev->size = stride << (conf->chunk_shift-1); | 2114 | mddev->dev_sectors = stride << conf->chunk_shift; |
2093 | 2115 | ||
2094 | if (fo) | 2116 | if (fo) |
2095 | stride = 1; | 2117 | stride = 1; |
@@ -2171,8 +2193,8 @@ static int run(mddev_t *mddev) | |||
2171 | /* | 2193 | /* |
2172 | * Ok, everything is just fine now | 2194 | * Ok, everything is just fine now |
2173 | */ | 2195 | */ |
2174 | mddev->array_sectors = size << conf->chunk_shift; | 2196 | md_set_array_sectors(mddev, raid10_size(mddev, 0, 0)); |
2175 | mddev->resync_max_sectors = size << conf->chunk_shift; | 2197 | mddev->resync_max_sectors = raid10_size(mddev, 0, 0); |
2176 | 2198 | ||
2177 | mddev->queue->unplug_fn = raid10_unplug; | 2199 | mddev->queue->unplug_fn = raid10_unplug; |
2178 | mddev->queue->backing_dev_info.congested_fn = raid10_congested; | 2200 | mddev->queue->backing_dev_info.congested_fn = raid10_congested; |
@@ -2208,6 +2230,9 @@ static int stop(mddev_t *mddev) | |||
2208 | { | 2230 | { |
2209 | conf_t *conf = mddev_to_conf(mddev); | 2231 | conf_t *conf = mddev_to_conf(mddev); |
2210 | 2232 | ||
2233 | raise_barrier(conf, 0); | ||
2234 | lower_barrier(conf); | ||
2235 | |||
2211 | md_unregister_thread(mddev->thread); | 2236 | md_unregister_thread(mddev->thread); |
2212 | mddev->thread = NULL; | 2237 | mddev->thread = NULL; |
2213 | blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ | 2238 | blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ |
@@ -2255,6 +2280,7 @@ static struct mdk_personality raid10_personality = | |||
2255 | .spare_active = raid10_spare_active, | 2280 | .spare_active = raid10_spare_active, |
2256 | .sync_request = sync_request, | 2281 | .sync_request = sync_request, |
2257 | .quiesce = raid10_quiesce, | 2282 | .quiesce = raid10_quiesce, |
2283 | .size = raid10_size, | ||
2258 | }; | 2284 | }; |
2259 | 2285 | ||
2260 | static int __init raid_init(void) | 2286 | static int __init raid_init(void) |