1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

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.
This commit is contained in:
Zdenek Kabelac 2011-10-23 16:02:01 +00:00
parent c13f82579c
commit 72ff89d279
7 changed files with 21 additions and 25 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.89 - Version 2.02.89 -
================================== ==================================
Always use vg memory pool for allocated lv segment.
Remove extra 4kB buffer allocated on stack in print_log(). Remove extra 4kB buffer allocated on stack in print_log().
Make move_lv_segment non-static function and use dm_list function. Make move_lv_segment non-static function and use dm_list function.
Pass exclusive LV locks to all nodes in the cluster. Pass exclusive LV locks to all nodes in the cluster.

View File

@ -222,8 +222,8 @@ static int _read_linear(struct cmd_context *cmd, struct lv_map *lvm)
while (le < lvm->lv->le_count) { while (le < lvm->lv->le_count) {
len = _area_length(lvm, le); len = _area_length(lvm, le);
if (!(seg = alloc_lv_segment(cmd->mem, segtype, lvm->lv, le, if (!(seg = alloc_lv_segment(segtype, lvm->lv, le, len, 0, 0,
len, 0, 0, NULL, NULL, 1, len, 0, 0, 0, NULL))) { NULL, NULL, 1, len, 0, 0, 0, NULL))) {
log_error("Failed to allocate linear segment."); log_error("Failed to allocate linear segment.");
return 0; 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, first_area_le, total_area_len))
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 * first_area_le,
lvm->stripes * area_len, lvm->stripes * area_len,
0, lvm->stripe_size, NULL, NULL, 0, lvm->stripe_size, NULL, NULL,

View File

@ -193,7 +193,7 @@ static int _add_stripe_seg(struct dm_pool *mem,
"striped"))) "striped")))
return_0; 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, area_len * usp->num_devs, 0,
usp->striping, NULL, NULL, usp->num_devs, usp->striping, NULL, NULL, usp->num_devs,
area_len, 0, 0, 0, NULL))) { 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++) { for (j = 0; j < usp->num_devs; j++) {
area_len = (usp->devs[j].blocks) / POOL_PE_SIZE; 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, area_len, 0, usp->striping,
NULL, NULL, 1, area_len, NULL, NULL, 1, area_len,
POOL_PE_SIZE, 0, 0, NULL))) { POOL_PE_SIZE, 0, 0, NULL))) {

View File

@ -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)) !segtype->ops->text_import_area_count(sn_child, &area_count))
return_0; 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, NULL, NULL, area_count,
extent_count, 0, 0, 0, NULL))) { extent_count, 0, 0, 0, NULL))) {
log_error("Segment allocation failed"); log_error("Segment allocation failed");

View File

@ -15,8 +15,7 @@
#ifndef _LVM_LV_ALLOC_H #ifndef _LVM_LV_ALLOC_H
struct lv_segment *alloc_lv_segment(struct dm_pool *mem, struct lv_segment *alloc_lv_segment(const struct segment_type *segtype,
const struct segment_type *segtype,
struct logical_volume *lv, struct logical_volume *lv,
uint32_t le, uint32_t len, uint32_t le, uint32_t len,
uint64_t status, uint64_t status,

View File

@ -201,8 +201,7 @@ uint32_t find_free_lvnum(struct logical_volume *lv)
/* /*
* All lv_segments get created here. * All lv_segments get created here.
*/ */
struct lv_segment *alloc_lv_segment(struct dm_pool *mem, struct lv_segment *alloc_lv_segment(const struct segment_type *segtype,
const struct segment_type *segtype,
struct logical_volume *lv, struct logical_volume *lv,
uint32_t le, uint32_t len, uint32_t le, uint32_t len,
uint64_t status, 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 *pvmove_source_seg)
{ {
struct lv_segment *seg; struct lv_segment *seg;
struct dm_pool *mem = lv->vg->vgmem;
uint32_t areas_sz = area_count * sizeof(*seg->areas); uint32_t areas_sz = area_count * sizeof(*seg->areas);
if (!segtype) { if (!segtype) {
@ -277,7 +277,7 @@ struct lv_segment *alloc_snapshot_seg(struct logical_volume *lv,
return NULL; 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, lv->le_count - old_le_count, status, 0,
NULL, NULL, 0, lv->le_count - old_le_count, NULL, NULL, 0, lv->le_count - old_le_count,
0, 0, 0, NULL))) { 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); area_multiple = _calc_area_multiple(segtype, area_count, 0);
if (!(seg = alloc_lv_segment(lv->vg->cmd->mem, segtype, lv, if (!(seg = alloc_lv_segment(segtype, lv, lv->le_count,
lv->le_count,
aa[0].len * area_multiple, aa[0].len * area_multiple,
status, stripe_size, NULL, NULL, status, stripe_size, NULL, NULL,
area_count, area_count,
@ -2044,9 +2043,9 @@ int lv_add_virtual_segment(struct logical_volume *lv, uint64_t status,
thin_pool_lv = lvl->lv; thin_pool_lv = lvl->lv;
} }
if (!(seg = alloc_lv_segment(lv->vg->cmd->mem, segtype, lv, if (!(seg = alloc_lv_segment(segtype, lv, lv->le_count, extents,
lv->le_count, extents, status, 0, status, 0, NULL, thin_pool_lv, 0,
NULL, thin_pool_lv, 0, extents, 0, 0, 0, NULL))) { extents, 0, 0, 0, NULL))) {
log_error("Couldn't allocate new zero segment."); log_error("Couldn't allocate new zero segment.");
return 0; return 0;
} }
@ -2178,8 +2177,7 @@ static struct lv_segment *_convert_seg_to_mirror(struct lv_segment *seg,
return NULL; return NULL;
} }
if (!(newseg = alloc_lv_segment(seg->lv->vg->cmd->mem, if (!(newseg = alloc_lv_segment(get_segtype_from_string(seg->lv->vg->cmd, "mirror"),
get_segtype_from_string(seg->lv->vg->cmd, "mirror"),
seg->lv, seg->le, seg->len, seg->lv, seg->le, seg->len,
seg->status, seg->stripe_size, seg->status, seg->stripe_size,
log_lv, NULL, 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 * First, create our top-level segment for our top-level LV
*/ */
if (!(mapseg = alloc_lv_segment(lv->vg->cmd->mem, segtype, if (!(mapseg = alloc_lv_segment(segtype, lv, 0, 0, lv->status,
lv, 0, 0, lv->status, stripe_size, NULL, NULL, stripe_size, NULL, NULL,
devices, 0, 0, region_size, 0, NULL))) { devices, 0, 0, region_size, 0, NULL))) {
log_error("Failed to create mapping segment for %s", lv->name); log_error("Failed to create mapping segment for %s", lv->name);
return 0; return 0;
@ -3593,8 +3591,7 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd,
return_NULL; return_NULL;
/* allocate a new linear segment */ /* allocate a new linear segment */
if (!(mapseg = alloc_lv_segment(cmd->mem, segtype, if (!(mapseg = alloc_lv_segment(segtype, lv_where, 0, layer_lv->le_count,
lv_where, 0, layer_lv->le_count,
status, 0, NULL, NULL, 1, layer_lv->le_count, status, 0, NULL, NULL, 1, layer_lv->le_count,
0, 0, 0, NULL))) 0, 0, 0, NULL)))
return_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); seg->lv->vg->name, seg->lv->name);
/* allocate a new segment */ /* allocate a new segment */
if (!(mapseg = alloc_lv_segment(layer_lv->vg->cmd->mem, segtype, if (!(mapseg = alloc_lv_segment(segtype, layer_lv, layer_lv->le_count,
layer_lv, layer_lv->le_count,
seg->area_len, status, 0, seg->area_len, status, 0,
NULL, NULL, 1, seg->area_len, 0, 0, 0, seg))) NULL, NULL, 1, seg->area_len, 0, 0, 0, seg)))
return_0; return_0;

View File

@ -433,7 +433,7 @@ static int _lv_split_segment(struct logical_volume *lv, struct lv_segment *seg,
} }
/* Clone the existing segment */ /* 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->lv, seg->le, seg->len,
seg->status, seg->stripe_size, seg->status, seg->stripe_size,
seg->log_lv, seg->pool_lv, seg->log_lv, seg->pool_lv,