Skip to contentSkip to conversation

master - display: basic vdo segment lvdisplay and lvs support

PATCH Zdenek Kabelac 1 participant 1 message Jul 9, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5807993bbfedfc7a7c58de082c92811109c02ea0
Commit:        5807993bbfedfc7a7c58de082c92811109c02ea0
Parent:        4f708e870974fb9414ce7f1b7d277f14af6c2d38
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Sun Jul 1 15:58:01 2018 +0200
Committer:     Zdenek Kabelac <[email protected]>
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(-)
lib/display/display.c +22 -0
index c6f855b..055fc69 100644
@@ -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)
lib/metadata/lv.c +19 -5
index cf6fafa..d8417bc 100644
@@ -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))
lib/vdo/vdo.c +44 -0

68 lines not on this page · raw message