From: Eric Biggers <ebiggers@kernel.org>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: Alasdair Kergon <agk@redhat.com>,
Mike Snitzer <snitzer@kernel.org>,
Benjamin Marzinski <bmarzins@redhat.com>,
Ming-Hung Tsai <mtsai@redhat.com>,
Zdenek Kabelac <zkabelac@redhat.com>,
Filip Suba <fsuba@redhat.com>,
dm-devel@lists.linux.dev
Subject: Re: [PATCH] dm-compress: introduce the dm-compress target
Date: Mon, 23 Nov 2026 22:27:22 +0000 [thread overview]
Message-ID: <20261123222722.GB18468@google.com> (raw)
In-Reply-To: <d3fbdf3d-c7d8-0e4f-31f4-b187eb52ec30@redhat.com>
On Mon, Nov 23, 2026 at 10:07:01PM +0100, Mikulas Patocka wrote:
> +static int __init dm_compress_init(void)
> +{
> + int r;
> + unsigned i;
> +
> + for (i = 0; i < dm_compress_n_algorithms; i++) {
> + unsigned request_size;
> + dm_compress_algorithms[i].cc = crypto_alloc_acomp(dm_compress_algorithms[i].name, 0, 0);
> + if (IS_ERR(dm_compress_algorithms[i].cc)) {
> + r = PTR_ERR(dm_compress_algorithms[i].cc);
> + dm_compress_algorithms[i].cc = NULL;
> + DMERR("Could not initialize algorithm %s", dm_compress_algorithms[i].name);
> + goto bad;
> + }
> + request_size = ALIGN(sizeof(struct acomp_req) + crypto_acomp_reqsize(dm_compress_algorithms[i].cc), CRYPTO_MINALIGN);
> + dm_compress_max_request_size = max(dm_compress_max_request_size, request_size);
> + }
I would strongly suggest avoiding crypto_acomp for now. Instead, it
would be better to simplify the set of supported algorithms to ZSTD and
LZ4 (the ones that are well known to do the best on the space/time
tradeoff curve) and call those library APIs directly.
That avoids all the scatterlist nonsense and other crypto_acomp issues,
especially when it seems the caller in this module has linear buffers
already and waits synchronously for each one to complete. (acomp does
now support virtual addresses too, but it's still an extra layer that
provides no benefit for a synchronous software-only user like this.)
As-is, it looks like it also doesn't work correctly with the scomp-based
algorithms (lz4, lz4hc, lzo, 842) when chunk_size > PAGE_SIZE. In that
case scomp either returns -ENOSYS (making dm-compress silently store
everything uncompressed) or overflows its internal scratch buffer.
There's plenty of precedent for just using the compression libraries
directly: zram, dm-vdo, btrfs, f2fs, etc. If hardware offload is ever
wanted, it can be added later as an optional path, like erofs does.
- Eric
prev parent reply other threads:[~2026-11-23 22:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 21:07 [PATCH] dm-compress: introduce the dm-compress target Mikulas Patocka
2026-11-23 21:35 ` sashiko-bot
2026-11-23 22:27 ` Eric Biggers [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=20261123222722.GB18468@google.com \
--to=ebiggers@kernel.org \
--cc=agk@redhat.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=fsuba@redhat.com \
--cc=mpatocka@redhat.com \
--cc=mtsai@redhat.com \
--cc=snitzer@kernel.org \
--cc=zkabelac@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.