Commit 746f7476 authored by Iustin Pop's avatar Iustin Pop
Browse files

Change BlockDev.Shutdown() failure result

Currently, the Shutdown() methods of block devices return True/False.
This doesn't permit any error detail reporting.

This patch changes the return type to None for success, and raises
BlockDeviceError in case of failure. This permits the details to be
passed up the stack.

For LVM and file-backed devices, this is a simple change. For DRBD, we
first remove the shutdown of disks in case of network activation
failures (since with static minors the minor is used anyway, we don't
gain anything by clearing it), and the we simply change _ShutdownAll()
to raise an exception.

Reviewed-by: ultrotter
parent cacfd1fd
......@@ -1249,24 +1249,24 @@ def BlockdevShutdown(disk):
msgs = []
result = True
r_dev = _RecursiveFindBD(disk)
if r_dev is not None:
r_path = r_dev.dev_path
result = r_dev.Shutdown()
except errors.BlockDeviceError, err:
result = False
if result:
result = True
if disk.children:
for child in disk.children:
c_status, c_msg = BlockdevShutdown(child)
result = result and c_status
if c_msg: # not an empty message
return (result, "; ".join(msgs))
......@@ -455,7 +455,7 @@ class LogicalVolume(BlockDev):
volumes on shutdown.
return True
def GetSyncStatus(self):
"""Returns the sync status of the device.
......@@ -1447,7 +1447,6 @@ class DRBD8(BaseDRBD):
if not result:
return False
need_localdev_teardown = True
if self._lhost and self._lport and self._rhost and self._rport:
result = self._AssembleNet(minor,
(self._lhost, self._lport,
......@@ -1456,10 +1455,6 @@ class DRBD8(BaseDRBD):
if not result:
if need_localdev_teardown:
# we will ignore failures from this
logging.error("net setup failed, tearing down local device")
return False
return True
......@@ -1498,21 +1493,19 @@ class DRBD8(BaseDRBD):
result = utils.RunCmd(["drbdsetup", cls._DevPath(minor), "down"])
if result.failed:
logging.error("Can't shutdown drbd device: %s", result.output)
return not result.failed
_ThrowError("Can't shutdown drbd device: %s", result.output)
def Shutdown(self):
"""Shutdown the DRBD device.
if self.minor is None and not self.Attach():"DRBD device not attached to a device during Shutdown")
return True
if not self._ShutdownAll(self.minor):
return False"drbd%d: not attached during Shutdown()", self._aminor)
minor = self.minor
self.minor = None
self.dev_path = None
return True
def Remove(self):
"""Stub remove for DRBD devices.
......@@ -1602,7 +1595,7 @@ class FileStorage(BlockDev):
the file on shutdown.
return True
def Open(self, force=False):
"""Make the device ready for I/O.
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