From 9db6dbceb6bca3af641b4b1595a68007a47f2c6f Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 6 Nov 2007 17:01:32 +0000 Subject: [PATCH] Implement degraded status for logical volumes Logical volumes can be 'degraded' in a similar way to mirrored devices, when their underlying storage has gone away (i.e. after a physical disk failure and 'vgreduce --removemissing'). If we can detect this, we can prevent mistaken replaces of disks that would use this LV (or its parent) as source data. This patch adds support for computing the degraded attribute and modifies gnt-instance to warn if the LV is virtual. Reviewed-by: imsnah --- lib/bdev.py | 32 ++++++++++++++++++++++++++++++++ scripts/gnt-instance | 6 ++++++ 2 files changed, 38 insertions(+) diff --git a/lib/bdev.py b/lib/bdev.py index f6d535f87..23de86045 100644 --- a/lib/bdev.py +++ b/lib/bdev.py @@ -451,6 +451,38 @@ class LogicalVolume(BlockDev): return retval + def GetSyncStatus(self): + """Returns the sync status of the device. + + If this device is a mirroring device, this function returns the + status of the mirror. + + Returns: + (sync_percent, estimated_time, is_degraded) + + For logical volumes, sync_percent and estimated_time are always + None (no recovery in progress, as we don't handle the mirrored LV + case). + + For the is_degraded parameter, we check if the logical volume has + the 'virtual' type, which means it's not backed by existing + storage anymore (read from it return I/O error). This happens + after a physical disk failure and subsequent 'vgreduce + --removemissing' on the volume group. + + """ + result = utils.RunCmd(["lvs", "--noheadings", "-olv_attr", self.dev_path]) + if result.failed: + logger.Error("Can't display lv: %s" % result.fail_reason) + return None, None, True + out = result.stdout.strip() + # format: type/permissions/alloc/fixed_minor/state/open + if len(out) != 6: + return None, None, True + is_degraded = out[0] == 'v' # virtual volume, i.e. doesn't have + # backing storage + return None, None, is_degraded + def Open(self, force=False): """Make the device ready for I/O. diff --git a/scripts/gnt-instance b/scripts/gnt-instance index ce0df7567..b101430ef 100755 --- a/scripts/gnt-instance +++ b/scripts/gnt-instance @@ -537,6 +537,12 @@ def _FormatBlockDevInfo(buf, dev, indent_level): else: degr_text = "ok" buf.write(" %s, status %s" % (sync_text, degr_text)) + elif dtype == constants.LD_LV: + if degr: + degr_text = " *DEGRADED* (failed drive?)" + else: + degr_text = "" + buf.write(degr_text) buf.write("\n") if dev["iv_name"] is not None: -- GitLab