Skip to content

Commit 4c4835f

Browse files
committed
fix(cleanup): remove running file before relink
Sometime, the VDI activation code in blktap2.py would wait on coalesce being stopped while the GC code would be waiting for the activation being done to continue with the relink, causing a deadlock. We remove the coalesce running file before the relink so that it continue as before, the activation will proceed then the relink will run and refresh the tapdisk with the new parent. We let the relink run everytime, it should be almost a noop if tapdisk has made the parent change itself. Signed-off-by: Damien Thenot <damien.thenot@vates.tech>
1 parent d28569e commit 4c4835f

1 file changed

Lines changed: 13 additions & 20 deletions

File tree

drivers/cleanup.py

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2480,7 +2480,6 @@ def _delete_running_file(self, vdi: VDI):
24802480
os.unlink(self._gc_running_file(vdi))
24812481

24822482
def _coalesce(self, vdi: VDI):
2483-
skipRelink = False
24842483
if self.journaler.get(vdi.JRN_RELINK, vdi.uuid):
24852484
# this means we had done the actual coalescing already and just
24862485
# need to finish relinking and/or refreshing the children
@@ -2508,42 +2507,36 @@ def _coalesce(self, vdi: VDI):
25082507
#Leaf opened on another host, we need to call online coalesce
25092508
util.SMlog("Remote coalesce for {}".format(vdi.path))
25102509
vdi._doCoalesceOnHost(list(host_refs)[0])
2511-
skipRelink = True
25122510
else:
25132511
util.SMlog("Offline coalesce for {}".format(vdi.path))
25142512
vdi._doCoalesce()
25152513
except Exception as e:
25162514
util.SMlog("EXCEPTION while coalescing: {}".format(e))
25172515
self._delete_running_file(vdi)
25182516
raise
2519-
"""
2520-
vdi._doCoalesce will call vdi._coalesceCowImage (after doing other things).
2521-
It will then call VDI._doCoalesceCowImage in a runAbortable context
2522-
"""
2517+
25232518
self.journaler.remove(vdi.JRN_COALESCE, vdi.uuid)
2519+
self._delete_running_file(vdi)
25242520

25252521
util.fistpoint.activate("LVHDRT_before_create_relink_journal", self.uuid)
25262522

25272523
# we now need to relink the children: lock the SR to prevent ops
25282524
# like SM.clone from manipulating the VDIs we'll be relinking and
25292525
# rescan the SR first in case the children changed since the last
25302526
# scan
2531-
if not skipRelink:
2532-
self.journaler.create(vdi.JRN_RELINK, vdi.uuid, "1")
2527+
self.journaler.create(vdi.JRN_RELINK, vdi.uuid, "1")
25332528

2534-
if not skipRelink: #TODO: we might want to let relink happen for VDI not currently in use
2535-
self.lock()
2536-
try:
2537-
vdi.parent._tagChildrenForRelink()
2538-
self.scan()
2539-
vdi._relinkSkip()
2540-
finally:
2541-
self.unlock()
2542-
# Reload the children to leave things consistent
2543-
vdi.parent._reloadChildren(vdi)
2544-
self.journaler.remove(vdi.JRN_RELINK, vdi.uuid)
2529+
self.lock()
2530+
try:
2531+
vdi.parent._tagChildrenForRelink()
2532+
self.scan()
2533+
vdi._relinkSkip() #TODO: We could check if the parent is already the right one before doing the relink, or we could do the relink a second time, it doesn't seem to cause issues
2534+
finally:
2535+
self.unlock()
2536+
# Reload the children to leave things consistent
2537+
vdi.parent._reloadChildren(vdi)
2538+
self.journaler.remove(vdi.JRN_RELINK, vdi.uuid)
25452539

2546-
self._delete_running_file(vdi)
25472540
self.deleteVDI(vdi)
25482541

25492542
class CoalesceTracker:

0 commit comments

Comments
 (0)