From 8462c37b7562280b608f4e59e2a9e07bee336c36 Mon Sep 17 00:00:00 2001 From: Mark Syms Date: Tue, 21 May 2024 14:28:30 +0100 Subject: [PATCH] CA-390937: don't clean caches until we have our locks 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 --- drivers/cleanup.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/cleanup.py b/drivers/cleanup.py index e83180e45..c6686e7cc 100755 --- a/drivers/cleanup.py +++ b/drivers/cleanup.py @@ -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" @@ -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: