1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

lvmdbusd: Correct object manager lookups

When we have two logical volumes which switch their names at the
same time we are left with incorrect lookups.  Anytime we find
an entry by doing a lookup by UUID or by name we will ensure
that the lookups are indeed correct.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1642176
This commit is contained in:
Tony Asleson 2019-01-16 15:27:55 -06:00
parent 1ed4b3f23b
commit b4c3382990

View File

@ -189,8 +189,8 @@ class ObjectManager(AutomatedProperties):
path = dbus_object.dbus_object_path() path = dbus_object.dbus_object_path()
interfaces = dbus_object.interface() interfaces = dbus_object.interface()
# print 'UN-Registering object path %s for %s' % \ # print('UN-Registering object path %s for %s' %
# (path, dbus_object.lvm_id) # (path, dbus_object.lvm_id))
self._lookup_remove(path) self._lookup_remove(path)
@ -240,39 +240,19 @@ class ObjectManager(AutomatedProperties):
return lookup_rc return lookup_rc
return '/' return '/'
def _uuid_verify(self, path, uuid, lvm_id): def _id_verify(self, path, uuid, lvm_id):
""" """
Ensure uuid is present for a successful lvm_id lookup Ensure our lookups are correct
NOTE: Internal call, assumes under object manager lock NOTE: Internal call, assumes under object manager lock
:param path: Path to object we looked up :param path: Path to object we looked up
:param uuid: lvm uuid to verify :param uuid: uuid lookup
:param lvm_id: lvm_id used to find object :param lvm_id: lvm_id lookup
:return: None :return: None
""" """
# This gets called when we found an object based on lvm_id, ensure # There is no durable non-changeable name in lvm
# uuid is correct too, as they can change. There is no durable
# non-changeable name in lvm
if lvm_id != uuid: if lvm_id != uuid:
if uuid and uuid not in self._id_to_object_path: obj = self.get_object_by_path(path)
obj = self.get_object_by_path(path) self._lookup_add(obj, path, lvm_id, uuid)
self._lookup_add(obj, path, lvm_id, uuid)
def _lvm_id_verify(self, path, uuid, lvm_id):
"""
Ensure lvm_id is present for a successful uuid lookup
NOTE: Internal call, assumes under object manager lock
:param path: Path to object we looked up
:param uuid: uuid used to find object
:param lvm_id: lvm_id to verify
:return: None
"""
# This gets called when we found an object based on uuid, ensure
# lvm_id is correct too, as they can change. There is no durable
# non-changeable name in lvm
if lvm_id != uuid:
if lvm_id and lvm_id not in self._id_to_object_path:
obj = self.get_object_by_path(path)
self._lookup_add(obj, path, lvm_id, uuid)
def _id_lookup(self, the_id): def _id_lookup(self, the_id):
path = None path = None
@ -339,22 +319,22 @@ class ObjectManager(AutomatedProperties):
# Lets check for the uuid first # Lets check for the uuid first
path = self._id_lookup(uuid) path = self._id_lookup(uuid)
if path: if path:
# Verify the lvm_id is sane # Ensure table lookups are correct
self._lvm_id_verify(path, uuid, lvm_id) self._id_verify(path, uuid, lvm_id)
else: else:
# Unable to find by UUID, lets lookup by lvm_id # Unable to find by UUID, lets lookup by lvm_id
path = self._id_lookup(lvm_id) path = self._id_lookup(lvm_id)
if path: if path:
# Verify the uuid is sane # Ensure table lookups are correct
self._uuid_verify(path, uuid, lvm_id) self._id_verify(path, uuid, lvm_id)
else: else:
# We have exhausted all lookups, let's create if we can # We have exhausted all lookups, let's create if we can
if path_create: if path_create:
path = path_create() path = path_create()
self._lookup_add(None, path, lvm_id, uuid) self._lookup_add(None, path, lvm_id, uuid)
# print('get_object_path_by_lvm_id(%s, %s, %s, %s: return %s' % # print('get_object_path_by_lvm_id(%s, %s, %s): return %s' %
# (uuid, lvm_id, str(path_create), str(gen_new), path)) # (uuid, lvm_id, str(path_create), path))
return path return path