mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
report: add lv_origin_uuid field
This commit is contained in:
parent
cb8f29d147
commit
199697accf
@ -219,21 +219,37 @@ uint32_t lv_kernel_read_ahead(const struct logical_volume *lv)
|
||||
return info.read_ahead;
|
||||
}
|
||||
|
||||
static char *_do_lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv,
|
||||
int uuid)
|
||||
{
|
||||
struct logical_volume *origin;
|
||||
|
||||
|
||||
if (lv_is_cow(lv))
|
||||
origin = origin_from_cow(lv);
|
||||
else if (lv_is_cache(lv) && first_seg(lv)->origin)
|
||||
origin = first_seg(lv)->origin;
|
||||
else if (lv_is_thin_volume(lv) && first_seg(lv)->origin)
|
||||
origin = first_seg(lv)->origin;
|
||||
else if (lv_is_thin_volume(lv) && first_seg(lv)->external_lv)
|
||||
origin = first_seg(lv)->external_lv;
|
||||
else
|
||||
return NULL;
|
||||
|
||||
if (uuid)
|
||||
return lv_uuid_dup(mem, origin);
|
||||
else
|
||||
return lv_name_dup(mem, origin);
|
||||
}
|
||||
|
||||
char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv)
|
||||
{
|
||||
if (lv_is_cow(lv))
|
||||
return lv_name_dup(mem, origin_from_cow(lv));
|
||||
return _do_lv_origin_dup(mem, lv, 0);
|
||||
}
|
||||
|
||||
if (lv_is_cache(lv) && first_seg(lv)->origin)
|
||||
return lv_name_dup(mem, first_seg(lv)->origin);
|
||||
|
||||
if (lv_is_thin_volume(lv) && first_seg(lv)->origin)
|
||||
return lv_name_dup(mem, first_seg(lv)->origin);
|
||||
|
||||
if (lv_is_thin_volume(lv) && first_seg(lv)->external_lv)
|
||||
return lv_name_dup(mem, first_seg(lv)->external_lv);
|
||||
|
||||
return NULL;
|
||||
char *lv_origin_uuid_dup(struct dm_pool *mem, const struct logical_volume *lv)
|
||||
{
|
||||
return _do_lv_origin_dup(mem, lv, 1);
|
||||
}
|
||||
|
||||
char *lv_name_dup(struct dm_pool *mem, const struct logical_volume *lv)
|
||||
|
@ -83,6 +83,8 @@ char *lv_fullname_dup(struct dm_pool *mem, const struct logical_volume *lv);
|
||||
struct logical_volume *lv_parent(const struct logical_volume *lv);
|
||||
char *lv_parent_dup(struct dm_pool *mem, const struct logical_volume *lv);
|
||||
char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv);
|
||||
char *lv_origin_uuid_dup(struct dm_pool *mem, const struct logical_volume *lv);
|
||||
|
||||
uint32_t lv_kernel_read_ahead(const struct logical_volume *lv);
|
||||
const char *lvseg_name(const struct lv_segment *seg);
|
||||
uint64_t lvseg_start(const struct lv_segment *seg);
|
||||
|
@ -63,6 +63,7 @@ FIELD(LVS, lv, SIZ, "LSize", size, 5, size64, lv_size, "Size of LV in current un
|
||||
FIELD(LVS, lv, SIZ, "MSize", lvid, 6, lvmetadatasize, lv_metadata_size, "For thin and cache pools, the size of the LV that holds the metadata.", 0)
|
||||
FIELD(LVS, lv, NUM, "#Seg", lvid, 4, lvsegcount, seg_count, "Number of segments in LV.", 0)
|
||||
FIELD(LVS, lv, STR, "Origin", lvid, 6, origin, origin, "For snapshots, the origin device of this LV.", 0)
|
||||
FIELD(LVS, lv, STR, "Origin UUID", lvid, 38, originuuid, origin_uuid, "For snapshots, the UUID of origin device of this LV.", 0)
|
||||
FIELD(LVS, lv, SIZ, "OSize", lvid, 5, originsize, origin_size, "For snapshots, the size of the origin device of this LV.", 0)
|
||||
FIELD(LVS, lv, STR_LIST, "Ancestors", lvid, 12, lvancestors, lv_ancestors, "Ancestors of this LV.", 0)
|
||||
FIELD(LVS, lv, STR_LIST, "Descendants", lvid, 12, lvdescendants, lv_descendants, "Descendants of this LV.", 0)
|
||||
|
@ -298,6 +298,8 @@ GET_LV_NUM_PROPERTY_FN(seg_count, dm_list_size(&lv->segments))
|
||||
#define _seg_count_set prop_not_implemented_set
|
||||
GET_LV_STR_PROPERTY_FN(origin, lv_origin_dup(lv->vg->vgmem, lv))
|
||||
#define _origin_set prop_not_implemented_set
|
||||
GET_LV_STR_PROPERTY_FN(origin_uuid, lv_origin_uuid_dup(lv->vg->vgmem, lv))
|
||||
#define _origin_uuid_set prop_not_implemented_set
|
||||
GET_LV_NUM_PROPERTY_FN(origin_size, (SECTOR_SIZE * lv_origin_size(lv)))
|
||||
#define _origin_size_set prop_not_implemented_set
|
||||
#define _lv_ancestors_set prop_not_implemented_set
|
||||
|
@ -1709,26 +1709,44 @@ static int _lvdmpath_disp(struct dm_report *rh, struct dm_pool *mem,
|
||||
return _field_set_value(field, repstr, NULL);
|
||||
}
|
||||
|
||||
static int _do_origin_disp(struct dm_report *rh, struct dm_pool *mem,
|
||||
struct dm_report_field *field,
|
||||
const void *data, void *private,
|
||||
int uuid)
|
||||
{
|
||||
const struct logical_volume *lv = (const struct logical_volume *) data;
|
||||
const struct lv_segment *seg = first_seg(lv);
|
||||
struct logical_volume *origin;
|
||||
|
||||
if (lv_is_cow(lv))
|
||||
origin = origin_from_cow(lv);
|
||||
else if (lv_is_cache(lv) && !lv_is_pending_delete(lv))
|
||||
origin = seg_lv(seg, 0);
|
||||
else if (lv_is_thin_volume(lv) && first_seg(lv)->origin)
|
||||
origin = first_seg(lv)->origin;
|
||||
else if (lv_is_thin_volume(lv) && first_seg(lv)->external_lv)
|
||||
origin = first_seg(lv)->external_lv;
|
||||
else
|
||||
return _field_set_value(field, "", NULL);
|
||||
|
||||
if (uuid)
|
||||
return _uuid_disp(rh, mem, field, &origin->lvid.id[1], private);
|
||||
else
|
||||
return _lvname_disp(rh, mem, field, origin, private);
|
||||
}
|
||||
|
||||
static int _origin_disp(struct dm_report *rh, struct dm_pool *mem,
|
||||
struct dm_report_field *field,
|
||||
const void *data, void *private)
|
||||
{
|
||||
const struct logical_volume *lv = (const struct logical_volume *) data;
|
||||
const struct lv_segment *seg = first_seg(lv);
|
||||
return _do_origin_disp(rh, mem, field, data, private, 0);
|
||||
}
|
||||
|
||||
if (lv_is_cow(lv))
|
||||
return _lvname_disp(rh, mem, field, origin_from_cow(lv), private);
|
||||
|
||||
if (lv_is_cache(lv) && !lv_is_pending_delete(lv))
|
||||
return _lvname_disp(rh, mem, field, seg_lv(seg, 0), private);
|
||||
|
||||
if (lv_is_thin_volume(lv) && first_seg(lv)->origin)
|
||||
return _lvname_disp(rh, mem, field, first_seg(lv)->origin, private);
|
||||
|
||||
if (lv_is_thin_volume(lv) && first_seg(lv)->external_lv)
|
||||
return _lvname_disp(rh, mem, field, first_seg(lv)->external_lv, private);
|
||||
|
||||
return _field_set_value(field, "", NULL);
|
||||
static int _originuuid_disp(struct dm_report *rh, struct dm_pool *mem,
|
||||
struct dm_report_field *field,
|
||||
const void *data, void *private)
|
||||
{
|
||||
return _do_origin_disp(rh, mem, field, data, private, 1);
|
||||
}
|
||||
|
||||
static int _find_ancestors(struct _str_list_append_baton *ancestors,
|
||||
|
Loading…
Reference in New Issue
Block a user