storage/reflink: delete stale tempfiles on start and remove
When the AT_REPLACE flag for linkat() finally lands in the Linux kernel, _replace_file() can be modified to use unnamed (O_TMPFILE) tempfiles. Until then, make sure stale tempfiles from previous crashes can't hang around for too long.
This commit is contained in:
parent
75a4a1340e
commit
d301aa2e50
@ -146,12 +146,17 @@ class ReflinkVolume(qubes.storage.Volume):
|
||||
oldest to newest; remove empty VM directory.
|
||||
'''
|
||||
self.pool._volumes.pop(self, None) # pylint: disable=protected-access
|
||||
self._cleanup()
|
||||
self._prune_revisions(keep=0)
|
||||
_remove_file(self._path_clean)
|
||||
_remove_file(self._path_dirty)
|
||||
_remove_empty_dir(os.path.dirname(self._path_dirty))
|
||||
return self
|
||||
|
||||
def _cleanup(self):
|
||||
for tmp in glob.iglob(glob.escape(self._path_vid) + '*.img*~*'):
|
||||
_remove_file(tmp)
|
||||
|
||||
def is_outdated(self):
|
||||
if self.snap_on_start:
|
||||
with suppress(FileNotFoundError):
|
||||
@ -164,6 +169,7 @@ class ReflinkVolume(qubes.storage.Volume):
|
||||
return self.save_on_stop and os.path.exists(self._path_dirty)
|
||||
|
||||
def start(self):
|
||||
self._cleanup()
|
||||
if self.is_dirty(): # implies self.save_on_stop
|
||||
return self
|
||||
if self.snap_on_start:
|
||||
|
Loading…
Reference in New Issue
Block a user