diff options
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 69 |
1 files changed, 66 insertions, 3 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index d169bc964676..b9dfdfccdb78 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -662,7 +662,8 @@ static int super_90_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version | |||
662 | } | 662 | } |
663 | 663 | ||
664 | if (sb->major_version != 0 || | 664 | if (sb->major_version != 0 || |
665 | sb->minor_version != 90) { | 665 | sb->minor_version < 90 || |
666 | sb->minor_version > 91) { | ||
666 | printk(KERN_WARNING "Bad version number %d.%d on %s\n", | 667 | printk(KERN_WARNING "Bad version number %d.%d on %s\n", |
667 | sb->major_version, sb->minor_version, | 668 | sb->major_version, sb->minor_version, |
668 | b); | 669 | b); |
@@ -747,6 +748,20 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev) | |||
747 | mddev->bitmap_offset = 0; | 748 | mddev->bitmap_offset = 0; |
748 | mddev->default_bitmap_offset = MD_SB_BYTES >> 9; | 749 | mddev->default_bitmap_offset = MD_SB_BYTES >> 9; |
749 | 750 | ||
751 | if (mddev->minor_version >= 91) { | ||
752 | mddev->reshape_position = sb->reshape_position; | ||
753 | mddev->delta_disks = sb->delta_disks; | ||
754 | mddev->new_level = sb->new_level; | ||
755 | mddev->new_layout = sb->new_layout; | ||
756 | mddev->new_chunk = sb->new_chunk; | ||
757 | } else { | ||
758 | mddev->reshape_position = MaxSector; | ||
759 | mddev->delta_disks = 0; | ||
760 | mddev->new_level = mddev->level; | ||
761 | mddev->new_layout = mddev->layout; | ||
762 | mddev->new_chunk = mddev->chunk_size; | ||
763 | } | ||
764 | |||
750 | if (sb->state & (1<<MD_SB_CLEAN)) | 765 | if (sb->state & (1<<MD_SB_CLEAN)) |
751 | mddev->recovery_cp = MaxSector; | 766 | mddev->recovery_cp = MaxSector; |
752 | else { | 767 | else { |
@@ -841,7 +856,6 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev) | |||
841 | 856 | ||
842 | sb->md_magic = MD_SB_MAGIC; | 857 | sb->md_magic = MD_SB_MAGIC; |
843 | sb->major_version = mddev->major_version; | 858 | sb->major_version = mddev->major_version; |
844 | sb->minor_version = mddev->minor_version; | ||
845 | sb->patch_version = mddev->patch_version; | 859 | sb->patch_version = mddev->patch_version; |
846 | sb->gvalid_words = 0; /* ignored */ | 860 | sb->gvalid_words = 0; /* ignored */ |
847 | memcpy(&sb->set_uuid0, mddev->uuid+0, 4); | 861 | memcpy(&sb->set_uuid0, mddev->uuid+0, 4); |
@@ -860,6 +874,17 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev) | |||
860 | sb->events_hi = (mddev->events>>32); | 874 | sb->events_hi = (mddev->events>>32); |
861 | sb->events_lo = (u32)mddev->events; | 875 | sb->events_lo = (u32)mddev->events; |
862 | 876 | ||
877 | if (mddev->reshape_position == MaxSector) | ||
878 | sb->minor_version = 90; | ||
879 | else { | ||
880 | sb->minor_version = 91; | ||
881 | sb->reshape_position = mddev->reshape_position; | ||
882 | sb->new_level = mddev->new_level; | ||
883 | sb->delta_disks = mddev->delta_disks; | ||
884 | sb->new_layout = mddev->new_layout; | ||
885 | sb->new_chunk = mddev->new_chunk; | ||
886 | } | ||
887 | mddev->minor_version = sb->minor_version; | ||
863 | if (mddev->in_sync) | 888 | if (mddev->in_sync) |
864 | { | 889 | { |
865 | sb->recovery_cp = mddev->recovery_cp; | 890 | sb->recovery_cp = mddev->recovery_cp; |
@@ -1104,6 +1129,20 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev) | |||
1104 | } | 1129 | } |
1105 | mddev->bitmap_offset = (__s32)le32_to_cpu(sb->bitmap_offset); | 1130 | mddev->bitmap_offset = (__s32)le32_to_cpu(sb->bitmap_offset); |
1106 | } | 1131 | } |
1132 | if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE)) { | ||
1133 | mddev->reshape_position = le64_to_cpu(sb->reshape_position); | ||
1134 | mddev->delta_disks = le32_to_cpu(sb->delta_disks); | ||
1135 | mddev->new_level = le32_to_cpu(sb->new_level); | ||
1136 | mddev->new_layout = le32_to_cpu(sb->new_layout); | ||
1137 | mddev->new_chunk = le32_to_cpu(sb->new_chunk)<<9; | ||
1138 | } else { | ||
1139 | mddev->reshape_position = MaxSector; | ||
1140 | mddev->delta_disks = 0; | ||
1141 | mddev->new_level = mddev->level; | ||
1142 | mddev->new_layout = mddev->layout; | ||
1143 | mddev->new_chunk = mddev->chunk_size; | ||
1144 | } | ||
1145 | |||
1107 | } else if (mddev->pers == NULL) { | 1146 | } else if (mddev->pers == NULL) { |
1108 | /* Insist of good event counter while assembling */ | 1147 | /* Insist of good event counter while assembling */ |
1109 | __u64 ev1 = le64_to_cpu(sb->events); | 1148 | __u64 ev1 = le64_to_cpu(sb->events); |
@@ -1175,6 +1214,14 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev) | |||
1175 | sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_offset); | 1214 | sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_offset); |
1176 | sb->feature_map = cpu_to_le32(MD_FEATURE_BITMAP_OFFSET); | 1215 | sb->feature_map = cpu_to_le32(MD_FEATURE_BITMAP_OFFSET); |
1177 | } | 1216 | } |
1217 | if (mddev->reshape_position != MaxSector) { | ||
1218 | sb->feature_map |= cpu_to_le32(MD_FEATURE_RESHAPE_ACTIVE); | ||
1219 | sb->reshape_position = cpu_to_le64(mddev->reshape_position); | ||
1220 | sb->new_layout = cpu_to_le32(mddev->new_layout); | ||
1221 | sb->delta_disks = cpu_to_le32(mddev->delta_disks); | ||
1222 | sb->new_level = cpu_to_le32(mddev->new_level); | ||
1223 | sb->new_chunk = cpu_to_le32(mddev->new_chunk>>9); | ||
1224 | } | ||
1178 | 1225 | ||
1179 | max_dev = 0; | 1226 | max_dev = 0; |
1180 | ITERATE_RDEV(mddev,rdev2,tmp) | 1227 | ITERATE_RDEV(mddev,rdev2,tmp) |
@@ -1497,7 +1544,7 @@ static void sync_sbs(mddev_t * mddev) | |||
1497 | } | 1544 | } |
1498 | } | 1545 | } |
1499 | 1546 | ||
1500 | static void md_update_sb(mddev_t * mddev) | 1547 | void md_update_sb(mddev_t * mddev) |
1501 | { | 1548 | { |
1502 | int err; | 1549 | int err; |
1503 | struct list_head *tmp; | 1550 | struct list_head *tmp; |
@@ -1574,6 +1621,7 @@ repeat: | |||
1574 | wake_up(&mddev->sb_wait); | 1621 | wake_up(&mddev->sb_wait); |
1575 | 1622 | ||
1576 | } | 1623 | } |
1624 | EXPORT_SYMBOL_GPL(md_update_sb); | ||
1577 | 1625 | ||
1578 | /* words written to sysfs files may, or my not, be \n terminated. | 1626 | /* words written to sysfs files may, or my not, be \n terminated. |
1579 | * We want to accept with case. For this we use cmd_match. | 1627 | * We want to accept with case. For this we use cmd_match. |
@@ -2545,6 +2593,14 @@ static int do_md_run(mddev_t * mddev) | |||
2545 | mddev->level = pers->level; | 2593 | mddev->level = pers->level; |
2546 | strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel)); | 2594 | strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel)); |
2547 | 2595 | ||
2596 | if (mddev->reshape_position != MaxSector && | ||
2597 | pers->reshape == NULL) { | ||
2598 | /* This personality cannot handle reshaping... */ | ||
2599 | mddev->pers = NULL; | ||
2600 | module_put(pers->owner); | ||
2601 | return -EINVAL; | ||
2602 | } | ||
2603 | |||
2548 | mddev->recovery = 0; | 2604 | mddev->recovery = 0; |
2549 | mddev->resync_max_sectors = mddev->size << 1; /* may be over-ridden by personality */ | 2605 | mddev->resync_max_sectors = mddev->size << 1; /* may be over-ridden by personality */ |
2550 | mddev->barriers_work = 1; | 2606 | mddev->barriers_work = 1; |
@@ -3433,11 +3489,18 @@ static int set_array_info(mddev_t * mddev, mdu_array_info_t *info) | |||
3433 | mddev->default_bitmap_offset = MD_SB_BYTES >> 9; | 3489 | mddev->default_bitmap_offset = MD_SB_BYTES >> 9; |
3434 | mddev->bitmap_offset = 0; | 3490 | mddev->bitmap_offset = 0; |
3435 | 3491 | ||
3492 | mddev->reshape_position = MaxSector; | ||
3493 | |||
3436 | /* | 3494 | /* |
3437 | * Generate a 128 bit UUID | 3495 | * Generate a 128 bit UUID |
3438 | */ | 3496 | */ |
3439 | get_random_bytes(mddev->uuid, 16); | 3497 | get_random_bytes(mddev->uuid, 16); |
3440 | 3498 | ||
3499 | mddev->new_level = mddev->level; | ||
3500 | mddev->new_chunk = mddev->chunk_size; | ||
3501 | mddev->new_layout = mddev->layout; | ||
3502 | mddev->delta_disks = 0; | ||
3503 | |||
3441 | return 0; | 3504 | return 0; |
3442 | } | 3505 | } |
3443 | 3506 | ||