From 90f25890cf291900457385a2738bd2a371854fb7 Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Fri, 17 Jan 2020 15:56:50 +0000 Subject: [PATCH 1/3] storage/reflink: pool.setup_check -> pool._setup_check --- qubes/storage/reflink.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qubes/storage/reflink.py b/qubes/storage/reflink.py index 795a7ffc..4a4812a3 100644 --- a/qubes/storage/reflink.py +++ b/qubes/storage/reflink.py @@ -61,14 +61,14 @@ class ReflinkPool(qubes.storage.Pool): def __init__(self, dir_path, setup_check='yes', revisions_to_keep=1, **kwargs): super().__init__(revisions_to_keep=revisions_to_keep, **kwargs) + self._setup_check = qubes.property.bool(None, None, setup_check) self._volumes = {} self.dir_path = os.path.abspath(dir_path) - self.setup_check = qubes.property.bool(None, None, setup_check) @_coroutinized def setup(self): created = _make_dir(self.dir_path) - if self.setup_check and not is_supported(self.dir_path): + if self._setup_check and not is_supported(self.dir_path): if created: _remove_empty_dir(self.dir_path) raise qubes.storage.StoragePoolException( From ba662d28195da81a85a8b2ef9b716f9ea9cbc575 Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Fri, 17 Jan 2020 15:56:51 +0000 Subject: [PATCH 2/3] storage/reflink: bail out early on most FICLONE errnos Don't fall back on 'cp' if the FICLONE ioctl gives an errno that's not plausibly reflink specific, because in such a case any fallback could theoretically mask real but intermittent system/storage errors. Looking through ioctl_ficlone(2) and the kernel source, it should be sufficient to do the fallback only on EBADF/EINVAL/EOPNOTSUPP/EXDEV. (EISDIR/ETXTBSY don't apply to this storage driver, which will never legitimately attempt to reflink a directory or an active - in the storage domain - swap file.) --- qubes/storage/reflink.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qubes/storage/reflink.py b/qubes/storage/reflink.py index 4a4812a3..436658aa 100644 --- a/qubes/storage/reflink.py +++ b/qubes/storage/reflink.py @@ -446,7 +446,10 @@ def _attempt_ficlone(src, dst): try: fcntl.ioctl(dst.fileno(), FICLONE, src.fileno()) return True - except OSError: + except OSError as ex: + if ex.errno not in (errno.EBADF, errno.EINVAL, + errno.EOPNOTSUPP, errno.EXDEV): + raise return False def _copy_file(src, dst): From d54e4b0c6e35c54bd6d4fb40439b575ea660ae56 Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Fri, 17 Jan 2020 16:45:29 +0000 Subject: [PATCH 3/3] storage/reflink: fix comment --- qubes/storage/reflink.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qubes/storage/reflink.py b/qubes/storage/reflink.py index 436658aa..99553ace 100644 --- a/qubes/storage/reflink.py +++ b/qubes/storage/reflink.py @@ -81,7 +81,7 @@ class ReflinkPool(qubes.storage.Pool): def init_volume(self, vm, volume_config): # Fail closed on any strange VM dir_path_prefix, just in case - # /etc/udev/rules/00-qubes-ignore-devices.rules needs updating + # /etc/udev/rules.d/00-qubes-ignore-devices.rules needs update assert vm.dir_path_prefix in self._known_dir_path_prefixes, \ 'Unknown dir_path_prefix {!r}'.format(vm.dir_path_prefix)