From abbaeef096251c4191e6da2518e646dd78b82da8 Mon Sep 17 00:00:00 2001 From: Peter Rajnoha Date: Mon, 15 Feb 2016 13:30:37 +0100 Subject: [PATCH] cleanup: use is_used_pv fn to detect whether PV is in use while reporting pv_free field --- lib/report/report.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/lib/report/report.c b/lib/report/report.c index c964bd82e..123b9f05d 100644 --- a/lib/report/report.c +++ b/lib/report/report.c @@ -2375,20 +2375,12 @@ static int _pvfree_disp(struct dm_report *rh, struct dm_pool *mem, { const struct physical_volume *pv = (const struct physical_volume *) data; - struct lvmcache_info *info; - uint32_t ext_flags; - uint64_t freespace = pv_free(pv); + uint64_t freespace; - if (is_orphan(pv)) { - if (!(info = lvmcache_info_from_pvid((const char *) &pv->id, 0))) { - log_error("Failed to find cached info for PV %s.", pv_dev_name(pv)); - return 0; - } - - ext_flags = lvmcache_ext_flags(info); - if (ext_flags & PV_EXT_USED) - freespace = 0; - } + if (is_orphan(pv) && is_used_pv(pv)) + freespace = 0; + else + freespace = pv_free(pv); return _size64_disp(rh, mem, field, &freespace, private); }