diff options
-rw-r--r-- | drivers/md/md.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 3742ce8b0acf..5404b2295820 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -1138,8 +1138,11 @@ static int super_90_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version | |||
1138 | ret = 0; | 1138 | ret = 0; |
1139 | } | 1139 | } |
1140 | rdev->sectors = rdev->sb_start; | 1140 | rdev->sectors = rdev->sb_start; |
1141 | /* Limit to 4TB as metadata cannot record more than that */ | ||
1142 | if (rdev->sectors >= (2ULL << 32)) | ||
1143 | rdev->sectors = (2ULL << 32) - 2; | ||
1141 | 1144 | ||
1142 | if (rdev->sectors < sb->size * 2 && sb->level > 1) | 1145 | if (rdev->sectors < ((sector_t)sb->size) * 2 && sb->level >= 1) |
1143 | /* "this cannot possibly happen" ... */ | 1146 | /* "this cannot possibly happen" ... */ |
1144 | ret = -EINVAL; | 1147 | ret = -EINVAL; |
1145 | 1148 | ||
@@ -1173,7 +1176,7 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev) | |||
1173 | mddev->clevel[0] = 0; | 1176 | mddev->clevel[0] = 0; |
1174 | mddev->layout = sb->layout; | 1177 | mddev->layout = sb->layout; |
1175 | mddev->raid_disks = sb->raid_disks; | 1178 | mddev->raid_disks = sb->raid_disks; |
1176 | mddev->dev_sectors = sb->size * 2; | 1179 | mddev->dev_sectors = ((sector_t)sb->size) * 2; |
1177 | mddev->events = ev1; | 1180 | mddev->events = ev1; |
1178 | mddev->bitmap_info.offset = 0; | 1181 | mddev->bitmap_info.offset = 0; |
1179 | mddev->bitmap_info.default_offset = MD_SB_BYTES >> 9; | 1182 | mddev->bitmap_info.default_offset = MD_SB_BYTES >> 9; |
@@ -1415,6 +1418,11 @@ super_90_rdev_size_change(mdk_rdev_t *rdev, sector_t num_sectors) | |||
1415 | rdev->sb_start = calc_dev_sboffset(rdev); | 1418 | rdev->sb_start = calc_dev_sboffset(rdev); |
1416 | if (!num_sectors || num_sectors > rdev->sb_start) | 1419 | if (!num_sectors || num_sectors > rdev->sb_start) |
1417 | num_sectors = rdev->sb_start; | 1420 | num_sectors = rdev->sb_start; |
1421 | /* Limit to 4TB as metadata cannot record more than that. | ||
1422 | * 4TB == 2^32 KB, or 2*2^32 sectors. | ||
1423 | */ | ||
1424 | if (num_sectors >= (2ULL << 32)) | ||
1425 | num_sectors = (2ULL << 32) - 2; | ||
1418 | md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size, | 1426 | md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size, |
1419 | rdev->sb_page); | 1427 | rdev->sb_page); |
1420 | md_super_wait(rdev->mddev); | 1428 | md_super_wait(rdev->mddev); |