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

report: add separate LVSINFOSTATUS field type for info+status combined fields

Add separate LVSINFOSTATUS field type for fields which display both
dm info-like and dm status-like information.

The internal interface is there with the introduction of LVSSTATUS
field type which can cope with the combination of LVSSTATUS
and LVSINFO field types (several fields).

However, till now, we considered that *single* field can display
either LVSINFO or LVSSTATUS, but not both at the same time.

Till now, we haven't had single field which needs both - hence
add LVSINFOSTATUS field type for such fields as we currently
need this for the lv_attr field which requires combination of
info and status.

This patch just adds interface for an ability to register such fields
(the code that copes with this is already in).
This commit is contained in:
Peter Rajnoha 2015-01-20 16:02:48 +01:00
parent 75b786c5ef
commit 158e998876
4 changed files with 17 additions and 13 deletions

View File

@ -38,7 +38,7 @@ FIELD(LVS, lv, STR, "LV", lvid, 4, lvfullname, lv_full_name, "Full name of LV in
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(LVSINFO, lv, STR, "Attr", lvid, 4, lvstatus, lv_attr, "Various attributes - see man page.", 0)
FIELD(LVSINFOSTATUS, lv, STR, "Attr", lvid, 4, lvstatus, lv_attr, "Various attributes - see man page.", 0)
FIELD(LVS, lv, STR_LIST, "Layout", lvid, 10, lvlayout, lv_layout, "LV layout.", 0)
FIELD(LVS, lv, STR_LIST, "Role", lvid, 10, lvrole, lv_role, "LV role.", 0)
FIELD(LVS, lv, BIN, "InitImgSync", lvid, 10, lvinitialimagesync, lv_initial_image_sync, "Set if mirror/RAID images underwent initial resynchronization.", 0)

View File

@ -1904,6 +1904,7 @@ static const struct dm_report_object_type _report_types[] = {
{ LVS, "Logical Volume", "lv_", _obj_get_lv },
{ LVSINFO, "Logical Volume Device Info", "lv_", _obj_get_lv_with_info_and_seg_status },
{ LVSSTATUS, "Logical Volume Device Status", "lv_", _obj_get_lv_with_info_and_seg_status },
{ LVSINFOSTATUS, "Logical Volume Device Info and Status Combined", "lv_", _obj_get_lv_with_info_and_seg_status },
{ PVS, "Physical Volume", "pv_", _obj_get_pv },
{ LABEL, "Physical Volume Label", "pv_", _obj_get_label },
{ SEGS, "Logical Volume Segment", "seg_", _obj_get_seg },

View File

@ -24,13 +24,14 @@ typedef enum {
LVS = 1,
LVSINFO = 2,
LVSSTATUS = 4,
PVS = 8,
VGS = 16,
SEGS = 32,
SEGSSTATUS = 64,
PVSEGS = 128,
LABEL = 256,
DEVTYPES = 512
LVSINFOSTATUS = 8,
PVS = 16,
VGS = 32,
SEGS = 64,
SEGSSTATUS = 128,
PVSEGS = 256,
LABEL = 512,
DEVTYPES = 1024
} report_type_t;
struct field;

View File

@ -523,17 +523,17 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
return_ECMD_FAILED;
/* Do we need to acquire LV device info in addition? */
lv_info_needed = (report_type & LVSINFO) ? 1 : 0;
lv_info_needed = (report_type & (LVSINFO | LVSINFOSTATUS)) ? 1 : 0;
/* Do we need to acquire LV device status in addition? */
lv_segment_status_needed = (report_type & (SEGSSTATUS | LVSSTATUS)) ? 1 : 0;
lv_segment_status_needed = (report_type & (SEGSSTATUS | LVSSTATUS | LVSINFOSTATUS)) ? 1 : 0;
/* Ensure options selected are compatible */
if (report_type & (SEGS | SEGSSTATUS))
report_type |= LVS;
if (report_type & PVSEGS)
report_type |= PVS;
if ((report_type & (LVS | LVSINFO | LVSSTATUS)) && (report_type & (PVS | LABEL)) && !args_are_pvs) {
if ((report_type & (LVS | LVSINFO | LVSSTATUS | LVSINFOSTATUS)) && (report_type & (PVS | LABEL)) && !args_are_pvs) {
log_error("Can't report LV and PV fields at the same time");
dm_report_free(report_handle);
return ECMD_FAILED;
@ -541,7 +541,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
/* Change report type if fields specified makes this necessary */
if ((report_type & PVSEGS) ||
((report_type & (PVS | LABEL)) && (report_type & (LVS | LVSINFO | LVSSTATUS))))
((report_type & (PVS | LABEL)) && (report_type & (LVS | LVSINFO | LVSSTATUS | LVSINFOSTATUS))))
report_type = PVSEGS;
else if ((report_type & LABEL) && (report_type & VGS))
report_type = PVS;
@ -549,7 +549,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
report_type = PVS;
else if (report_type & (SEGS | SEGSSTATUS))
report_type = SEGS;
else if (report_type & (LVS | LVSINFO | LVSSTATUS))
else if (report_type & (LVS | LVSINFO | LVSSTATUS | LVSINFOSTATUS))
report_type = LVS;
/*
@ -574,6 +574,8 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
/* fall through */
case LVSSTATUS:
/* fall through */
case LVSINFOSTATUS:
/* fall through */
case LVS:
r = process_each_lv(cmd, argc, argv, 0, report_handle,
lv_info_needed && !lv_segment_status_needed ? &_lvs_with_info_single :