All of lore.kernel.org
 help / color / mirror / Atom feed
* [LVM2 PATCH] Add pvseg_free field to 'pvs' output
@ 2007-09-10 17:58 Dave Wysochanski
  2007-09-10 20:07 ` Dave Wysochanski
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Wysochanski @ 2007-09-10 17:58 UTC (permalink / raw)
  To: lvm-devel

Add pvseg_free field to 'pvs' output to display whether a segment
is free or allocated to an LV.  This brings pvs segment output 
closer to 'pvdisplay --maps'.

# tools/lvm pvs -o pv_name,pvseg_start,pvseg_size,pvseg_free 
  PV         Start SSize Free 
  /dev/loop1     0    32 Y    
  /dev/loop1    32    31 N    
  /dev/loop2     0    32 Y    
  /dev/loop2    32    15 Y    
  /dev/loop2    47    16 N    
  /dev/loop3     0    63 N    


---
Index: LVM2/lib/report/columns.h
===================================================================
--- LVM2.orig/lib/report/columns.h	2007-08-20 16:55:27.000000000 -0400
+++ LVM2/lib/report/columns.h	2007-09-10 13:47:33.000000000 -0400
@@ -83,4 +83,5 @@ FIELD(SEGS, seg, STR, "Devices", list, 5
 
 FIELD(PVSEGS, pvseg, NUM, "Start", pe, 5, uint32, "pvseg_start", "Physical Extent number of start of segment.")
 FIELD(PVSEGS, pvseg, NUM, "SSize", len, 5, uint32, "pvseg_size", "Number of extents in segment.")
+FIELD(PVSEGS, pvseg, STR, "Free", lvseg, 5, lvseg, "pvseg_free", "Whether the segment is free or allocated to an LV.")
 /* *INDENT-ON* */
Index: LVM2/lib/report/report.c
===================================================================
--- LVM2.orig/lib/report/report.c	2007-08-22 10:38:17.000000000 -0400
+++ LVM2/lib/report/report.c	2007-09-10 13:47:33.000000000 -0400
@@ -62,6 +62,15 @@ static char _alloc_policy_char(alloc_pol
 /*
  * Data-munging functions to prepare each data type for display and sorting
  */
+static int _lvseg_disp(struct dm_report *rh, struct dm_pool *mem __attribute((unused)),
+		       struct dm_report_field *field,
+		       const void *data, void *private __attribute((unused)))
+{
+	const struct lv_segment *seg = *(const struct lv_segment **) data;
+	dm_report_field_set_value(field, seg ? "Y" : "N", NULL);
+	return 1;
+}
+
 static int _string_disp(struct dm_report *rh, struct dm_pool *mem __attribute((unused)),
 			struct dm_report_field *field,
 			const void *data, void *private __attribute((unused)))




^ permalink raw reply	[flat|nested] 2+ messages in thread

* [LVM2 PATCH] Add pvseg_free field to 'pvs' output
  2007-09-10 17:58 [LVM2 PATCH] Add pvseg_free field to 'pvs' output Dave Wysochanski
@ 2007-09-10 20:07 ` Dave Wysochanski
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Wysochanski @ 2007-09-10 20:07 UTC (permalink / raw)
  To: lvm-devel

On Mon, 2007-09-10 at 13:58 -0400, Dave Wysochanski wrote:
> Add pvseg_free field to 'pvs' output to display whether a segment
> is free or allocated to an LV.  This brings pvs segment output 
> closer to 'pvdisplay --maps'.
> 
> # tools/lvm pvs -o pv_name,pvseg_start,pvseg_size,pvseg_free 
>   PV         Start SSize Free 
>   /dev/loop1     0    32 Y    
>   /dev/loop1    32    31 N    
>   /dev/loop2     0    32 Y    
>   /dev/loop2    32    15 Y    
>   /dev/loop2    47    16 N    
>   /dev/loop3     0    63 N    
> 
> 
> ---
> Index: LVM2/lib/report/columns.h
> ===================================================================
> --- LVM2.orig/lib/report/columns.h	2007-08-20 16:55:27.000000000 -0400
> +++ LVM2/lib/report/columns.h	2007-09-10 13:47:33.000000000 -0400
> @@ -83,4 +83,5 @@ FIELD(SEGS, seg, STR, "Devices", list, 5
>  
>  FIELD(PVSEGS, pvseg, NUM, "Start", pe, 5, uint32, "pvseg_start", "Physical Extent number of start of segment.")
>  FIELD(PVSEGS, pvseg, NUM, "SSize", len, 5, uint32, "pvseg_size", "Number of extents in segment.")
> +FIELD(PVSEGS, pvseg, STR, "Free", lvseg, 5, lvseg, "pvseg_free", "Whether the segment is free or allocated to an LV.")
>  /* *INDENT-ON* */
> Index: LVM2/lib/report/report.c
> ===================================================================
> --- LVM2.orig/lib/report/report.c	2007-08-22 10:38:17.000000000 -0400
> +++ LVM2/lib/report/report.c	2007-09-10 13:47:33.000000000 -0400
> @@ -62,6 +62,15 @@ static char _alloc_policy_char(alloc_pol
>  /*
>   * Data-munging functions to prepare each data type for display and sorting
>   */
> +static int _lvseg_disp(struct dm_report *rh, struct dm_pool *mem __attribute((unused)),
> +		       struct dm_report_field *field,
> +		       const void *data, void *private __attribute((unused)))
> +{
> +	const struct lv_segment *seg = *(const struct lv_segment **) data;
> +	dm_report_field_set_value(field, seg ? "Y" : "N", NULL);

Logic actually reversed here but fixed on commit.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-09-10 20:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-10 17:58 [LVM2 PATCH] Add pvseg_free field to 'pvs' output Dave Wysochanski
2007-09-10 20:07 ` Dave Wysochanski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.