1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

pv: add is_used_pv fn

This commit is contained in:
Peter Rajnoha 2016-02-12 10:17:18 +01:00
parent 71ea2e1602
commit 4cbaaa5c98
2 changed files with 22 additions and 0 deletions

View File

@ -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;

View File

@ -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);