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

report: update report_object API

Internal API change - pass single struct for both info & seg_status.
This commit is contained in:
Zdenek Kabelac 2015-01-20 13:16:41 +01:00
parent b3a348c03c
commit ae8b9baa04
5 changed files with 23 additions and 20 deletions

View File

@ -246,7 +246,7 @@ int lv_info_with_seg_status(struct cmd_context *cmd, const struct logical_volume
return 0;
}
int lv_status(struct cmd_context *cmd, const struct lv_segment *lv_seg,
struct lv_seg_status *lv_seg_status)
int use_layer, struct lv_seg_status *lv_seg_status)
{
return 0;
}
@ -716,12 +716,12 @@ int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, int use_layer,
* else 0 on failure or if device not active locally.
*/
int lv_status(struct cmd_context *cmd, const struct lv_segment *lv_seg,
struct lv_seg_status *lv_seg_status)
int use_layer, struct lv_seg_status *lv_seg_status)
{
if (!activation())
return 0;
return _lv_info(cmd, lv_seg->lv, 1, NULL, lv_seg, lv_seg_status, 0, 0);
return _lv_info(cmd, lv_seg->lv, use_layer, NULL, lv_seg, lv_seg_status, 0, 0);
}
/*

View File

@ -132,7 +132,7 @@ int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, int use_layer,
* else 0 on failure or if device not active locally.
*/
int lv_status(struct cmd_context *cmd, const struct lv_segment *lv_seg,
struct lv_seg_status *lv_seg_status);
int use_layer, struct lv_seg_status *lv_seg_status);
/*
* Returns 1 if lv_info_and_seg_status structure has been populated,

View File

@ -47,7 +47,7 @@ void report_free(void *handle);
int report_object(void *handle, const struct volume_group *vg,
const struct logical_volume *lv, const struct physical_volume *pv,
const struct lv_segment *seg, const struct pv_segment *pvseg,
const struct lvinfo *lvinfo, const struct lv_seg_status *lv_seg_status,
const struct lv_with_info_and_seg_status *lvdm,
const struct label *label);
int report_devtypes(void *handle);
int report_output(void *handle);

View File

@ -88,6 +88,7 @@ FIELD_RESERVED_VALUE(lv_read_ahead, lv_read_ahead_auto, "", &GET_TYPE_RESERVED_V
/* Reserved values for SEG fields */
FIELD_RESERVED_VALUE(cache_policy, cache_policy_undef, "", "", "", "undefined")
FIELD_RESERVED_VALUE(lv_health_status, health_undef, "", "", "", "undefined")
/* TODO the following 2 need STR_LIST support for reserved values
FIELD_RESERVED_VALUE(cache_settings, cache_settings_default, "", "default", "default")
FIELD_RESERVED_VALUE(cache_settings, cache_settings_undef, "", "undefined", "undefined") */

View File

@ -31,7 +31,7 @@ static int _vgs_single(struct cmd_context *cmd __attribute__((unused)),
const char *vg_name, struct volume_group *vg,
void *handle)
{
if (!report_object(handle, vg, NULL, NULL, NULL, NULL, NULL, NULL, NULL))
if (!report_object(handle, vg, NULL, NULL, NULL, NULL, NULL, NULL))
return_ECMD_FAILED;
check_current_backup(vg);
@ -83,7 +83,9 @@ static int _do_lvs_with_info_and_status_single(struct cmd_context *cmd,
int do_info, int do_status,
void *handle)
{
struct lv_with_info_and_seg_status status;
struct lv_with_info_and_seg_status status = {
.seg_status.type = SEG_STATUS_NONE
};
int r = ECMD_FAILED;
if (!_do_info_and_status(cmd, lv, NULL, &status, do_info, do_status)) {
@ -92,9 +94,7 @@ static int _do_lvs_with_info_and_status_single(struct cmd_context *cmd,
}
if (!report_object(handle, lv->vg, lv, NULL, NULL, NULL,
do_info ? &status.info : NULL,
do_status ? &status.seg_status : NULL,
NULL))
&status, NULL))
goto_out;
r = ECMD_PROCESSED;
@ -134,7 +134,9 @@ static int _do_segs_with_info_and_status_single(struct cmd_context *cmd,
int do_info, int do_status,
void *handle)
{
struct lv_with_info_and_seg_status status;
struct lv_with_info_and_seg_status status = {
.seg_status.type = SEG_STATUS_NONE
};
int r = ECMD_FAILED;
if (!_do_info_and_status(cmd, seg->lv, seg, &status, do_info, do_status)) {
@ -143,9 +145,7 @@ static int _do_segs_with_info_and_status_single(struct cmd_context *cmd,
}
if (!report_object(handle, seg->lv->vg, seg->lv, NULL, seg, NULL,
do_info ? &status.info : NULL,
do_status ? &status.seg_status : NULL,
NULL))
&status, NULL))
goto_out;
r = ECMD_PROCESSED;
@ -225,9 +225,6 @@ static int _do_pvsegs_sub_single(struct cmd_context *cmd,
{
int ret = ECMD_PROCESSED;
struct lv_segment *seg = pvseg->lvseg;
struct lv_with_info_and_seg_status status = {
.seg_status.type = SEG_STATUS_NONE
};
struct segment_type _freeseg_type = {
.name = "free",
@ -262,11 +259,16 @@ static int _do_pvsegs_sub_single(struct cmd_context *cmd,
.origin_list = DM_LIST_HEAD_INIT(_free_lv_segment.origin_list),
};
struct lv_with_info_and_seg_status status = {
.seg_status.type = SEG_STATUS_NONE,
.lv = &_free_logical_volume
};
if (seg)
_do_info_and_status(cmd, seg->lv, seg, &status, do_info, do_status);
if (!report_object(handle, vg, seg ? seg->lv : &_free_logical_volume, pvseg->pv,
seg ? : &_free_lv_segment, pvseg, &status.info, &status.seg_status,
seg ? : &_free_lv_segment, pvseg, &status,
pv_label(pvseg->pv))) {
ret = ECMD_FAILED;
goto_out;
@ -346,7 +348,7 @@ static int _pvsegs_with_lv_info_and_status_single(struct cmd_context *cmd,
static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
struct physical_volume *pv, void *handle)
{
if (!report_object(handle, vg, NULL, pv, NULL, NULL, NULL, NULL, NULL))
if (!report_object(handle, vg, NULL, pv, NULL, NULL, NULL, NULL))
return_ECMD_FAILED;
return ECMD_PROCESSED;
@ -355,7 +357,7 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
static int _label_single(struct cmd_context *cmd, struct label *label,
void *handle)
{
if (!report_object(handle, NULL, NULL, NULL, NULL, NULL, NULL, NULL, label))
if (!report_object(handle, NULL, NULL, NULL, NULL, NULL, NULL, label))
return_ECMD_FAILED;
return ECMD_PROCESSED;