From: Eric Biggers <ebiggers@kernel.org>
To: David Sterba <dsterba@suse.cz>
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-btrfs@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Ard Biesheuvel <ardb@kernel.org>,
"Jason A . Donenfeld" <Jason@zx2c4.com>
Subject: Re: [PATCH 10/10] btrfs: switch to library APIs for checksums
Date: Wed, 22 Oct 2025 10:59:34 -0700 [thread overview]
Message-ID: <20251022175934.GA1646@quark> (raw)
In-Reply-To: <20251022071141.GV13776@twin.jikos.cz>
On Wed, Oct 22, 2025 at 09:11:41AM +0200, David Sterba wrote:
> On Fri, Oct 17, 2025 at 09:31:06PM -0700, Eric Biggers wrote:
> > Make btrfs use the library APIs instead of crypto_shash, for all
> > checksum computations. This has many benefits:
> >
> > - Allows future checksum types, e.g. XXH3 or CRC64, to be more easily
> > supported. Only a library API will be needed, not crypto_shash too.
> >
> > - Eliminates the overhead of the generic crypto layer, including an
> > indirect call for every function call and other API overhead. A
> > microbenchmark of btrfs_check_read_bio() with crc32c checksums shows a
> > speedup from 658 cycles to 608 cycles per 4096-byte block.
> >
> > - Decreases the stack usage of btrfs by reducing the size of checksum
> > contexts from 384 bytes to 240 bytes, and by eliminating the need for
> > some functions to declare a checksum context at all.
> >
> > - Increases reliability. The library functions always succeed and
> > return void. In contrast, crypto_shash can fail and return errors.
> > Also, the library functions are guaranteed to be available when btrfs
> > is loaded; there's no longer any need to use module softdeps to try to
> > work around the crypto modules sometimes not being loaded.
> >
> > - Fixes a bug where blake2b checksums didn't work on kernels booted with
> > fips=1. Since btrfs checksums are for integrity only, it's fine for
> > them to use non-FIPS-approved algorithms.
> >
> > Note that with having to handle 4 algorithms instead of just 1-2, this
> > commit does result in a slightly positive diffstat. That being said,
> > this wouldn't have been the case if btrfs had actually checked for
> > errors from crypto_shash, which technically it should have been doing.
> >
> > Signed-off-by: Eric Biggers <ebiggers@kernel.org>
>
> Thanks, this simplifies quite a few things. I'd like to take it via the
> btrfs tree as there may be the hash additions (XXH3, BLAKE3) but
> currently I'm not sure if it won't make things more complicated. I
> haven't started the kernel part yet so I can use this patchset for
> development and rebase once it's merged.
Great. I'm planning to take patches 1-9 through libcrypto-next for
6.19. You can then take patch 10 through the btrfs tree for 6.20. Does
that sound good? We can work out the XXH3 and BLAKE3 support later. If
you'd like to add another checksum algorithm, I'd suggest picking just
one. btrfs already supports an awful lot of choices for the checksum.
But we can discuss that later.
- Eric
next prev parent reply other threads:[~2025-10-22 17:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-18 4:30 [PATCH 00/10] BLAKE2b library API Eric Biggers
2025-10-18 4:30 ` [PATCH 01/10] lib/crypto: blake2s: Adjust parameter order of blake2s() Eric Biggers
2025-10-19 14:36 ` Jason A. Donenfeld
2025-10-19 16:07 ` Eric Biggers
2025-10-20 17:44 ` Jason A. Donenfeld
2025-10-18 4:30 ` [PATCH 02/10] lib/crypto: blake2s: Rename blake2s_state to blake2s_ctx Eric Biggers
2025-10-18 4:30 ` [PATCH 03/10] lib/crypto: blake2s: Drop excessive const & rename block => data Eric Biggers
2025-10-18 4:31 ` [PATCH 04/10] lib/crypto: blake2s: Document the BLAKE2s library API Eric Biggers
2025-10-18 4:31 ` [PATCH 05/10] byteorder: Add le64_to_cpu_array() and cpu_to_le64_array() Eric Biggers
2025-10-18 4:31 ` [PATCH 06/10] lib/crypto: blake2b: Add BLAKE2b library functions Eric Biggers
2025-10-18 4:31 ` [PATCH 07/10] lib/crypto: arm/blake2b: Migrate optimized code into library Eric Biggers
2025-10-19 16:32 ` Eric Biggers
2025-10-18 4:31 ` [PATCH 08/10] lib/crypto: tests: Add KUnit tests for BLAKE2b Eric Biggers
2025-10-18 4:31 ` [PATCH 09/10] crypto: blake2b - Reimplement using library API Eric Biggers
2025-10-18 4:31 ` [PATCH 10/10] btrfs: switch to library APIs for checksums Eric Biggers
2025-10-22 7:11 ` David Sterba
2025-10-22 17:59 ` Eric Biggers [this message]
2025-10-23 18:45 ` David Sterba
2025-10-22 10:06 ` [PATCH 00/10] BLAKE2b library API Ard Biesheuvel
2025-10-24 19:21 ` Eric Biggers
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=20251022175934.GA1646@quark \
--to=ebiggers@kernel.org \
--cc=Jason@zx2c4.com \
--cc=ardb@kernel.org \
--cc=dsterba@suse.cz \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).