Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage: Restore VM filesystem size.state quota on backup restore #9628

Merged

Conversation

tomponline
Copy link
Member

@tomponline tomponline commented Dec 6, 2021

Use size.state (if set) or otherwise use default 100MiB setting if size is set, to apply quota to VM's filesystem volume.

Warning:
Whilst this PR does fix a bug, it will introduce further issues with the BTRFS storage driver.
Due to the way that BTRFS accounts for subvolume quota by conflating both CoW snapshot writes and actual new usage in a subvolume, this will cause issues with VM snapshots.

This is because when applying a VM disk quota, the LXD BTRFS driver will set the subvolume quota to <size.state>+<raw disk image size>, where size.state defaults to 100MiB.

When restoring a non-optimised VM backup, BTRFS will account (correctly) that 100% of the raw disk file has been written to.
But this will then mean that when creating a VM snapshot, that only up to 100MiB (or whatever size.state) can be written to the VM's disk before the BTRFS quota is reached, causing I/O errors in the VM. This is because despite of setting nodatacow for new VM disk files (https://github.com/lxc/lxd/pull/9627) the initial write to an extent after a snapshot has been taken will necessarily trigger a CoW (in order to keep track of the snapshot's contents). BTRFS extents can be up to 128MiB in size, and this will then cause both the old and new extents to be accounted toward the subvolume's quota usage.

Previously this bug masked the issue by not enforcing a BTRFS quota for restored VM backups.

Related to #9124

Signed-off-by: Thomas Parrott thomas.parrott@canonical.com

…ckup restore

Use size.state (if set) or otherwise use default 100MiB setting if size is non-empty, to apply quota to VM's filesystem volume.

Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
@tomponline tomponline self-assigned this Dec 6, 2021
@stgraber stgraber merged commit 39f8be9 into canonical:master Dec 7, 2021
@tomponline tomponline deleted the tp-storage-backup-restore-state-quota branch December 7, 2021 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants