Skip to content

Commit

Permalink
CA-390937: don't clean caches until we have our locks
Browse files Browse the repository at this point in the history
Doing the cleanupCache before acquiring the locks can result in a
failure, in particular as part of XenCert where an sr_detach operation
attempts to abort GC but the GC is not registered as running and then
the umount of NFS fails as the cache cleanup still has the directory
open.

Also check for the SR still being attached after the active lock has
been acquired.

Signed-off-by: Mark Syms <[email protected]>
  • Loading branch information
MarkSymsCtx committed May 22, 2024
1 parent 468de2e commit 32562bb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 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

0 comments on commit 32562bb

Please sign in to comment.