Skip to content

Commit

Permalink
CA-390937: start GC as a standalone process
Browse files Browse the repository at this point in the history
To avoind inheriting locks and open files through a fork start the GC
cleanup script as a standalone process.

Signed-off-by: Mark Syms <[email protected]>
  • Loading branch information
MarkSymsCtx committed May 23, 2024
1 parent b82d549 commit 0074702
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
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
6 changes: 6 additions & 0 deletions drivers/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3198,6 +3198,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

0 comments on commit 0074702

Please sign in to comment.