mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
metadata: add lv_set_name
Add function to set lv->name. Also when creating empty LV, first add this LV to linked list in a VG and just after that allocate lv name.
This commit is contained in:
parent
73f24443e5
commit
c681d4e61a
@ -633,7 +633,8 @@ static int _read_lvnames(struct cmd_context *cmd,
|
|||||||
if (!link_lv_to_vg(vg, lv))
|
if (!link_lv_to_vg(vg, lv))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
if (!(lv->name = dm_pool_strdup(mem, lvn->key)))
|
if (!(str = dm_pool_strdup(mem, lvn->key)) ||
|
||||||
|
!lv_set_name(lv, str))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
log_debug_metadata("Importing logical volume %s.", lv->name);
|
log_debug_metadata("Importing logical volume %s.", lv->name);
|
||||||
|
@ -1577,6 +1577,13 @@ int lv_set_creation(struct logical_volume *lv,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int lv_set_name(struct logical_volume *lv, const char *lv_name)
|
||||||
|
{
|
||||||
|
lv->name = lv_name; /* NULL -> LV is removed from tree */
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static char *_time_dup(struct cmd_context *cmd, struct dm_pool *mem,
|
static char *_time_dup(struct cmd_context *cmd, struct dm_pool *mem,
|
||||||
time_t ts, int iso_mode)
|
time_t ts, int iso_mode)
|
||||||
{
|
{
|
||||||
|
@ -153,6 +153,7 @@ char *lvseg_kernel_discards_dup(struct dm_pool *mem, const struct lv_segment *se
|
|||||||
/* LV modification functions */
|
/* LV modification functions */
|
||||||
int lv_set_creation(struct logical_volume *lv,
|
int lv_set_creation(struct logical_volume *lv,
|
||||||
const char *hostname, uint64_t timestamp);
|
const char *hostname, uint64_t timestamp);
|
||||||
|
int lv_set_name(struct logical_volume *lv, const char *lv_name);
|
||||||
int lv_active_change(struct cmd_context *cmd, struct logical_volume *lv,
|
int lv_active_change(struct cmd_context *cmd, struct logical_volume *lv,
|
||||||
enum activation_change activate);
|
enum activation_change activate);
|
||||||
|
|
||||||
|
@ -4654,7 +4654,8 @@ static int _rename_single_lv(struct logical_volume *lv, char *new_name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
lv->name = new_name;
|
if (!lv_set_name(lv, new_name))
|
||||||
|
return_0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -4877,7 +4878,8 @@ int lv_rename_update(struct cmd_context *cmd, struct logical_volume *lv,
|
|||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
/* rename main LV */
|
/* rename main LV */
|
||||||
lv->name = lv_names.new;
|
if (!lv_set_name(lv, lv_names.new))
|
||||||
|
return_0;
|
||||||
|
|
||||||
if (lv_is_cow(lv))
|
if (lv_is_cow(lv))
|
||||||
lv = origin_from_cow(lv);
|
lv = origin_from_cow(lv);
|
||||||
@ -7307,6 +7309,7 @@ struct logical_volume *lv_create_empty(const char *name,
|
|||||||
struct format_instance *fi = vg->fid;
|
struct format_instance *fi = vg->fid;
|
||||||
struct logical_volume *lv;
|
struct logical_volume *lv;
|
||||||
char dname[NAME_LEN];
|
char dname[NAME_LEN];
|
||||||
|
const char *lv_name;
|
||||||
int historical;
|
int historical;
|
||||||
|
|
||||||
if (strstr(name, "%d") &&
|
if (strstr(name, "%d") &&
|
||||||
@ -7328,7 +7331,11 @@ struct logical_volume *lv_create_empty(const char *name,
|
|||||||
if (!(lv = alloc_lv(vg->vgmem)))
|
if (!(lv = alloc_lv(vg->vgmem)))
|
||||||
return_NULL;
|
return_NULL;
|
||||||
|
|
||||||
if (!(lv->name = dm_pool_strdup(vg->vgmem, name)))
|
if (!link_lv_to_vg(vg, lv))
|
||||||
|
goto_bad;
|
||||||
|
|
||||||
|
if (!(lv_name = dm_pool_strdup(vg->vgmem, name)) ||
|
||||||
|
!lv_set_name(lv, lv_name))
|
||||||
goto_bad;
|
goto_bad;
|
||||||
|
|
||||||
lv->status = status;
|
lv->status = status;
|
||||||
@ -7342,9 +7349,6 @@ struct logical_volume *lv_create_empty(const char *name,
|
|||||||
if (lvid)
|
if (lvid)
|
||||||
lv->lvid = *lvid;
|
lv->lvid = *lvid;
|
||||||
|
|
||||||
if (!link_lv_to_vg(vg, lv))
|
|
||||||
goto_bad;
|
|
||||||
|
|
||||||
if (!lv_set_creation(lv, NULL, 0))
|
if (!lv_set_creation(lv, NULL, 0))
|
||||||
goto_bad;
|
goto_bad;
|
||||||
|
|
||||||
|
@ -544,8 +544,10 @@ struct logical_volume *convert_vdo_lv(struct logical_volume *lv,
|
|||||||
return_NULL;
|
return_NULL;
|
||||||
|
|
||||||
/* Also swap naming, so the passed in LV keeps the passed-in name */
|
/* Also swap naming, so the passed in LV keeps the passed-in name */
|
||||||
vdo_lv->name = lv->name;
|
tmp_lv.name = lv->name;
|
||||||
lv->name = lvc.lv_name;
|
lv_set_name(lv, NULL);
|
||||||
|
lv_set_name(vdo_lv, tmp_lv.name);
|
||||||
|
lv_set_name(lv, lvc.lv_name);
|
||||||
|
|
||||||
/* Swap segment referencing */
|
/* Swap segment referencing */
|
||||||
if (!remove_seg_from_segs_using_this_lv(lv, first_seg(lv)))
|
if (!remove_seg_from_segs_using_this_lv(lv, first_seg(lv)))
|
||||||
|
Loading…
Reference in New Issue
Block a user