Skip to content

Commit 31c760e

Browse files
committed
fix(cleanup.py): protect LinstorSR init against race condition (#79)
During `LinstorSR` init, only create the journaler to make `should_preempt` happy. The volume manager MUST always be created in a SR lock context. Otherwise, we can trigger major issues. For example, a volume can be deleted from the KV-store by `cleanup.py` during a snapshot rollback. Very rare situation but which allowed this problem to be discovered. Signed-off-by: Ronan Abhamon <[email protected]>
1 parent 44d8cf5 commit 31c760e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/cleanup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3320,7 +3320,7 @@ def __init__(self, uuid, xapi, createLock, force):
33203320

33213321
SR.__init__(self, uuid, xapi, createLock, force)
33223322
self.path = LinstorVolumeManager.DEV_ROOT_PATH
3323-
self._reloadLinstor()
3323+
self._reloadLinstor(journaler_only=True)
33243324

33253325
@override
33263326
def deleteVDI(self, vdi) -> None:
@@ -3355,7 +3355,7 @@ def pauseVDIs(self, vdiList) -> None:
33553355
)
33563356
return super(LinstorSR, self).pauseVDIs(vdiList)
33573357

3358-
def _reloadLinstor(self):
3358+
def _reloadLinstor(self, journaler_only=False):
33593359
session = self.xapi.session
33603360
host_ref = util.get_this_host_ref(session)
33613361
sr_ref = session.xenapi.SR.get_by_uuid(self.uuid)
@@ -3372,6 +3372,9 @@ def _reloadLinstor(self):
33723372
controller_uri, group_name, logger=util.SMlog
33733373
)
33743374

3375+
if journaler_only:
3376+
return
3377+
33753378
self._linstor = LinstorVolumeManager(
33763379
controller_uri,
33773380
group_name,

0 commit comments

Comments
 (0)