pvdisplay --maps
Patch below adds the -m/--maps option to pvdisplay. Addresses BZ 149814.
-m, --maps
Display the mapping of physical extents to logical
volumes and logical extents.
Cheers,
Dave
lib/display/display.c +26 -0
@@ -258,6 +258,32 @@ void pvdisplay_colons(struct physical_voreturn ; } +void pvdisplay_segments (struct physical_volume *pv) +{ +struct pv_segment *seg; + +log_print ("--- Segments ---" ); + + list_iterate_items(seg, &pv->segments) { +if (seg->len == pv->pe_count)continue ; +log_print ("Physical extent %u to %u:" , + seg->pe, seg->pe + seg->len -1 ); + +if (seg->lvseg) { +log_print (" LV Name\t\t%s%s/%s" , + seg->lvseg->lv->vg->cmd->dev_dir, + seg->lvseg->lv->vg->name, + seg->lvseg->lv->name); +log_print (" Logical extents\t%d to %d" , + seg->lvseg->le, seg->lvseg->le + + seg->lvseg->len -1 ); + } + } + +log_print (" " ); +return ; +} +/* FIXME Include label fields */ void pvdisplay_full (struct cmd_context *cmd,struct physical_volume *pv,void *handle __attribute((unused)))
lib/display/display.h +0 -0
@@ -31,6 +31,7 @@ char *display_uuid(char *uuidstr); void display_stripe(const struct lv_segment *seg, uint32_t s, const
char *pre);
void pvdisplay_colons(struct physical_volume *pv);
+void pvdisplay_segments(struct physical_volume *pv);
void pvdisplay_full(struct cmd_context *cmd, struct physical_volume *pv,
void *handle);
int pvdisplay_short(struct cmd_context *cmd, struct volume_group *vg,
tools/pvdisplay.c +2 -2
@@ -71,8 +71,8 @@ static int _pvdisplay_single(struct cmd_pvdisplay_full (cmd, pv, handle); -if (!arg_count (cmd, maps_ARG)) - goto out; +if (arg_count (cmd, maps_ARG)) +pvdisplay_segments (pv); out:if (pv->vg_name)
Quoted 8 lines · David Robinson
Patch below adds the -m/--maps option to pvdisplay. Addresses BZ 149814.
-m, --maps
Display the mapping of physical extents to logical
volumes and logical extents.Cheers,
Dave
Thanks - looks good. Minor comments below.
Quoted 23 lines
diff -urp
LVM2.orig/lib/display/display.cLVM2/lib/display/display.clib/display/display.c +16
-0@@ -258,6 +258,32 @@ void pvdisplay_colons(struct physical_voreturn ; } +void pvdisplay_segments (struct physical_volume *pv) +{ +struct pv_segment *seg; + +log_print ("--- Segments ---" ); + + list_iterate_items(seg, &pv->segments) { +if (seg->len == pv->pe_count)continue ; +log_print ("Physical extent %u to %u:" , + seg->pe, seg->pe + seg->len -1 ); + +if (seg->lvseg) { +log_print (" LV Name\t\t%s%s/%s" , + seg->lvseg->lv->vg->cmd->dev_dir, + seg->lvseg->lv->vg->name, + seg->lvseg->lv->name);
lib/display/display.c void pvdisplay_colons(struct physical_vo · line 286
Quoted 10 lines
lib/display/display.c +10
-0+log_print (" Logical extents\t%d to %d" , + seg->lvseg->le, seg->lvseg->le + + seg->lvseg->len -1 ); + } + } + +log_print (" " ); +return ; +} +
Some minor whitespace problems here (mix of tabs / spaces) - will fix.
Also we probably want to display the "Type" of the extents, as well as "Logical volume" instead of "LV Name", since that more closely matches the output of lvdisplay. And an 'else' clause here to explicitly state "FREE" for PEs that are not allocated.
lib/display/display.c +18 -14
@@ -260,27 +260,31 @@ void pvdisplay_colons(struct physical_vovoid pvdisplay_segments (struct physical_volume *pv) { -struct pv_segment *seg; +struct pv_segment *seg; -log_print ("--- Segments ---" ); +log_print ("--- Segments ---" ); list_iterate_items(seg, &pv->segments) { -if (seg->len == pv->pe_count)continue ; -log_print ("Physical extent %u to %u:" , - seg->pe, seg->pe + seg->len -1 ); +if (seg->len == pv->pe_count)continue ; + +log_print ("Physical extent %u to %u:" , + seg->pe, seg->pe + seg->len -1 );if (seg->lvseg) { -log_print (" LV Name\t\t%s%s/%s" , - seg->lvseg->lv->vg->cmd->dev_dir, - seg->lvseg->lv->vg->name, - seg->lvseg->lv->name); +log_print (" Type\t\t%s" , + seg->lvseg->segtype->ops->name (seg->lvseg)); +log_print (" Logical volume\t%s%s/%s" , + seg->lvseg->lv->vg->cmd->dev_dir, + seg->lvseg->lv->vg->name, + seg->lvseg->lv->name);log_print (" Logical extents\t%d to %d" , - seg->lvseg->le, seg->lvseg->le + - seg->lvseg->len -1 ); - } - } + seg->lvseg->le, seg->lvseg->le + + seg->lvseg->len -1 ); + }else +log_print (" FREE" ); + } -log_print (" " ); +log_print (" " );return ; }