mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
Add 'LVM-' prefix to uuids.
This commit is contained in:
parent
a6d97ede7b
commit
03b49fe193
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.00 -
|
Version 2.02.00 -
|
||||||
===================================
|
===================================
|
||||||
|
Add 'LVM-' prefix to uuids.
|
||||||
Split lv_segment_area from lv_segment to permit extension.
|
Split lv_segment_area from lv_segment to permit extension.
|
||||||
Replacement deactivation code using libdevmapper dependency tree.
|
Replacement deactivation code using libdevmapper dependency tree.
|
||||||
Simplify dev_manager_info().
|
Simplify dev_manager_info().
|
||||||
|
@ -309,7 +309,9 @@ static int _target_present(const char *target_name)
|
|||||||
|
|
||||||
int target_present(const char *target_name)
|
int target_present(const char *target_name)
|
||||||
{
|
{
|
||||||
|
#ifdef MODPROBE_CMD
|
||||||
char module[128];
|
char module[128];
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!activation())
|
if (!activation())
|
||||||
return 0;
|
return 0;
|
||||||
@ -350,7 +352,8 @@ static int _lv_info(struct cmd_context *cmd, const struct logical_volume *lv, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
log_debug("Getting device info for %s", name);
|
log_debug("Getting device info for %s", name);
|
||||||
if (!dev_manager_info(name, lv->lvid.s, with_mknodes, with_open_count, &dminfo)) {
|
if (!dev_manager_info(lv->vg->cmd->mem, name, lv, with_mknodes,
|
||||||
|
with_open_count, &dminfo)) {
|
||||||
dm_pool_free(cmd->mem, name);
|
dm_pool_free(cmd->mem, name);
|
||||||
stack;
|
stack;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -167,19 +167,17 @@ static char *_build_dlid(struct dm_pool *mem, const char *lvid, const char *laye
|
|||||||
char *dlid;
|
char *dlid;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
/* FIXME Prepend 'LVM2-' */
|
|
||||||
|
|
||||||
if (!layer)
|
if (!layer)
|
||||||
layer = "";
|
layer = "";
|
||||||
|
|
||||||
len = strlen(lvid) + strlen(layer) + 2;
|
len = 4 + strlen(lvid) + strlen(layer) + 2;
|
||||||
|
|
||||||
if (!(dlid = dm_pool_alloc(mem, len))) {
|
if (!(dlid = dm_pool_alloc(mem, len))) {
|
||||||
stack;
|
stack;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(dlid, "%s%s%s", lvid, (*layer) ? "-" : "", layer);
|
sprintf(dlid, "LVM-%s%s%s", lvid, (*layer) ? "-" : "", layer);
|
||||||
|
|
||||||
return dlid;
|
return dlid;
|
||||||
}
|
}
|
||||||
@ -209,7 +207,7 @@ static struct dm_task *_setup_task(const char *name, const char *uuid,
|
|||||||
return dmt;
|
return dmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _info_run(const char *name, const char *uuid, struct dm_info *info,
|
static int _info_run(const char *name, const char *dlid, struct dm_info *info,
|
||||||
int mknodes, int with_open_count, struct dm_pool *mem,
|
int mknodes, int with_open_count, struct dm_pool *mem,
|
||||||
char **uuid_out)
|
char **uuid_out)
|
||||||
{
|
{
|
||||||
@ -220,7 +218,7 @@ static int _info_run(const char *name, const char *uuid, struct dm_info *info,
|
|||||||
|
|
||||||
dmtask = mknodes ? DM_DEVICE_MKNODES : DM_DEVICE_INFO;
|
dmtask = mknodes ? DM_DEVICE_MKNODES : DM_DEVICE_INFO;
|
||||||
|
|
||||||
if (!(dmt = _setup_task(name, uuid, 0, dmtask))) {
|
if (!(dmt = _setup_task(name, dlid, 0, dmtask))) {
|
||||||
stack;
|
stack;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -253,12 +251,12 @@ static int _info_run(const char *name, const char *uuid, struct dm_info *info,
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _info(const char *name, const char *uuid, int mknodes,
|
static int _info(const char *name, const char *dlid, int mknodes,
|
||||||
int with_open_count, struct dm_info *info,
|
int with_open_count, struct dm_info *info,
|
||||||
struct dm_pool *mem, char **uuid_out)
|
struct dm_pool *mem, char **uuid_out)
|
||||||
{
|
{
|
||||||
if (!mknodes && uuid && *uuid &&
|
if (!mknodes && dlid && *dlid &&
|
||||||
_info_run(NULL, uuid, info, 0, with_open_count, mem, uuid_out) &&
|
_info_run(NULL, dlid, info, 0, with_open_count, mem, uuid_out) &&
|
||||||
info->exists)
|
info->exists)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@ -269,10 +267,19 @@ static int _info(const char *name, const char *uuid, int mknodes,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dev_manager_info(const char *name, const char *uuid,
|
int dev_manager_info(struct dm_pool *mem, const char *name,
|
||||||
int with_mknodes, int with_open_count, struct dm_info *info)
|
const struct logical_volume *lv, int with_mknodes,
|
||||||
|
int with_open_count, struct dm_info *info)
|
||||||
{
|
{
|
||||||
return _info(name, uuid, with_mknodes, with_open_count, info, NULL, NULL);
|
const char *dlid;
|
||||||
|
|
||||||
|
if (!(dlid = _build_dlid(mem, lv->lvid.s, NULL))) {
|
||||||
|
log_error("dlid build failed for %s", lv->name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _info(name, dlid, with_mknodes, with_open_count, info,
|
||||||
|
NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME Interface must cope with multiple targets */
|
/* FIXME Interface must cope with multiple targets */
|
||||||
@ -347,7 +354,7 @@ static int _status(const char *name, const char *uuid,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int _percent_run(struct dev_manager *dm, const char *name,
|
static int _percent_run(struct dev_manager *dm, const char *name,
|
||||||
const char *uuid,
|
const char *dlid,
|
||||||
const char *target_type, int wait,
|
const char *target_type, int wait,
|
||||||
struct logical_volume *lv, float *percent,
|
struct logical_volume *lv, float *percent,
|
||||||
uint32_t *event_nr)
|
uint32_t *event_nr)
|
||||||
@ -367,7 +374,7 @@ static int _percent_run(struct dev_manager *dm, const char *name,
|
|||||||
|
|
||||||
*percent = -1;
|
*percent = -1;
|
||||||
|
|
||||||
if (!(dmt = _setup_task(name, uuid, event_nr,
|
if (!(dmt = _setup_task(name, dlid, event_nr,
|
||||||
wait ? DM_DEVICE_WAITEVENT : DM_DEVICE_STATUS))) {
|
wait ? DM_DEVICE_WAITEVENT : DM_DEVICE_STATUS))) {
|
||||||
stack;
|
stack;
|
||||||
return 0;
|
return 0;
|
||||||
@ -438,13 +445,13 @@ static int _percent_run(struct dev_manager *dm, const char *name,
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _percent(struct dev_manager *dm, const char *name, const char *uuid,
|
static int _percent(struct dev_manager *dm, const char *name, const char *dlid,
|
||||||
const char *target_type, int wait,
|
const char *target_type, int wait,
|
||||||
struct logical_volume *lv, float *percent,
|
struct logical_volume *lv, float *percent,
|
||||||
uint32_t *event_nr)
|
uint32_t *event_nr)
|
||||||
{
|
{
|
||||||
if (uuid && *uuid
|
if (dlid && *dlid
|
||||||
&& _percent_run(dm, NULL, uuid, target_type, wait, lv, percent,
|
&& _percent_run(dm, NULL, dlid, target_type, wait, lv, percent,
|
||||||
event_nr))
|
event_nr))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@ -998,6 +1005,7 @@ int dev_manager_snapshot_percent(struct dev_manager *dm,
|
|||||||
struct logical_volume *lv, float *percent)
|
struct logical_volume *lv, float *percent)
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
|
const char *dlid;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Build a name for the top layer.
|
* Build a name for the top layer.
|
||||||
@ -1007,11 +1015,16 @@ int dev_manager_snapshot_percent(struct dev_manager *dm,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(dlid = _build_dlid(dm->mem, lv->lvid.s, NULL))) {
|
||||||
|
stack;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Try and get some info on this device.
|
* Try and get some info on this device.
|
||||||
*/
|
*/
|
||||||
log_debug("Getting device status percentage for %s", name);
|
log_debug("Getting device status percentage for %s", name);
|
||||||
if (!(_percent(dm, name, lv->lvid.s, "snapshot", 0, NULL, percent,
|
if (!(_percent(dm, name, dlid, "snapshot", 0, NULL, percent,
|
||||||
NULL))) {
|
NULL))) {
|
||||||
stack;
|
stack;
|
||||||
return 0;
|
return 0;
|
||||||
@ -1122,25 +1135,6 @@ static struct dev_layer *_create_layer(struct dev_manager *dm,
|
|||||||
return dl;
|
return dl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Finds the specified layer.
|
|
||||||
*/
|
|
||||||
static struct dev_layer *_lookup(struct dev_manager *dm,
|
|
||||||
const char *lvid, const char *layer)
|
|
||||||
{
|
|
||||||
char *dlid;
|
|
||||||
struct dev_layer *dl;
|
|
||||||
|
|
||||||
if (!(dlid = _build_dlid(dm->mem, lvid, layer))) {
|
|
||||||
stack;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
dl = dm_hash_lookup(dm->layers, dlid);
|
|
||||||
dm_pool_free(dm->mem, dlid);
|
|
||||||
return dl;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _expand_vanilla(struct dev_manager *dm, struct logical_volume *lv,
|
static int _expand_vanilla(struct dev_manager *dm, struct logical_volume *lv,
|
||||||
int was_origin)
|
int was_origin)
|
||||||
{
|
{
|
||||||
@ -1425,6 +1419,25 @@ static int _trace_all_marks(struct dev_manager *dm, int flag)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Finds the specified layer.
|
||||||
|
*/
|
||||||
|
static struct dev_layer *_lookup(struct dev_manager *dm,
|
||||||
|
const char *lvid, const char *layer)
|
||||||
|
{
|
||||||
|
char *dlid;
|
||||||
|
struct dev_layer *dl;
|
||||||
|
|
||||||
|
if (!(dlid = _build_dlid(dm->mem, lvid, layer))) {
|
||||||
|
stack;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
dl = dm_hash_lookup(dm->layers, dlid);
|
||||||
|
dm_pool_free(dm->mem, dlid);
|
||||||
|
return dl;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Marks the top layers, then traces these through the
|
* Marks the top layers, then traces these through the
|
||||||
* dependencies.
|
* dependencies.
|
||||||
@ -2191,7 +2204,7 @@ void dev_manager_exit(void)
|
|||||||
*/
|
*/
|
||||||
static int _add_lv_to_deptree(struct dev_manager *dm, struct deptree *dtree, struct logical_volume *lv)
|
static int _add_lv_to_deptree(struct dev_manager *dm, struct deptree *dtree, struct logical_volume *lv)
|
||||||
{
|
{
|
||||||
char *dlid, *name, *uuid;
|
char *dlid, *name;
|
||||||
struct dm_info info;
|
struct dm_info info;
|
||||||
|
|
||||||
if (!(name = build_dm_name(dm->mem, lv->vg->name, lv->name, NULL))) {
|
if (!(name = build_dm_name(dm->mem, lv->vg->name, lv->name, NULL))) {
|
||||||
@ -2199,13 +2212,13 @@ static int _add_lv_to_deptree(struct dev_manager *dm, struct deptree *dtree, str
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dlid = _build_dlid(dm->mem, lv->lvid.s, ""))) {
|
if (!(dlid = _build_dlid(dm->mem, lv->lvid.s, NULL))) {
|
||||||
stack;
|
stack;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_debug("Getting device info for %s [%s]", name, dlid);
|
log_debug("Getting device info for %s [%s]", name, dlid);
|
||||||
if (!_info(name, dlid, 0, 1, &info, dm->mem, &uuid)) {
|
if (!_info(name, dlid, 0, 1, &info, dm->mem, NULL)) {
|
||||||
stack;
|
stack;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2271,12 +2284,13 @@ int dev_manager_deactivate(struct dev_manager *dm, struct logical_volume *lv)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dlid = _build_dlid(dm->mem, lv->lvid.s, ""))) {
|
if (!(dlid = _build_dlid(dm->mem, lv->lvid.s, NULL))) {
|
||||||
log_error("dlid build failed for %s", lv->name);
|
log_error("dlid build failed for %s", lv->name);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dm_deptree_deactivate_children(dnode, dlid, ID_LEN)) {
|
/* Only process nodes with uuid of "LVM-" plus VG id. */
|
||||||
|
if (!dm_deptree_deactivate_children(dnode, dlid, ID_LEN + 4)) {
|
||||||
stack;
|
stack;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,8 @@ void dev_manager_exit(void);
|
|||||||
* (eg, an origin is created before its snapshot, but is not
|
* (eg, an origin is created before its snapshot, but is not
|
||||||
* unsuspended until the snapshot is also created.)
|
* unsuspended until the snapshot is also created.)
|
||||||
*/
|
*/
|
||||||
int dev_manager_info(const char *name, const char *uuid,
|
int dev_manager_info(struct dm_pool *mem, const char *name,
|
||||||
|
const struct logical_volume *lv,
|
||||||
int mknodes, int with_open_count, struct dm_info *info);
|
int mknodes, int with_open_count, struct dm_info *info);
|
||||||
int dev_manager_snapshot_percent(struct dev_manager *dm,
|
int dev_manager_snapshot_percent(struct dev_manager *dm,
|
||||||
struct logical_volume *lv, float *percent);
|
struct logical_volume *lv, float *percent);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user