master - pvs: new attr and field for unchosen duplicate device
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d4e434d1e6082ff4d448f4fbc03962c6f0926da4 Commit: d4e434d1e6082ff4d448f4fbc03962c6f0926da4 Parent: d3d13e134af15611c3f12107aa1627b12110a974 Author: David Teigland <[email protected]> AuthorDate: Fri Apr 29 14:42:14 2016 -0500 Committer: David Teigland <[email protected]> CommitterDate: Fri May 6 09:00:00 2016 -0500
pvs: new attr and field for unchosen duplicate device
When there are duplicate devices for a PV, one device is preferred and chosen to exist in the VG. The other devices are not used by lvm, but are displayed by pvs with a new PV attr "d", indicating that they are unchosen duplicate PVs.
The "duplicate" reporting field is set to "duplicate" when the PV is an unchosen duplicate, and that field is blank for the chosen PV.
--- lib/cache/lvmcache.c | 11 +++++++++++ lib/cache/lvmcache.h | 2 ++ lib/metadata/pv.c | 11 ++++++++++- lib/report/columns.h | 1 + lib/report/properties.c | 2 ++ lib/report/report.c | 10 ++++++++++ lib/report/values.h | 1 + man/pvs.8.in | 4 ++-- 8 files changed, 39 insertions(+), 3 deletions(-)
lib/cache/lvmcache.c +11 -0
@@ -782,6 +782,17 @@ int vg_has_duplicate_pvs(struct volume_group *vg)return 0 ; } +int lvmcache_dev_is_unchosen_duplicate (struct device *dev) +{ +struct device_list *devl; + + dm_list_iterate_items(devl, &_unused_duplicate_devs) { +if (devl->dev == dev) +return 1 ; + } +return 0 ; +} +/* * Compare _found_duplicate_devs entries with the corresponding duplicate dev * in lvmcache. There may be multiple duplicates in _found_duplicate_devs for
lib/cache/lvmcache.h +2 -0
@@ -209,4 +209,6 @@ int lvmcache_vg_is_foreign(struct cmd_context *cmd, const char *vgname, const chvoid lvmcache_lock_ordering (int enable); +int lvmcache_dev_is_unchosen_duplicate (struct device *dev); +#endif
lib/metadata/pv.c +10 -1
@@ -236,6 +236,7 @@ char *pv_attr_dup(struct dm_pool *mem, const struct physical_volume *pv) {char *repstr;int used =is_used_pv (pv); +int duplicate =lvmcache_dev_is_unchosen_duplicate (pv->dev);if (!(repstr =dm_pool_zalloc (mem,4 ))) {log_error ("dm_pool_alloc failed" );
@@ -245,7 +246,15 @@ char *pv_attr_dup(struct dm_pool *mem, const struct physical_volume *pv)/* * An allocatable PV is always used, so we don't need to show 'u'. */ - repstr[0 ] = (pv->status &ALLOCATABLE_PV ) ?'a' : (used >0 ) ?'u' :'-' ; +if (duplicate) + repstr[0 ] ='d' ; +else if (pv->status &ALLOCATABLE_PV ) + repstr[0 ] ='a' ; +else if (used >0 ) + repstr[0 ] ='u' ; +else + repstr[0 ] ='-' ; + repstr[1 ] = (pv->status &EXPORTED_VG ) ?'x' :'-' ; repstr[2 ] = (pv->status &MISSING_PV ) ?'m' :'-' ;
lib/report/columns.h +1 -0
@@ -148,6 +148,7 @@ FIELD(PVS, pv, NUM, "#PMdaUse", id, 0, pvmdasused, pv_mda_used_count, "Number of FIELD(PVS, pv, SIZ, "BA Start", ba_start, 0, size64, pv_ba_start, "Offset to the start of PV Bootloader Area on the underlying device in current units.", 0) FIELD(PVS, pv, SIZ, "BA Size", ba_size, 0, size64, pv_ba_size, "Size of PV Bootloader Area in current units.", 0) FIELD(PVS, pv, BIN, "PInUse", id, 0, pvinuse, pv_in_use, "Set if PV is used.", 0) +FIELD(PVS, pv, BIN, "Duplicate", id, 0, pvduplicate, pv_duplicate, "Set if PV is an unchosen duplicate.", 0) FIELD(VGS, vg, STR, "Fmt", cmd, 0, vgfmt, vg_fmt, "Type of metadata.", 0)FIELD (VGS , vg,STR ,"VG UUID" , id,38 , uuid, vg_uuid,"Unique identifier." ,0 )
lib/report/properties.c +2 -0
@@ -194,6 +194,8 @@ GET_PV_NUM_PROPERTY_FN(pv_ba_size, SECTOR_SIZE * pv->ba_size)#define _pv_ext_vsn_set prop_not_implemented_set#define _pv_in_use_get prop_not_implemented_get#define _pv_in_use_set prop_not_implemented_set +#define _pv_duplicate_get prop_not_implemented_get +#define _pv_duplicate_set prop_not_implemented_set#define _pv_major_get prop_not_implemented_get#define _pv_major_set prop_not_implemented_set#define _pv_minor_get prop_not_implemented_get
lib/report/report.c +10 -0
@@ -3111,6 +3111,16 @@ static int _pvinuse_disp(struct dm_report *rh, struct dm_pool *mem,return _binary_disp (rh, mem, field, used,GET_FIRST_RESERVED_NAME (pv_in_use_y), private); } +static int _pvduplicate_disp (struct dm_report *rh,struct dm_pool *mem, +struct dm_report_field *field, +const void *data,void *private) +{ +const struct physical_volume *pv = (const struct physical_volume *) data; +int duplicate =lvmcache_dev_is_unchosen_duplicate (pv->dev); + +return _binary_disp (rh, mem, field, duplicate,GET_FIRST_RESERVED_NAME (pv_duplicate_y), private); +} +static int _vgpermissions_disp (struct dm_report *rh,struct dm_pool *mem,struct dm_report_field *field,const void *data,void *private)
lib/report/values.h +1 -0
@@ -53,6 +53,7 @@ FIELD_RESERVED_BINARY_VALUE(pv_allocatable, pv_allocatable, "", "allocatable") FIELD_RESERVED_BINARY_VALUE(pv_exported, pv_exported, "", "exported") FIELD_RESERVED_BINARY_VALUE(pv_missing, pv_missing, "", "missing") FIELD_RESERVED_BINARY_VALUE(pv_in_use, pv_in_use, "", "used", "in use") +FIELD_RESERVED_BINARY_VALUE (pv_duplicate, pv_duplicate,"" ,"duplicate" ) /* Reserved values for VG fields */FIELD_RESERVED_BINARY_VALUE (vg_extendable, vg_extendable,"" ,"extendable" )
man/pvs.8.in +2 -2
@@ -85,8 +85,8 @@ pv_mda_used_count, pvseg_start, and pvseg_size .IP With \fB\-\-segments\fP, any "pvseg_" prefixes are optional; otherwise any "pv_" prefixes are optional. Columns mentioned in \fBvgs\fP(8) can also -be chosen. The pv_attr bits are: (a)llocatable, e(x)ported, (m)issing and -(u)sed (but not allocatable). +be chosen. The pv_attr bits are: (a)llocatable, e(x)ported, (m)issing, +(u)sed (but not allocatable), (d)uplicate. .TP .B \-\-segments Produces one line of output for each contiguous allocation of space on each