aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid1.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/raid1.c')
-rw-r--r--drivers/md/raid1.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index e2466425d9ca..b4f4badc0068 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -31,10 +31,13 @@
31 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 31 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 */ 32 */
33 33
34#include "dm-bio-list.h"
35#include <linux/delay.h> 34#include <linux/delay.h>
36#include <linux/raid/raid1.h> 35#include <linux/blkdev.h>
37#include <linux/raid/bitmap.h> 36#include <linux/seq_file.h>
37#include "md.h"
38#include "dm-bio-list.h"
39#include "raid1.h"
40#include "bitmap.h"
38 41
39#define DEBUG 0 42#define DEBUG 0
40#if DEBUG 43#if DEBUG
@@ -1723,7 +1726,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1723 return 0; 1726 return 0;
1724 } 1727 }
1725 1728
1726 max_sector = mddev->size << 1; 1729 max_sector = mddev->dev_sectors;
1727 if (sector_nr >= max_sector) { 1730 if (sector_nr >= max_sector) {
1728 /* If we aborted, we need to abort the 1731 /* If we aborted, we need to abort the
1729 * sync on the 'current' bitmap chunk (there will 1732 * sync on the 'current' bitmap chunk (there will
@@ -1919,6 +1922,14 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1919 return nr_sectors; 1922 return nr_sectors;
1920} 1923}
1921 1924
1925static 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
1922static int run(mddev_t *mddev) 1933static int run(mddev_t *mddev)
1923{ 1934{
1924 conf_t *conf; 1935 conf_t *conf;
@@ -2048,7 +2059,7 @@ static int run(mddev_t *mddev)
2048 /* 2059 /*
2049 * Ok, everything is just fine now 2060 * Ok, everything is just fine now
2050 */ 2061 */
2051 mddev->array_sectors = mddev->size * 2; 2062 md_set_array_sectors(mddev, raid1_size(mddev, 0, 0));
2052 2063
2053 mddev->queue->unplug_fn = raid1_unplug; 2064 mddev->queue->unplug_fn = raid1_unplug;
2054 mddev->queue->backing_dev_info.congested_fn = raid1_congested; 2065 mddev->queue->backing_dev_info.congested_fn = raid1_congested;
@@ -2089,6 +2100,9 @@ static int stop(mddev_t *mddev)
2089 /* need to kick something here to make sure I/O goes? */ 2100 /* need to kick something here to make sure I/O goes? */
2090 } 2101 }
2091 2102
2103 raise_barrier(conf);
2104 lower_barrier(conf);
2105
2092 md_unregister_thread(mddev->thread); 2106 md_unregister_thread(mddev->thread);
2093 mddev->thread = NULL; 2107 mddev->thread = NULL;
2094 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ 2108 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
@@ -2110,15 +2124,17 @@ static int raid1_resize(mddev_t *mddev, sector_t sectors)
2110 * any io in the removed space completes, but it hardly seems 2124 * any io in the removed space completes, but it hardly seems
2111 * worth it. 2125 * worth it.
2112 */ 2126 */
2113 mddev->array_sectors = sectors; 2127 md_set_array_sectors(mddev, raid1_size(mddev, sectors, 0));
2128 if (mddev->array_sectors > raid1_size(mddev, sectors, 0))
2129 return -EINVAL;
2114 set_capacity(mddev->gendisk, mddev->array_sectors); 2130 set_capacity(mddev->gendisk, mddev->array_sectors);
2115 mddev->changed = 1; 2131 mddev->changed = 1;
2116 if (mddev->array_sectors / 2 > mddev->size && 2132 if (sectors > mddev->dev_sectors &&
2117 mddev->recovery_cp == MaxSector) { 2133 mddev->recovery_cp == MaxSector) {
2118 mddev->recovery_cp = mddev->size << 1; 2134 mddev->recovery_cp = mddev->dev_sectors;
2119 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 2135 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
2120 } 2136 }
2121 mddev->size = mddev->array_sectors / 2; 2137 mddev->dev_sectors = sectors;
2122 mddev->resync_max_sectors = sectors; 2138 mddev->resync_max_sectors = sectors;
2123 return 0; 2139 return 0;
2124} 2140}
@@ -2264,6 +2280,7 @@ static struct mdk_personality raid1_personality =
2264 .spare_active = raid1_spare_active, 2280 .spare_active = raid1_spare_active,
2265 .sync_request = sync_request, 2281 .sync_request = sync_request,
2266 .resize = raid1_resize, 2282 .resize = raid1_resize,
2283 .size = raid1_size,
2267 .check_reshape = raid1_reshape, 2284 .check_reshape = raid1_reshape,
2268 .quiesce = raid1_quiesce, 2285 .quiesce = raid1_quiesce,
2269}; 2286};