From nobody Thu Oct 19 01:32:51 2023 X-Original-To: freebsd-fs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4S9qwd6MfFz4xmp9 for ; Thu, 19 Oct 2023 01:33:05 +0000 (UTC) (envelope-from eborisch@alumni.stanford.edu) Received: from mail-yb1-xb2b.google.com (mail-yb1-xb2b.google.com [IPv6:2607:f8b0:4864:20::b2b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4S9qwd0yvpz3bBg for ; Thu, 19 Oct 2023 01:33:05 +0000 (UTC) (envelope-from eborisch@alumni.stanford.edu) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20230601 header.b=D79Yvk54; spf=pass (mx1.freebsd.org: domain of eborisch@alumni.stanford.edu designates 2607:f8b0:4864:20::b2b as permitted sender) smtp.mailfrom=eborisch@alumni.stanford.edu; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-yb1-xb2b.google.com with SMTP id 3f1490d57ef6-d9a64ca9cedso7698184276.1 for ; Wed, 18 Oct 2023 18:33:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697679183; x=1698283983; darn=freebsd.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=7SALuW4wamfSGBrY4/+HD5Yq+J/Qv7iuk0MNfBl3dz4=; b=D79Yvk54iLdKsLdnDD7OmhS5YSYc49nH2RU4BAUZVyEtEUhebq7QkERmWNqswwG+G0 R81MGOBfAdrik5i99IG+maHac1UvUmojKfUDkCdPJ/AghsaDnkmbqqABKfOyEPcPLaBX 69mj4ohNxryb+T4NO80fsl7vw/sd1Qglo+LSTTlVGxhyDXvL62I2AL/0+8zXVUY4JIzM BJI6LkUg0oIni2UMyyvAE5PRxh8CaElQkhc1eLnGjk93YFS1XwLUnCTwFQ7DDk8IRvwY g1rJjd0sjY3sKefAzqT9kzBICxOHOqPZtKtJ4jDu6xC9oTxHx/6djcUeye48F3PPjDEZ jG4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697679183; x=1698283983; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7SALuW4wamfSGBrY4/+HD5Yq+J/Qv7iuk0MNfBl3dz4=; b=iUR1Yc38a7C6x18OUd7PmZ0llUZfI2TZOOGI+alVPbSlWtl7bm5ABD5CaYgo4pT4QQ AVS1t0uPmFrK9aMFxHVMT7Muk+hga+mxQgVtO3XqqDYYBKWHQ6icG/bqs5kudv1GYyd+ vNrcBOZOjFtb1/qHLB+U2KH6sdDd0kp+lx2alqnW1etXw+hdbwb0Xu9qFGi5MM/VGH7z b7V6Q8Wv5RVa16gyantQbUqH6OyRRKEyVPhclSt6rrbM2TOiVZHJqccwvozxX5EjiZ5O JuY6rL4zJVrfvW0clH3P4wTKUCrFcowe0MHEM0bz0SOzgzlqZKnGv7L1K+h1hEICrPCk YrAQ== X-Gm-Message-State: AOJu0Yx10TI3OGRFN9VkRcdjRBJuOBpLiLmXQ8OLuw1IS0xBY+U4PziN nuyVsbMQeFgLQSGG+GDPOgKOeIqVKDIZwzpZ4KvE8K6KzAHor2Bc X-Google-Smtp-Source: AGHT+IGmccVjZi3uwTF4ekjtuHkt9KD4nlC2y9d+neskRRbk7SoTPEPYeF8AT/QajcvqKY+AINqceivqezr78QEsB98= X-Received: by 2002:a25:2d07:0:b0:d9b:87f3:54f7 with SMTP id t7-20020a252d07000000b00d9b87f354f7mr1099391ybt.49.1697679183458; Wed, 18 Oct 2023 18:33:03 -0700 (PDT) List-Id: Filesystems List-Archive: https://lists.freebsd.org/archives/freebsd-fs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-fs@freebsd.org MIME-Version: 1.0 References: <1733602178.6691.1697636557003@localhost> In-Reply-To: From: Eric Borisch Date: Wed, 18 Oct 2023 20:32:51 -0500 Message-ID: Subject: Re: free space considerations writing bhyve image to a zvol To: freebsd-fs@freebsd.org Content-Type: multipart/alternative; boundary="000000000000ac44ef060807bcf3" X-Spamd-Bar: --- X-Spamd-Result: default: False [-3.70 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; FORGED_SENDER(0.30)[eborisch@gmail.com,eborisch@alumni.stanford.edu]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20230601]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RCVD_COUNT_ONE(0.00)[1]; RCVD_TLS_LAST(0.00)[]; MLMMJ_DEST(0.00)[freebsd-fs@freebsd.org]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::b2b:from]; ARC_NA(0.00)[]; FROM_NEQ_ENVFROM(0.00)[eborisch@gmail.com,eborisch@alumni.stanford.edu]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; FROM_HAS_DN(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; PREVIOUSLY_DELIVERED(0.00)[freebsd-fs@freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; TO_DN_NONE(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim] X-Rspamd-Queue-Id: 4S9qwd0yvpz3bBg --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 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
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's sector size (2**ashift).

Ashift =3D 12 -> 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.

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).

If you don't need any of the shows-up-as-a-device and more predictab= le RW IOPS (operations on the volblocksize won'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's filesy= stem in a plan file will (assuming you haven't dialed down recordsize) = give you better compression.
=C2=A0- Eric

On Wed, Oct 18, 2023 at 8:51=E2=80=AFAM = void <void@f-m.fm&g= t; wrote:
On Wed, Oct 18, 2023 at 03:42:37PM +020= 0, Ronald Klop wrote:
>You can test how much it will compress your linuxvm.img.
>
>$ [/tmp] ls -l ./bla.txt
>-rw-------=C2=A0 1 ronald=C2=A0 wheel=C2=A0 5242880 Oct 18 15:39 ./bla.= txt
>
>$ [/tmp] lz4 -c ./bla.txt | wc -c
>=C2=A0 20604
>
>
>So do "lz4 -c linuxvm.img | wc -c" and it will print about th= e 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 ha= ve
tried similar, and if they can recall the results. Searching hasn't
come up with a near-enough matching context.
--

--000000000000ac44ef060807bcf3--