aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/md.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r--drivers/md/md.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 653d4dcbee23..d05e3125d298 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1024,7 +1024,7 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
1024 rdev-> sb_size = (rdev->sb_size | bmask)+1; 1024 rdev-> sb_size = (rdev->sb_size | bmask)+1;
1025 1025
1026 if (refdev == 0) 1026 if (refdev == 0)
1027 return 1; 1027 ret = 1;
1028 else { 1028 else {
1029 __u64 ev1, ev2; 1029 __u64 ev1, ev2;
1030 struct mdp_superblock_1 *refsb = 1030 struct mdp_superblock_1 *refsb =
@@ -1044,7 +1044,9 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
1044 ev2 = le64_to_cpu(refsb->events); 1044 ev2 = le64_to_cpu(refsb->events);
1045 1045
1046 if (ev1 > ev2) 1046 if (ev1 > ev2)
1047 return 1; 1047 ret = 1;
1048 else
1049 ret = 0;
1048 } 1050 }
1049 if (minor_version) 1051 if (minor_version)
1050 rdev->size = ((rdev->bdev->bd_inode->i_size>>9) - le64_to_cpu(sb->data_offset)) / 2; 1052 rdev->size = ((rdev->bdev->bd_inode->i_size>>9) - le64_to_cpu(sb->data_offset)) / 2;
@@ -1058,7 +1060,7 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
1058 1060
1059 if (le32_to_cpu(sb->size) > rdev->size*2) 1061 if (le32_to_cpu(sb->size) > rdev->size*2)
1060 return -EINVAL; 1062 return -EINVAL;
1061 return 0; 1063 return ret;
1062} 1064}
1063 1065
1064static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev) 1066static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
@@ -1081,7 +1083,7 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
1081 mddev->size = le64_to_cpu(sb->size)/2; 1083 mddev->size = le64_to_cpu(sb->size)/2;
1082 mddev->events = le64_to_cpu(sb->events); 1084 mddev->events = le64_to_cpu(sb->events);
1083 mddev->bitmap_offset = 0; 1085 mddev->bitmap_offset = 0;
1084 mddev->default_bitmap_offset = 1024; 1086 mddev->default_bitmap_offset = 1024 >> 9;
1085 1087
1086 mddev->recovery_cp = le64_to_cpu(sb->resync_offset); 1088 mddev->recovery_cp = le64_to_cpu(sb->resync_offset);
1087 memcpy(mddev->uuid, sb->set_uuid, 16); 1089 memcpy(mddev->uuid, sb->set_uuid, 16);
@@ -1162,7 +1164,7 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1162 sb->cnt_corrected_read = atomic_read(&rdev->corrected_errors); 1164 sb->cnt_corrected_read = atomic_read(&rdev->corrected_errors);
1163 1165
1164 sb->raid_disks = cpu_to_le32(mddev->raid_disks); 1166 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
1165 sb->size = cpu_to_le64(mddev->size); 1167 sb->size = cpu_to_le64(mddev->size<<1);
1166 1168
1167 if (mddev->bitmap && mddev->bitmap_file == NULL) { 1169 if (mddev->bitmap && mddev->bitmap_file == NULL) {
1168 sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_offset); 1170 sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_offset);
@@ -2942,6 +2944,8 @@ static int get_array_info(mddev_t * mddev, void __user * arg)
2942 info.ctime = mddev->ctime; 2944 info.ctime = mddev->ctime;
2943 info.level = mddev->level; 2945 info.level = mddev->level;
2944 info.size = mddev->size; 2946 info.size = mddev->size;
2947 if (info.size != mddev->size) /* overflow */
2948 info.size = -1;
2945 info.nr_disks = nr; 2949 info.nr_disks = nr;
2946 info.raid_disks = mddev->raid_disks; 2950 info.raid_disks = mddev->raid_disks;
2947 info.md_minor = mddev->md_minor; 2951 info.md_minor = mddev->md_minor;
@@ -3523,7 +3527,7 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info)
3523 ) 3527 )
3524 return -EINVAL; 3528 return -EINVAL;
3525 /* Check there is only one change */ 3529 /* Check there is only one change */
3526 if (mddev->size != info->size) cnt++; 3530 if (info->size >= 0 && mddev->size != info->size) cnt++;
3527 if (mddev->raid_disks != info->raid_disks) cnt++; 3531 if (mddev->raid_disks != info->raid_disks) cnt++;
3528 if (mddev->layout != info->layout) cnt++; 3532 if (mddev->layout != info->layout) cnt++;
3529 if ((state ^ info->state) & (1<<MD_SB_BITMAP_PRESENT)) cnt++; 3533 if ((state ^ info->state) & (1<<MD_SB_BITMAP_PRESENT)) cnt++;
@@ -3540,7 +3544,7 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info)
3540 else 3544 else
3541 return mddev->pers->reconfig(mddev, info->layout, -1); 3545 return mddev->pers->reconfig(mddev, info->layout, -1);
3542 } 3546 }
3543 if (mddev->size != info->size) 3547 if (info->size >= 0 && mddev->size != info->size)
3544 rv = update_size(mddev, info->size); 3548 rv = update_size(mddev, info->size);
3545 3549
3546 if (mddev->raid_disks != info->raid_disks) 3550 if (mddev->raid_disks != info->raid_disks)