diff --git a/WHATS_NEW b/WHATS_NEW index 3e633bc79..b2a6249aa 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Make move_lv_segment non-static function and use dm_list function. Pass exclusive LV locks to all nodes in the cluster. Improve lvcreate man documentation of the chunksize option. Improve man page style for lvcreate. diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 8ca1715e2..3ab8a8f88 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -3446,23 +3446,20 @@ int remove_layers_for_segments_all(struct cmd_context *cmd, return 1; } -static int _move_lv_segments(struct logical_volume *lv_to, - struct logical_volume *lv_from, - uint64_t set_status, uint64_t reset_status) +int move_lv_segments(struct logical_volume *lv_to, + struct logical_volume *lv_from, + uint64_t set_status, uint64_t reset_status) { struct lv_segment *seg; - dm_list_iterate_items(seg, &lv_to->segments) { + dm_list_iterate_items(seg, &lv_to->segments) if (seg->origin) { - log_error("Can't move snapshot segment"); + log_error("Can't move snapshot segment."); return 0; } - } - if (!dm_list_empty(&lv_from->segments)) - lv_to->segments = lv_from->segments; - lv_to->segments.n->p = &lv_to->segments; - lv_to->segments.p->n = &lv_to->segments; + dm_list_init(&lv_to->segments); + dm_list_splice(&lv_to->segments, &lv_from->segments); dm_list_iterate_items(seg, &lv_to->segments) { seg->lv = lv_to; @@ -3470,8 +3467,6 @@ static int _move_lv_segments(struct logical_volume *lv_to, seg->status |= set_status; } - dm_list_init(&lv_from->segments); - lv_to->le_count = lv_from->le_count; lv_to->size = lv_from->size; @@ -3512,7 +3507,7 @@ int remove_layer_from_lv(struct logical_volume *lv, if (!lv_empty(parent)) return_0; - if (!_move_lv_segments(parent, layer_lv, 0, 0)) + if (!move_lv_segments(parent, layer_lv, 0, 0)) return_0; /* Replace the empty layer with error segment */ @@ -3602,7 +3597,7 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd, log_very_verbose("Inserting layer %s for %s", layer_lv->name, lv_where->name); - if (!_move_lv_segments(layer_lv, lv_where, 0, 0)) + if (!move_lv_segments(layer_lv, lv_where, 0, 0)) return_NULL; if (!(segtype = get_segtype_from_string(cmd, "striped"))) diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h index 11cac5701..2a9062ba4 100644 --- a/lib/metadata/metadata.h +++ b/lib/metadata/metadata.h @@ -420,6 +420,9 @@ int for_each_sub_lv(struct cmd_context *cmd, struct logical_volume *lv, int (*fn)(struct cmd_context *cmd, struct logical_volume *lv, void *data), void *data); +int move_lv_segments(struct logical_volume *lv_to, + struct logical_volume *lv_from, + uint64_t set_status, uint64_t reset_status); /* * Calculate readahead from underlying PV devices