diff options
author | Heinz Mauelshagen <heinzm@redhat.com> | 2016-08-26 14:35:07 +0200 |
---|---|---|
committer | Heinz Mauelshagen <heinzm@redhat.com> | 2016-08-26 14:35:07 +0200 |
commit | 74210f86623b75b7da0b9bfb7f23181ce7902d7f (patch) | |
tree | 0f3a59aaf6bd4d05d66e55404973ea213a7178a2 | |
parent | ddb382652306c79b03953ec46103a2c36cf6762d (diff) | |
download | lvm2-dev-lvmguy-raid_tiny_extent_size_v2.tar.gz |
raid: fixup some size issues; allow for striped -> raid4 conversiondev-lvmguy-raid_tiny_extent_size_v2
-rw-r--r-- | lib/format_text/import_vsn1.c | 2 | ||||
-rw-r--r-- | lib/metadata/lv_manip.c | 13 | ||||
-rw-r--r-- | lib/metadata/merge.c | 4 | ||||
-rw-r--r-- | lib/metadata/raid_manip.c | 18 | ||||
-rw-r--r-- | tools/toollib.c | 1 |
5 files changed, 19 insertions, 19 deletions
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c index d2219e45a..bdba5bd90 100644 --- a/lib/format_text/import_vsn1.c +++ b/lib/format_text/import_vsn1.c @@ -391,7 +391,7 @@ static int _read_segment(struct logical_volume *lv, const struct dm_config_node if (!(seg = alloc_lv_segment(segtype, lv, start_extent, extent_count, 0, 0, NULL, area_count, - extent_count, 0, 0, 0, NULL))) { + segtype->parity_devs ? (extent_count / (area_count - segtype->parity_devs)) : extent_count, 0, 0, 0, NULL))) { log_error("Segment allocation failed"); return 0; } diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index d159dea1d..00558553c 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -1259,13 +1259,13 @@ static int _lv_segment_reduce(struct lv_segment *seg, uint32_t reduction) /* Caller must ensure exact divisibility */ if (seg_is_striped(seg) || (seg_is_raid(seg) && !seg_is_raid1(seg))) { - if (reduction % seg->area_count) { + if (reduction % (seg->area_count - seg->segtype->parity_devs)) { log_error("Segment extent reduction %" PRIu32 " not divisible by #stripes %" PRIu32, reduction, seg->area_count); return 0; } - area_reduction = (reduction / (seg->area_count - seg->segtype->parity_devs)); + area_reduction = reduction / (seg->area_count - seg->segtype->parity_devs); } else area_reduction = reduction; @@ -3878,7 +3878,6 @@ static int _lv_extend_layered_lv(struct alloc_handle *ah, stripes = 1; stripe_size = 0; area_multiple = _calc_area_multiple(seg->segtype, seg->area_count, seg_is_raid1(seg) ? 1 : seg->area_count - seg->segtype->parity_devs); -printf("area_multiple=%u\n", area_multiple); } for (fa = first_area, s = 0; s < seg->area_count; s++) { @@ -4005,12 +4004,15 @@ printf("area_multiple=%u\n", area_multiple); void lv_adjust_region_and_stripe_size(struct logical_volume *lv) { uint32_t size; + uint64_t area_size; struct lv_segment *seg = first_seg(lv); if (!seg) return; - if (seg->region_size > seg_lv(seg, 0)->size) { + area_size = (uint64_t) seg->area_len * lv->vg->extent_size; + + if (seg->region_size > area_size) { size = _round_down_pow2(seg_lv(seg, 0)->size); log_warn("Region size %s too large for LV %s size %s, rounded down to %s", display_size(lv->vg->cmd, seg->region_size), @@ -4020,7 +4022,7 @@ void lv_adjust_region_and_stripe_size(struct logical_volume *lv) seg->region_size = size; } - if (seg->stripe_size > seg_lv(seg, 0)->size) { + if (seg->stripe_size > area_size) { size = _round_down_pow2(seg_lv(seg, 0)->size); log_warn("Stripe size %s too large for LV %s size %s, rounded down to %s", display_size(lv->vg->cmd, seg->stripe_size), @@ -4484,6 +4486,7 @@ static int _validate_stripesize(const struct volume_group *vg, return 0; } + /* Limit stripe size to extent size for non-RAID */ if (lp->stripe_size > vg->extent_size) { log_print_unless_silent("Reducing stripe size %s to maximum, " "physical extent size %s.", diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c index 091fbac32..f49d305aa 100644 --- a/lib/metadata/merge.c +++ b/lib/metadata/merge.c @@ -413,8 +413,8 @@ int check_lv_segments(struct logical_volume *lv, int complete_vg) inc_error_count; } - area_multiplier = segtype_is_striped(seg->segtype) ? - seg->area_count : 1; + area_multiplier = (segtype_is_striped(seg->segtype) || (seg_is_raid(seg) && !seg_is_raid1(seg))) ? + (seg->area_count - seg->segtype->parity_devs) : 1; if (seg->area_len * area_multiplier != seg->len) { log_error("LV %s: segment %u has inconsistent " "area_len %u", diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c index eeeb258a7..b2b0bda6c 100644 --- a/lib/metadata/raid_manip.c +++ b/lib/metadata/raid_manip.c @@ -652,7 +652,6 @@ static int _alloc_image_components(struct logical_volume *lv, region_size = get_default_region_size(lv->vg->cmd); if (seg_is_raid(seg)) - if (seg_is_raid(seg)) segtype = seg->segtype; else if (!(segtype = get_segtype_from_string(lv->vg->cmd, SEG_TYPE_NAME_RAID1))) return_0; @@ -2548,7 +2547,7 @@ static struct possible_takeover_reshape_type _possible_takeover_reshape_types[] .current_areas = 1, .options = ALLOW_STRIPE_SIZE }, { .current_types = SEG_STRIPED_TARGET, /* striped, i.e. seg->area_count > 1 */ - .possible_types = SEG_RAID0|SEG_RAID0_META, + .possible_types = SEG_RAID0|SEG_RAID0_META|SEG_RAID4, .current_areas = ~0U, .options = ALLOW_NONE }, /* raid0* -> */ @@ -2914,7 +2913,7 @@ static int _raid456_to_raid0_or_striped_wrapper(TAKEOVER_FN_ARGS) return_0; /* FIXME Hard-coded raid4 to raid0 */ - seg->area_len = seg->extents_copied = seg->area_len / seg->area_count; + seg->area_len = seg->extents_copied = seg->len / (seg->area_count - seg->segtype->parity_devs); if (segtype_is_striped_target(new_segtype)) { if (!_convert_raid0_to_striped(lv, 0, &removal_lvs)) @@ -2986,11 +2985,6 @@ static int _striped_or_raid0_to_raid45610_wrapper(TAKEOVER_FN_ARGS) return 0; } - /* FIXME Hard-coded raid0/4/5/6 */ - /* Be prepared for any image addition -> raid5/6 */ - if (seg_is_any_raid0(seg)) - seg->area_len = seg->extents_copied = seg->len / seg->area_count; - /* Add the additional component LV pairs */ log_debug_metadata("Adding %" PRIu32 " component LV pair(s) to %s", new_image_count - lv_raid_image_count(lv), display_lvname(lv)); @@ -3006,6 +3000,10 @@ static int _striped_or_raid0_to_raid45610_wrapper(TAKEOVER_FN_ARGS) seg->segtype = new_segtype; seg->region_size = new_region_size; + /* FIXME Hard-coded raid0 -> raid4 */ + if (seg_is_any_raid0(seg)) + seg->area_len = seg->extents_copied = seg->len / (seg->area_count - seg->segtype->parity_devs); + _check_and_adjust_region_size(lv); lv_adjust_region_and_stripe_size(lv); @@ -3097,7 +3095,7 @@ static int _takeover_from_raid0_to_raid10(TAKEOVER_FN_ARGS) static int _takeover_from_raid0_to_raid45(TAKEOVER_FN_ARGS) { - return _striped_or_raid0_to_raid45610_wrapper(lv, new_segtype, yes, force, first_seg(lv)->area_count + 1, 1 /* data_copies */, 0, 0, new_region_size, allocate_pvs); + return _striped_or_raid0_to_raid45610_wrapper(lv, new_segtype, yes, force, first_seg(lv)->area_count + 1, 2 /* data_copies */, 0, 0, new_region_size, allocate_pvs); } static int _takeover_from_raid0_to_raid6(TAKEOVER_FN_ARGS) @@ -3143,7 +3141,7 @@ static int _takeover_from_raid0_meta_to_raid10(TAKEOVER_FN_ARGS) static int _takeover_from_raid0_meta_to_raid45(TAKEOVER_FN_ARGS) { - return _striped_or_raid0_to_raid45610_wrapper(lv, new_segtype, yes, force, first_seg(lv)->area_count + 1, 1 /* data_copies */, 0, 0, new_region_size, allocate_pvs); + return _striped_or_raid0_to_raid45610_wrapper(lv, new_segtype, yes, force, first_seg(lv)->area_count + 1, 2 /* data_copies */, 0, 0, new_region_size, allocate_pvs); } static int _takeover_from_raid0_meta_to_raid6(TAKEOVER_FN_ARGS) diff --git a/tools/toollib.c b/tools/toollib.c index 9999d0d00..4c694284a 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -1304,7 +1304,6 @@ static int _validate_stripe_params(struct cmd_context *cmd, const struct segment } #endif -printf("stripe_size_required=%d\n", stripe_size_required); if (stripe_size_required) { if (!*stripe_size) { *stripe_size = find_config_tree_int(cmd, metadata_stripesize_CFG, NULL) * 2; |