master - report: show active state of LV
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8d004b51274b2d7638673c4985c0c298d253ef0d Commit: 8d004b51274b2d7638673c4985c0c298d253ef0d Parent: 8b18ab76d27f40094f281d5695a6bb82b65e1976 Author: Zdenek Kabelac <[email protected]> AuthorDate: Thu Apr 25 12:12:05 2013 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Thu Apr 25 17:33:24 2013 +0200
report: show active state of LV
For non clustered VG - show "active"/""
For clustered VG its more complex:
"local exclusive"
"remote exclusive"
"locally"
"remotely"
--- WHATS_NEW | 1 + lib/metadata/lv.c | 19 +++++++++++++++++++ lib/metadata/lv.h | 1 + lib/report/columns.h | 1 + lib/report/properties.c | 2 ++ lib/report/report.c | 14 ++++++++++++++ 6 files changed, 38 insertions(+), 0 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.99 - =================================== + Add "active" LV reporting field to show activation state. Add "monitor" segment reporting field to show dmevent monitoring status. Document lvextend --use-policies option in man. Fix creation and removal of clustered snapshot.
lib/metadata/lv.c +19 -0
@@ -703,3 +703,22 @@ char *lv_host_dup(struct dm_pool *mem, const struct logical_volume *lv) {return dm_pool_strdup (mem, lv->hostname ? :"" ); } + +char *lv_active_dup (struct dm_pool *mem,const struct logical_volume *lv) +{ +const char *s; + +if (!lv_is_active (lv)) + s ="" ;/* not active */ +else if (!vg_is_clustered (lv->vg)) + s ="active" ; +else if (lv_is_active_exclusive (lv)) +/* exclusive cluster activation */ + s =lv_is_active_exclusive_locally (lv) ? +"local exclusive" :"remote exclusive" ; +else /* locally active */ + s =lv_is_active_but_not_locally (lv) ? +"remotely" :"locally" ; + +return dm_pool_strdup (mem, s); +}
lib/metadata/lv.h +1 -0
@@ -85,4 +85,5 @@ char *lv_host_dup(struct dm_pool *mem, const struct logical_volume *lv);int lv_set_creation (struct logical_volume *lv,const char *hostname,uint64_t timestamp);const char *lv_layer (const struct logical_volume *lv); +char *lv_active_dup (struct dm_pool *mem,const struct logical_volume *lv);#endif /* _LVM_LV_H */
lib/report/columns.h +1 -0
@@ -82,6 +82,7 @@ FIELD(LVS, lv, NUM, "Cpy%Sync", lvid, 8, copypercent, copy_percent, "For RAID, m FIELD(LVS, lv, NUM, "Cpy%Sync", lvid, 8, copypercent, sync_percent, "For RAID, mirrors and pvmove, current percentage in-sync.", 0) FIELD(LVS, lv, NUM, "Mismatches", lvid, 10, mismatch_count, mismatches, "For RAID, number of mismatches found or repaired.", 0) FIELD(LVS, lv, STR, "SyncAction", lvid, 10, sync_action, syncaction, "For RAID, the current synchronization action being performed.", 0) +FIELD(LVS, lv, STR, "Active", lvid, 6, lvactive, lv_active, "Active state of the LV.", 0) FIELD(LVS, lv, NUM, "WBehind", lvid, 7, write_behind, writebehind, "For RAID1, the number of outstanding writes allowed to writemostly devices.", 0) FIELD(LVS, lv, STR, "Move", lvid, 4, movepv, move_pv, "For pvmove, Source PV of temporary LV created by pvmove.", 0)FIELD (LVS , lv,STR ,"Convert" , lvid,7 , convertlv, convert_lv,"For lvconvert, Name of temporary LV created by lvconvert." ,0 )
lib/report/properties.c +2 -0
@@ -247,6 +247,8 @@ GET_LV_STR_PROPERTY_FN(lv_time, lv_time_dup(lv->vg->vgmem, lv))#define _lv_time_set _not_implemented_set GET_LV_STR_PROPERTY_FN(lv_host, lv_host_dup(lv->vg->vgmem, lv))#define _lv_host_set _not_implemented_set +GET_LV_STR_PROPERTY_FN(lv_active, lv_active_dup(lv->vg->vgmem, lv)) +#define _lv_active_set _not_implemented_set/* VG */ GET_VG_STR_PROPERTY_FN (vg_fmt,vg_fmt_dup (vg))
lib/report/report.c +14 -0
@@ -1151,6 +1151,20 @@ static int _lvhost_disp(struct dm_report *rh, struct dm_pool *mem,return 1 ; } +static int _lvactive_disp (struct dm_report *rh,struct dm_pool *mem, +struct dm_report_field *field, +const void *data,void *private) +{ +char *repstr; + +if (!(repstr =lv_active_dup (mem, (const struct logical_volume *) data))) + return_0; + +dm_report_field_set_value (field, repstr,NULL ); + +return 1 ; +} +/* Report object types */ /* necessary for displaying something for PVs not belonging to VG */