[master 2/2] Wait for auto-activation of LVs when lvmetad is running. (#1261621)
dwlehman
installerbot-noreply at redhat.com
Wed Sep 16 14:08:14 UTC 2015
From: David Lehman <dlehman at redhat.com>
When lvmetad is running, activating the last PV in a VG will trigger
automatic activation of the LVs. This happens asynchronously, however,
so we have to just wait for it to be done. Since it is possible to
configure which VGs/LVs get auto-activated, we only wait for two
seconds. After that, we will try to activate the LV ourselves.
---
blivet/devices/lvm.py | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py
index 3396a8a..a658c11 100644
--- a/blivet/devices/lvm.py
+++ b/blivet/devices/lvm.py
@@ -26,6 +26,7 @@
import pprint
import re
import os
+import time
import gi
gi.require_version("BlockDev", "1.0")
@@ -721,6 +722,38 @@ def setupParents(self, orig=False):
# parent is a vg, which has no formatting (or device for that matter)
Device.setupParents(self, orig=orig)
+ def _preSetup(self, orig=False):
+ # If the lvmetad socket exists and any PV is inactive before we call
+ # setupParents (via _preSetup, below), we should wait for auto-
+ # activation before trying to manually activate this LV.
+ auto_activate = (lvm.lvmetad_socket_exists() and
+ any(not pv.status for pv in self.vg.pvs))
+ if not super(LVMLogicalVolumeDevice, self)._preSetup(orig=orig):
+ return False
+
+ if auto_activate:
+ log.debug("waiting for lvm auto-activation of %s", self.name)
+ # Wait for auto-activation for two seconds. If this LV hasn't been
+ # activated when the timeout is reached, there may be some lvm.conf
+ # content preventing auto-activation of this LV, so we have to do it
+ # ourselves.
+ # The timeout value of 30 seconds was suggested by prajnoha. He
+ # noted that udev uses the same value, so...
+ timeout = 30 # seconds
+ start = time.time()
+ while time.time() - start < timeout:
+ if self.status:
+ # already active -- don't try to activate it manually
+ log.debug("%s has been auto-activated", self.name)
+ return False
+ else:
+ log.debug("%s not active yet; sleeping...", self.name)
+ time.sleep(0.5)
+
+ log.debug("lvm auto-activation timeout reached for %s", self.name)
+
+ return True
+
def _setup(self, orig=False):
""" Open, or set up, a device. """
log_method_call(self, self.name, orig=orig, status=self.status,
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/90a67d65a2b79b7fd39b43b33e4445fc9456a57e
More information about the anaconda-patches
mailing list