Commit e739bd57 authored by Iustin Pop's avatar Iustin Pop
Browse files

Change the way remove children is called in bdev

For some cases, we don't have to have access to the children of a device
in order to remove them (e.g. md over lvs, or drbd over lvs). In order
to ease the removal process, skip over finding the child if it provides
a static dev path.

This is needed in order to support removal of children when the
underlying storage has gone away.

Reviewed-by: imsnah
parent 222f2dd5
......@@ -807,12 +807,20 @@ def MirrorRemoveChildren(parent_cdev, new_cdevs):
if parent_bdev is None:
logger.Error("Can't find parent in remove children: %s" % parent_cdev)
return False
new_bdevs = [_RecursiveFindBD(disk) for disk in new_cdevs]
if new_bdevs.count(None) > 0:
logger.Error("Can't find some devices while removing children: %s %s" %
(new_cdevs, new_bdevs))
devs = []
for disk in new_cdevs:
rpath = disk.StaticDevPath()
if rpath is None:
bd = _RecursiveFindBD(disk)
if bd is None:
logger.Error("Can't find dynamic device %s while removing children" %
return False
return True
......@@ -744,9 +744,9 @@ class MDRaid1(BlockDev):
args = ["mdadm", "-f", self.dev_path]
orig_devs = []
for dev in devices:
for c in self._children:
if c.dev_path == dev.dev_path:
if c.dev_path == dev:
......@@ -1878,13 +1878,16 @@ class DRBD8(BaseDRBD):
if len(self._children) != 2:
raise errors.BlockDeviceError("We don't have two children: %s" %
if self._children.count(None) == 2: # we don't actually have children :)
logger.Error("Requested detach while detached")
if len(devices) != 2:
raise errors.BlockDeviceError("We need two children in RemoveChildren")
for idx, dev in enumerate(devices):
if dev.dev_path != self._children[idx].dev_path:
raise errors.BlockDeviceError("Mismatch in local storage (%d) in"
" RemoveChildren" % idx)
for child, dev in zip(self._children, devices):
if dev != child.dev_path:
raise errors.BlockDeviceError("Mismatch in local storage"
" (%s != %s) in RemoveChildren" %
(dev, child.dev_path))
if not self._ShutdownLocal(self.minor):
raise errors.BlockDeviceError("Can't detach from local storage")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment