Merge remote-tracking branch 'qubesos/pr/194'
* qubesos/pr/194: reflink: style fix storage: typo fix lvm_thin: _remove_revisions() on revisions_to_keep==0 lvm_thin: don't purge one revision too few lvm_thin: really remove revision lvm_thin: fill in volume's revisions_to_keep from pool
This commit is contained in:
commit
033100fa7e
@ -58,7 +58,7 @@ class ThinPool(qubes.storage.Pool):
|
|||||||
self.volume_group = volume_group
|
self.volume_group = volume_group
|
||||||
self.thin_pool = thin_pool
|
self.thin_pool = thin_pool
|
||||||
self._pool_id = "{!s}/{!s}".format(volume_group, thin_pool)
|
self._pool_id = "{!s}/{!s}".format(volume_group, thin_pool)
|
||||||
self.log = logging.getLogger('qube.storage.lvm.%s' % self._pool_id)
|
self.log = logging.getLogger('qubes.storage.lvm.%s' % self._pool_id)
|
||||||
|
|
||||||
self._volume_objects_cache = {}
|
self._volume_objects_cache = {}
|
||||||
|
|
||||||
@ -78,6 +78,8 @@ class ThinPool(qubes.storage.Pool):
|
|||||||
''' Initialize a :py:class:`qubes.storage.Volume` from `volume_config`.
|
''' Initialize a :py:class:`qubes.storage.Volume` from `volume_config`.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
if 'revisions_to_keep' not in volume_config.keys():
|
||||||
|
volume_config['revisions_to_keep'] = self.revisions_to_keep
|
||||||
if 'vid' not in volume_config.keys():
|
if 'vid' not in volume_config.keys():
|
||||||
if vm and hasattr(vm, 'name'):
|
if vm and hasattr(vm, 'name'):
|
||||||
vm_name = vm.name
|
vm_name = vm.name
|
||||||
@ -196,7 +198,7 @@ class ThinVolume(qubes.storage.Volume):
|
|||||||
def __init__(self, volume_group, size=0, **kwargs):
|
def __init__(self, volume_group, size=0, **kwargs):
|
||||||
self.volume_group = volume_group
|
self.volume_group = volume_group
|
||||||
super(ThinVolume, self).__init__(size=size, **kwargs)
|
super(ThinVolume, self).__init__(size=size, **kwargs)
|
||||||
self.log = logging.getLogger('qube.storage.lvm.%s' % str(self.pool))
|
self.log = logging.getLogger('qubes.storage.lvm.%s' % str(self.pool))
|
||||||
|
|
||||||
if self.snap_on_start or self.save_on_stop:
|
if self.snap_on_start or self.save_on_stop:
|
||||||
self._vid_snap = self.vid + '-snap'
|
self._vid_snap = self.vid + '-snap'
|
||||||
@ -260,12 +262,13 @@ class ThinVolume(qubes.storage.Volume):
|
|||||||
if revisions is None:
|
if revisions is None:
|
||||||
revisions = sorted(self.revisions.items(),
|
revisions = sorted(self.revisions.items(),
|
||||||
key=operator.itemgetter(1))
|
key=operator.itemgetter(1))
|
||||||
revisions = revisions[:-self.revisions_to_keep]
|
# pylint: disable=invalid-unary-operand-type
|
||||||
|
revisions = revisions[:(-self.revisions_to_keep) or None]
|
||||||
revisions = [rev_id for rev_id, _ in revisions]
|
revisions = [rev_id for rev_id, _ in revisions]
|
||||||
|
|
||||||
for rev_id in revisions:
|
for rev_id in revisions:
|
||||||
try:
|
try:
|
||||||
cmd = ['remove', self.vid + rev_id]
|
cmd = ['remove', self.vid + '-' + rev_id]
|
||||||
qubes_lvm(cmd, self.log)
|
qubes_lvm(cmd, self.log)
|
||||||
except qubes.storage.StoragePoolException:
|
except qubes.storage.StoragePoolException:
|
||||||
pass
|
pass
|
||||||
@ -284,7 +287,8 @@ class ThinVolume(qubes.storage.Volume):
|
|||||||
cmd = ['clone', self.vid,
|
cmd = ['clone', self.vid,
|
||||||
'{}-{}-back'.format(self.vid, int(time.time()))]
|
'{}-{}-back'.format(self.vid, int(time.time()))]
|
||||||
qubes_lvm(cmd, self.log)
|
qubes_lvm(cmd, self.log)
|
||||||
self._remove_revisions()
|
reset_cache()
|
||||||
|
self._remove_revisions()
|
||||||
|
|
||||||
# TODO: when converting this function to coroutine, this _must_ be
|
# TODO: when converting this function to coroutine, this _must_ be
|
||||||
# under a lock
|
# under a lock
|
||||||
|
@ -37,7 +37,7 @@ import qubes.storage
|
|||||||
|
|
||||||
BLKSIZE = 512
|
BLKSIZE = 512
|
||||||
FICLONE = 1074041865 # see ioctl_ficlone manpage
|
FICLONE = 1074041865 # see ioctl_ficlone manpage
|
||||||
LOGGER = logging.getLogger('qube.storage.reflink')
|
LOGGER = logging.getLogger('qubes.storage.reflink')
|
||||||
|
|
||||||
|
|
||||||
class ReflinkPool(qubes.storage.Pool):
|
class ReflinkPool(qubes.storage.Pool):
|
||||||
@ -187,9 +187,9 @@ class ReflinkVolume(qubes.storage.Volume):
|
|||||||
_rename_file(self._path_dirty, self._path_clean)
|
_rename_file(self._path_dirty, self._path_clean)
|
||||||
|
|
||||||
def _add_revision(self):
|
def _add_revision(self):
|
||||||
if self.revisions_to_keep is 0:
|
if self.revisions_to_keep == 0:
|
||||||
return
|
return
|
||||||
if _get_file_disk_usage(self._path_clean) is 0:
|
if _get_file_disk_usage(self._path_clean) == 0:
|
||||||
return
|
return
|
||||||
ctime = os.path.getctime(self._path_clean)
|
ctime = os.path.getctime(self._path_clean)
|
||||||
revision = qubes.storage.isodate(int(ctime)) + 'Z'
|
revision = qubes.storage.isodate(int(ctime)) + 'Z'
|
||||||
|
Loading…
Reference in New Issue
Block a user