Skip to contentSkip to conversation

zstd: Import upstream v1.5.7

PATCH In review Nick Terrell 3 participants 5 messages Mar 13, 2025 – Mar 19, 2025 Zstd

lore
Share & tools
lore
#0 lore raw

cover zstd: Import upstream v1.5.7

From: Nick Terrell <[email protected]>

Since this is a large patch, I have also prepared a pull request as an alternate means of fetching the commit:

The following changes since commit 7eb172143d5508b4da468ed59ee857c6e5e01da6:

Linux 6.14-rc5 (2025-03-02 11:48:20 -0800)

are available in the Git repository at:

https://github.com/terrelln/linux.git tags/2025-03-13-zstd-v1.5.7-v1

for you to fetch changes up to 65d1f5507ed2c78c64fce40e44e5574a9419eb09:

----------------------------------------------------------------
zstd: Import upstream v1.5.7

----------------------------------------------------------------

Nick Terrell (1):
zstd: Import upstream v1.5.7

 include/linux/zstd.h                          |   87 +-
 include/linux/zstd_errors.h                   |   30 +-
 include/linux/zstd_lib.h                      | 1123 ++++--
 lib/zstd/Makefile                             |    3 +-
 lib/zstd/common/allocations.h                 |   56 +
 lib/zstd/common/bits.h                        |  150 +
 lib/zstd/common/bitstream.h                   |  155 +-
 lib/zstd/common/compiler.h                    |  151 +-
 lib/zstd/common/cpu.h                         |    3 +-
 lib/zstd/common/debug.c                       |    9 +-
 lib/zstd/common/debug.h                       |   37 +-
 lib/zstd/common/entropy_common.c              |   42 +-
 lib/zstd/common/error_private.c               |   13 +-
 lib/zstd/common/error_private.h               |   88 +-
 lib/zstd/common/fse.h                         |  103 +-
 lib/zstd/common/fse_decompress.c              |  132 +-
 lib/zstd/common/huf.h                         |  240 +-
 lib/zstd/common/mem.h                         |    3 +-
 lib/zstd/common/portability_macros.h          |   45 +-
 lib/zstd/common/zstd_common.c                 |   38 +-
 lib/zstd/common/zstd_deps.h                   |   16 +-
 lib/zstd/common/zstd_internal.h               |  153 +-
 lib/zstd/compress/clevels.h                   |    3 +-
 lib/zstd/compress/fse_compress.c              |   74 +-
 lib/zstd/compress/hist.c                      |   13 +-
 lib/zstd/compress/hist.h                      |   10 +-
 lib/zstd/compress/huf_compress.c              |  441 ++-
 lib/zstd/compress/zstd_compress.c             | 3293 ++++++++++++-----
 lib/zstd/compress/zstd_compress_internal.h    |  621 +++-
 lib/zstd/compress/zstd_compress_literals.c    |  157 +-
 lib/zstd/compress/zstd_compress_literals.h    |   25 +-
 lib/zstd/compress/zstd_compress_sequences.c   |   21 +-
 lib/zstd/compress/zstd_compress_sequences.h   |   16 +-
 lib/zstd/compress/zstd_compress_superblock.c  |  394 +-
 lib/zstd/compress/zstd_compress_superblock.h  |    3 +-
 lib/zstd/compress/zstd_cwksp.h                |  222 +-
 lib/zstd/compress/zstd_double_fast.c          |  245 +-
 lib/zstd/compress/zstd_double_fast.h          |   27 +-
 lib/zstd/compress/zstd_fast.c                 |  703 +++-
 lib/zstd/compress/zstd_fast.h                 |   16 +-
 lib/zstd/compress/zstd_lazy.c                 |  840 +++--
 lib/zstd/compress/zstd_lazy.h                 |  195 +-
 lib/zstd/compress/zstd_ldm.c                  |  102 +-
 lib/zstd/compress/zstd_ldm.h                  |   17 +-
 lib/zstd/compress/zstd_ldm_geartab.h          |    3 +-
 lib/zstd/compress/zstd_opt.c                  |  571 +--
 lib/zstd/compress/zstd_opt.h                  |   55 +-
 lib/zstd/compress/zstd_preSplit.c             |  239 ++
 lib/zstd/compress/zstd_preSplit.h             |   34 +
 lib/zstd/decompress/huf_decompress.c          |  887 +++--
 lib/zstd/decompress/zstd_ddict.c              |    9 +-
 lib/zstd/decompress/zstd_ddict.h              |    3 +-
 lib/zstd/decompress/zstd_decompress.c         |  375 +-
 lib/zstd/decompress/zstd_decompress_block.c   |  724 ++--
 lib/zstd/decompress/zstd_decompress_block.h   |   10 +-
 .../decompress/zstd_decompress_internal.h     |   19 +-
 lib/zstd/decompress_sources.h                 |    2 +-
 lib/zstd/zstd_common_module.c                 |    5 +-
 lib/zstd/zstd_compress_module.c               |   75 +-
 lib/zstd/zstd_decompress_module.c             |    4 +-
 60 files changed, 8749 insertions(+), 4381 deletions(-)
 create mode 100644 lib/zstd/common/allocations.h
 create mode 100644 lib/zstd/common/bits.h
 create mode 100644 lib/zstd/compress/zstd_preSplit.c
 create mode 100644 lib/zstd/compress/zstd_preSplit.h
Signature · 1 line
2.48.1
#1 lore raw

PATCH 1/1 zstd: Import upstream v1.5.7

From: Nick Terrell <[email protected]>

In addition to keeping the kernel's copy of zstd up to date, this update was requested by Intel to expose upstream's APIs that allow QAT to accelerate the LZ match finding stage of Zstd.

This patch is imported from the upstream tag v1.5.7-kernel [0], which is signed with upstream's signing key EF8FE99528B52FFD [1]. It was imported from upstream using this command:

export ZSTD=/path/to/repo/zstd/
export LINUX=/path/to/repo/linux/
cd "$ZSTD/contrib/linux-kernel"
git checkout v1.5.7-kernel
make import LINUX="$LINUX"

This patch has been tested on x86-64, and has been boot tested with a zstd compressed kernel & initramfs on i386 and aarch64. I benchmarked the patch on x86-64 with gcc-14.2.1 on an Intel i9-9900K by measruing the performance of compressed filesystem reads and writes.

Component, Level, Size delta, C. time delta, D. time delta

Btrfs    ,      1,      +0.00%,         -6.1%,          +1.4%
Btrfs    ,      3,      +0.00%,         -9.8%,          +3.0%
Btrfs    ,      5,      +0.00%,         +1.7%,          +1.4%
Btrfs    ,      7,      +0.00%,         -1.9%,          +2.7%
Btrfs    ,      9,      +0.00%,         -3.4%,          +3.7%
Btrfs    ,     15,      +0.00%,         -0.3%,          +3.6%
SquashFS ,      1,      +0.00%,           N/A,          +1.9%

The major changes that impact the kernel use cases for each version are:

v1.5.7: https://github.com/facebook/zstd/releases/tag/v1.5.7
* Add zstd_compress_sequences_and_literals() for use by Intel's QAT driver to implement Zstd compression acceleration in the kernel.
* Fix an underflow bug in 32-bit builds that can cause data corruption when processing more than 4GB of data with a single ZSTD_CCtx object, when an input crosses the 4GB boundry. I don't believe this impacts any current kernel use cases, because the ZSTD_CCtx is typically reconstructed between compressions.
* Levels 1-4 see 5-10% compression speed improvements for inputs smaller than 128KB.

v1.5.6: https://github.com/facebook/zstd/releases/tag/v1.5.6
* Improved compression ratio for the highest compression levels. I don't expect these see much use however, due to their slow speeds.

v1.5.5: https://github.com/facebook/zstd/releases/tag/v1.5.5
* Fix a rare corruption bug that can trigger on levels 13 and above.
* Improve compression speed of levels 5-11 on incompressible data.

v1.5.4: https://github.com/facebook/zstd/releases/tag/v1.5.4
* Improve copmression speed of levels 5-11 on ARM.
* Improve dictionary compression speed.

---
 include/linux/zstd.h                          |   87 +-
 include/linux/zstd_errors.h                   |   30 +-
 include/linux/zstd_lib.h                      | 1123 ++++--
 lib/zstd/Makefile                             |    3 +-
 lib/zstd/common/allocations.h                 |   56 +
 lib/zstd/common/bits.h                        |  150 +
 lib/zstd/common/bitstream.h                   |  155 +-
 lib/zstd/common/compiler.h                    |  151 +-
 lib/zstd/common/cpu.h                         |    3 +-
 lib/zstd/common/debug.c                       |    9 +-
 lib/zstd/common/debug.h                       |   37 +-
 lib/zstd/common/entropy_common.c              |   42 +-
 lib/zstd/common/error_private.c               |   13 +-
 lib/zstd/common/error_private.h               |   88 +-
 lib/zstd/common/fse.h                         |  103 +-
 lib/zstd/common/fse_decompress.c              |  132 +-
 lib/zstd/common/huf.h                         |  240 +-
 lib/zstd/common/mem.h                         |    3 +-
 lib/zstd/common/portability_macros.h          |   45 +-
 lib/zstd/common/zstd_common.c                 |   38 +-
 lib/zstd/common/zstd_deps.h                   |   16 +-
 lib/zstd/common/zstd_internal.h               |  153 +-
 lib/zstd/compress/clevels.h                   |    3 +-
 lib/zstd/compress/fse_compress.c              |   74 +-
 lib/zstd/compress/hist.c                      |   13 +-
 lib/zstd/compress/hist.h                      |   10 +-
 lib/zstd/compress/huf_compress.c              |  441 ++-
 lib/zstd/compress/zstd_compress.c             | 3293 ++++++++++++-----
 lib/zstd/compress/zstd_compress_internal.h    |  621 +++-
 lib/zstd/compress/zstd_compress_literals.c    |  157 +-
 lib/zstd/compress/zstd_compress_literals.h    |   25 +-
 lib/zstd/compress/zstd_compress_sequences.c   |   21 +-
 lib/zstd/compress/zstd_compress_sequences.h   |   16 +-
 lib/zstd/compress/zstd_compress_superblock.c  |  394 +-
 lib/zstd/compress/zstd_compress_superblock.h  |    3 +-
 lib/zstd/compress/zstd_cwksp.h                |  222 +-
 lib/zstd/compress/zstd_double_fast.c          |  245 +-
 lib/zstd/compress/zstd_double_fast.h          |   27 +-
 lib/zstd/compress/zstd_fast.c                 |  703 +++-
 lib/zstd/compress/zstd_fast.h                 |   16 +-
 lib/zstd/compress/zstd_lazy.c                 |  840 +++--
 lib/zstd/compress/zstd_lazy.h                 |  195 +-
 lib/zstd/compress/zstd_ldm.c                  |  102 +-
 lib/zstd/compress/zstd_ldm.h                  |   17 +-
 lib/zstd/compress/zstd_ldm_geartab.h          |    3 +-
 lib/zstd/compress/zstd_opt.c                  |  571 +--
 lib/zstd/compress/zstd_opt.h                  |   55 +-
 lib/zstd/compress/zstd_preSplit.c             |  239 ++
 lib/zstd/compress/zstd_preSplit.h             |   34 +
 lib/zstd/decompress/huf_decompress.c          |  887 +++--
 lib/zstd/decompress/zstd_ddict.c              |    9 +-
 lib/zstd/decompress/zstd_ddict.h              |    3 +-
 lib/zstd/decompress/zstd_decompress.c         |  375 +-
 lib/zstd/decompress/zstd_decompress_block.c   |  724 ++--
 lib/zstd/decompress/zstd_decompress_block.h   |   10 +-
 .../decompress/zstd_decompress_internal.h     |   19 +-
 lib/zstd/decompress_sources.h                 |    2 +-
 lib/zstd/zstd_common_module.c                 |    5 +-
 lib/zstd/zstd_compress_module.c               |   75 +-
 lib/zstd/zstd_decompress_module.c             |    4 +-
 60 files changed, 8749 insertions(+), 4381 deletions(-)
 create mode 100644 lib/zstd/common/allocations.h
 create mode 100644 lib/zstd/common/bits.h
 create mode 100644 lib/zstd/compress/zstd_preSplit.c
 create mode 100644 lib/zstd/compress/zstd_preSplit.h
include/linux/zstd.h +82 -5
index b2c7cf310c8f..2f2a3c8b8a33 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
 /*
- * Copyright (c) Yann Collet, Facebook, Inc.
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
  * All rights reserved.
  *
  * This source code is licensed under both the BSD-style license (found in the
@@ -160,7 +160,6 @@ typedef ZSTD_parameters zstd_parameters;
 zstd_parameters zstd_get_params(int level,
 	unsigned long long estimated_src_size);
 
-
 /**
  * zstd_get_cparams() - returns zstd_compression_parameters for selected level
  * @level:              The compression level
@@ -173,9 +172,20 @@ zstd_parameters zstd_get_params(int level,
 zstd_compression_parameters zstd_get_cparams(int level,
 	unsigned long long estimated_src_size, size_t dict_size);
 
-/* ======   Single-pass Compression   ====== */
-
 typedef ZSTD_CCtx zstd_cctx;
+typedef ZSTD_cParameter zstd_cparameter;
+
+/**
+ * zstd_cctx_set_param() - sets a compression parameter
+ * @cctx:         The context. Must have been initialized with zstd_init_cctx().
+ * @param:        The parameter to set.
+ * @value:        The value to set the parameter to.
+ *
+ * Return:        Zero or an error, which can be checked using zstd_is_error().
+ */
+size_t zstd_cctx_set_param(zstd_cctx *cctx, zstd_cparameter param, int value);
+
+/* ======   Single-pass Compression   ====== */
 
 /**
  * zstd_cctx_workspace_bound() - max memory needed to initialize a zstd_cctx
@@ -190,6 +200,20 @@ typedef ZSTD_CCtx zstd_cctx;
  */
 size_t zstd_cctx_workspace_bound(const zstd_compression_parameters *parameters);
 
+/**
+ * zstd_cctx_workspace_bound_with_ext_seq_prod() - max memory needed to
+ * initialize a zstd_cctx when using the block-level external sequence
+ * producer API.
+ * @parameters: The compression parameters to be used.
+ *
+ * If multiple compression parameters might be used, the caller must call
+ * this function for each set of parameters and use the maximum size.
+ *
+ * Return:      A lower bound on the size of the workspace that is passed to
+ *              zstd_init_cctx().
+ */
+size_t zstd_cctx_workspace_bound_with_ext_seq_prod(const zstd_compression_parameters *parameters);
+
 /**
  * zstd_init_cctx() - initialize a zstd compression context
  * @workspace:      The workspace to emplace the context into. It must outlive
@@ -424,6 +448,16 @@ typedef ZSTD_CStream zstd_cstream;
  */
 size_t zstd_cstream_workspace_bound(const zstd_compression_parameters *cparams);
 
+/**
+ * zstd_cstream_workspace_bound_with_ext_seq_prod() - memory needed to initialize
+ * a zstd_cstream when using the block-level external sequence producer API.
+ * @cparams: The compression parameters to be used for compression.
+ *
+ * Return:   A lower bound on the size of the workspace that is passed to
+ *           zstd_init_cstream().
+ */
+size_t zstd_cstream_workspace_bound_with_ext_seq_prod(const zstd_compression_parameters *cparams);
+
 /**
  * zstd_init_cstream() - initialize a zstd streaming compression context
  * @parameters        The zstd parameters to use for compression.
@@ -583,6 +617,18 @@ size_t zstd_decompress_stream(zstd_dstream *dstream, zstd_out_buffer *output,
  */
 size_t zstd_find_frame_compressed_size(const void *src, size_t src_size);
 
+/**
+ * zstd_register_sequence_producer() - exposes the zstd library function
+ * ZSTD_registerSequenceProducer(). This is used for the block-level external
+ * sequence producer API. See upstream zstd.h for detailed documentation.
+ */
+typedef ZSTD_sequenceProducer_F zstd_sequence_producer_f;
+void zstd_register_sequence_producer(
+  zstd_cctx *cctx,
+  void* sequence_producer_state,
+  zstd_sequence_producer_f sequence_producer
+);
+
 /**
  * struct zstd_frame_params - zstd frame parameters stored in the frame header
  * @frameContentSize: The frame content size, or ZSTD_CONTENTSIZE_UNKNOWN if not
@@ -596,7 +642,7 @@ size_t zstd_find_frame_compressed_size(const void *src, size_t src_size);
  *
  * See zstd_lib.h.
  */
-typedef ZSTD_frameHeader zstd_frame_header;
+typedef ZSTD_FrameHeader zstd_frame_header;
 
 /**
  * zstd_get_frame_header() - extracts parameters from a zstd or skippable frame
@@ -611,4 +657,35 @@ typedef ZSTD_frameHeader zstd_frame_header;
 size_t zstd_get_frame_header(zstd_frame_header *params, const void *src,
 	size_t src_size);
 
+/**
+ * struct zstd_sequence - a sequence of literals or a match
+ *
+ * @offset: The offset of the match
+ * @litLength: The literal length of the sequence
+ * @matchLength: The match length of the sequence
+ * @rep: Represents which repeat offset is used
+ */
+typedef ZSTD_Sequence zstd_sequence;
+
+/**
+ * zstd_compress_sequences_and_literals() - compress an array of zstd_sequence and literals
+ *
+ * @cctx: The zstd compression context.
+ * @dst: The buffer to compress the data into.
+ * @dst_capacity: The size of the destination buffer.
+ * @in_seqs: The array of zstd_sequence to compress.
+ * @in_seqs_size: The number of sequences in in_seqs.
+ * @literals: The literals associated to the sequences to be compressed.
+ * @lit_size: The size of the literals in the literals buffer.
+ * @lit_capacity: The size of the literals buffer.
+ * @decompressed_size: The size of the input data
+ *
+ * Return: The compressed size or an error, which can be checked using
+ * 	   zstd_is_error().
+ */
+size_t zstd_compress_sequences_and_literals(zstd_cctx *cctx, void* dst, size_t dst_capacity,
+					    const zstd_sequence *in_seqs, size_t in_seqs_size,
+					    const void* literals, size_t lit_size, size_t lit_capacity,
+					    size_t decompressed_size);
+
 #endif  /* LINUX_ZSTD_H */
include/linux/zstd_errors.h +20 -10
index 58b6dd45a969..c307fb011132 100644
@@ -1,5 +1,6 @@
+/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
 /*
- * Copyright (c) Yann Collet, Facebook, Inc.
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
  * All rights reserved.
  *
  * This source code is licensed under both the BSD-style license (found in the
@@ -12,13 +13,18 @@
 #define ZSTD_ERRORS_H_398273423
 
 
-/*===== dependency =====*/
-#include <linux/types.h>   /* size_t */
+/* =====   ZSTDERRORLIB_API : control library symbols visibility   ===== */
+#define ZSTDERRORLIB_VISIBLE 
 
+#ifndef ZSTDERRORLIB_HIDDEN
+#  if (__GNUC__ >= 4) && !defined(__MINGW32__)
+#    define ZSTDERRORLIB_HIDDEN __attribute__ ((visibility ("hidden")))
+#  else
+#    define ZSTDERRORLIB_HIDDEN
+#  endif
+#endif
 
-/* =====   ZSTDERRORLIB_API : control library symbols visibility   ===== */
-#define ZSTDERRORLIB_VISIBILITY 
-#define ZSTDERRORLIB_API ZSTDERRORLIB_VISIBILITY
+#define ZSTDERRORLIB_API ZSTDERRORLIB_VISIBLE
 
 /*-*********************************************
  *  Error codes list
@@ -43,14 +49,18 @@ typedef enum {
   ZSTD_error_frameParameter_windowTooLarge = 16,
   ZSTD_error_corruption_detected = 20,
   ZSTD_error_checksum_wrong      = 22,
+  ZSTD_error_literals_headerWrong = 24,
   ZSTD_error_dictionary_corrupted      = 30,
   ZSTD_error_dictionary_wrong          = 32,
   ZSTD_error_dictionaryCreation_failed = 34,
   ZSTD_error_parameter_unsupported   = 40,
+  ZSTD_error_parameter_combination_unsupported = 41,
   ZSTD_error_parameter_outOfBound    = 42,
   ZSTD_error_tableLog_tooLarge       = 44,
   ZSTD_error_maxSymbolValue_tooLarge = 46,
   ZSTD_error_maxSymbolValue_tooSmall = 48,
+  ZSTD_error_cannotProduce_uncompressedBlock = 49,
+  ZSTD_error_stabilityCondition_notRespected = 50,
   ZSTD_error_stage_wrong       = 60,
   ZSTD_error_init_missing      = 62,
   ZSTD_error_memory_allocation = 64,
@@ -58,18 +68,18 @@ typedef enum {
   ZSTD_error_dstSize_tooSmall = 70,
   ZSTD_error_srcSize_wrong    = 72,
   ZSTD_error_dstBuffer_null   = 74,
+  ZSTD_error_noForwardProgress_destFull = 80,
+  ZSTD_error_noForwardProgress_inputEmpty = 82,
   /* following error codes are __NOT STABLE__, they can be removed or changed in future versions */
   ZSTD_error_frameIndex_tooLarge = 100,
   ZSTD_error_seekableIO          = 102,
   ZSTD_error_dstBuffer_wrong     = 104,
   ZSTD_error_srcBuffer_wrong     = 105,
+  ZSTD_error_sequenceProducer_failed = 106,
+  ZSTD_error_externalSequences_invalid = 107,
   ZSTD_error_maxCode = 120  /* never EVER use this value directly, it can change in future versions! Use ZSTD_isError() instead */
 } ZSTD_ErrorCode;
 
-/*! ZSTD_getErrorCode() :
-    convert a `size_t` function result into a `ZSTD_ErrorCode` enum type,
-    which can be used to compare with enum list published above */
-ZSTDERRORLIB_API ZSTD_ErrorCode ZSTD_getErrorCode(size_t functionResult);
 ZSTDERRORLIB_API const char* ZSTD_getErrorString(ZSTD_ErrorCode code);   /*< Same as ZSTD_getErrorName, but using a `ZSTD_ErrorCode` enum argument */
 
 
include/linux/zstd_lib.h +866 -257

1,802 lines not on this page · raw message

lib/zstd/Makefile +2 -1
index 20f08c644b71..be218b5e0ed5 100644
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
 # ################################################################
-# Copyright (c) Facebook, Inc.
+# Copyright (c) Meta Platforms, Inc. and affiliates.
 # All rights reserved.
 #
 # This source code is licensed under both the BSD-style license (found in the
@@ -26,6 +26,7 @@ zstd_compress-y := \
 		compress/zstd_lazy.o \
 		compress/zstd_ldm.o \
 		compress/zstd_opt.o \
+		compress/zstd_preSplit.o \
 
 zstd_decompress-y := \
 		zstd_decompress_module.o \
lib/zstd/common/allocations.h new file +56 -0

56 lines not on this page · raw message

lib/zstd/common/bits.h new file +150 -0

150 lines not on this page · raw message

lib/zstd/common/bitstream.h +74 -81

358 lines not on this page · raw message

lib/zstd/common/compiler.h +128 -23

220 lines not on this page · raw message

lib/zstd/common/cpu.h +2 -1
index 0db7b42407ee..d8319a2bef4c 100644
@@ -1,5 +1,6 @@
+/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
 /*
- * Copyright (c) Facebook, Inc.
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
  * All rights reserved.
  *
  * This source code is licensed under both the BSD-style license (found in the
lib/zstd/common/debug.c +8 -1
index bb863c9ea616..8eb6aa9a3b20 100644
@@ -1,7 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
 /* ******************************************************************
  * debug
  * Part of FSE library
- * Copyright (c) Yann Collet, Facebook, Inc.
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
  *
  * You can contact the author at :
  * - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
@@ -21,4 +22,10 @@
 
 #include "debug.h"
 
+#if (DEBUGLEVEL>=2)
+/* We only use this when DEBUGLEVEL>=2, but we get -Werror=pedantic errors if a
+ * translation unit is empty. So remove this from Linux kernel builds, but
+ * otherwise just leave it in.
+ */
 int g_debuglevel = DEBUGLEVEL;
+#endif
lib/zstd/common/debug.h +22 -15
index 6dd88d1fbd02..c8a10281f112 100644
@@ -1,7 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
 /* ******************************************************************
  * debug
  * Part of FSE library
- * Copyright (c) Yann Collet, Facebook, Inc.
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
  *
  * You can contact the author at :
  * - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
@@ -33,7 +34,6 @@
 #define DEBUG_H_12987983217
 
 
-
 /* static assert is triggered at compile time, leaving no runtime artefact.
  * static assert only works with compile-time constants.
  * Also, this variant can only be used inside a function. */
@@ -82,20 +82,27 @@ extern int g_debuglevel; /* the variable is only declared,
                             It's useful when enabling very verbose levels
                             on selective conditions (such as position in src) */
 
-#  define RAWLOG(l, ...) {                                       \
-                if (l<=g_debuglevel) {                           \
-                    ZSTD_DEBUG_PRINT(__VA_ARGS__);               \
-            }   }
-#  define DEBUGLOG(l, ...) {                                     \
-                if (l<=g_debuglevel) {                           \
-                    ZSTD_DEBUG_PRINT(__FILE__ ": " __VA_ARGS__); \
-                    ZSTD_DEBUG_PRINT(" \n");                     \
-            }   }
+#  define RAWLOG(l, ...)                   \
+    do {                                   \
+        if (l<=g_debuglevel) {             \
+            ZSTD_DEBUG_PRINT(__VA_ARGS__); \
+        }                                  \
+    } while (0)
+
+#define STRINGIFY(x) #x
+#define TOSTRING(x) STRINGIFY(x)
+#define LINE_AS_STRING TOSTRING(__LINE__)
+
+#  define DEBUGLOG(l, ...)                               \
+    do {                                                 \
+        if (l<=g_debuglevel) {                           \
+            ZSTD_DEBUG_PRINT(__FILE__ ":" LINE_AS_STRING ": " __VA_ARGS__); \
+            ZSTD_DEBUG_PRINT(" \n");                     \
+        }                                                \
+    } while (0)
 #else
-#  define RAWLOG(l, ...)      {}    /* disabled */
-#  define DEBUGLOG(l, ...)    {}    /* disabled */
+#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
+#  define DEBUGLOG(l, ...) do { } while (0)    /* disabled */
 #endif
 
-
-
 #endif /* DEBUG_H_12987983217 */
lib/zstd/common/entropy_common.c +13 -29

105 lines not on this page · raw message

lib/zstd/common/error_private.c +11 -2
index 6d1135f8c373..6c3dbad838b6 100644
@@ -1,5 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
 /*
- * Copyright (c) Yann Collet, Facebook, Inc.
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
  * All rights reserved.
  *
  * This source code is licensed under both the BSD-style license (found in the
@@ -27,9 +28,11 @@ const char* ERR_getErrorString(ERR_enum code)
     case PREFIX(version_unsupported): return "Version not supported";
     case PREFIX(frameParameter_unsupported): return "Unsupported frame parameter";
     case PREFIX(frameParameter_windowTooLarge): return "Frame requires too much memory for decoding";
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

lib/zstd/common/error_private.h +47 -41

88 lines not on this page · raw message

lib/zstd/common/fse.h +9 -94

103 lines not on this page · raw message

lib/zstd/common/fse_decompress.c +29 -103

132 lines not on this page · raw message

lib/zstd/common/huf.h +80 -160

240 lines not on this page · raw message

lib/zstd/common/mem.h +2 -1
index c22a2e69bf46..d9bd752fe17b 100644

Lines of this file are not shown. View the raw message.

lib/zstd/common/portability_macros.h +35 -10

45 lines not on this page · raw message

lib/zstd/common/zstd_common.c +2 -36
index 3d7e35b309b5..44b95b25344a 100644

Lines of this file are not shown. View the raw message.

lib/zstd/common/zstd_deps.h +15 -1
index 2c34e8a33a1c..f931f7d0e294 100644

Lines of this file are not shown. View the raw message.

lib/zstd/common/zstd_internal.h +14 -139

153 lines not on this page · raw message

lib/zstd/compress/clevels.h +2 -1
index d9a76112ec3a..6ab8be6532ef 100644

Lines of this file are not shown. View the raw message.

lib/zstd/compress/fse_compress.c +16 -58

74 lines not on this page · raw message

lib/zstd/compress/hist.c +12 -1
index 3ddc6dfb6894..87145a2d9160 100644

Lines of this file are not shown. View the raw message.

lib/zstd/compress/hist.h +9 -1
index fc1830abc9c6..e5d57d79e4d5 100644

Lines of this file are not shown. View the raw message.

lib/zstd/compress/huf_compress.c +284 -157

441 lines not on this page · raw message

lib/zstd/compress/zstd_compress.c +2399 -894

3,293 lines not on this page · raw message

lib/zstd/compress/zstd_compress_internal.h +425 -196

621 lines not on this page · raw message

lib/zstd/compress/zstd_compress_literals.c +117 -40

157 lines not on this page · raw message

lib/zstd/compress/zstd_compress_literals.h +17 -8
index 9775fb97cb70..a2a85d6b69e5 100644

Lines of this file are not shown. View the raw message.

lib/zstd/compress/zstd_compress_sequences.c +11 -10
index 21ddc1b37acf..256980c9d85a 100644

Lines of this file are not shown. View the raw message.

lib/zstd/compress/zstd_compress_sequences.h +9 -7
index 7991364c2f71..14fdccb6547f 100644

Lines of this file are not shown. View the raw message.

lib/zstd/compress/zstd_compress_superblock.c +255 -139

394 lines not on this page · raw message

lib/zstd/compress/zstd_compress_superblock.h +2 -1
index 224ece79546e..826bbc9e029b 100644

Lines of this file are not shown. View the raw message.

lib/zstd/compress/zstd_cwksp.h +142 -80

222 lines not on this page · raw message

lib/zstd/compress/zstd_double_fast.c +164 -81

245 lines not on this page · raw message

lib/zstd/compress/zstd_double_fast.h +19 -8
index 6822bde65a1d..011556ce56f7 100644

Lines of this file are not shown. View the raw message.

lib/zstd/compress/zstd_fast.c +506 -197

703 lines not on this page · raw message

lib/zstd/compress/zstd_fast.h +8 -8
index fddc2f532d21..04fde0a72a4e 100644

Lines of this file are not shown. View the raw message.

lib/zstd/compress/zstd_lazy.c +469 -371

840 lines not on this page · raw message

lib/zstd/compress/zstd_lazy.h +135 -60

195 lines not on this page · raw message

lib/zstd/compress/zstd_ldm.c +62 -40

102 lines not on this page · raw message

lib/zstd/compress/zstd_ldm.h +8 -9
index fbc6a5e88fd7..41400a7191b2 100644

Lines of this file are not shown. View the raw message.

lib/zstd/compress/zstd_ldm_geartab.h +2 -1
index 647f865be290..cfccfc46f6f7 100644

Lines of this file are not shown. View the raw message.

lib/zstd/compress/zstd_opt.c +353 -218

571 lines not on this page · raw message

lib/zstd/compress/zstd_opt.h +39 -16

55 lines not on this page · raw message

lib/zstd/compress/zstd_preSplit.c new file +239 -0

239 lines not on this page · raw message

lib/zstd/compress/zstd_preSplit.h new file +34 -0
new file mode 100644
index 000000000000..f98f797fe191

Lines of this file are not shown. View the raw message.

lib/zstd/decompress/huf_decompress.c +544 -343

887 lines not on this page · raw message

lib/zstd/decompress/zstd_ddict.c +5 -4
index dbbc7919de53..30ef65e1ab5c 100644

Lines of this file are not shown. View the raw message.

lib/zstd/decompress/zstd_ddict.h +2 -1
index 8c1a79d666f8..de459a0dacd1 100644

Lines of this file are not shown. View the raw message.

lib/zstd/decompress/zstd_decompress.c +264 -111

375 lines not on this page · raw message

lib/zstd/decompress/zstd_decompress_block.c +431 -293

724 lines not on this page · raw message

lib/zstd/decompress/zstd_decompress_block.h +8 -2
index 3d2d57a5d25a..becffbd89364 100644

Lines of this file are not shown. View the raw message.

lib/zstd/decompress/zstd_decompress_internal.h +12 -7
index 98102edb6a83..2a225d1811c4 100644

Lines of this file are not shown. View the raw message.

lib/zstd/decompress_sources.h +1 -1
index a06ca187aab5..8a47eb2a4514 100644

Lines of this file are not shown. View the raw message.

lib/zstd/zstd_common_module.c +1 -4
index 22686e367e6f..466828e35752 100644

Lines of this file are not shown. View the raw message.

lib/zstd/zstd_compress_module.c +74 -1

75 lines not on this page · raw message

lib/zstd/zstd_decompress_module.c +2 -2
index 469fc3059be0..0ae819f0c927 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.48.1

Part of the diff is not shown here. View the raw message.

#2 lore raw
In reply to Nick Terrell
Quoted 5 lines · Nick Terrell

From: Nick Terrell <[email protected]>

Since this is a large patch, I have also prepared a pull request as an alternate means of fetching the commit:

Quoted 7 lines

The following changes since commit 7eb172143d5508b4da468ed59ee857c6e5e01da6:

Linux 6.14-rc5 (2025-03-02 11:48:20 -0800)

are available in the Git repository at:

https://github.com/terrelln/linux.git tags/2025-03-13-zstd-v1.5.7-v1

This tag is not in the branch that is pulled to the linux-next tree, the zstd-next branch still points to v6.14-rc5. This means the 1.5.7 update hasn't been exposed to linux-next testing. Please update the branch to the tag as well, the merge window opens next week leaving little time before sending the pull request.

I've tested this patch with fstests and btrfs, no problems found, but regarding the process the updates need to be in linux-next 1-2 weeks before the merge window. We're past that. As this is restarting the zstd merging I hope we can get away with that this time, skipping another development cycle would be unfortunate but also not helping anything.

#3 lore raw
Quoted 12 lines · David Sterba
Quoted 11 lines · Nick Terrell

From: Nick Terrell <[email protected]>

Since this is a large patch, I have also prepared a pull request as an alternate means of fetching the commit:

The following changes since commit 7eb172143d5508b4da468ed59ee857c6e5e01da6:

Linux 6.14-rc5 (2025-03-02 11:48:20 -0800)

are available in the Git repository at:

Quoted 7 lines
Quoted 1 line

https://github.com/terrelln/linux.git tags/2025-03-13-zstd-v1.5.7-v1

This tag is not in the branch that is pulled to the linux-next tree, the zstd-next branch still points to v6.14-rc5. This means the 1.5.7 update hasn't been exposed to linux-next testing. Please update the branch to the tag as well, the merge window opens next week leaving little time before sending the pull request.

I'm taking a proactive step and the tag mentioned above is now merged to my btrfs for-next branch snapshot. As it's been pulled from your tree the commit id (65d1f5507ed2c78c64fce40e44e5574a9419eb09) is the same and git will handle it transparently in case you update your zstd-next branch.

#4 lore raw
In reply to David Sterba
Quoted 25 lines · David Sterba
Quoted 2 lines
Quoted 5 lines · Nick Terrell

From: Nick Terrell <[email protected]>

Since this is a large patch, I have also prepared a pull request as an alternate means of fetching the commit:

Quoted 7 lines

The following changes since commit 7eb172143d5508b4da468ed59ee857c6e5e01da6:

Linux 6.14-rc5 (2025-03-02 11:48:20 -0800)

are available in the Git repository at:

https://github.com/terrelln/linux.git tags/2025-03-13-zstd-v1.5.7-v1

This tag is not in the branch that is pulled to the linux-next tree, the zstd-next branch still points to v6.14-rc5. This means the 1.5.7 update hasn't been exposed to linux-next testing. Please update the branch to the tag as well, the merge window opens next week leaving little time before sending the pull request.

Quoted 5 lines

I've tested this patch with fstests and btrfs, no problems found, but regarding the process the updates need to be in linux-next 1-2 weeks before the merge window. We're past that. As this is restarting the zstd merging I hope we can get away with that this time, skipping another development cycle would be unfortunate but also not helping anything.

Thanks David, I've pushed my linux-next trees yesterday morning, hopefully it will be early enough. Thank you for testing as well!

Best,
Nick Terrell