Skip to contentSkip to conversation

master - toollib: handle duplicate pvs in process_in_pv

PATCH David Teigland 1 participant 1 message Jan 14, 2015

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c1f246fedfc349c25749da501e68a7f70bd122b0
Commit:        c1f246fedfc349c25749da501e68a7f70bd122b0
Parent:        eac4e1e939c6fe7eba0d2c3865e25b8ed43fe6d9
Author:        David Teigland <[email protected]>
AuthorDate:    Fri Jan 9 14:55:16 2015 -0600
Committer:     David Teigland <[email protected]>
CommitterDate: Wed Jan 14 11:57:29 2015 -0600

toollib: handle duplicate pvs in process_in_pv

Processes a PV once for each time a device with its PV ID exists on the command line.

This fixes a regression in the case where:

. devices /dev/sdA and /dev/sdB where clones (same PV ID)

. the cached VG references /dev/sdA

. before the regression, the command: pvs /dev/sdB
would display the cached device clone /dev/sdA

. after the regression, pvs /dev/sdB would display nothing,
causing vgimportclone /dev/sdB to fail.

. with this fix, pvs /dev/sdB displays /dev/sdA

Also, pvs /dev/sdA /dev/sdB will report two lines, one for each device on the command line, but /dev/sdA is displayed for each.

This only works without lvmetad.

---
 lib/cache/lvmcache.c |    2 +-
 tools/toollib.c      |  139 ++++++++++++++++++++++++++++++++++++--------------
 2 files changed, 101 insertions(+), 40 deletions(-)
lib/cache/lvmcache.c +1 -1
index 416907e..932b1ca 100644
@@ -1539,7 +1539,7 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller, const char *pvid,
 			//else if (dm_is_dm_major(MAJOR(existing->dev->dev)) &&
 				 //dm_is_dm_major(MAJOR(dev->dev)))
 				 //
-			else if (!strcmp(pvid_s, existing->dev->pvid)) 
+			else if (!strcmp(pvid_s, existing->dev->pvid))
 				log_error("Found duplicate PV %s: using %s not "
 					  "%s", pvid, dev_name(dev),
 					  dev_name(existing->dev));
tools/toollib.c +100 -39

262 lines not on this page · raw message