From: Mark Harmstone <mark@harmstone.com>
To: dsterba@suse.cz
Cc: linux-btrfs@vger.kernel.org, wqu@suse.com, boris@bur.io,
lakshmipathi.g@gmail.com
Subject: Re: [PATCH v3] btrfs: add BTRFS_IOC_GET_CSUMS ioctl
Date: Wed, 15 Apr 2026 17:52:18 +0100 [thread overview]
Message-ID: <d02c32df-7b98-409f-9931-7240da9ef817@harmstone.com> (raw)
In-Reply-To: <20260415164345.GR12792@twin.jikos.cz>
On 15/04/2026 5.43 pm, David Sterba wrote:
> On Wed, Apr 15, 2026 at 02:56:49PM +0100, Mark Harmstone wrote:
>>>> When using the --reflink option added in btrfs-progs v6.16.1, we can forgo
>>>> reading the data entirely, resulting a ~2200% speed-up on the same test
>>>> (128s to 6s).
>>>
>>> Repeated mkfs is a specific use case, normaly it happens just once but I
>>> understand that for preparing various images the time savings are
>>> significiant.
>>>
>>> Once this ioctl is available I think the deduplication tools will make
>>> use of it as an initial filter before actually doing the real
>>> deduplication of extents.
>>
>> IIRC the mathematics of the birthday paradox is that for an n-bit hash,
>> you need 2^(n/2) sectors to have a 50% chance of a collision.
>>
>> For the 32-bit hashes, that means a 50% chance of a collision every 256
>> MB. For the 256-bit hashes, that's 2^140 bytes... whatever that works
>> out as. So the dedupe logic would no doubt be that for larger hash sizes
>> GET_CSUMS itself will be sufficient.
>
> It's used as a hint in the initial filter (e.g. in
> https://github.com/lakshmipathi/dduper), the final deduplication does
> full byte compariison (memcmp() inside vfs_dedupe_file_range_compare()).
I've only had a brief look at the project, but what Lakshmipathi calls
the "insane mode" ought to be safe for SHA256.
prev parent reply other threads:[~2026-04-15 16:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 17:14 [PATCH v3] btrfs: add BTRFS_IOC_GET_CSUMS ioctl Mark Harmstone
2026-04-13 22:17 ` Qu Wenruo
2026-04-14 12:57 ` Mark Harmstone
2026-04-14 2:07 ` David Sterba
2026-04-15 13:56 ` Mark Harmstone
2026-04-15 16:43 ` David Sterba
2026-04-15 16:52 ` Mark Harmstone [this message]
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=d02c32df-7b98-409f-9931-7240da9ef817@harmstone.com \
--to=mark@harmstone.com \
--cc=boris@bur.io \
--cc=dsterba@suse.cz \
--cc=lakshmipathi.g@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox