Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ca 390937: fix conflicts between GC and SR detach #688

Merged
merged 2 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drivers/FileSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def _kickGC(self):
lockRunning.release()

util.SMlog("Kicking GC")
cleanup.gc(self.session, self.uuid, True)
cleanup.start_gc(self.uuid)

def _isbind(self):
# os.path.ismount can't deal with bind mount
Expand Down
2 changes: 1 addition & 1 deletion drivers/LVHDSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ def _kickGC(self):
lockRunning.release()

util.SMlog("Kicking GC")
cleanup.gc(self.session, self.uuid, True)
cleanup.start_gc(self.uuid)

def ensureCBTSpace(self):
# Ensure we have space for at least one LV
Expand Down
16 changes: 15 additions & 1 deletion drivers/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2937,6 +2937,15 @@ def _gcLoop(sr, dryRun=False, immediate=False):
if not lockActive.acquireNoblock():
Util.log("Another GC instance already active, exiting")
return

# Check we're still attached after acquiring locks
if not sr.xapi.isPluggedHere():
Util.log("SR no longer attached, exiting")
return

# Clean up Intellicache files
sr.cleanupCache()

# Track how many we do
coalesced = 0
task_status = "success"
Expand Down Expand Up @@ -3045,7 +3054,6 @@ def _gc(session, srUuid, dryRun=False, immediate=False):
if not sr.gcEnabled(False):
return

sr.cleanupCache()
try:
_gcLoop(sr, dryRun, immediate=immediate)
finally:
Expand Down Expand Up @@ -3198,6 +3206,12 @@ def gc(session, srUuid, inBackground, dryRun=False):
_gc(session, srUuid, dryRun, immediate=True)


def start_gc(sr_uuid):
util.SMlog(f"Starting GC file is {__file__}")
subprocess.run([__file__, '-b', '-u', sr_uuid, '-g'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)


def gc_force(session, srUuid, force=False, dryRun=False, lockSR=False):
"""Garbage collect all deleted VDIs in SR "srUuid". The caller must ensure
the SR lock is held.
Expand Down
Loading