Skip to content

Commit

Permalink
fix(cleanup.py): protect LinstorSR init against race condition (#79)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Wescoeur authored Jan 9, 2025
1 parent fab39d8 commit 2249fc3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3221,7 +3221,7 @@ def __init__(self, uuid, xapi, createLock, force):

SR.__init__(self, uuid, xapi, createLock, force)
self.path = LinstorVolumeManager.DEV_ROOT_PATH
self._reloadLinstor()
self._reloadLinstor(journaler_only=True)

@override
def deleteVDI(self, vdi) -> None:
Expand Down Expand Up @@ -3256,7 +3256,7 @@ def pauseVDIs(self, vdiList) -> None:
)
return super(LinstorSR, self).pauseVDIs(vdiList)

def _reloadLinstor(self):
def _reloadLinstor(self, journaler_only=False):
session = self.xapi.session
host_ref = util.get_this_host_ref(session)
sr_ref = session.xenapi.SR.get_by_uuid(self.uuid)
Expand All @@ -3273,6 +3273,9 @@ def _reloadLinstor(self):
controller_uri, group_name, logger=util.SMlog
)

if journaler_only:
return

self._linstor = LinstorVolumeManager(
controller_uri,
group_name,
Expand Down

0 comments on commit 2249fc3

Please sign in to comment.