Skip to contentSkip to conversation

Add pvseg_free field to 'pvs' output

PATCH New Dave Wysochanski 1 participant 2 messages Sep 10, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add pvseg_free field to 'pvs' output

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    

---

lib/report/columns.h +1 -0
Index: LVM2/lib/report/columns.h
===================================================================
@@ -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* */
lib/report/report.c +9 -0
Index: LVM2/lib/report/report.c
===================================================================
@@ -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)))
#1 lore raw

PATCH 1/1 Add pvseg_free field to 'pvs' output

Quoted 30 lines · Dave Wysochanski

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
===================================================================

lib/report/columns.h +1 -0
@@ -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
===================================================================

lib/report/report.c static char _alloc_policy_char(alloc_pol · line 70

Quoted 9 lines
lib/report/report.c +6 -0
@@ -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.