Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Oct 2023 20:32:51 -0500
From:      Eric Borisch <eborisch@gmail.com>
To:        freebsd-fs@freebsd.org
Subject:   Re: free space considerations writing bhyve image to a zvol
Message-ID:  <CAMsT2=kc3rrTL=S%2B=Woxz0te=Jgr=u_HRLibDZ=XiifdBkob-Q@mail.gmail.com>
In-Reply-To: <ZS_ivB48NWpD1D8s@int21h>
References:  <ZS_WZD-JlHEo_Em5@int21h> <1733602178.6691.1697636557003@localhost> <ZS_ivB48NWpD1D8s@int21h>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
Be aware that compression of a zvol can be _very_ different from
compression of a file -- zvols must work on volblocksize-d segments to
compress, and are also forced into integer multiples of the underlying
pool's sector size (2**ashift).

Ashift = 12 -> 4k sector size are typical these days, so a zvol with
volblocksize=4k will not compress (save trivial all-0 areas and the like).
With volblocksize=8k, only if an 8k segment reaches 50% reduction can zfs
successfully compress, 25% for 16k volblocksize, etc.

On top of this, raidz setups bring their own allocation size requirements,
which hit harder on small recordsize / volbolcksize settings (which again,
are typically set smaller on zvols).

If you don't need any of the shows-up-as-a-device and more predictable RW
IOPS (operations on the volblocksize won't risk write amplification in the
ZFS layers or require decompressing a larger record) features of zvol, and
are more concerned about compression, leaving the VM's filesystem in a plan
file will (assuming you haven't dialed down recordsize) give you better
compression.

 - Eric

On Wed, Oct 18, 2023 at 8:51 AM void <void@f-m.fm> wrote:

> On Wed, Oct 18, 2023 at 03:42:37PM +0200, Ronald Klop wrote:
> >You can test how much it will compress your linuxvm.img.
> >
> >$ [/tmp] ls -l ./bla.txt
> >-rw-------  1 ronald  wheel  5242880 Oct 18 15:39 ./bla.txt
> >
> >$ [/tmp] lz4 -c ./bla.txt | wc -c
> >  20604
> >
> >
> >So do "lz4 -c linuxvm.img | wc -c" and it will print about the size of
> the zvol you need.
>
> thanks for that. I'm concerned about wrecking the linux vm's
> filesystem internally in this process though. I know it's easier to
> expand than contract; what i don't know is the detail
>
> >NB: What keeps you from just trying to write it to the zvol and see if it
> works?
>
> downtime & space considerations on the system. And curious if people have
> tried similar, and if they can recall the results. Searching hasn't
> come up with a near-enough matching context.
> --
>
>

[-- Attachment #2 --]
<div><div dir="ltr"><div>Be aware that compression of a zvol can be _very_ different from compression of a file -- zvols must work on volblocksize-d segments to compress, and are also forced into integer multiples of the underlying pool&#39;s sector size (2**ashift).</div><div><br></div><div dir="auto">Ashift = 12 -&gt; 4k sector size are typical these days, so a zvol with volblocksize=4k will not compress (save trivial all-0 areas and the like). With volblocksize=8k, only if an 8k segment reaches 50% reduction can zfs successfully compress, 25% for 16k volblocksize, etc.</div><div><br></div><div>On top of this, raidz setups bring their own allocation size requirements, which hit harder on small recordsize / volbolcksize settings (which again, are typically set smaller on zvols).</div><div><br></div><div>If you don&#39;t need any of the shows-up-as-a-device and more predictable RW IOPS (operations on the volblocksize won&#39;t risk write amplification in the ZFS layers or require decompressing a larger record) features of zvol, and are more concerned about compression, leaving the VM&#39;s filesystem in a plan file will (assuming you haven&#39;t dialed down recordsize) give you better compression.</div></div></div><div><div dir="ltr"><div><br></div><div> - Eric<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 18, 2023 at 8:51 AM void &lt;<a href="mailto:void@f-m.fm" target="_blank">void@f-m.fm</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)">On Wed, Oct 18, 2023 at 03:42:37PM +0200, Ronald Klop wrote:<br>
&gt;You can test how much it will compress your linuxvm.img.<br>
&gt;<br>
&gt;$ [/tmp] ls -l ./bla.txt<br>
&gt;-rw-------  1 ronald  wheel  5242880 Oct 18 15:39 ./bla.txt<br>
&gt;<br>
&gt;$ [/tmp] lz4 -c ./bla.txt | wc -c<br>
&gt;  20604<br>
&gt;<br>
&gt;<br>
&gt;So do &quot;lz4 -c linuxvm.img | wc -c&quot; and it will print about the size of the zvol you need.<br>
<br>
thanks for that. I&#39;m concerned about wrecking the linux vm&#39;s<br>
filesystem internally in this process though. I know it&#39;s easier to<br>
expand than contract; what i don&#39;t know is the detail<br>
<br>
&gt;NB: What keeps you from just trying to write it to the zvol and see if it works?<br>
<br>
downtime &amp; space considerations on the system. And curious if people have<br>
tried similar, and if they can recall the results. Searching hasn&#39;t<br>
come up with a near-enough matching context.<br>
-- <br>
<br>
</blockquote></div>
</div>
home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAMsT2=kc3rrTL=S%2B=Woxz0te=Jgr=u_HRLibDZ=XiifdBkob-Q>