From a1b5262426a4e77c3d867715cc60993d5a3dc333 Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Tue, 7 Jul 2020 15:39:06 +0000 Subject: [PATCH] storeage/reflink: unlock size getter Don't update _size in the getter, so it can be unlocked (which is helpful for QubesOS/qubes-issues#5935). !!! If cherry-picking for release4.0, also adjust import_data() to !!! !!! use self.size (no underscore) instead of self._get_size() !!! --- qubes/storage/reflink.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/qubes/storage/reflink.py b/qubes/storage/reflink.py index 806a2fae..396dc5c7 100644 --- a/qubes/storage/reflink.py +++ b/qubes/storage/reflink.py @@ -217,7 +217,7 @@ class ReflinkVolume(qubes.storage.Volume): # Preferably use the size of a leftover image, in case # the volume was previously resized - but then a crash # prevented qubes.xml serialization of the new size. - _create_sparse_file(self._path_dirty, self._get_size()) + _create_sparse_file(self._path_dirty, self.size) return self @_coroutinized @@ -227,7 +227,7 @@ class ReflinkVolume(qubes.storage.Volume): self._commit(self._path_dirty) else: if not self.snap_on_start: - self._get_size() # preserve manual resize of image + self._size = self.size # preserve manual resize of image _remove_file(self._path_dirty) _remove_file(self._path_clean) return self @@ -339,15 +339,13 @@ class ReflinkVolume(qubes.storage.Volume): return collections.OrderedDict(sorted(items, key=lambda item: int(item[0]))) - def _get_size(self): + @property + def size(self): for path in (self._path_dirty, self._path_clean): with suppress(FileNotFoundError): - self._size = os.path.getsize(path) - break + return os.path.getsize(path) return self._size - size = property(_locked(_get_size)) - @property def usage(self): ''' Return volume disk usage from the VM's perspective. It is