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

[lvm-devel] [PATCH 25/30] Update vgmdafree_disp to call liblvm 'get' function.



Signed-off-by: Dave Wysochanski <dwysocha redhat com>
---
 lib/report/lvm_object_prop.c |   16 ++++++++++++++--
 lib/report/report.c          |   14 ++------------
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/lib/report/lvm_object_prop.c b/lib/report/lvm_object_prop.c
index 3d14ecf..63b742f 100644
--- a/lib/report/lvm_object_prop.c
+++ b/lib/report/lvm_object_prop.c
@@ -822,8 +822,20 @@ int lvm_vg_set_mda_count(vg_t *vg, const uint64_t value)
  */
 uint64_t lvm_vg_get_mda_free(const vg_t *vg)
 {
-	/* FIXME: implement function body */
-	return 0;
+	uint64_t freespace = UINT64_MAX, mda_free;
+	struct metadata_area *mda;
+
+	dm_list_iterate_items(mda, &vg->fid->metadata_areas) {
+		if (!mda->ops->mda_free_sectors)
+			continue;
+		mda_free = mda->ops->mda_free_sectors(mda);
+		if (mda_free < freespace)
+			freespace = mda_free;
+	}
+
+	if (freespace == UINT64_MAX)
+		freespace = UINT64_C(0);
+	return freespace;
 }
 int lvm_vg_set_mda_free(vg_t *vg, const uint64_t value)
 {
diff --git a/lib/report/report.c b/lib/report/report.c
index 52b800e..c9deba3 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1068,19 +1068,9 @@ static int _vgmdafree_disp(struct dm_report *rh, struct dm_pool *mem,
 			   const void *data, void *private)
 {
 	const struct volume_group *vg = (const struct volume_group *) data;
-	uint64_t freespace = UINT64_MAX, mda_free;
-	struct metadata_area *mda;
-
-	dm_list_iterate_items(mda, &vg->fid->metadata_areas) {
-		if (!mda->ops->mda_free_sectors)
-			continue;
-		mda_free = mda->ops->mda_free_sectors(mda);
-		if (mda_free < freespace)
-			freespace = mda_free;
-	}
+	uint64_t freespace;
 
-	if (freespace == UINT64_MAX)
-		freespace = UINT64_C(0);
+	freespace = lvm_vg_get_mda_free(vg);
 
 	return _size64_disp(rh, mem, field, &freespace, private);
 }
-- 
1.6.0.6


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