Files
mirror_zfs/module/zstd/README.md
T

57 lines
2.4 KiB
Markdown
Raw Normal View History

2026-01-14 10:42:55 +01:00
# Zstd-On-ZFS Library Manual
2020-08-18 19:10:17 +02:00
## Introduction
2026-01-14 10:42:55 +01:00
This subtree contains the Zstd library used in ZFS. It is heavily cut-down by
2020-08-18 19:10:17 +02:00
dropping any unneeded files, and combined into a single file, but otherwise is
intentionally unmodified. Please do not alter the file containing the zstd
2026-01-14 10:42:55 +01:00
library, besides upgrading to a newer Zstd release.
2020-08-18 19:10:17 +02:00
Tree structure:
* `zfs_zstd.c` are the actual `zfs` kernel module hooks.
* `lib/` contains the unmodified version of the `Zstandard` library
* `zstd-in.c` is our template file for generating the single-file library
2020-08-18 19:10:17 +02:00
* `include/`: This directory contains supplemental includes for platform
compatibility, which are not expected to be used by ZFS elsewhere in the
2026-01-14 10:42:55 +01:00
future. Thus we keep them private to Zstd.
2020-08-18 19:10:17 +02:00
2026-01-14 10:42:55 +01:00
## Zstd update policy
2020-08-18 19:10:17 +02:00
2026-01-14 10:42:55 +01:00
Since the exact compressed byte stream may change between Zstd versions, updates
should follow this policy:
2020-08-18 19:10:17 +02:00
2026-01-14 10:42:55 +01:00
1. Zstd may be updated, as needed, after a new .0 release is tagged.
2. Critical patches may be applied up until the next release freeze,
_potentially_ even updating to a newer upstream version.
3. The Zstd version will not be upgraded within a major release.
4. Multiple Zstd versions are not supported concurrently within a release.
5. The library import commit must be a clean, unmodified upstream import. Any
OpenZFS-specific integration or local adjustments go into follow-up commits.
6. Release notes should highlight Zstd updates and any expected impact (e.g.
changes in compression ratio/performance, and differences in compressed byte
streams which may affect deduplication or NOP writes).
## Updating Zstd
To update Zstd the following steps need to be taken:
1. Grab the latest release of [Zstd](https://github.com/facebook/zstd/releases).
2. Copy the files output by the following script to `module/zstd/lib/`:
2026-01-14 10:42:55 +01:00
```
grep include [path to zstd]/build/single_file_libs/zstd-in.c | awk '{ print $2 }'
```
3. Remove debug.c, threading.c, and zstdmt_compress.c.
4. Update Makefiles with resulting file lists.
2026-01-14 10:42:55 +01:00
5. Follow symbol renaming notes in `include/zstd_compat_wrapper.h`.
2020-08-18 19:10:17 +02:00
2026-01-14 10:42:55 +01:00
## Altering Zstd and breaking changes
2020-08-18 19:10:17 +02:00
2026-01-14 10:42:55 +01:00
If Zstd made changes that break compatibility or you need to make breaking
changes to the way we handle Zstd, it is required to maintain backwards
2020-08-18 19:10:17 +02:00
compatibility.
2026-01-14 10:42:55 +01:00
We already save the Zstd version number within the block header to be used
2020-08-18 19:10:17 +02:00
to add future compatibility checks and/or fixes. However, currently it is
not actually used in such a way.