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

Create sparse files on backup import and migration receive #773

Merged
merged 3 commits into from
Apr 20, 2024

Conversation

milaiwi
Copy link
Contributor

@milaiwi milaiwi commented Apr 20, 2024

What Changed

  1. incusd/storage/drivers: Introduce SparseFileWrapper
  • Added SparseFileWrapper struct and Write function to internal/server/storage/drivers/utils.go
  1. incusd/storage/drivers/vfs: Use SpraseFileWrapper on backup import
  • Changed the io.Copy call in genericVFSBackupUnpack to use our wrapper struct.

Examples

  • On Creation
ubuntu@ubuntu:~/incus$ sudo du -sch /var/lib/incus/storage-pools/dir/virtual-machines/a1/root.img
254M	/var/lib/incus/storage-pools/dir/virtual-machines/a1/root.img
254M	total
ubuntu@ubuntu:~/incus$ sudo  sha256sum /var/lib/incus/storage-pools/dir/virtual-machines/a1/root.img
3621514d973e5e7f80f7c9302d1348bd2a9789454421ec3f458bac7c0feb9f0c  /var/lib/incus/storage-pools/dir/virtual-machines/a1/root.img
  • On Import
ubuntu@ubuntu:~/incus$ sudo du -sch /var/lib/incus/storage-pools/dir/virtual-machines/a1/root.img
254M	/var/lib/incus/storage-pools/dir/virtual-machines/a1/root.img
254M	total
ubuntu@ubuntu:~/incus$ sudo  sha256sum /var/lib/incus/storage-pools/dir/virtual-machines/a1/root.img
3621514d973e5e7f80f7c9302d1348bd2a9789454421ec3f458bac7c0feb9f0c  /var/lib/incus/storage-pools/dir/virtual-machines/a1/root.img

Closes #662

@milaiwi milaiwi requested a review from stgraber as a code owner April 20, 2024 02:32
@stgraber stgraber changed the title Fixed: Investigate sparse file support for VMs (#662) Create sparse files on backup import and migration receive Apr 20, 2024
@stgraber
Copy link
Member

Thanks, I've just done a few minor edits:

  • Move the struct and function together so it's easier to find
  • Tweaked the comments on the struct and function to comply with godoc format
  • Made the W field private (renamed to w)
  • Added a NewSparseFileWrapper function that can be used externally (as w is now private)
  • Simplified the wrapping in genericVFSBackupUnpack
  • Added the same wrapping to genericVFSCreateVolumeFromMigration

@stgraber stgraber merged commit 7f42843 into lxc:main Apr 20, 2024
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Investigate sparse file support for VMs
2 participants