[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH 21/30] Update a few simple vg 'NUM' fields to call liblvm 'get' functions.



Add new 'disp' functions for vg fields vg_extent_size, vg_extent_count,
vg_free_count, max_lv, max_pv, and pv_count.  Call into liblvm 'get'
functions to get the value (Note - the liblvm functions were some of
the autogenerated ones with simple pointer dereferences).

Move uint32_disp() higher in the report.c file so it can be called from
the new 'disp' functions.

Should be no functional change.

Signed-off-by: Dave Wysochanski <dwysocha redhat com>
---
 lib/report/columns.h |   12 +++---
 lib/report/report.c  |   86 +++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 85 insertions(+), 13 deletions(-)

diff --git a/lib/report/columns.h b/lib/report/columns.h
index f8d3516..398ff81 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -101,12 +101,12 @@ FIELD(VGS, vg, STR, "Attr", cmd, 5, vgstatus, "vg_attr", "Various attributes - s
 FIELD(VGS, vg, NUM, "VSize", cmd, 5, vgsize, "vg_size", "Total size of VG in current units.")
 FIELD(VGS, vg, NUM, "VFree", cmd, 5, vgfree, "vg_free", "Total amount of free space in current units.")
 FIELD(VGS, vg, STR, "SYS ID", system_id, 6, string, "vg_sysid", "System ID indicating when and where it was created.")
-FIELD(VGS, vg, NUM, "Ext", extent_size, 3, size32, "vg_extent_size", "Size of Physical Extents in current units.")
-FIELD(VGS, vg, NUM, "#Ext", extent_count, 4, uint32, "vg_extent_count", "Total number of Physical Extents.")
-FIELD(VGS, vg, NUM, "Free", free_count, 4, uint32, "vg_free_count", "Total number of unallocated Physical Extents.")
-FIELD(VGS, vg, NUM, "MaxLV", max_lv, 5, uint32, "max_lv", "Maximum number of LVs allowed in VG or 0 if unlimited.")
-FIELD(VGS, vg, NUM, "MaxPV", max_pv, 5, uint32, "max_pv", "Maximum number of PVs allowed in VG or 0 if unlimited.")
-FIELD(VGS, vg, NUM, "#PV", pv_count, 3, uint32, "pv_count", "Number of PVs.")
+FIELD(VGS, vg, NUM, "Ext", cmd, 3, vgextentsize, "vg_extent_size", "Size of Physical Extents in current units.")
+FIELD(VGS, vg, NUM, "#Ext", cmd, 4, vgextentcount, "vg_extent_count", "Total number of Physical Extents.")
+FIELD(VGS, vg, NUM, "Free", cmd, 4, vgfreecount, "vg_free_count", "Total number of unallocated Physical Extents.")
+FIELD(VGS, vg, NUM, "MaxLV", cmd, 5, vgmaxlv, "max_lv", "Maximum number of LVs allowed in VG or 0 if unlimited.")
+FIELD(VGS, vg, NUM, "MaxPV", cmd, 5, vgmaxpv, "max_pv", "Maximum number of PVs allowed in VG or 0 if unlimited.")
+FIELD(VGS, vg, NUM, "#PV", cmd, 3, vgpvcount, "pv_count", "Number of PVs.")
 FIELD(VGS, vg, NUM, "#LV", cmd, 3, lvcount, "lv_count", "Number of LVs.")
 FIELD(VGS, vg, NUM, "#SN", snapshot_count, 3, uint32, "snap_count", "Number of snapshots.")
 FIELD(VGS, vg, NUM, "Seq", seqno, 3, uint32, "vg_seqno", "Revision number of internal metadata.  Incremented whenever it changes.")
diff --git a/lib/report/report.c b/lib/report/report.c
index 2d03e11..2bd0886 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -635,6 +635,13 @@ static int _size32_disp(struct dm_report *rh __attribute((unused)), struct dm_po
 	return 1;
 }
 
+static int _uint32_disp(struct dm_report *rh, struct dm_pool *mem __attribute((unused)),
+			struct dm_report_field *field,
+			const void *data, void *private __attribute((unused)))
+{
+	return dm_report_field_uint32(rh, field, data);
+}
+
 static int _size64_disp(struct dm_report *rh __attribute((unused)),
 			struct dm_pool *mem,
 			struct dm_report_field *field,
@@ -870,6 +877,78 @@ static int _devsize_disp(struct dm_report *rh, struct dm_pool *mem,
 	return _size64_disp(rh, mem, field, &size, private);
 }
 
+static int _vgextentsize_disp(struct dm_report *rh, struct dm_pool *mem,
+			      struct dm_report_field *field,
+			      const void *data, void *private)
+{
+	const struct volume_group *vg = (const struct volume_group *) data;
+	uint32_t value;
+
+	value = lvm_vg_get_extent_size(vg);
+
+	return _size32_disp(rh, mem, field, &value, private);
+}
+
+static int _vgextentcount_disp(struct dm_report *rh, struct dm_pool *mem,
+			       struct dm_report_field *field,
+			       const void *data, void *private)
+{
+	const struct volume_group *vg = (const struct volume_group *) data;
+	uint32_t value;
+
+	value = lvm_vg_get_extent_count(vg);
+
+	return _uint32_disp(rh, mem, field, &value, private);
+}
+
+static int _vgfreecount_disp(struct dm_report *rh, struct dm_pool *mem,
+			     struct dm_report_field *field,
+			     const void *data, void *private)
+{
+	const struct volume_group *vg = (const struct volume_group *) data;
+	uint32_t value;
+
+	value = lvm_vg_get_free_count(vg);
+
+	return _uint32_disp(rh, mem, field, &value, private);
+}
+
+static int _vgmaxlv_disp(struct dm_report *rh, struct dm_pool *mem,
+			 struct dm_report_field *field,
+			 const void *data, void *private)
+{
+	const struct volume_group *vg = (const struct volume_group *) data;
+	uint32_t value;
+
+	value = lvm_vg_get_max_lv(vg);
+
+	return _uint32_disp(rh, mem, field, &value, private);
+}
+
+static int _vgmaxpv_disp(struct dm_report *rh, struct dm_pool *mem,
+			       struct dm_report_field *field,
+			       const void *data, void *private)
+{
+	const struct volume_group *vg = (const struct volume_group *) data;
+	uint32_t value;
+
+	value = lvm_vg_get_max_pv(vg);
+
+	return _uint32_disp(rh, mem, field, &value, private);
+}
+
+static int _vgpvcount_disp(struct dm_report *rh, struct dm_pool *mem,
+			   struct dm_report_field *field,
+			   const void *data, void *private)
+{
+	const struct volume_group *vg = (const struct volume_group *) data;
+	uint32_t value;
+
+	value = lvm_vg_get_pv_count(vg);
+
+	return _uint32_disp(rh, mem, field, &value, private);
+}
+
 static int _vgfree_disp(struct dm_report *rh, struct dm_pool *mem,
 			struct dm_report_field *field,
 			const void *data, void *private)
@@ -900,13 +979,6 @@ static int _uuid_disp(struct dm_report *rh __attribute((unused)), struct dm_pool
 	return 1;
 }
 
-static int _uint32_disp(struct dm_report *rh, struct dm_pool *mem __attribute((unused)),
-			struct dm_report_field *field,
-			const void *data, void *private __attribute((unused)))
-{
-	return dm_report_field_uint32(rh, field, data);
-}
-
 static int _pvmdas_disp(struct dm_report *rh, struct dm_pool *mem,
 			struct dm_report_field *field,
 			const void *data, void *private)
-- 
1.6.0.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]