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>

next in thread | previous in thread | raw e-mail | index | archive | help
--000000000000ac44ef060807bcf3
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

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 =3D 12 -> 4k sector size are typical these days, so a zvol with
volblocksize=3D4k will not compress (save trivial all-0 areas and the like)=
.
With volblocksize=3D8k, 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=E2=80=AFAM 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 i=
t
> 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.
> --
>
>

--000000000000ac44ef060807bcf3
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div><div dir=3D"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 un=
derlying pool&#39;s sector size (2**ashift).</div><div><br></div><div dir=
=3D"auto">Ashift =3D 12 -&gt; 4k sector size are typical these days, so a z=
vol with volblocksize=3D4k will not compress (save trivial all-0 areas and =
the like). With volblocksize=3D8k, only if an 8k segment reaches 50% reduct=
ion can zfs successfully compress, 25% for 16k volblocksize, etc.</div><div=
><br></div><div>On top of this, raidz setups bring their own allocation siz=
e requirements, which hit harder on small recordsize / volbolcksize setting=
s (which again, are typically set smaller on zvols).</div><div><br></div><d=
iv>If you don&#39;t need any of the shows-up-as-a-device and more predictab=
le RW IOPS (operations on the volblocksize won&#39;t risk write amplificati=
on in the ZFS layers or require decompressing a larger record) features of =
zvol, and are more concerned about compression, leaving the VM&#39;s filesy=
stem in a plan file will (assuming you haven&#39;t dialed down recordsize) =
give you better compression.</div></div></div><div><div dir=3D"ltr"><div><b=
r></div><div>=C2=A0- Eric<br></div></div><br><div class=3D"gmail_quote"><di=
v dir=3D"ltr" class=3D"gmail_attr">On Wed, Oct 18, 2023 at 8:51=E2=80=AFAM =
void &lt;<a href=3D"mailto:void@f-m.fm" target=3D"_blank">void@f-m.fm</a>&g=
t; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0p=
x 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 +020=
0, 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-------=C2=A0 1 ronald=C2=A0 wheel=C2=A0 5242880 Oct 18 15:39 ./bla.=
txt<br>
&gt;<br>
&gt;$ [/tmp] lz4 -c ./bla.txt | wc -c<br>
&gt;=C2=A0 20604<br>
&gt;<br>
&gt;<br>
&gt;So do &quot;lz4 -c linuxvm.img | wc -c&quot; and it will print about th=
e 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 ha=
ve<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>

--000000000000ac44ef060807bcf3--



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>