1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-08-29 01:49:28 +03:00

Tidy format1 import LV function.

Later patch initializes lv->vg after the LV structure is prepared,
so pass through cmd context and do not use vg->cmd here.
Also move LV id calculation (which uses lv->vg too).

Also properly free memory pool if operation fails.
This commit is contained in:
Milan Broz
2009-05-13 21:24:12 +00:00
parent d60f341d96
commit 494b4cec7b
2 changed files with 10 additions and 6 deletions

View File

@ -215,7 +215,8 @@ int import_vg(struct dm_pool *mem,
struct volume_group *vg, struct disk_list *dl);
int export_vg(struct vg_disk *vgd, struct volume_group *vg);
int import_lv(struct dm_pool *mem, struct logical_volume *lv, struct lv_disk *lvd);
int import_lv(struct cmd_context *cmd, struct dm_pool *mem,
struct logical_volume *lv, struct lv_disk *lvd);
int import_extents(struct cmd_context *cmd, struct volume_group *vg,
struct dm_list *pvds);

View File

@ -294,10 +294,9 @@ int export_vg(struct vg_disk *vgd, struct volume_group *vg)
return 1;
}
int import_lv(struct dm_pool *mem, struct logical_volume *lv, struct lv_disk *lvd)
int import_lv(struct cmd_context *cmd, struct dm_pool *mem,
struct logical_volume *lv, struct lv_disk *lvd)
{
lvid_from_lvnum(&lv->lvid, &lv->vg->id, lvd->lv_number);
if (!(lv->name = _create_lv_name(mem, (char *)lvd->lv_name)))
return_0;
@ -331,7 +330,7 @@ int import_lv(struct dm_pool *mem, struct logical_volume *lv, struct lv_disk *lv
lv->alloc = ALLOC_NORMAL;
if (!lvd->lv_read_ahead)
lv->read_ahead = lv->vg->cmd->default_settings.read_ahead;
lv->read_ahead = cmd->default_settings.read_ahead;
else
lv->read_ahead = lvd->lv_read_ahead;
@ -465,8 +464,12 @@ static struct logical_volume *_add_lv(struct dm_pool *mem,
lv = ll->lv;
lv->vg = vg;
if (!import_lv(mem, lv, lvd))
lvid_from_lvnum(&lv->lvid, &vg->id, lvd->lv_number);
if (!import_lv(vg->cmd, mem, lv, lvd)) {
dm_pool_free(mem, ll);
return_NULL;
}
dm_list_add(&vg->lvs, &ll->list);