/*
* Prepare for adding parallel areas to an existing segment.
*/
-static int _lv_segment_add_areas(struct logical_volume *lv,
- struct lv_segment *seg,
- uint32_t new_area_count)
+int add_lv_segment_areas(struct lv_segment *seg, uint32_t new_area_count)
{
struct lv_segment_area *newareas;
uint32_t areas_sz = new_area_count * sizeof(*newareas);
- if (!(newareas = dm_pool_zalloc(lv->vg->cmd->mem, areas_sz)))
+ if (!(newareas = dm_pool_zalloc(seg->lv->vg->vgmem, areas_sz))) {
+ log_error("Failed to allocate widened LV segment for %s.",
+ display_lvname(seg->lv));
return_0;
+ }
- memcpy(newareas, seg->areas, seg->area_count * sizeof(*seg->areas));
+ if (seg->area_count)
+ memcpy(newareas, seg->areas, seg->area_count * sizeof(*seg->areas));
seg->areas = newareas;
seg->area_count = new_area_count;
old_area_count = seg->area_count;
new_area_count = old_area_count + ah->area_count;
- if (!_lv_segment_add_areas(lv, seg, new_area_count))
+ if (!add_lv_segment_areas(seg, new_area_count))
return_0;
for (s = 0; s < ah->area_count; s++) {
old_area_count = seg->area_count;
new_area_count = old_area_count + num_extra_areas;
- if (!_lv_segment_add_areas(lv, seg, new_area_count)) {
- log_error("Failed to allocate widened LV segment for %s.",
- display_lvname(lv));
- return 0;
- }
+ if (!add_lv_segment_areas(seg, new_area_count))
+ return_0;
for (m = 0; m < old_area_count; m++)
seg_lv(seg, m)->status |= status;
int move_lv_segments(struct logical_volume *lv_to,
struct logical_volume *lv_from,
uint64_t set_status, uint64_t reset_status);
+/* Widen existing segment areas */
+int add_lv_segment_areas(struct lv_segment *seg, uint32_t new_area_count);
/*
* Calculate readahead from underlying PV devices