Commit f208978a authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Convert ldisk_degraded to tri-state value



This allows us to report “uncertain” states (LDS_UNKNOWN) for cases
where the code can't easily detect or report what's wrong with a
block device.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 74f37195
...@@ -238,7 +238,7 @@ class BlockDev(object): ...@@ -238,7 +238,7 @@ class BlockDev(object):
sync_percent=None, sync_percent=None,
estimated_time=None, estimated_time=None,
is_degraded=False, is_degraded=False,
ldisk_degraded=False) ldisk_status=constants.LDS_OKAY)
def CombinedSyncStatus(self): def CombinedSyncStatus(self):
"""Calculate the mirror status recursively for our children. """Calculate the mirror status recursively for our children.
...@@ -255,7 +255,7 @@ class BlockDev(object): ...@@ -255,7 +255,7 @@ class BlockDev(object):
min_percent = status.sync_percent min_percent = status.sync_percent
max_time = status.estimated_time max_time = status.estimated_time
is_degraded = status.is_degraded is_degraded = status.is_degraded
ldisk_degraded = status.ldisk_degraded ldisk_status = status.ldisk_status
if self._children: if self._children:
for child in self._children: for child in self._children:
...@@ -272,7 +272,11 @@ class BlockDev(object): ...@@ -272,7 +272,11 @@ class BlockDev(object):
max_time = max(max_time, child_status.estimated_time) max_time = max(max_time, child_status.estimated_time)
is_degraded = is_degraded or child_status.is_degraded is_degraded = is_degraded or child_status.is_degraded
ldisk_degraded = ldisk_degraded or child_status.ldisk_degraded
if ldisk_status is None:
ldisk_status = child_status.ldisk_status
elif child_status.ldisk_status is not None:
ldisk_status = max(ldisk_status, child_status.ldisk_status)
return objects.BlockDevStatus(dev_path=self.dev_path, return objects.BlockDevStatus(dev_path=self.dev_path,
major=self.major, major=self.major,
...@@ -280,7 +284,7 @@ class BlockDev(object): ...@@ -280,7 +284,7 @@ class BlockDev(object):
sync_percent=min_percent, sync_percent=min_percent,
estimated_time=max_time, estimated_time=max_time,
is_degraded=is_degraded, is_degraded=is_degraded,
ldisk_degraded=ldisk_degraded) ldisk_status=ldisk_status)
def SetInfo(self, text): def SetInfo(self, text):
...@@ -532,13 +536,18 @@ class LogicalVolume(BlockDev): ...@@ -532,13 +536,18 @@ class LogicalVolume(BlockDev):
@rtype: objects.BlockDevStatus @rtype: objects.BlockDevStatus
""" """
if self._degraded:
ldisk_status = constants.LDS_FAULTY
else:
ldisk_status = constants.LDS_OKAY
return objects.BlockDevStatus(dev_path=self.dev_path, return objects.BlockDevStatus(dev_path=self.dev_path,
major=self.major, major=self.major,
minor=self.minor, minor=self.minor,
sync_percent=None, sync_percent=None,
estimated_time=None, estimated_time=None,
is_degraded=self._degraded, is_degraded=self._degraded,
ldisk_degraded=self._degraded) ldisk_status=ldisk_status)
def Open(self, force=False): def Open(self, force=False):
"""Make the device ready for I/O. """Make the device ready for I/O.
...@@ -1335,16 +1344,22 @@ class DRBD8(BaseDRBD): ...@@ -1335,16 +1344,22 @@ class DRBD8(BaseDRBD):
_ThrowError("drbd%d: can't Attach() in GetSyncStatus", self._aminor) _ThrowError("drbd%d: can't Attach() in GetSyncStatus", self._aminor)
stats = self.GetProcStatus() stats = self.GetProcStatus()
ldisk_degraded = not stats.is_disk_uptodate is_degraded = not stats.is_connected or not stats.is_disk_uptodate
is_degraded = not stats.is_connected
if stats.is_disk_uptodate:
ldisk_status = constants.LDS_OKAY
elif stats.is_diskless:
ldisk_status = constants.LDS_FAULTY
else:
ldisk_status = constants.LDS_UNKNOWN
return objects.BlockDevStatus(dev_path=self.dev_path, return objects.BlockDevStatus(dev_path=self.dev_path,
major=self.major, major=self.major,
minor=self.minor, minor=self.minor,
sync_percent=stats.sync_percent, sync_percent=stats.sync_percent,
estimated_time=stats.est_time, estimated_time=stats.est_time,
is_degraded=(is_degraded or ldisk_degraded), is_degraded=is_degraded,
ldisk_degraded=ldisk_degraded) ldisk_status=ldisk_status)
def Open(self, force=False): def Open(self, force=False):
"""Make the local state primary. """Make the local state primary.
......
...@@ -1888,7 +1888,7 @@ def _CheckDiskConsistency(lu, dev, node, on_primary, ldisk=False): ...@@ -1888,7 +1888,7 @@ def _CheckDiskConsistency(lu, dev, node, on_primary, ldisk=False):
result = False result = False
else: else:
if ldisk: if ldisk:
result = result and not rstats.payload.ldisk_degraded result = result and rstats.payload.ldisk_status == constants.LDS_OKAY
else: else:
result = result and not rstats.payload.is_degraded result = result and not rstats.payload.is_degraded
...@@ -6314,7 +6314,7 @@ class LUQueryInstanceData(NoHooksLU): ...@@ -6314,7 +6314,7 @@ class LUQueryInstanceData(NoHooksLU):
return (status.dev_path, status.major, status.minor, return (status.dev_path, status.major, status.minor,
status.sync_percent, status.estimated_time, status.sync_percent, status.estimated_time,
status.is_degraded, status.ldisk_degraded) status.is_degraded, status.ldisk_status)
def _ComputeDiskStatus(self, instance, snode, dev): def _ComputeDiskStatus(self, instance, snode, dev):
"""Compute block device status. """Compute block device status.
......
...@@ -874,7 +874,7 @@ class BlockDevStatus(ConfigObject): ...@@ -874,7 +874,7 @@ class BlockDevStatus(ConfigObject):
"sync_percent", "sync_percent",
"estimated_time", "estimated_time",
"is_degraded", "is_degraded",
"ldisk_degraded", "ldisk_status",
] ]
......
...@@ -995,7 +995,7 @@ def _FormatBlockDevInfo(idx, top_level, dev, static): ...@@ -995,7 +995,7 @@ def _FormatBlockDevInfo(idx, top_level, dev, static):
if not status: if not status:
return "not active" return "not active"
txt = "" txt = ""
(path, major, minor, syncp, estt, degr, ldisk) = status (path, major, minor, syncp, estt, degr, ldisk_status) = status
if major is None: if major is None:
major_string = "N/A" major_string = "N/A"
else: else:
...@@ -1020,13 +1020,15 @@ def _FormatBlockDevInfo(idx, top_level, dev, static): ...@@ -1020,13 +1020,15 @@ def _FormatBlockDevInfo(idx, top_level, dev, static):
degr_text = "*DEGRADED*" degr_text = "*DEGRADED*"
else: else:
degr_text = "ok" degr_text = "ok"
if ldisk: if ldisk_status == constants.LDS_FAULTY:
ldisk_text = " *MISSING DISK*" ldisk_text = " *MISSING DISK*"
elif ldisk_status == constants.LDS_UNKNOWN:
ldisk_text = " *UNCERTAIN STATE*"
else: else:
ldisk_text = "" ldisk_text = ""
txt += (" %s, status %s%s" % (sync_text, degr_text, ldisk_text)) txt += (" %s, status %s%s" % (sync_text, degr_text, ldisk_text))
elif dtype == constants.LD_LV: elif dtype == constants.LD_LV:
if ldisk: if ldisk_status == constants.LDS_FAULTY:
ldisk_text = " *FAILED* (failed drive?)" ldisk_text = " *FAILED* (failed drive?)"
else: else:
ldisk_text = "" ldisk_text = ""
......
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