mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Consolidate LV allocation into alloc_lv().
This commit is contained in:
parent
673ecf73cf
commit
d557773841
@ -1,5 +1,6 @@
|
||||
Version 2.02.54 -
|
||||
=====================================
|
||||
Consolidate LV allocation into alloc_lv().
|
||||
Treat input units of both 's' and 'S' as 512-byte sectors. (2.02.49)
|
||||
Use standard output units for 'PE Size' and 'Stripe size' in pv/lvdisplay.
|
||||
Add configure --enable-units-compat to set si_unit_consistency off by default.
|
||||
|
@ -337,12 +337,6 @@ int import_lv(struct cmd_context *cmd, struct dm_pool *mem,
|
||||
lv->size = lvd->lv_size;
|
||||
lv->le_count = lvd->lv_allocated_le;
|
||||
|
||||
lv->snapshot = NULL;
|
||||
dm_list_init(&lv->snapshot_segs);
|
||||
dm_list_init(&lv->segments);
|
||||
dm_list_init(&lv->tags);
|
||||
dm_list_init(&lv->segs_using_this_lv);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -457,7 +451,7 @@ static struct logical_volume *_add_lv(struct dm_pool *mem,
|
||||
{
|
||||
struct logical_volume *lv;
|
||||
|
||||
if (!(lv = dm_pool_zalloc(mem, sizeof(*lv))))
|
||||
if (!(lv = alloc_lv(mem)))
|
||||
return_NULL;
|
||||
|
||||
lvid_from_lvnum(&lv->lvid, &vg->id, lvd->lv_number);
|
||||
|
@ -59,10 +59,8 @@ int import_pool_lvs(struct volume_group *vg, struct dm_pool *mem, struct dm_list
|
||||
struct pool_list *pl;
|
||||
struct logical_volume *lv;
|
||||
|
||||
if (!(lv = dm_pool_zalloc(mem, sizeof(*lv)))) {
|
||||
log_error("Unable to allocate logical volume structure");
|
||||
return 0;
|
||||
}
|
||||
if (!(lv = alloc_lv(mem)))
|
||||
return_0;
|
||||
|
||||
lv->status = 0;
|
||||
lv->alloc = ALLOC_NORMAL;
|
||||
@ -70,11 +68,6 @@ int import_pool_lvs(struct volume_group *vg, struct dm_pool *mem, struct dm_list
|
||||
lv->name = NULL;
|
||||
lv->le_count = 0;
|
||||
lv->read_ahead = vg->cmd->default_settings.read_ahead;
|
||||
lv->snapshot = NULL;
|
||||
dm_list_init(&lv->snapshot_segs);
|
||||
dm_list_init(&lv->segments);
|
||||
dm_list_init(&lv->tags);
|
||||
dm_list_init(&lv->segs_using_this_lv);
|
||||
|
||||
dm_list_iterate_items(pl, pls) {
|
||||
lv->size += pl->pd.pl_blocks;
|
||||
@ -99,10 +92,6 @@ int import_pool_lvs(struct volume_group *vg, struct dm_pool *mem, struct dm_list
|
||||
} else {
|
||||
lv->minor = -1;
|
||||
}
|
||||
lv->snapshot = NULL;
|
||||
dm_list_init(&lv->snapshot_segs);
|
||||
dm_list_init(&lv->segments);
|
||||
dm_list_init(&lv->tags);
|
||||
}
|
||||
|
||||
lv->le_count = lv->size / POOL_PE_SIZE;
|
||||
|
@ -495,7 +495,7 @@ static int _read_lvnames(struct format_instance *fid __attribute((unused)),
|
||||
struct logical_volume *lv;
|
||||
struct config_node *cn;
|
||||
|
||||
if (!(lv = dm_pool_zalloc(mem, sizeof(*lv))))
|
||||
if (!(lv = alloc_lv(mem)))
|
||||
return_0;
|
||||
|
||||
if (!(lv->name = dm_pool_strdup(mem, lvn->key)))
|
||||
@ -541,12 +541,6 @@ static int _read_lvnames(struct format_instance *fid __attribute((unused)),
|
||||
}
|
||||
}
|
||||
|
||||
lv->snapshot = NULL;
|
||||
dm_list_init(&lv->snapshot_segs);
|
||||
dm_list_init(&lv->segments);
|
||||
dm_list_init(&lv->tags);
|
||||
dm_list_init(&lv->segs_using_this_lv);
|
||||
|
||||
/* Optional tags */
|
||||
if ((cn = find_config_node(lvn, "tags")) &&
|
||||
!(read_tags(mem, &lv->tags, cn->v))) {
|
||||
|
@ -1862,6 +1862,24 @@ int vg_max_lv_reached(struct volume_group *vg)
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct logical_volume *alloc_lv(struct dm_pool *mem)
|
||||
{
|
||||
struct logical_volume *lv;
|
||||
|
||||
if (!(lv = dm_pool_zalloc(mem, sizeof(*lv)))) {
|
||||
log_error("Unable to allocate logical volume structure");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lv->snapshot = NULL;
|
||||
dm_list_init(&lv->snapshot_segs);
|
||||
dm_list_init(&lv->segments);
|
||||
dm_list_init(&lv->tags);
|
||||
dm_list_init(&lv->segs_using_this_lv);
|
||||
|
||||
return lv;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a new empty LV.
|
||||
*/
|
||||
@ -1891,7 +1909,7 @@ struct logical_volume *lv_create_empty(const char *name,
|
||||
|
||||
log_verbose("Creating logical volume %s", name);
|
||||
|
||||
if (!(lv = dm_pool_zalloc(vg->vgmem, sizeof(*lv))))
|
||||
if (!(lv = alloc_lv(vg->vgmem)))
|
||||
return_NULL;
|
||||
|
||||
if (!(lv->name = dm_pool_strdup(vg->vgmem, name)))
|
||||
@ -1904,11 +1922,6 @@ struct logical_volume *lv_create_empty(const char *name,
|
||||
lv->minor = -1;
|
||||
lv->size = UINT64_C(0);
|
||||
lv->le_count = 0;
|
||||
lv->snapshot = NULL;
|
||||
dm_list_init(&lv->snapshot_segs);
|
||||
dm_list_init(&lv->segments);
|
||||
dm_list_init(&lv->tags);
|
||||
dm_list_init(&lv->segs_using_this_lv);
|
||||
|
||||
if (lvid)
|
||||
lv->lvid = *lvid;
|
||||
|
@ -316,6 +316,8 @@ struct pv_segment *find_peg_by_pe(const struct physical_volume *pv, uint32_t pe)
|
||||
*/
|
||||
const char *strip_dir(const char *vg_name, const char *dir);
|
||||
|
||||
struct logical_volume *alloc_lv(struct dm_pool *mem);
|
||||
|
||||
/*
|
||||
* Checks that an lv has no gaps or overlapping segments.
|
||||
* Set complete_vg to perform additional VG level checks.
|
||||
|
Loading…
Reference in New Issue
Block a user