1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

dev_manager: add dev_manager_vdo_pool_status

This commit is contained in:
Zdenek Kabelac 2018-06-29 11:15:54 +02:00
parent 493ffe7a0f
commit 4f708e8709
4 changed files with 106 additions and 0 deletions

View File

@ -1313,6 +1313,46 @@ int lv_thin_device_id(const struct logical_volume *lv, uint32_t *device_id)
return r;
}
/*
* lv_vdo_pool_status obtains status information about VDO pool
*
* If the 'params' string has been already retrieved, use it.
* If the mempool already exists, use it.
*
*/
int lv_vdo_pool_status(const struct logical_volume *lv, int flush,
struct lv_status_vdo **vdo_status)
{
int r = 0;
struct dev_manager *dm;
struct lv_status_vdo *status;
char *params;
if (!lv_info(lv->vg->cmd, lv, 0, NULL, 0, 0))
return 0;
log_debug_activation("Checking VDO pool status for LV %s.",
display_lvname(lv));
if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, !lv_is_pvmove(lv))))
return_0;
if (!dev_manager_vdo_pool_status(dm, lv, flush, &params, &status))
goto_out;
if (!parse_vdo_pool_status(status->mem, lv, params, status))
goto_out;
/* User is responsible to dm_pool_destroy memory pool! */
*vdo_status = status;
r = 1;
out:
if (!r)
dev_manager_destroy(dm);
return r;
}
static int _lv_active(struct cmd_context *cmd, const struct logical_volume *lv)
{
struct lvinfo info;

View File

@ -193,6 +193,8 @@ int lv_thin_percent(const struct logical_volume *lv, int mapped,
int lv_thin_pool_transaction_id(const struct logical_volume *lv,
uint64_t *transaction_id);
int lv_thin_device_id(const struct logical_volume *lv, uint32_t *device_id);
int lv_vdo_pool_status(const struct logical_volume *lv, int flush,
struct lv_status_vdo **status);
/*
* Return number of LVs in the VG that are active.

View File

@ -1640,6 +1640,65 @@ out:
return r;
}
int dev_manager_vdo_pool_status(struct dev_manager *dm,
const struct logical_volume *lv,
int flush,
char **vdo_params,
struct lv_status_vdo **vdo_status)
{
struct lv_status_vdo *status;
const char *dlid;
struct dm_info info;
uint64_t start, length;
struct dm_task *dmt = NULL;
char *type = NULL;
char *params = NULL;
int r = 0;
*vdo_params = NULL;
*vdo_status = NULL;
if (!(status = dm_pool_zalloc(dm->mem, sizeof(struct lv_status_vdo)))) {
log_error("Cannot allocate VDO status structure.");
return 0;
}
if (!(dlid = build_dm_uuid(dm->mem, lv, lv_layer(lv))))
return_0;
if (!(dmt = _setup_task_run(DM_DEVICE_STATUS, &info, NULL, dlid, 0, 0, 0, 0, flush, 0)))
return_0;
if (!info.exists)
goto_out;
if (dm_get_next_target(dmt, NULL, &start, &length, &type, &params)) {
log_error("More then one table line found for %s.",
display_lvname(lv));
goto out;
}
if (!type || strcmp(type, TARGET_NAME_VDO)) {
log_error("Expected %s segment type but got %s instead.",
TARGET_NAME_VDO, type ? type : "NULL");
goto out;
}
if (!(*vdo_params = dm_pool_strdup(dm->mem, params))) {
log_error("Cannot duplicate VDO status params.");
goto out;
}
status->mem = dm->mem;
*vdo_status = status;
r = 1;
out:
dm_task_destroy(dmt);
return r;
}
/*************************/
/* NEW CODE STARTS HERE */

View File

@ -79,6 +79,11 @@ int dev_manager_thin_percent(struct dev_manager *dm,
int dev_manager_thin_device_id(struct dev_manager *dm,
const struct logical_volume *lv,
uint32_t *device_id);
int dev_manager_vdo_pool_status(struct dev_manager *dm,
const struct logical_volume *lv,
int flush,
char **vdo_params,
struct lv_status_vdo **vdo_status);
int dev_manager_suspend(struct dev_manager *dm, const struct logical_volume *lv,
struct lv_activate_opts *laopts, int lockfs, int flush_required);
int dev_manager_activate(struct dev_manager *dm, const struct logical_volume *lv,