Re: What is needed for ZFS block cloning to work?

Rich <[email protected]> Sun, 12 Jul 2026 15:38:06 -0400
Newsgroups gmane.os.freebsd.devel.file-systems
Message-ID <CAOeNLurOB9fK48Crp4zV8nNdFAmErOFe-GNwC-bvfuGvK91oEA@mail.gmail.com>
--00000000000097479a06566f1d65
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Unless it changed, it's very specifically "if the block is marked as
deduplicated" (that is, the block pointer has the dedup bit set), because
otherwise you'd have trouble reasoning about who managed lifecycle of
blocks, because BRT isn't a bit set at the time the block is written, but
dedup is, so you would either need to have replaced both lifecycle
management systems with one, or let the one that was in control before BRT
was added remain in control of anything in it.

So I would expect if you have a dedup=3Doff dataset, even on a pool with a
DDT, then write new data, then try cloning it, it should clone as expected.
(Similarly for setting dedup=3Doff and dealing with data written after you
did that.)

It's been a minute since I looked, though, and it's possible that this was
changed since I did, or my memory is wrong.

- Rich


On Sun, Jul 12, 2026 at 3:21=E2=80=AFPM John F Carr <[email protected]> wrote:

>
>
> > On Jul 12, 2026, at 11:57=E2=80=AFAM, Rich <[email protected]> wrote=
:
> >
> > Unless the design changed from my memory, if you try to clone a block
> with the dedup bit set, it just increments the dedup table refcount and
> points to that copy, so BRT's accounting is never gonna get involved.
> >
> > - Rich
>
> That's it.  I think the condition is "if the pool ever had dedup active
> bcloneused will
> never increase and sharing will be accounted in the DEDUP column of zpool
> list."
> Copying a file of random data doesn't contribute to bcloneused even if I
> turn dedup off
> before creating the file.
>
> Deduplication is not well documented.  The ZFS developers seem to have
> regretted
> implementing it.  In hindsight the behavior makes a little sense.
>
> I plan to create logical copies of terabytes of data.  I will watch the
> allocated and dedup
> counts carefully.
>
> John
>
>

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

<div dir=3D"ltr"><div>Unless it changed, it&#39;s very specifically &quot;i=
f the block is marked as deduplicated&quot; (that is, the block pointer has=
 the dedup bit set), because otherwise you&#39;d have trouble reasoning abo=
ut who managed lifecycle of blocks, because BRT isn&#39;t a bit set at the =
time the block is written, but dedup is, so you would either need to have r=
eplaced both lifecycle management systems with one, or let the one that was=
 in control before BRT was added remain in control of anything in it.</div>=
<div><br></div><div>So I would expect if you have a dedup=3Doff dataset, ev=
en on a pool with a DDT, then write new data, then try cloning it, it shoul=
d clone as expected. (Similarly for setting dedup=3Doff and dealing with da=
ta written after you did that.)</div><div><br></div><div>It&#39;s been a mi=
nute since I looked, though, and it&#39;s possible that this was changed si=
nce I did, or my memory is wrong.</div><div><br></div><div>- Rich</div><div=
><br></div></div><br><div class=3D"gmail_quote gmail_quote_container"><div =
dir=3D"ltr" class=3D"gmail_attr">On Sun, Jul 12, 2026 at 3:21=E2=80=AFPM Jo=
hn F Carr &lt;<a href=3D"mailto:[email protected]">[email protected]</a>&gt; wrote:<br>=
</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;b=
order-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
&gt; On Jul 12, 2026, at 11:57=E2=80=AFAM, Rich &lt;<a href=3D"mailto:rince=
[email protected]" target=3D"_blank">[email protected]</a>&gt; wrote:<br>
&gt; <br>
&gt; Unless the design changed from my memory, if you try to clone a block =
with the dedup bit set, it just increments the dedup table refcount and poi=
nts to that copy, so BRT&#39;s accounting is never gonna get involved.<br>
&gt; <br>
&gt; - Rich<br>
<br>
That&#39;s it.=C2=A0 I think the condition is &quot;if the pool ever had de=
dup active bcloneused will<br>
never increase and sharing will be accounted in the DEDUP column of zpool l=
ist.&quot;<br>
Copying a file of random data doesn&#39;t contribute to bcloneused even if =
I turn dedup off<br>
before creating the file.<br>
<br>
Deduplication is not well documented.=C2=A0 The ZFS developers seem to have=
 regretted<br>
implementing it.=C2=A0 In hindsight the behavior makes a little sense.<br>
<br>
I plan to create logical copies of terabytes of data.=C2=A0 I will watch th=
e allocated and dedup<br>
counts carefully.<br>
<br>
John<br>
<br>
</blockquote></div>

--00000000000097479a06566f1d65--