]> sourceware.org Git - lvm2.git/commitdiff
lv_manip: add new internal api function
authorZdenek Kabelac <zkabelac@redhat.com>
Sat, 23 Jun 2018 09:35:22 +0000 (11:35 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 25 Jun 2018 13:07:55 +0000 (15:07 +0200)
lib/metadata/lv_manip.c
lib/metadata/metadata.h

index 4efe04a372802c6cda45cedd8ea8a91608b2da9a..11a6927c07ba49c552390f8873681e710331c9bd 100644 (file)
@@ -1219,17 +1219,19 @@ int set_lv_segment_area_lv(struct lv_segment *seg, uint32_t area_num,
 /*
  * 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;
@@ -3766,7 +3768,7 @@ int lv_add_mirror_areas(struct alloc_handle *ah,
                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++) {
@@ -3818,11 +3820,8 @@ int lv_add_mirror_lvs(struct logical_volume *lv,
        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;
index 129267ce403380d39480fbeb48b38d54abf23c34..1c4be48185278235e37d43fd34ab82f90b469b3f 100644 (file)
@@ -445,6 +445,8 @@ int for_each_sub_lv(struct logical_volume *lv,
 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
This page took 0.049235 seconds and 5 git commands to generate.