Skip to contentSkip to conversation

LVM2/lib/metadata mirror.c

PATCH [email protected] 3 participants 3 messages Apr 23, 2009 – May 3, 2009

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: mornfall at sourceware.org 2009-04-23 16:43:01

Modified files:
lib/metadata : mirror.c

Log message:
A more thorough PV equality test (that also copes better with MISSING_PVs) in _is_mirror_image_removable.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.84&r2=1.85

lib/metadata/mirror.c +6 -1
@@ -440,7 +440,12 @@
 
 			pv_found = 0;
 			dm_list_iterate_items(pvl, removable_pvs) {
-				if (pv->dev->dev == pvl->pv->dev->dev) {
+				if (id_equal(&pv->id, &pvl->pv->id)) {
+					pv_found = 1;
+					break;
+				}
+				if (pvl->pv->dev && pv->dev &&
+				    pv->dev->dev == pvl->pv->dev->dev) {
 					pv_found = 1;
 					break;
 				}
#1 lore raw
Quoted 5 lines · mornfall at sourceware.org

A more thorough PV equality test (that also copes better with MISSING_PVs) in _is_mirror_image_removable.

lib/metadata/mirror.c +0 -0
 			pv_found = 0;
 			dm_list_iterate_items(pvl, removable_pvs) {

lib/metadata/mirror.c line 451

Quoted 10 lines
lib/metadata/mirror.c +6 -1
-				if (pv->dev->dev == pvl->pv->dev->dev) {
+				if (id_equal(&pv->id, &pvl->pv->id)) {
+					pv_found = 1;
+					break;
+				}
+				if (pvl->pv->dev && pv->dev &&
+				    pv->dev->dev == pvl->pv->dev->dev) {
 					pv_found = 1;
 					break;
 				}

I'm not at all sure about this: what is your test case that requires the id_equal() check and fails without it?

(Is there a danger it could match the wrong device, if, say, someone cloned a PV?)

Alasdair

Signature · 1 line
agk at redhat.com
#2 lore raw

(I was pretty sure I have sent this one already, but I can't find it now on the list... re-sending in case it got lost somewhere...)

Quoted 2 lines · Alasdair G Kergon

I'm not at all sure about this: what is your test case that requires the id_equal() check and fails without it?

The testcase is that the sought-for PV is a MISSING_PV. This happens when trying to repair a mirror: we are looking for a PV to remove and we certainly want the missing one to be found to be removable. But we can't use pv->dev for checking that, since there is no device associated to a MISSING_PV. So I have guessed that UUID is the next best thing.

Quoted 2 lines

(Is there a danger it could match the wrong device, if, say, someone cloned a PV?)

If the reading code will allow us to proceed with dup PVs, then yes, this could happen. However, it seems to me that lvmcache_add will throw away any such dup PVs (in lvmcache.c) -- and even if that path is not invoked, vg_validate will reject any VG with a dup PV in it. Hopefully, that is robust enough.

Yours,
Petr.

Signature · 6 lines
Peter Rockai | me()mornfall!net | prockai()redhat!com
 http://blog.mornfall.net | http://web.mornfall.net

"In My Egotistical Opinion, most people's C programs should be
 indented six feet downward and covered with dirt."
     -- Blair P. Houghton on the subject of C program indentation