diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2019-01-21 00:24:30 +0100 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2019-01-21 12:53:16 +0100 |
commit | 3d367f3348da072360c9dd251d981e627c8444ff (patch) | |
tree | 9cc3060564bc0393db1df369eb4aa4e45ed106b2 | |
parent | cbadf3d3704f1153b2919392ab8259b9a798a221 (diff) | |
download | lvm2-3d367f3348da072360c9dd251d981e627c8444ff.tar.gz |
vdo: add simple wrapper for getting pool percentage
Just like with i.e. thins provide simple function for
getting percentage of VDO Pool usage (uses existing
status function).
-rw-r--r-- | lib/activate/activate.c | 13 | ||||
-rw-r--r-- | lib/activate/activate.h | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/activate/activate.c b/lib/activate/activate.c index 678dec9e8..072e84ef1 100644 --- a/lib/activate/activate.c +++ b/lib/activate/activate.c @@ -1387,6 +1387,19 @@ out: return r; } +int lv_vdo_pool_percent(const struct logical_volume *lv, dm_percent_t *percent) +{ + struct lv_status_vdo *vdo_status; + + if (!lv_vdo_pool_status(lv, 0, &vdo_status)) + return_0; + + *percent = vdo_status->usage; + dm_pool_destroy(vdo_status->mem); + + return 1; +} + static int _lv_active(struct cmd_context *cmd, const struct logical_volume *lv) { struct lvinfo info; diff --git a/lib/activate/activate.h b/lib/activate/activate.h index aa5410c39..dc13f176a 100644 --- a/lib/activate/activate.h +++ b/lib/activate/activate.h @@ -198,6 +198,7 @@ int lv_thin_pool_transaction_id(const struct logical_volume *lv, 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); +int lv_vdo_pool_percent(const struct logical_volume *lv, dm_percent_t *percent); /* * Return number of LVs in the VG that are active. |