Hello Federico Simoncelli,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/21501
to review the following change.
Change subject: lvm: deactivate lvs during bootstrap
......................................................................
lvm: deactivate lvs during bootstrap
When using FC storage, physical volumes are connected during boot, and vdsm
logical volumes are auto-activated by both /etc/rc.sysinit and
/etc/init.d/netfs startup scripts. These logical volumes do not pick changes
done by the SPM on the storage, which may lead to data corruption sooner or
later, when a vm is trying to write to logical volume with stale meta data.
This patch check all vdsm logical volumes during lvm bootstrap and
deactivate them if possible. Special logical volumes are refreshed,
since they are accessed early when connecting to storage pool, possibly
before lvm bootstrap is done. Open logical volumes are skipped because
we assume that they use correct meta data when opened.
To fix the auto-activation during boot, we could perform this only on
the first start of the service and limit the operation to FC storage.
However, we decided to use this on all block storage types, and on every
start of the service, as additional layer of protection from logical
volumes left active after unclean shutdown of the service, or other
failures to deactivate logical volumes.
Deactivation adds up to two lvchange calls for each volume group with
active logical volumes. After the first service start, logical volumes
are typically inactive and this change adds minimal additional cost,
refreshing active special logical volumes.
Depends on http://gerrit.ovirt.org/#/c/19871 for refreshing multiple
logical volumes in one call.
Change-Id: I5f142ebca7a00d45f2500ad2631fab2366f2f7db
Bug-Url: https://bugzilla.redhat.com/1009812
Signed-off-by: Nir Soffer <[email protected]>
Reviewed-on: http://gerrit.ovirt.org/21291
Reviewed-by: Federico Simoncelli <[email protected]>
---
M vdsm/storage/hsm.py
M vdsm/storage/lvm.py
2 files changed, 45 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/01/21501/1
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 3e0c022..d4c5dfc 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -371,7 +371,7 @@
self.log.warn("Failed to clean Storage Repository.", exc_info=True)
def storageRefresh():
- lvm._lvminfo.bootstrap()
+ lvm.bootstrap(refreshlvs=blockSD.SPECIAL_LVS)
sdCache.refreshStorage()
fileUtils.createdir(self.tasksDir)
diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py
index b195343..52bb8b3 100644
--- a/vdsm/storage/lvm.py
+++ b/vdsm/storage/lvm.py
@@ -650,6 +650,50 @@
_lvminfo = LVMCache()
+def bootstrap(refreshlvs=()):
+ """
+ Bootstrap lvm module
+
+ This function builds the lvm cache and ensure that all unused lvs are
+ deactivated, expect lvs matching refreshlvs, which are refreshed instead.
+ """
+ _lvminfo.bootstrap()
+
+ refreshlvs = set(refreshlvs)
+
+ for vg in _lvminfo.getAllVgs():
+ deactivate = []
+ refresh = []
+
+ for lv in _lvminfo.getLv(vg.name):
+ if lv.active:
+ if lv.name in refreshlvs:
+ refresh.append(lv.name)
+ elif lv.opened:
+ log.debug("Skipping open lv: vg=%s lv=%s", vg.name,
+ lv.name)
+ else:
+ deactivate.append(lv.name)
+
+ if deactivate:
+ log.info("Deactivating lvs: vg=%s lvs=%s", vg.name, deactivate)
+ try:
+ _setLVAvailability(vg.name, deactivate, "n")
+ except se.CannotDeactivateLogicalVolume:
+ log.error("Error deactivating lvs: vg=%s lvs=%s", vg.name,
+ deactivate)
+ # Some lvs are inactive now
+ _lvminfo._invalidatelvs(vg.name, deactivate)
+
+ if refresh:
+ log.info("Refreshing lvs: vg=%s lvs=%s", vg.name, refresh)
+ try:
+ refreshLVs(vg.name, refresh)
+ except se.LogicalVolumeRefreshError:
+ log.error("Error refreshing lvs: vg=%s lvs=%s", vg.name,
+ refresh)
+
+
def invalidateCache():
_lvminfo.invalidateCache()
--
To view, visit http://gerrit.ovirt.org/21501
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5f142ebca7a00d45f2500ad2631fab2366f2f7db
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.3
Gerrit-Owner: Nir Soffer <[email protected]>
Gerrit-Reviewer: Federico Simoncelli <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches