1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

report: Add lv_parent field.

Only defined for thin/cache/raid/mirror at this stage as it
relies on get_only_segment_using_this_lv().
This commit is contained in:
Alasdair G Kergon 2014-07-03 23:49:34 +01:00
parent 1e1c2769a7
commit 137ed3081a
8 changed files with 38 additions and 3 deletions

View File

@ -1,7 +1,7 @@
Version 2.02.108 -
=================================
Fix VG component of lvid in vgsplit/vgmerge and check in vg_validate.
Add lv_full_name and lv_dm_path fields to reports.
Add lv_full_name, lv_parent and lv_dm_path fields to reports.
Change lv_path field to suppress devices that never appear in /dev/vg.
Postpone thin pool lvconvert prompts (2.02.107).
Require --yes option to skip prompt to lvconvert thin pool chunksize.

View File

@ -231,6 +231,24 @@ char *lv_fullname_dup(struct dm_pool *mem, const struct logical_volume *lv)
return dm_pool_strdup(mem, lvfullname);
}
char *lv_parent_dup(struct dm_pool *mem, const struct logical_volume *lv)
{
const char *parent = "";
if (lv_is_visible(lv))
;
else if (lv_is_mirror_image(lv) || lv_is_mirror_log(lv))
parent = get_only_segment_using_this_lv(lv)->lv->name;
else if (lv_is_raid_image(lv) || lv_is_raid_metadata(lv))
parent = get_only_segment_using_this_lv(lv)->lv->name;
else if (lv_is_cache_pool_data(lv) || lv_is_cache_pool_metadata(lv))
parent = get_only_segment_using_this_lv(lv)->lv->name;
else if (lv_is_thin_pool_data(lv) || lv_is_thin_pool_metadata(lv))
parent = get_only_segment_using_this_lv(lv)->lv->name;
return dm_pool_strdup(mem, parent);
}
char *lv_modules_dup(struct dm_pool *mem, const struct logical_volume *lv)
{
struct dm_list *modules;

View File

@ -73,6 +73,7 @@ char *lv_pool_lv_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_modules_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_name_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_fullname_dup(struct dm_pool *mem, 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);
uint32_t lv_kernel_read_ahead(const struct logical_volume *lv);
uint64_t lvseg_start(const struct lv_segment *seg);

View File

@ -342,7 +342,7 @@ int remove_seg_from_segs_using_this_lv(struct logical_volume *lv,
*
* In general, walk through lv->segs_using_this_lv.
*/
struct lv_segment *get_only_segment_using_this_lv(struct logical_volume *lv)
struct lv_segment *get_only_segment_using_this_lv(const struct logical_volume *lv)
{
struct seg_list *sl;

View File

@ -428,7 +428,7 @@ int lv_split_segment(struct logical_volume *lv, uint32_t le);
*/
int add_seg_to_segs_using_this_lv(struct logical_volume *lv, struct lv_segment *seg);
int remove_seg_from_segs_using_this_lv(struct logical_volume *lv, struct lv_segment *seg);
struct lv_segment *get_only_segment_using_this_lv(struct logical_volume *lv);
struct lv_segment *get_only_segment_using_this_lv(const struct logical_volume *lv);
int for_each_sub_lv(struct logical_volume *lv,
int (*fn)(struct logical_volume *lv, void *data),

View File

@ -33,6 +33,7 @@ FIELD(LVS, lv, STR, "LV", lvid, 4, lvname, lv_name, "Name. LVs created for inte
FIELD(LVS, lv, STR, "LV", lvid, 4, lvfullname, lv_full_name, "Full name of LV including its VG, namely VG/LV.", 0)
FIELD(LVS, lv, STR, "Path", lvid, 4, lvpath, lv_path, "Full pathname for LV. Blank for internal LVs.", 0)
FIELD(LVS, lv, STR, "DMPath", lvid, 6, lvdmpath, lv_dm_path, "Internal device-mapper pathname for LV (in /dev/mapper directory).", 0)
FIELD(LVS, lv, STR, "Parent", lvid, 6, lvparent, lv_parent, "For LVs that are components of another LV, the parent LV.", 0)
FIELD(LVS, lv, STR, "Attr", lvid, 4, lvstatus, lv_attr, "Various attributes - see man page.", 0)
FIELD(LVS, lv, STR, "Active", lvid, 6, lvactive, lv_active, "Active state of the LV.", 0)
FIELD(LVS, lv, NUM, "Maj", major, 3, int32, lv_major, "Persistent major number or -1 if not persistent.", 0)

View File

@ -170,6 +170,8 @@ GET_LV_STR_PROPERTY_FN(lv_path, lv_path_dup(lv->vg->vgmem, lv))
#define _lv_path_set prop_not_implemented_set
GET_LV_STR_PROPERTY_FN(lv_dm_path, lv_dmpath_dup(lv->vg->vgmem, lv))
#define _lv_dm_path_set prop_not_implemented_set
GET_LV_STR_PROPERTY_FN(lv_parent, lv_parent_dup(lv->vg->vgmem, lv))
#define _lv_parent_set prop_not_implemented_set
GET_LV_STR_PROPERTY_FN(lv_attr, lv_attr_dup(lv->vg->vgmem, lv))
#define _lv_attr_set prop_not_implemented_set
GET_LV_NUM_PROPERTY_FN(lv_major, lv->major)

View File

@ -324,6 +324,19 @@ static int _lvfullname_disp(struct dm_report *rh, struct dm_pool *mem,
return _field_set_value(field, repstr, NULL);
}
static int _lvparent_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private __attribute__((unused)))
{
const struct logical_volume *lv = (const struct logical_volume *) data;
char *repstr;
if (!(repstr = lv_parent_dup(mem, lv)))
return_0;
return _field_set_value(field, repstr, NULL);
}
static int _datalv_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
struct dm_report_field *field,
const void *data, void *private __attribute__((unused)))