You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cherry-picks support for using zstd's external sequence producer API in the
kernel. This unblocks the use of QuickAssist hardware acceleration for zstd in
applications such as BTRFS.
Some context: the kernel uses ZSTD_initStaticCCtx() to create compression
contexts. This function builds the compression context in a user-provided buffer
which must be sized according to the compression parameters. zstd provides size
estimation functions for this purpose, but until now they were not compatible
with the external sequence producer API.
This cherry-pick fixes that incompatibility. More specifically, it pulls in zstd
upstream PRs #3839 and #3854. PR #3854 includes a unit test (upstream only)
which validates that the external sequence producer API works correctly in
conjunction with ZSTD_initStaticCCtx().
To build this commit, I first cherry-picked the relevant commits onto the
upstream v1.5.5-kernel tag:
cd ~/repos/zstd
git checkout tags/v1.5.5-kernel
git cherry-pick -m 1 126ec2669c927b24acd38ea903a211c1b5416588
git cherry-pick c6cabf94417d84ebb5da62e05d8b8a9623763585
I then ran "make import" to copy the changes into my fork of Linux:
cd ~/repos/zstd/contrib/linux-kernel/
make import
Signed-off-by: Elliot Gorokhovsky <embg@meta.com>
Copy file name to clipboardexpand all lines: lib/zstd/compress/zstd_compress_internal.h
+12-14
Original file line number
Diff line number
Diff line change
@@ -355,10 +355,11 @@ struct ZSTD_CCtx_params_s {
355
355
* if the external matchfinder returns an error code. */
356
356
intenableMatchFinderFallback;
357
357
358
-
/* Indicates whether an external matchfinder has been referenced.
359
-
* Users can't set this externally.
360
-
* It is set internally in ZSTD_registerSequenceProducer(). */
361
-
intuseSequenceProducer;
358
+
/* Parameters for the external sequence producer API.
359
+
* Users set these parameters through ZSTD_registerSequenceProducer().
360
+
* It is not possible to set these parameters individually through the public API. */
361
+
void*extSeqProdState;
362
+
ZSTD_sequenceProducer_FextSeqProdFunc;
362
363
363
364
/* Adjust the max block size*/
364
365
size_tmaxBlockSize;
@@ -396,14 +397,6 @@ typedef struct {
396
397
ZSTD_entropyCTablesMetadata_tentropyMetadata;
397
398
} ZSTD_blockSplitCtx;
398
399
399
-
/* Context for block-level external matchfinder API */
400
-
typedefstruct {
401
-
void*mState;
402
-
ZSTD_sequenceProducer_F*mFinder;
403
-
ZSTD_Sequence*seqBuffer;
404
-
size_tseqBufferCapacity;
405
-
} ZSTD_externalMatchCtx;
406
-
407
400
structZSTD_CCtx_s {
408
401
ZSTD_compressionStage_estage;
409
402
intcParamsChanged; /* == 1 if cParams(except wlog) or compression level are changed in requestedParams. Triggers transmission of new params to ZSTDMT (if available) then reset to 0. */
@@ -468,8 +461,9 @@ struct ZSTD_CCtx_s {
468
461
/* Workspace for block splitter */
469
462
ZSTD_blockSplitCtxblockSplitCtx;
470
463
471
-
/* Workspace for external matchfinder */
472
-
ZSTD_externalMatchCtxexternalMatchCtx;
464
+
/* Buffer for output from external sequence producer */
0 commit comments