Storage: Restore VM filesystem size.state quota on backup restore #9628
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Use
size.state
(if set) or otherwise use default 100MiB setting ifsize
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>
, wheresize.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 settingnodatacow
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