Skip to contentSkip to conversation

master - report: display lv_name, lv_uuid, vg_name, lv_time and new lv_time_removed for historical LVs

PATCH Peter Rajnoha 1 participant 1 message Mar 3, 2016

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=28f96d5ab617cc41b8aab66c7cb19d750d68d2fd
Commit:        28f96d5ab617cc41b8aab66c7cb19d750d68d2fd
Parent:        2e7a1210622e25a5a3d813b9a069767eaad3b4ac
Author:        Peter Rajnoha <[email protected]>
AuthorDate:    Tue Mar 1 15:23:23 2016 +0100
Committer:     Peter Rajnoha <[email protected]>
CommitterDate: Thu Mar 3 13:49:14 2016 +0100

report: display lv_name,lv_uuid,vg_name,lv_time and new lv_time_removed for historical LVs

---
 lib/display/display.c   |    2 +-
 lib/metadata/lv.c       |   23 ++++++++++++++++++++---
 lib/metadata/lv.h       |    4 +++-
 lib/report/columns.h    |    5 +++--
 lib/report/properties.c |    4 +++-
 lib/report/report.c     |   43 +++++++++++++++++++++++++++++++++++++++++--
 lib/report/values.h     |    1 +
 7 files changed, 72 insertions(+), 10 deletions(-)
lib/display/display.c +1 -1
index 0948dda..2b7ea52 100644
@@ -383,7 +383,7 @@ int lvdisplay_full(struct cmd_context *cmd,
 	log_print("LV UUID                %s", uuid);
 	log_print("LV Write Access        %s", access_str);
 	log_print("LV Creation host, time %s, %s",
-		  lv_host_dup(cmd->mem, lv), lv_time_dup(cmd->mem, lv, 1));
+		  lv_host_dup(cmd->mem, lv), lv_creation_time_dup(cmd->mem, lv, 1));
 
 	if (lv_is_origin(lv)) {
 		log_print("LV snapshot status     source of");
lib/metadata/lv.c +20 -3
index a5144e9..ab937c4 100644
@@ -1274,12 +1274,13 @@ int lv_set_creation(struct logical_volume *lv,
 	return 1;
 }
 
-char *lv_time_dup(struct dm_pool *mem, const struct logical_volume *lv, int iso_mode)
+static char *_time_dup(struct cmd_context *cmd, struct dm_pool *mem,
+		       time_t ts, int iso_mode)
 {
 	char buffer[4096];
 	struct tm *local_tm;
-	time_t ts = (time_t)lv->timestamp;
-	const char *format = iso_mode ? DEFAULT_TIME_FORMAT : lv->vg->cmd->time_format;
+	const char *format = iso_mode ? DEFAULT_TIME_FORMAT
+				      : cmd->time_format;
 
 	if (!ts ||
 	    !(local_tm = localtime(&ts)) ||
@@ -1289,6 +1290,22 @@ char *lv_time_dup(struct dm_pool *mem, const struct logical_volume *lv, int iso_
 	return dm_pool_strdup(mem, buffer);
 }
 
+char *lv_creation_time_dup(struct dm_pool *mem, const struct logical_volume *lv, int iso_mode)
+{
+	time_t ts = lv_is_historical(lv) ? (time_t) lv->this_glv->historical->timestamp
+					 : (time_t) lv->timestamp;
+
+	return _time_dup(lv->vg->cmd, mem, ts, iso_mode);
+}
+
+char *lv_removal_time_dup(struct dm_pool *mem, const struct logical_volume *lv, int iso_mode)
+{
+	time_t ts = lv_is_historical(lv) ? (time_t)lv->this_glv->historical->timestamp_removed
+					 : (time_t)0;
+
+	return _time_dup(lv->vg->cmd, mem, ts, iso_mode);
+}
+
 char *lv_host_dup(struct dm_pool *mem, const struct logical_volume *lv)
 {
 	return dm_pool_strdup(mem, lv->hostname ? : "");
lib/metadata/lv.h +3 -1
index f554bce..f9f5b4e 100644
@@ -187,10 +187,12 @@ char *lvseg_discards_dup(struct dm_pool *mem, const struct lv_segment *seg);
 char *lvseg_cachemode_dup(struct dm_pool *mem, const struct lv_segment *seg);
 char *lvseg_monitor_dup(struct dm_pool *mem, const struct lv_segment *seg);
 char *lvseg_tags_dup(const struct lv_segment *seg);
-char *lv_time_dup(struct dm_pool *mem, const struct logical_volume *lv, int iso_mode);
+char *lv_creation_time_dup(struct dm_pool *mem, const struct logical_volume *lv, int iso_mode);
+char *lv_removal_time_dup(struct dm_pool *mem, const struct logical_volume *lv, int iso_mode);
 char *lv_host_dup(struct dm_pool *mem, const struct logical_volume *lv);
 char *lv_active_dup(struct dm_pool *mem, const struct logical_volume *lv);
 char *lv_profile_dup(struct dm_pool *mem, const struct logical_volume *lv);
 char *lv_lock_args_dup(struct dm_pool *mem, const struct logical_volume *lv);
 char *lvseg_kernel_discards_dup_with_info_and_seg_status(struct dm_pool *mem, const struct lv_with_info_and_seg_status *lvdm);
+char *lv_time_dup(struct dm_pool *mem, const struct logical_volume *lv, int iso_mode);
 #endif /* _LVM_LV_H */
lib/report/columns.h +3 -2
index 56a8628..35c2b2f 100644
@@ -32,7 +32,7 @@
  */
 
 /* *INDENT-OFF* */
-FIELD(LVS, lv, STR, "LV UUID", lvid.id[1], 38, uuid, lv_uuid, "Unique identifier.", 0)
+FIELD(LVS, lv, STR, "LV UUID", lvid, 38, lvuuid, lv_uuid, "Unique identifier.", 0)
 FIELD(LVS, lv, STR, "LV", lvid, 4, lvname, lv_name, "Name.  LVs created for internal use are enclosed in brackets.", 0)
 FIELD(LVS, lv, STR, "LV", lvid, 4, lvfullname, lv_full_name, "Full name of LV including its VG, namely VG/LV.", 0)
 FIELD(LVS, lv, STR, "Path", lvid, 4, lvpath, lv_path, "Full pathname for LV. Blank for internal LVs.", 0)
@@ -92,7 +92,8 @@ FIELD(LVS, lv, STR, "Pool UUID", lvid, 38, poollvuuid, pool_lv_uuid, "For thin v
 FIELD(LVS, lv, STR_LIST, "LV Tags", tags, 7, tags, lv_tags, "Tags, if any.", 0)
 FIELD(LVS, lv, STR, "LProfile", lvid, 8, lvprofile, lv_profile, "Configuration profile attached to this LV.", 0)
 FIELD(LVS, lv, STR, "Lock Args", lvid, 9, lvlockargs, lv_lockargs, "Lock args of the LV used by lvmlockd.", 0)
-FIELD(LVS, lv, TIM, "Time", lvid, 26, lvtime, lv_time, "Creation time of the LV, if known", 0)
+FIELD(LVS, lv, TIM, "CTime", lvid, 26, lvtime, lv_time, "Creation time of the LV, if known", 0)
+FIELD(LVS, lv, TIM, "RTime", lvid, 26, lvtimeremoved, lv_time_removed, "Removal time of the LV, if known", 0)
 FIELD(LVS, lv, STR, "Host", lvid, 10, lvhost, lv_host, "Creation host of the LV, if known.", 0)
 FIELD(LVS, lv, STR_LIST, "Modules", lvid, 7, modules, lv_modules, "Kernel device-mapper modules required for this LV.", 0)
 
lib/report/properties.c +3 -1
index 76a72be..030936b 100644
@@ -362,8 +362,10 @@ GET_LV_NUM_PROPERTY_FN(metadata_percent, _metadata_percent(lv))
 #define _metadata_percent_set prop_not_implemented_set
 GET_LV_NUM_PROPERTY_FN(lv_metadata_size, lv_metadata_size(lv) * SECTOR_SIZE)
 #define _lv_metadata_size_set prop_not_implemented_set
-GET_LV_STR_PROPERTY_FN(lv_time, lv_time_dup(lv->vg->vgmem, lv, 0))
+GET_LV_STR_PROPERTY_FN(lv_time, lv_creation_time_dup(lv->vg->vgmem, lv, 0))
 #define _lv_time_set prop_not_implemented_set
+GET_LV_STR_PROPERTY_FN(lv_time_removed, lv_removal_time_dup(lv->vg->vgmem, lv, 0))
+#define _lv_time_removed_set prop_not_implemented_set
 GET_LV_STR_PROPERTY_FN(lv_host, lv_host_dup(lv->vg->vgmem, lv))
 #define _lv_host_set prop_not_implemented_set
 GET_LV_STR_PROPERTY_FN(lv_active, lv_active_dup(lv->vg->vgmem, lv))
lib/report/report.c +41 -2

67 lines not on this page · raw message

lib/report/values.h +1 -0
index 43c5abe..4a6c235 100644
@@ -90,6 +90,7 @@ FIELD_RESERVED_VALUE(NAMED, lv_when_full, lv_when_full_error, "", "error", "erro
 FIELD_RESERVED_VALUE(NAMED, lv_when_full, lv_when_full_queue, "", "queue", "queue", "queue when full", "queue if no space")
 FIELD_RESERVED_VALUE(NOFLAG, lv_when_full, lv_when_full_undef, "", "", "", "undefined")
 FIELD_RESERVED_VALUE(NAMED | RANGE | FUZZY | DYNAMIC, lv_time, lv_time_fuzzy, "", lv_time_handler, NULL)
+FIELD_RESERVED_VALUE(NAMED | RANGE | FUZZY | DYNAMIC, lv_time_removed, lv_time_removed_fuzzy, "", lv_time_handler, NULL)
 
 /* Reserved values for SEG fields */
 FIELD_RESERVED_VALUE(NOFLAG, cache_policy, cache_policy_undef, "", "", "", "undefined")