aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid1.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2009-03-31 00:00:31 -0400
committerDan Williams <dan.j.williams@intel.com>2009-03-31 00:00:31 -0400
commitb522adcde9c4d3fb7b579cfa9160d8bde7744be8 (patch)
tree4208e3dcec3ebdfa6ad9bc153f76129400532717 /drivers/md/raid1.c
parent1f403624bde3c678a166984b1e6a727a0ce06f2b (diff)
md: 'array_size' sysfs attribute
Allow userspace to set the size of the array according to the following semantics: 1/ size must be <= to the size returned by mddev->pers->size(mddev, 0, 0) a) If size is set before the array is running, do_md_run will fail if size is greater than the default size b) A reshape attempt that reduces the default size to less than the set array size should be blocked 2/ once userspace sets the size the kernel will not change it 3/ writing 'default' to this attribute returns control of the size to the kernel and reverts to the size reported by the personality Also, convert locations that need to know the default size from directly reading ->array_sectors to <pers>_size. Resync/reshape operations always follow the default size. Finally, fixup other locations that read a number of 1k-blocks from userspace to use strict_blocks_to_sectors() which checks for unsigned long long to sector_t overflow and blocks to sectors overflow. 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.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 044116b53f7a..b4f4badc0068 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2125,14 +2125,16 @@ static int raid1_resize(mddev_t *mddev, sector_t sectors)
2125 * worth it. 2125 * worth it.
2126 */ 2126 */
2127 md_set_array_sectors(mddev, raid1_size(mddev, sectors, 0)); 2127 md_set_array_sectors(mddev, raid1_size(mddev, sectors, 0));
2128 if (mddev->array_sectors > raid1_size(mddev, sectors, 0))
2129 return -EINVAL;
2128 set_capacity(mddev->gendisk, mddev->array_sectors); 2130 set_capacity(mddev->gendisk, mddev->array_sectors);
2129 mddev->changed = 1; 2131 mddev->changed = 1;
2130 if (mddev->array_sectors > mddev->dev_sectors && 2132 if (sectors > mddev->dev_sectors &&
2131 mddev->recovery_cp == MaxSector) { 2133 mddev->recovery_cp == MaxSector) {
2132 mddev->recovery_cp = mddev->dev_sectors; 2134 mddev->recovery_cp = mddev->dev_sectors;
2133 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 2135 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
2134 } 2136 }
2135 mddev->dev_sectors = mddev->array_sectors; 2137 mddev->dev_sectors = sectors;
2136 mddev->resync_max_sectors = sectors; 2138 mddev->resync_max_sectors = sectors;
2137 return 0; 2139 return 0;
2138} 2140}