master - pv: add is_used_pv fn
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4cbaaa5c98c78784e9eab5489c12d2e72e952f32 Commit: 4cbaaa5c98c78784e9eab5489c12d2e72e952f32 Parent: 71ea2e1602f9b058ee1cad445a07bf80413f833f Author: Peter Rajnoha <[email protected]> AuthorDate: Fri Feb 12 10:17:18 2016 +0100 Committer: Peter Rajnoha <[email protected]> CommitterDate: Mon Feb 15 12:44:46 2016 +0100
pv: add is_used_pv fn
--- lib/metadata/pv.c | 21 +++++++++++++++++++++ lib/metadata/pv.h | 1 + 2 files changed, 22 insertions(+), 0 deletions(-)
lib/metadata/pv.c +21 -0
@@ -208,6 +208,27 @@ int is_missing_pv(const struct physical_volume *pv)return pv_field (pv, status) &MISSING_PV ?1 :0 ; } +int is_used_pv (const struct physical_volume *pv) +{ +struct lvmcache_info *info; +uint32_t ext_flags; + +if (!is_orphan (pv)) +return 1 ; + +if (!(pv->fmt->features &FMT_PV_FLAGS )) +return 0 ; + +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 -1 ; + } + + ext_flags =lvmcache_ext_flags (info); + +return ext_flags &PV_EXT_USED ?1 :0 ; +} +char *pv_attr_dup (struct dm_pool *mem,const struct physical_volume *pv) {char *repstr;
lib/metadata/pv.h +1 -0
@@ -96,6 +96,7 @@ uint32_t pv_mda_used_count(const struct physical_volume *pv);unsigned pv_mda_set_ignored (const struct physical_volume *pv,unsigned ignored);int is_orphan (const struct physical_volume *pv);int is_missing_pv (const struct physical_volume *pv); +int is_used_pv (const struct physical_volume *pv);int is_pv (const struct physical_volume *pv);struct label *pv_label (const struct physical_volume *pv);