From: Fabian Ebner <f.ebner@proxmox.com>
To: Lorenz Stechauner <l.stechauner@proxmox.com>,
pve-devel@lists.proxmox.com, aderumier@odiso.com
Subject: Re: [pve-devel] [PATCH storage 1/1] fix #3580: plugins: make preallocation mode selectable for qcow2 and raw images
Date: Thu, 9 Sep 2021 14:04:35 +0200 [thread overview]
Message-ID: <b7e0cac5-696e-e4fc-8bf0-5d0d98f395c6@proxmox.com> (raw)
In-Reply-To: <31f9f8d5-e356-65aa-9a9c-301c4d1f68c6@proxmox.com>
Am 09.09.21 um 13:11 schrieb Lorenz Stechauner:
>
> On 09.09.21 12:25, Fabian Ebner wrote:
>> Am 08.09.21 um 10:11 schrieb alexandre derumier:
>>> Hi,
>>> it can be done too with ceph rbd with "rbd create ... –thick-provision"
>>>
>>
>> Hi,
>> there also is the 'sparse' storage config option (currently only used
>> for ZFS plugins). If there is only thick or thin, re-using that one is
>> probably nicer, because the newly proposed preallocation option seems
>> to be closely tied to qemu-img.
>
> Sounds like a good idea. I doubt, that anyone would use full
> prellocation anyway, so simply using 'sparse' for prealloc=off and
> default remains prealloc=metadata sounds good.
>
I actually only meant re-using 'sparse' for the RBD use case. But yes,
it seems like re-using it for the qemu-img use case would be enough to
fix the bug too. It might be a bit confusing though, because when sparse
is not set, the images would still be mostly sparse (except for metadata).
>>
>>> Le lundi 06 septembre 2021 à 15:15 +0200, Lorenz Stechauner a écrit :
>>>> the plugins for file based storages
>>>> * BTRFS
>>>> * CIFS
>>>> * Dir
>>>> * Glusterfs
>>>> * NFS
>>>> now allow the option 'preallocation'.
>>>>
>>>> 'preallocation' can have four values:
>>>> * default
>>>> * off
>>>> * metadata
>>>> * falloc
>>>> * full
>>>> see man pages for `qemu-img` for what these mean exactly. [0]
>>>>
>>>> the defualt value was chosen to be
>>>> * qcow2: metadata (as previously)
>>>> * raw: off (I was unable to find any documentation on this, so
>>>> could only test this and found, that 'off' was the most
>>>> fitting.)
>>>>
>>>> when using 'metadata' as preallocation mode, for raw images 'off'
>>>> is used.
>>>>
>>>> [0]
>>>> https://qemu.readthedocs.io/en/latest/system/images.html#disk-image-file-formats
>>>>
>>>>
>>>> Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
>>>> ---
>>>> PVE/Storage/BTRFSPlugin.pm | 1 +
>>>> PVE/Storage/CIFSPlugin.pm | 1 +
>>>> PVE/Storage/DirPlugin.pm | 1 +
>>>> PVE/Storage/GlusterfsPlugin.pm | 4 ++-
>>>> PVE/Storage/NFSPlugin.pm | 1 +
>>>> PVE/Storage/Plugin.pm | 46
>>>> +++++++++++++++++++++++++++++++++-
>>>> 6 files changed, 52 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/PVE/Storage/BTRFSPlugin.pm b/PVE/Storage/BTRFSPlugin.pm
>>>> index fe42082..31a2954 100644
>>>> --- a/PVE/Storage/BTRFSPlugin.pm
>>>> +++ b/PVE/Storage/BTRFSPlugin.pm
>>>> @@ -73,6 +73,7 @@ sub options {
>>>> is_mountpoint => { optional => 1 },
>>>> nocow => { optional => 1 },
>>>> mkdir => { optional => 1 },
>>>> + preallocation => { optional => 1 },
>>>> # TODO: The new variant of mkdir with `populate` vs
>>>> `create`...
>>>> };
>>>> }
>>>> diff --git a/PVE/Storage/CIFSPlugin.pm b/PVE/Storage/CIFSPlugin.pm
>>>> index 0221069..2d94413 100644
>>>> --- a/PVE/Storage/CIFSPlugin.pm
>>>> +++ b/PVE/Storage/CIFSPlugin.pm
>>>> @@ -140,6 +140,7 @@ sub options {
>>>> smbversion => { optional => 1},
>>>> mkdir => { optional => 1 },
>>>> bwlimit => { optional => 1 },
>>>> + preallocation => { optional => 1 },
>>>> };
>>>> }
>>>> diff --git a/PVE/Storage/DirPlugin.pm b/PVE/Storage/DirPlugin.pm
>>>> index 2267f11..3eeec98 100644
>>>> --- a/PVE/Storage/DirPlugin.pm
>>>> +++ b/PVE/Storage/DirPlugin.pm
>>>> @@ -59,6 +59,7 @@ sub options {
>>>> mkdir => { optional => 1 },
>>>> is_mountpoint => { optional => 1 },
>>>> bwlimit => { optional => 1 },
>>>> + preallocation => { optional => 1 },
>>>> };
>>>> }
>>>> diff --git a/PVE/Storage/GlusterfsPlugin.pm
>>>> b/PVE/Storage/GlusterfsPlugin.pm
>>>> index ea4df82..d8d2b88 100644
>>>> --- a/PVE/Storage/GlusterfsPlugin.pm
>>>> +++ b/PVE/Storage/GlusterfsPlugin.pm
>>>> @@ -137,6 +137,7 @@ sub options {
>>>> format => { optional => 1 },
>>>> mkdir => { optional => 1 },
>>>> bwlimit => { optional => 1 },
>>>> + preallocation => { optional => 1 },
>>>> };
>>>> }
>>>> @@ -260,7 +261,8 @@ sub alloc_image {
>>>> my $cmd = ['/usr/bin/qemu-img', 'create'];
>>>> - push @$cmd, '-o', 'preallocation=metadata' if $fmt eq 'qcow2';
>>>> + my $prealloc_opt =
>>>> PVE::Storage::Plugin::preallocation_cmd_option($scfg, $fmt);
>>>> + push @$cmd, '-o', $prealloc_opt if defined($prealloc_opt);
>>>> push @$cmd, '-f', $fmt, $volumepath, "${size}K";
>>>> diff --git a/PVE/Storage/NFSPlugin.pm b/PVE/Storage/NFSPlugin.pm
>>>> index 39bf15a..21b288a 100644
>>>> --- a/PVE/Storage/NFSPlugin.pm
>>>> +++ b/PVE/Storage/NFSPlugin.pm
>>>> @@ -90,6 +90,7 @@ sub options {
>>>> format => { optional => 1 },
>>>> mkdir => { optional => 1 },
>>>> bwlimit => { optional => 1 },
>>>> + preallocation => { optional => 1 },
>>>> };
>>>> }
>>>> diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
>>>> index b1865cb..4924525 100644
>>>> --- a/PVE/Storage/Plugin.pm
>>>> +++ b/PVE/Storage/Plugin.pm
>>>> @@ -41,6 +41,19 @@ our @SHARED_STORAGE = (
>>>> 'pbs',
>>>> );
>>>> +our $QCOW2_PREALLOCATION = {
>>>> + off => 1,
>>>> + metadata => 1,
>>>> + falloc => 1,
>>>> + full => 1,
>>>> +};
>>>> +
>>>> +our $RAW_PREALLOCATION = {
>>>> + off => 1,
>>>> + falloc => 1,
>>>> + full => 1,
>>>> +};
>>>> +
>>>> our $MAX_VOLUMES_PER_GUEST = 1024;
>>>> cfs_register_file ('storage.cfg',
>>>> @@ -150,6 +163,11 @@ my $defaultData = {
>>>> type => 'string', format => 'pve-storage-format',
>>>> optional => 1,
>>>> },
>>>> + preallocation => {
>>>> + description => "Preallocation mode for raw and qcow2
>>>> images.",
>>>> + type => 'string', enum => ['default', 'off', 'metadata',
>>>> 'falloc', 'full'],
>>>> + optional => 1,
>>>> + },
>>>> },
>>>> };
>>>> @@ -762,7 +780,8 @@ sub alloc_image {
>>>> } else {
>>>> my $cmd = ['/usr/bin/qemu-img', 'create'];
>>>> - push @$cmd, '-o', 'preallocation=metadata' if $fmt eq
>>>> 'qcow2';
>>>> + my $prealloc_opt = preallocation_cmd_option($scfg, $fmt);
>>>> + push @$cmd, '-o', $prealloc_opt if defined($prealloc_opt);
>>>> push @$cmd, '-f', $fmt, $path, "${size}K";
>>>> @@ -1484,4 +1503,29 @@ sub volume_import_formats {
>>>> return ();
>>>> }
>>>> +sub preallocation_cmd_option {
>>>> + my ($scfg, $fmt) = @_;
>>>> +
>>>> + my $prealloc = $scfg->{preallocation};
>>>> +
>>>> + $prealloc = undef if $prealloc eq 'default';
>>>> +
>>>> + if ($fmt eq 'qcow2') {
>>>> + $prealloc = $prealloc // 'metadata';
>>>> +
>>>> + die "preallocation mode '$prealloc' not supported by format
>>>> '$fmt'\n" if !$QCOW2_PREALLOCATION->{$prealloc};
>>>> +
>>>> + return "preallocation=$prealloc";
>>>> + } elsif ($fmt eq 'raw') {
>>>> + $prealloc = $prealloc // 'off';
>>>> + $prealloc = 'off' if $prealloc eq 'metadata';
>>>> +
>>>> + die "preallocation mode '$prealloc' not supported by format
>>>> '$fmt'\n" if !$RAW_PREALLOCATION->{$prealloc};
>>>> +
>>>> + return "preallocation=$prealloc";
>>>> + }
>>>> +
>>>> + return undef;
>>>> +}
>>>> +
>>>> 1;
>>>
>>> _______________________________________________
>>> pve-devel mailing list
>>> pve-devel@lists.proxmox.com
>>> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>>>
next prev parent reply other threads:[~2021-09-09 12:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-06 13:15 [pve-devel] [PATCH-SERIES storage/manager] fix #3580: " Lorenz Stechauner
2021-09-06 13:15 ` [pve-devel] [PATCH storage 1/1] fix #3580: plugins: " Lorenz Stechauner
2021-09-08 8:11 ` alexandre derumier
2021-09-09 10:25 ` Fabian Ebner
2021-09-09 11:11 ` Lorenz Stechauner
2021-09-09 12:04 ` Fabian Ebner [this message]
2021-09-09 12:26 ` Lorenz Stechauner
2021-09-09 12:28 ` Thomas Lamprecht
2021-09-14 9:44 ` Fabian Ebner
2021-09-06 13:15 ` [pve-devel] [PATCH manager 1/2] ui: add PreallocationSelector Lorenz Stechauner
2021-09-06 13:15 ` [pve-devel] [PATCH manager 2/2] fix 3850: ui: storage: using PreallocationSelector for file based storage types Lorenz Stechauner
2021-09-14 9:55 ` Fabian Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b7e0cac5-696e-e4fc-8bf0-5d0d98f395c6@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=aderumier@odiso.com \
--cc=l.stechauner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.