master - args: new options for vdo segment
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=96e9929f2f2d23d2113...
Commit: 96e9929f2f2d23d2113920efd67431d0272aba5f
Parent: a821b88a439dd2d0f22e5bb1c4d6671ab517198b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jun 29 11:31:08 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 9 15:28:35 2018 +0200
args: new options for vdo segment
Introduce new options usable with commands supporting VDO:
--compression, --deduplication, --vdo, --vdopool
---
tools/args.h | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/tools/args.h b/tools/args.h
index e574bc7..0d4d3bc 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -125,6 +125,10 @@ arg(commandprofile_ARG, '\0', "commandprofile", string_VAL, 0, 0,
"The command profile to use for command configuration.\n"
"See \\fBlvm.conf\\fP(5) for more information about profiles.\n")
+arg(compression_ARG, '\0', "compression", bool_VAL, 0, 0,
+ "Controls whether compression is enabled or disable for VDO volume.\n"
+ "See \\fBlvmvdo\\fP(7) for more information about VDO usage.\n")
+
arg(config_ARG, '\0', "config", string_VAL, 0, 0,
"Config settings for the command. These override lvm.conf settings.\n"
"The String arg uses the same format as lvm.conf,\n"
@@ -178,6 +182,10 @@ arg(dataalignment_ARG, '\0', "dataalignment", sizekb_VAL, 0, 0,
arg(dataalignmentoffset_ARG, '\0', "dataalignmentoffset", sizekb_VAL, 0, 0,
"Shift the start of the data area by this additional offset.\n")
+arg(deduplication_ARG, '\0', "deduplication", bool_VAL, 0, 0,
+ "Controls whether deduplication is enabled or disable for VDO volume.\n"
+ "See \\fBlvmvdo\\fP(7) for more information about VDO usage.\n")
+
arg(deltag_ARG, '\0', "deltag", tag_VAL, ARG_GROUPABLE, 0,
"Deletes a tag from a PV, VG or LV. This option can be repeated to delete\n"
"multiple tags at once. See \\fBlvm\\fP(8) for information about tags.\n")
@@ -757,6 +765,15 @@ arg(validate_ARG, '\0', "validate", 0, 0, 0,
"merged configuration tree, also use --mergedconfig.\n"
"The validation is done even if lvm.conf config/checks is disabled.\n")
+arg(vdo_ARG, '\0', "vdo", 0, 0, 0,
+ "Specifies the command is handling VDO LV.\n"
+ "See --type vdo.\n"
+ "See \\fBlvmvdo\\fP(7) for more information about VDO usage.\n")
+
+arg(vdopool_ARG, '\0', "vdopool", lv_VAL, 0, 0,
+ "The name of a VDO pool LV.\n"
+ "See \\fBlvmvdo\\fP(7) for more information about VDO usage.\n")
+
arg(version_ARG, '\0', "version", 0, 0, 0,
"Display version information.\n")
5 years, 8 months
master - toollib: support new command rules queries
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a821b88a439dd2d0f22...
Commit: a821b88a439dd2d0f22e5bb1c4d6671ab517198b
Parent: 44c99a882299b4a6d6d675df3db5a6ef481fa2a0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jul 2 10:50:41 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 9 15:28:35 2018 +0200
toollib: support new command rules queries
Add: LV_vdo, LV_vdopool, LV_vdopooldata
---
tools/lv_types.h | 3 +++
tools/toollib.c | 12 ++++++++++++
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/tools/lv_types.h b/tools/lv_types.h
index bd4666e..494776b 100644
--- a/tools/lv_types.h
+++ b/tools/lv_types.h
@@ -20,6 +20,9 @@ lvt(thin_LVT, "thin", NULL)
lvt(thinpool_LVT, "thinpool", NULL)
lvt(cache_LVT, "cache", NULL)
lvt(cachepool_LVT, "cachepool", NULL)
+lvt(vdo_LVT, "vdo", NULL)
+lvt(vdopool_LVT, "vdopool", NULL)
+lvt(vdopooldata_LVT, "vdopooldata", NULL)
lvt(mirror_LVT, "mirror", NULL)
lvt(raid_LVT, "raid", NULL) /* any raid type */
lvt(raid0_LVT, "raid0", NULL)
diff --git a/tools/toollib.c b/tools/toollib.c
index f0cf78e..62e1ecf 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -2544,6 +2544,12 @@ static int _lv_is_type(struct cmd_context *cmd, struct logical_volume *lv, int l
return lv_is_cache(lv);
case cachepool_LVT:
return lv_is_cache_pool(lv);
+ case vdo_LVT:
+ return lv_is_vdo(lv);
+ case vdopool_LVT:
+ return lv_is_vdo_pool(lv);
+ case vdopooldata_LVT:
+ return lv_is_vdo_pool_data(lv);
case mirror_LVT:
return lv_is_mirror(lv);
case raid_LVT:
@@ -2594,6 +2600,12 @@ int get_lvt_enum(struct logical_volume *lv)
return cache_LVT;
if (lv_is_cache_pool(lv))
return cachepool_LVT;
+ if (lv_is_vdo(lv))
+ return vdo_LVT;
+ if (lv_is_vdo_pool(lv))
+ return vdopool_LVT;
+ if (lv_is_vdo_pool_data(lv))
+ return vdopooldata_LVT;
if (lv_is_mirror(lv))
return mirror_LVT;
if (lv_is_raid(lv))
5 years, 8 months
master - vdo: data percentage
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=44c99a882299b4a6d6d...
Commit: 44c99a882299b4a6d6d675df3db5a6ef481fa2a0
Parent: 5807993bbfedfc7a7c58de082c92811109c02ea0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 4 23:17:38 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 9 15:28:35 2018 +0200
vdo: data percentage
Display percentage of used virtual size of vdo-pool volume.
---
lib/activate/activate.c | 15 +++++++++++++++
lib/metadata/lv.c | 5 ++++-
lib/metadata/metadata-exported.h | 1 +
lib/metadata/vdo_manip.c | 4 ++++
4 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 0435139..28d67b4 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -798,6 +798,21 @@ int lv_info_with_seg_status(struct cmd_context *cmd,
lv_seg = find_snapshot(lv);
}
+ if (lv_is_vdo(lv)) {
+ if (!_lv_info(cmd, lv, 0, &status->info, NULL, NULL,
+ with_open_count, with_read_ahead))
+ return_0;
+ if (status->info.exists) {
+ /* Status for VDO pool */
+ (void) _lv_info(cmd, seg_lv(lv_seg, 0), 1, NULL,
+ first_seg(seg_lv(lv_seg, 0)),
+ &status->seg_status, 0, 0);
+ /* Use VDO pool segtype result for VDO segtype */
+ status->seg_status.seg = lv_seg;
+ }
+ return 1;
+ }
+
return _lv_info(cmd, lv, 0, &status->info, lv_seg, &status->seg_status,
with_open_count, with_read_ahead);
}
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index d8417bc..9c8b028 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -451,7 +451,10 @@ dm_percent_t lvseg_percent_with_info_and_seg_status(const struct lv_with_info_an
}
break;
case SEG_STATUS_VDO_POOL:
- p = s->vdo_pool.usage;
+ if (seg_is_vdo_pool(lvdm->seg_status.seg))
+ p = s->vdo_pool.usage;
+ else
+ p = s->vdo_pool.data_usage;
break;
default:
p = DM_PERCENT_INVALID;
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index b6ac4cb..92def2b 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1257,6 +1257,7 @@ struct lv_status_vdo {
uint64_t logical_blocks_used; /* grabbed from /sys/kvdo */
dm_percent_t usage;
dm_percent_t saving;
+ dm_percent_t data_usage;
};
const char *get_vdo_compression_state_name(enum dm_vdo_compression_state state);
diff --git a/lib/metadata/vdo_manip.c b/lib/metadata/vdo_manip.c
index 5801a1b..1286e84 100644
--- a/lib/metadata/vdo_manip.c
+++ b/lib/metadata/vdo_manip.c
@@ -141,6 +141,7 @@ int parse_vdo_pool_status(struct dm_pool *mem, const struct logical_volume *vdo_
status->usage = DM_PERCENT_INVALID;
status->saving = DM_PERCENT_INVALID;
+ status->data_usage = DM_PERCENT_INVALID;
if (!(dm_name = dm_build_dm_name(mem, vdo_pool_lv->vg->name,
vdo_pool_lv->name, NULL))) {
@@ -170,6 +171,9 @@ int parse_vdo_pool_status(struct dm_pool *mem, const struct logical_volume *vdo_
result.status->total_blocks);
status->saving = dm_make_percent(status->logical_blocks_used - status->data_blocks_used,
status->logical_blocks_used);
+ status->data_usage = dm_make_percent(status->data_blocks_used * DM_VDO_BLOCK_SIZE,
+ first_seg(vdo_pool_lv)->vdo_pool_virtual_extents *
+ (uint64_t) vdo_pool_lv->vg->extent_size);
}
return 1;
5 years, 8 months
master - display: basic vdo segment lvdisplay and lvs support
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5807993bbfedfc7a7c5...
Commit: 5807993bbfedfc7a7c58de082c92811109c02ea0
Parent: 4f708e870974fb9414ce7f1b7d277f14af6c2d38
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Jul 1 15:58:01 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 9 15:28:35 2018 +0200
display: basic vdo segment lvdisplay and lvs support
Print some basic info about vdo segment.
'lvdisplay -m' ATM shows the most.
lvs shows usage percentage.
---
lib/display/display.c | 22 ++++++++++++++++++++++
lib/metadata/lv.c | 24 +++++++++++++++++++-----
lib/vdo/vdo.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 85 insertions(+), 5 deletions(-)
diff --git a/lib/display/display.c b/lib/display/display.c
index c6f855b..055fc69 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -411,6 +411,7 @@ int lvdisplay_full(struct cmd_context *cmd,
int thin_active = 0;
dm_percent_t thin_percent;
struct lv_status_cache *cache_status = NULL;
+ struct lv_status_vdo *vdo_status = NULL;
if (lv_is_historical(lv))
return _lvdisplay_historical_full(cmd, lv);
@@ -529,6 +530,27 @@ int lvdisplay_full(struct cmd_context *cmd,
seg = first_seg(lv);
log_print("LV Pool metadata %s", seg->metadata_lv->name);
log_print("LV Pool data %s", seg_lv(seg, 0)->name);
+ } else if (lv_is_vdo_pool(lv)) {
+ seg = first_seg(lv);
+ log_print("LV VDO Pool data %s", seg_lv(seg, 0)->name);
+ if (inkernel && lv_vdo_pool_status(lv, 0, &vdo_status)) { /* FIXME: flush option? */
+ log_print("LV VDO Pool usage %s%%",
+ display_percent(cmd, vdo_status->usage));
+ log_print("LV VDO Pool saving %s%%",
+ display_percent(cmd, vdo_status->saving));
+ log_print("LV VDO Operating mode %s",
+ get_vdo_operating_mode_name(vdo_status->vdo->operating_mode));
+ log_print("LV VDO Index state %s",
+ get_vdo_index_state_name(vdo_status->vdo->index_state));
+ log_print("LV VDO Compression st %s",
+ get_vdo_compression_state_name(vdo_status->vdo->compression_state));
+ log_print("LV VDO Used size %s",
+ display_size(cmd, vdo_status->vdo->used_blocks * DM_VDO_BLOCK_SIZE));
+ dm_pool_destroy(vdo_status->mem);
+ }
+ } else if (lv_is_vdo(lv)) {
+ seg = first_seg(lv);
+ log_print("LV VDO Pool name %s", seg_lv(seg, 0)->name);
}
if (inkernel && info.suspended)
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index cf6fafa..d8417bc 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -450,6 +450,9 @@ dm_percent_t lvseg_percent_with_info_and_seg_status(const struct lv_with_info_an
}
}
break;
+ case SEG_STATUS_VDO_POOL:
+ p = s->vdo_pool.usage;
+ break;
default:
p = DM_PERCENT_INVALID;
}
@@ -695,11 +698,13 @@ char *lv_mirror_log_uuid_dup(struct dm_pool *mem, const struct logical_volume *l
struct logical_volume *lv_pool_lv(const struct logical_volume *lv)
{
- struct lv_segment *seg = (lv_is_thin_volume(lv) || lv_is_cache(lv)) ?
- first_seg(lv) : NULL;
- struct logical_volume *pool_lv = seg ? seg->pool_lv : NULL;
+ if (lv_is_thin_volume(lv) || lv_is_cache(lv))
+ return first_seg(lv)->pool_lv;
+
+ if (lv_is_vdo(lv))
+ return seg_lv(first_seg(lv), 0);
- return pool_lv;
+ return NULL;
}
static char *_do_lv_pool_lv_dup(struct dm_pool *mem, const struct logical_volume *lv,
@@ -728,7 +733,9 @@ char *lv_pool_lv_uuid_dup(struct dm_pool *mem, const struct logical_volume *lv)
struct logical_volume *lv_data_lv(const struct logical_volume *lv)
{
- struct lv_segment *seg = (lv_is_thin_pool(lv) || lv_is_cache_pool(lv)) ?
+ struct lv_segment *seg = (lv_is_cache_pool(lv) ||
+ lv_is_thin_pool(lv) ||
+ lv_is_vdo_pool(lv)) ?
first_seg(lv) : NULL;
struct logical_volume *data_lv = seg ? seg_lv(seg, 0) : NULL;
@@ -1181,6 +1188,13 @@ char *lv_attr_dup_with_info_and_seg_status(struct dm_pool *mem, const struct lv_
else if (lv_is_thin_volume(lv))
repstr[0] = lv_is_merging_origin(lv) ?
'O' : (lv_is_merging_thin_snapshot(lv) ? 'S' : 'V');
+ //else if (lv_is_vdo(lv))
+ // repstr[0] = 'V'; // TODO: Show 'V' like Virtual Thin ?
+ // ATM shows 'v' as virtual target just like: error, zero
+ else if (lv_is_vdo_pool(lv))
+ repstr[0] = 'd';
+ else if (lv_is_vdo_pool_data(lv))
+ repstr[0] = 'D';
else if (lv_is_virtual(lv))
repstr[0] = 'v';
else if (lv_is_thin_pool(lv))
diff --git a/lib/vdo/vdo.c b/lib/vdo/vdo.c
index a32ffcd..80ddcfd 100644
--- a/lib/vdo/vdo.c
+++ b/lib/vdo/vdo.c
@@ -66,6 +66,11 @@ static const char *_vdo_name(const struct lv_segment *seg)
return SEG_TYPE_NAME_VDO;
}
+static void _vdo_display(const struct lv_segment *seg)
+{
+ display_stripe(seg, 0, " ");
+}
+
static int _vdo_text_import(struct lv_segment *seg,
const struct dm_config_node *n,
struct dm_hash_table *pv_hash __attribute__((unused)))
@@ -150,6 +155,43 @@ static const char *_vdo_pool_name(const struct lv_segment *seg)
return SEG_TYPE_NAME_VDO_POOL;
}
+static void _vdo_pool_display(const struct lv_segment *seg)
+{
+ struct cmd_context *cmd = seg->lv->vg->cmd;
+ const struct dm_vdo_target_params *vtp = &seg->vdo_params;
+
+ log_print(" Virtual size\t%s", display_size(cmd, get_vdo_pool_virtual_size(seg)));
+ log_print(" Header size\t\t%s", display_size(cmd, seg->vdo_pool_header_size));
+
+ _print_yes_no("Compression\t", vtp->use_compression);
+ _print_yes_no("Deduplication", vtp->use_deduplication);
+ _print_yes_no("Emulate 512 sectors", vtp->emulate_512_sectors);
+
+ log_print(" Block map cache sz\t%s",
+ display_size(cmd, vtp->block_map_cache_size_mb * UINT64_C(2 * 1024)));
+ log_print(" Block map period\t%u", vtp->block_map_period);
+
+ _print_yes_no("Sparse index", vtp->use_sparse_index);
+
+ log_print(" Index memory size\t%s",
+ display_size(cmd, vtp->index_memory_size_mb * UINT64_C(2 * 1024)));
+
+ _print_yes_no("Using read cache", vtp->use_read_cache);
+
+ log_print(" Read cache size\t%s",
+ display_size(cmd, vtp->read_cache_size_mb * UINT64_C(2 * 1024)));
+ log_print(" Slab size\t\t%s",
+ display_size(cmd, vtp->slab_size_mb * UINT64_C(2 * 1024)));
+
+ log_print(" # Ack threads\t%u", (unsigned) vtp->ack_threads);
+ log_print(" # Bio threads\t%u", (unsigned) vtp->bio_threads);
+ log_print(" Bio rotation\t%u", (unsigned) vtp->bio_rotation);
+ log_print(" # CPU threads\t%u", (unsigned) vtp->cpu_threads);
+ log_print(" # Hash zone threads\t%u", (unsigned) vtp->hash_zone_threads);
+ log_print(" # Logical threads\t%u", (unsigned) vtp->logical_threads);
+ log_print(" # Physical threads\t%u", (unsigned) vtp->physical_threads);
+}
+
/* reused as _vdo_text_import_area_count */
static int _vdo_pool_text_import_area_count(const struct dm_config_node *sn __attribute__((unused)),
uint32_t *area_count)
@@ -419,6 +461,7 @@ static void _vdo_pool_destroy(struct segment_type *segtype)
static struct segtype_handler _vdo_ops = {
.name = _vdo_name,
+ .display = _vdo_display,
.text_import = _vdo_text_import,
.text_import_area_count = _vdo_pool_text_import_area_count,
.text_export = _vdo_text_export,
@@ -434,6 +477,7 @@ static struct segtype_handler _vdo_ops = {
static struct segtype_handler _vdo_pool_ops = {
.name = _vdo_pool_name,
+ .display = _vdo_pool_display,
.text_import = _vdo_pool_text_import,
.text_import_area_count = _vdo_pool_text_import_area_count,
.text_export = _vdo_pool_text_export,
5 years, 8 months
master - dev_manager: add dev_manager_vdo_pool_status
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4f708e870974fb9414c...
Commit: 4f708e870974fb9414ce7f1b7d277f14af6c2d38
Parent: 493ffe7a0f4646d151bd4a48e2ec9756892c4944
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jun 29 11:15:54 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 9 15:28:35 2018 +0200
dev_manager: add dev_manager_vdo_pool_status
---
lib/activate/activate.c | 40 +++++++++++++++++++++++++++++
lib/activate/activate.h | 2 +
lib/activate/dev_manager.c | 59 ++++++++++++++++++++++++++++++++++++++++++++
lib/activate/dev_manager.h | 5 +++
4 files changed, 106 insertions(+), 0 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 4facb7c..0435139 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -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, ¶ms, &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;
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index 6d70f64..cca2504 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -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.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 25d5e69..43dba8c 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -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, ¶ms)) {
+ 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 */
diff --git a/lib/activate/dev_manager.h b/lib/activate/dev_manager.h
index 809fd04..bd96832 100644
--- a/lib/activate/dev_manager.h
+++ b/lib/activate/dev_manager.h
@@ -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,
5 years, 8 months
master - lv_manip: layout and role support for vdo segment
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=493ffe7a0f4646d151b...
Commit: 493ffe7a0f4646d151bd4a48e2ec9756892c4944
Parent: 00990ed53e4d00fe7b030d366193a51bd646c85b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jun 29 11:18:44 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 9 15:28:35 2018 +0200
lv_manip: layout and role support for vdo segment
---
lib/metadata/lv_manip.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 2dfe994..d3c4e76 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -113,6 +113,7 @@ enum {
LV_TYPE_POOL,
LV_TYPE_DATA,
LV_TYPE_SPARE,
+ LV_TYPE_VDO,
LV_TYPE_VIRTUAL,
LV_TYPE_RAID0,
LV_TYPE_RAID0_META,
@@ -164,6 +165,7 @@ static const char *_lv_type_names[] = {
[LV_TYPE_POOL] = "pool",
[LV_TYPE_DATA] = "data",
[LV_TYPE_SPARE] = "spare",
+ [LV_TYPE_VDO] = "vdo",
[LV_TYPE_VIRTUAL] = "virtual",
[LV_TYPE_RAID0] = SEG_TYPE_NAME_RAID0,
[LV_TYPE_RAID0_META] = SEG_TYPE_NAME_RAID0_META,
@@ -466,6 +468,44 @@ bad:
return 0;
}
+static int _lv_layout_and_role_vdo(struct dm_pool *mem,
+ const struct logical_volume *lv,
+ struct dm_list *layout,
+ struct dm_list *role,
+ int *public_lv)
+{
+ int top_level = 0;
+
+ /* non-top-level LVs */
+ if (lv_is_vdo_pool(lv)) {
+ if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_VDO]) ||
+ !str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_POOL]))
+ goto_bad;
+ } else if (lv_is_vdo_pool_data(lv)) {
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_VDO]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_POOL]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_DATA]))
+ goto_bad;
+ } else
+ top_level = 1;
+
+ if (!top_level) {
+ *public_lv = 0;
+ return 1;
+ }
+
+ /* top-level LVs */
+ if (lv_is_vdo(lv)) {
+ if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_VDO]) ||
+ !str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_SPARSE]))
+ goto_bad;
+ }
+
+ return 1;
+bad:
+ return 0;
+}
+
int lv_layout_and_role(struct dm_pool *mem, const struct logical_volume *lv,
struct dm_list **layout, struct dm_list **role) {
int linear, striped;
@@ -510,6 +550,11 @@ int lv_layout_and_role(struct dm_pool *mem, const struct logical_volume *lv,
!_lv_layout_and_role_cache(mem, lv, *layout, *role, &public_lv))
goto_bad;
+ /* VDO and related */
+ if (lv_is_vdo_type(lv) &&
+ !_lv_layout_and_role_vdo(mem, lv, *layout, *role, &public_lv))
+ goto_bad;
+
/* Pool-specific */
if (lv_is_pool_metadata_spare(lv)) {
if (!str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_POOL]) ||
5 years, 8 months
master - check_lv_segment: internal vdo segment validation
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=00990ed53e4d00fe7b0...
Commit: 00990ed53e4d00fe7b030d366193a51bd646c85b
Parent: 0dafd159a862aa76a950a3568eba32a73c0422cc
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jun 29 11:13:43 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 9 15:28:35 2018 +0200
check_lv_segment: internal vdo segment validation
Check if settings for vdo segment are correct.
---
lib/metadata/merge.c | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c
index cf8789c..035a56c 100644
--- a/lib/metadata/merge.c
+++ b/lib/metadata/merge.c
@@ -486,6 +486,29 @@ static void _check_lv_segment(struct logical_volume *lv, struct lv_segment *seg,
seg_error("sets indirect_origin LV");
}
+ if (seg_is_vdo_pool(seg)) {
+ if (!lv_is_vdo_pool(lv))
+ seg_error("is not flagged as VDO pool LV");
+ if ((seg->area_count != 1) || (seg_type(seg, 0) != AREA_LV)) {
+ seg_error("is missing a VDO pool data LV");
+ } else if (!lv_is_vdo_pool_data(seg_lv(seg, 0)))
+ seg_error("is not VDO pool data LV");
+ } else { /* !VDO pool */
+ if (seg->vdo_pool_header_size)
+ seg_error("sets vdo_pool_header_size");
+ if (seg->vdo_pool_virtual_extents)
+ seg_error("sets vdo_pool_virtual_extents");
+ }
+
+ if (seg_is_vdo(seg)) {
+ if (!lv_is_vdo(lv))
+ seg_error("is not flagged as VDO LV");
+ if (!seg_lv(seg, 0))
+ seg_error("is missing VDO pool LV");
+ else if (!lv_is_vdo_pool(seg_lv(seg, 0)))
+ seg_error("is not referencing VDO pool LV");
+ }
+
/* Some multi-seg vars excluded here */
if (!seg_is_cache(seg) &&
!seg_is_thin_volume(seg)) {
5 years, 8 months
master - vdo_manip: parsing status of VDO device
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0dafd159a862aa76a95...
Commit: 0dafd159a862aa76a950a3568eba32a73c0422cc
Parent: aa63dfbe39860f04d8965e2afc4959cd20988411
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jul 2 17:20:30 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 9 15:28:35 2018 +0200
vdo_manip: parsing status of VDO device
---
lib/activate/activate.h | 2 +
lib/activate/dev_manager.c | 4 ++
lib/metadata/metadata-exported.h | 10 +++++
lib/metadata/vdo_manip.c | 83 ++++++++++++++++++++++++++++++++++++++
4 files changed, 99 insertions(+), 0 deletions(-)
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index 09cd688..6d70f64 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -37,6 +37,7 @@ typedef enum {
SEG_STATUS_SNAPSHOT,
SEG_STATUS_THIN,
SEG_STATUS_THIN_POOL,
+ SEG_STATUS_VDO_POOL,
SEG_STATUS_UNKNOWN
} lv_seg_status_type_t;
@@ -50,6 +51,7 @@ struct lv_seg_status {
struct dm_status_snapshot *snapshot;
struct dm_status_thin *thin;
struct dm_status_thin_pool *thin_pool;
+ struct lv_status_vdo vdo_pool;
};
};
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 07fc93e..25d5e69 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -209,6 +209,10 @@ static int _get_segment_status_from_target_params(const char *target_name,
if (!dm_get_status_snapshot(seg_status->mem, params, &seg_status->snapshot))
return_0;
seg_status->type = SEG_STATUS_SNAPSHOT;
+ } else if (segtype_is_vdo_pool(segtype)) {
+ if (!parse_vdo_pool_status(seg_status->mem, seg->lv, params, &seg_status->vdo_pool))
+ return_0;
+ seg_status->type = SEG_STATUS_VDO_POOL;
} else
/*
* TODO: Add support for other segment types too!
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index b221139..b6ac4cb 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1250,11 +1250,21 @@ int wipe_cache_pool(struct logical_volume *cache_pool_lv);
/* ++ metadata/vdo_manip.c */
+struct lv_status_vdo {
+ struct dm_pool *mem;
+ struct dm_vdo_status *vdo;
+ uint64_t data_blocks_used; /* grabbed from /sys/kvdo */
+ uint64_t logical_blocks_used; /* grabbed from /sys/kvdo */
+ dm_percent_t usage;
+ dm_percent_t saving;
+};
const char *get_vdo_compression_state_name(enum dm_vdo_compression_state state);
const char *get_vdo_index_state_name(enum dm_vdo_index_state state);
const char *get_vdo_operating_mode_name(enum dm_vdo_operating_mode mode);
uint64_t get_vdo_pool_virtual_size(const struct lv_segment *vdo_pool_seg);
+int parse_vdo_pool_status(struct dm_pool *mem, const struct logical_volume *vdo_pool_lv,
+ const char *params, struct lv_status_vdo *status);
struct logical_volume *convert_vdo_pool_lv(struct logical_volume *data_lv,
const struct dm_vdo_target_params *vtp,
uint32_t *virtual_extents);
diff --git a/lib/metadata/vdo_manip.c b/lib/metadata/vdo_manip.c
index 8aee3dc..5801a1b 100644
--- a/lib/metadata/vdo_manip.c
+++ b/lib/metadata/vdo_manip.c
@@ -93,6 +93,89 @@ uint64_t get_vdo_pool_virtual_size(const struct lv_segment *vdo_pool_seg)
vdo_pool_seg->vdo_pool_header_size);
}
+static int _sysfs_get_kvdo_value(const char *dm_name, const char *vdo_param, uint64_t *value)
+{
+ char path[PATH_MAX];
+ char temp[64];
+ int fd, size, r = 0;
+
+ if (dm_snprintf(path, sizeof(path), "%skvdo/%s/%s",
+ dm_sysfs_dir(), dm_name, vdo_param) < 0) {
+ log_error("Failed to build kmod path.");
+ goto bad;
+ }
+
+ if ((fd = open(path, O_RDONLY)) < 0) {
+ if (errno != ENOENT)
+ log_sys_error("open", path);
+ else
+ log_sys_debug("open", path);
+ goto bad;
+ }
+
+ if ((size = read(fd, temp, sizeof(temp) - 1)) < 0) {
+ log_sys_error("read", path);
+ goto bad;
+ }
+ temp[size] = 0;
+ errno = 0;
+ *value = strtoll(temp, NULL, 0);
+ if (errno) {
+ log_sys_error("strtool", path);
+ goto bad;
+ }
+
+ r = 1;
+bad:
+ if (fd >= 0 && close(fd))
+ log_sys_error("close", path);
+
+ return r;
+}
+
+int parse_vdo_pool_status(struct dm_pool *mem, const struct logical_volume *vdo_pool_lv,
+ const char *params, struct lv_status_vdo *status)
+{
+ struct dm_vdo_status_parse_result result;
+ char *dm_name;
+
+ status->usage = DM_PERCENT_INVALID;
+ status->saving = DM_PERCENT_INVALID;
+
+ if (!(dm_name = dm_build_dm_name(mem, vdo_pool_lv->vg->name,
+ vdo_pool_lv->name, NULL))) {
+ log_error("Failed to build VDO DM name %s.",
+ display_lvname(vdo_pool_lv));
+ return 0;
+ }
+
+ if (!dm_vdo_status_parse(mem, params, &result)) {
+ log_error("Cannot parse %s VDO pool status %s.",
+ display_lvname(vdo_pool_lv), result.error);
+ return 0;
+ }
+
+ status->vdo = result.status;
+
+ if (result.status->operating_mode == DM_VDO_MODE_NORMAL) {
+ if (!_sysfs_get_kvdo_value(dm_name, "statistics/data_blocks_used",
+ &status->data_blocks_used))
+ return_0;
+
+ if (!_sysfs_get_kvdo_value(dm_name, "statistics/logical_blocks_used",
+ &status->logical_blocks_used))
+ return_0;
+
+ status->usage = dm_make_percent(result.status->used_blocks,
+ result.status->total_blocks);
+ status->saving = dm_make_percent(status->logical_blocks_used - status->data_blocks_used,
+ status->logical_blocks_used);
+ }
+
+ return 1;
+}
+
+
/*
* Formats data LV for a use as a VDO pool LV.
*
5 years, 8 months
master - vdo: support functions to map enums to string names
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=aa63dfbe39860f04d89...
Commit: aa63dfbe39860f04d8965e2afc4959cd20988411
Parent: aff69ecf396a858d684cd3e54baea131e229f5a2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jul 2 21:58:18 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 9 15:28:35 2018 +0200
vdo: support functions to map enums to string names
Translate VDO enums to printable strings.
---
lib/metadata/metadata-exported.h | 3 ++
lib/metadata/vdo_manip.c | 50 ++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index f5b540a..b221139 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1251,6 +1251,9 @@ int wipe_cache_pool(struct logical_volume *cache_pool_lv);
/* ++ metadata/vdo_manip.c */
+const char *get_vdo_compression_state_name(enum dm_vdo_compression_state state);
+const char *get_vdo_index_state_name(enum dm_vdo_index_state state);
+const char *get_vdo_operating_mode_name(enum dm_vdo_operating_mode mode);
uint64_t get_vdo_pool_virtual_size(const struct lv_segment *vdo_pool_seg);
struct logical_volume *convert_vdo_pool_lv(struct logical_volume *data_lv,
const struct dm_vdo_target_params *vtp,
diff --git a/lib/metadata/vdo_manip.c b/lib/metadata/vdo_manip.c
index 451c8bd..8aee3dc 100644
--- a/lib/metadata/vdo_manip.c
+++ b/lib/metadata/vdo_manip.c
@@ -25,6 +25,56 @@
#include "lib/misc/lvm-signal.h"
#include "lib/misc/lvm-exec.h"
+const char *get_vdo_compression_state_name(enum dm_vdo_compression_state state)
+{
+ switch (state) {
+ case DM_VDO_COMPRESSION_ONLINE:
+ return "online";
+ default:
+ log_debug(INTERNAL_ERROR "Unrecognized compression state: %u.", state);
+ /* Fall through */
+ case DM_VDO_COMPRESSION_OFFLINE:
+ return "offline";
+ }
+}
+
+const char *get_vdo_index_state_name(enum dm_vdo_index_state state)
+{
+ switch (state) {
+ case DM_VDO_INDEX_ERROR:
+ return "error";
+ case DM_VDO_INDEX_CLOSED:
+ return "closed";
+ case DM_VDO_INDEX_OPENING:
+ return "opening";
+ case DM_VDO_INDEX_CLOSING:
+ return "closing";
+ case DM_VDO_INDEX_OFFLINE:
+ return "offline";
+ case DM_VDO_INDEX_ONLINE:
+ return "online";
+ default:
+ log_debug(INTERNAL_ERROR "Unrecognized index state: %u.", state);
+ /* Fall through */
+ case DM_VDO_INDEX_UNKNOWN:
+ return "unknown";
+ }
+}
+
+const char *get_vdo_operating_mode_name(enum dm_vdo_operating_mode mode)
+{
+ switch (mode) {
+ case DM_VDO_MODE_RECOVERING:
+ return "recovering";
+ case DM_VDO_MODE_READ_ONLY:
+ return "read-only";
+ default:
+ log_debug(INTERNAL_ERROR "Unrecognized operating mode: %u.", mode);
+ /* Fall through */
+ case DM_VDO_MODE_NORMAL:
+ return "normal";
+ }
+}
/*
* Size of VDO virtual LV is adding header_size in front and back of device
5 years, 8 months
master - vdo: component activation of VDO data LV
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=aff69ecf396a858d684...
Commit: aff69ecf396a858d684cd3e54baea131e229f5a2
Parent: 4b7a57c9ed5187e32394a983e08be3b4a0b19079
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 3 11:05:50 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 9 15:28:35 2018 +0200
vdo: component activation of VDO data LV
Allow component activation of VDO data LV.
---
lib/metadata/metadata-exported.h | 1 +
lib/misc/lvm-string.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 4a9f2e0..f5b540a 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -267,6 +267,7 @@
#define lv_is_component(lv) (lv_is_cache_origin(lv) || ((lv)->status & (\
CACHE_POOL_DATA |\
CACHE_POOL_METADATA |\
+ LV_VDO_POOL_DATA |\
MIRROR_IMAGE |\
MIRROR_LOG |\
RAID_IMAGE |\
diff --git a/lib/misc/lvm-string.c b/lib/misc/lvm-string.c
index 689a6b5..901243c 100644
--- a/lib/misc/lvm-string.c
+++ b/lib/misc/lvm-string.c
@@ -162,7 +162,8 @@ static const char *_lvname_has_reserved_component_string(const char *lvname)
"_rimage",
"_rmeta",
"_tdata",
- "_tmeta"
+ "_tmeta",
+ "_vdata"
};
unsigned i;
5 years, 8 months