From 72ff89d27904d0a6f78f7638f1a37c3291bf7b62 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Sun, 23 Oct 2011 16:02:01 +0000 Subject: [PATCH] Always use vg memory pool for allocated lv segment Remove mem pool parameter from alloc_lv_segment() Since we should always allocate LV segment from the vg mempool. --- WHATS_NEW | 1 + lib/format1/import-extents.c | 6 +++--- lib/format_pool/import_export.c | 4 ++-- lib/format_text/import_vsn1.c | 2 +- lib/metadata/lv_alloc.h | 3 +-- lib/metadata/lv_manip.c | 28 ++++++++++++---------------- lib/metadata/merge.c | 2 +- 7 files changed, 21 insertions(+), 25 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 80bcb3702..5d8743301 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Always use vg memory pool for allocated lv segment. Remove extra 4kB buffer allocated on stack in print_log(). Make move_lv_segment non-static function and use dm_list function. Pass exclusive LV locks to all nodes in the cluster. diff --git a/lib/format1/import-extents.c b/lib/format1/import-extents.c index 1f1e5324f..46c1b7b7e 100644 --- a/lib/format1/import-extents.c +++ b/lib/format1/import-extents.c @@ -222,8 +222,8 @@ static int _read_linear(struct cmd_context *cmd, struct lv_map *lvm) while (le < lvm->lv->le_count) { len = _area_length(lvm, le); - if (!(seg = alloc_lv_segment(cmd->mem, segtype, lvm->lv, le, - len, 0, 0, NULL, NULL, 1, len, 0, 0, 0, NULL))) { + if (!(seg = alloc_lv_segment(segtype, lvm->lv, le, len, 0, 0, + NULL, NULL, 1, len, 0, 0, 0, NULL))) { log_error("Failed to allocate linear segment."); return 0; } @@ -292,7 +292,7 @@ static int _read_stripes(struct cmd_context *cmd, struct lv_map *lvm) area_len, first_area_le, total_area_len)) area_len++; - if (!(seg = alloc_lv_segment(cmd->mem, segtype, lvm->lv, + if (!(seg = alloc_lv_segment(segtype, lvm->lv, lvm->stripes * first_area_le, lvm->stripes * area_len, 0, lvm->stripe_size, NULL, NULL, diff --git a/lib/format_pool/import_export.c b/lib/format_pool/import_export.c index a1a1f08eb..f7f619e84 100644 --- a/lib/format_pool/import_export.c +++ b/lib/format_pool/import_export.c @@ -193,7 +193,7 @@ static int _add_stripe_seg(struct dm_pool *mem, "striped"))) return_0; - if (!(seg = alloc_lv_segment(mem, segtype, lv, *le_cur, + if (!(seg = alloc_lv_segment(segtype, lv, *le_cur, area_len * usp->num_devs, 0, usp->striping, NULL, NULL, usp->num_devs, area_len, 0, 0, 0, NULL))) { @@ -233,7 +233,7 @@ static int _add_linear_seg(struct dm_pool *mem, for (j = 0; j < usp->num_devs; j++) { area_len = (usp->devs[j].blocks) / POOL_PE_SIZE; - if (!(seg = alloc_lv_segment(mem, segtype, lv, *le_cur, + if (!(seg = alloc_lv_segment(segtype, lv, *le_cur, area_len, 0, usp->striping, NULL, NULL, 1, area_len, POOL_PE_SIZE, 0, 0, NULL))) { diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c index 111dad017..677904d4e 100644 --- a/lib/format_text/import_vsn1.c +++ b/lib/format_text/import_vsn1.c @@ -328,7 +328,7 @@ static int _read_segment(struct dm_pool *mem, struct volume_group *vg, !segtype->ops->text_import_area_count(sn_child, &area_count)) return_0; - if (!(seg = alloc_lv_segment(mem, segtype, lv, start_extent, + if (!(seg = alloc_lv_segment(segtype, lv, start_extent, extent_count, 0, 0, NULL, NULL, area_count, extent_count, 0, 0, 0, NULL))) { log_error("Segment allocation failed"); diff --git a/lib/metadata/lv_alloc.h b/lib/metadata/lv_alloc.h index 9ef563cd0..85c4bfed1 100644 --- a/lib/metadata/lv_alloc.h +++ b/lib/metadata/lv_alloc.h @@ -15,8 +15,7 @@ #ifndef _LVM_LV_ALLOC_H -struct lv_segment *alloc_lv_segment(struct dm_pool *mem, - const struct segment_type *segtype, +struct lv_segment *alloc_lv_segment(const struct segment_type *segtype, struct logical_volume *lv, uint32_t le, uint32_t len, uint64_t status, diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 657796210..9336a55a4 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -201,8 +201,7 @@ uint32_t find_free_lvnum(struct logical_volume *lv) /* * All lv_segments get created here. */ -struct lv_segment *alloc_lv_segment(struct dm_pool *mem, - const struct segment_type *segtype, +struct lv_segment *alloc_lv_segment(const struct segment_type *segtype, struct logical_volume *lv, uint32_t le, uint32_t len, uint64_t status, @@ -217,6 +216,7 @@ struct lv_segment *alloc_lv_segment(struct dm_pool *mem, struct lv_segment *pvmove_source_seg) { struct lv_segment *seg; + struct dm_pool *mem = lv->vg->vgmem; uint32_t areas_sz = area_count * sizeof(*seg->areas); if (!segtype) { @@ -277,7 +277,7 @@ struct lv_segment *alloc_snapshot_seg(struct logical_volume *lv, return NULL; } - if (!(seg = alloc_lv_segment(lv->vg->cmd->mem, segtype, lv, old_le_count, + if (!(seg = alloc_lv_segment(segtype, lv, old_le_count, lv->le_count - old_le_count, status, 0, NULL, NULL, 0, lv->le_count - old_le_count, 0, 0, 0, NULL))) { @@ -954,8 +954,7 @@ static int _setup_alloced_segment(struct logical_volume *lv, uint64_t status, area_multiple = _calc_area_multiple(segtype, area_count, 0); - if (!(seg = alloc_lv_segment(lv->vg->cmd->mem, segtype, lv, - lv->le_count, + if (!(seg = alloc_lv_segment(segtype, lv, lv->le_count, aa[0].len * area_multiple, status, stripe_size, NULL, NULL, area_count, @@ -2044,9 +2043,9 @@ int lv_add_virtual_segment(struct logical_volume *lv, uint64_t status, thin_pool_lv = lvl->lv; } - if (!(seg = alloc_lv_segment(lv->vg->cmd->mem, segtype, lv, - lv->le_count, extents, status, 0, - NULL, thin_pool_lv, 0, extents, 0, 0, 0, NULL))) { + if (!(seg = alloc_lv_segment(segtype, lv, lv->le_count, extents, + status, 0, NULL, thin_pool_lv, 0, + extents, 0, 0, 0, NULL))) { log_error("Couldn't allocate new zero segment."); return 0; } @@ -2178,8 +2177,7 @@ static struct lv_segment *_convert_seg_to_mirror(struct lv_segment *seg, return NULL; } - if (!(newseg = alloc_lv_segment(seg->lv->vg->cmd->mem, - get_segtype_from_string(seg->lv->vg->cmd, "mirror"), + if (!(newseg = alloc_lv_segment(get_segtype_from_string(seg->lv->vg->cmd, "mirror"), seg->lv, seg->le, seg->len, seg->status, seg->stripe_size, log_lv, NULL, @@ -2375,8 +2373,8 @@ static int _lv_insert_empty_sublvs(struct logical_volume *lv, /* * First, create our top-level segment for our top-level LV */ - if (!(mapseg = alloc_lv_segment(lv->vg->cmd->mem, segtype, - lv, 0, 0, lv->status, stripe_size, NULL, NULL, + if (!(mapseg = alloc_lv_segment(segtype, lv, 0, 0, lv->status, + stripe_size, NULL, NULL, devices, 0, 0, region_size, 0, NULL))) { log_error("Failed to create mapping segment for %s", lv->name); return 0; @@ -3593,8 +3591,7 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd, return_NULL; /* allocate a new linear segment */ - if (!(mapseg = alloc_lv_segment(cmd->mem, segtype, - lv_where, 0, layer_lv->le_count, + if (!(mapseg = alloc_lv_segment(segtype, lv_where, 0, layer_lv->le_count, status, 0, NULL, NULL, 1, layer_lv->le_count, 0, 0, 0, NULL))) return_NULL; @@ -3636,8 +3633,7 @@ static int _extend_layer_lv_for_segment(struct logical_volume *layer_lv, seg->lv->vg->name, seg->lv->name); /* allocate a new segment */ - if (!(mapseg = alloc_lv_segment(layer_lv->vg->cmd->mem, segtype, - layer_lv, layer_lv->le_count, + if (!(mapseg = alloc_lv_segment(segtype, layer_lv, layer_lv->le_count, seg->area_len, status, 0, NULL, NULL, 1, seg->area_len, 0, 0, 0, seg))) return_0; diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c index 2ee4a396d..fbfa579e8 100644 --- a/lib/metadata/merge.c +++ b/lib/metadata/merge.c @@ -433,7 +433,7 @@ static int _lv_split_segment(struct logical_volume *lv, struct lv_segment *seg, } /* Clone the existing segment */ - if (!(split_seg = alloc_lv_segment(lv->vg->vgmem, seg->segtype, + if (!(split_seg = alloc_lv_segment(seg->segtype, seg->lv, seg->le, seg->len, seg->status, seg->stripe_size, seg->log_lv, seg->pool_lv,