ntfs: implement codec ops for LZX and XPRESS

Implement the transparent compression codec ops for XPRESS (4K, 8K,
16K) and LZX (32K) algorithms. The xpress_scratch_size,
lzx_scratch_size, xpress_decompress_chunk, and lzx_decompress_chunk
wrappers provide unified interfaces and use per-call dynamic scratch
state allocation (avoiding global mutexed singletons).

Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
This commit is contained in:
Hyunchul Lee 2026-08-21 14:00:57 +09:00 committed by Namjae Jeon
parent f39cd3f7fc
commit 7ddb3fef35
3 changed files with 61 additions and 0 deletions

View File

@ -14,6 +14,7 @@
#include "decompress_common.h"
#include "lib.h"
#include "../ntfs_codec.h"
/* Number of literal byte values. */
#define LZX_NUM_CHARS 256
@ -608,3 +609,23 @@ void lzx_free_decompressor(struct lzx_decompressor *d)
{
kfree(d);
}
static size_t lzx_scratch_size(u32 chunk_size)
{
return sizeof(struct lzx_decompressor);
}
static int lzx_decompress_chunk(void *scratch, const void *src, size_t src_len,
void *dst, size_t dst_len, u32 chunk_size)
{
struct lzx_decompressor *d = scratch;
return lzx_decompress(d, src, src_len, dst, dst_len);
}
const struct ntfs_codec_ops ntfs_lzx32k_codec_ops = {
.id = NTFS_CODEC_LZX32K,
.name = "lzx32k",
.scratch_size = lzx_scratch_size,
.decompress_chunk = lzx_decompress_chunk,
};

View File

@ -15,6 +15,7 @@
#include "decompress_common.h"
#include "lib.h"
#include "../ntfs_codec.h"
#define XPRESS_NUM_CHARS 256
#define XPRESS_NUM_SYMBOLS 512
@ -118,3 +119,36 @@ void xpress_free_decompressor(struct xpress_decompressor *d)
{
kfree(d);
}
static size_t xpress_scratch_size(u32 chunk_size)
{
return sizeof(struct xpress_decompressor);
}
static int xpress_decompress_chunk(void *scratch, const void *src,
size_t src_len, void *dst, size_t dst_len,
u32 chunk_size)
{
return xpress_decompress(scratch, src, src_len, dst, dst_len);
}
const struct ntfs_codec_ops ntfs_xpress4k_codec_ops = {
.id = NTFS_CODEC_XPRESS4K,
.name = "xpress4k",
.scratch_size = xpress_scratch_size,
.decompress_chunk = xpress_decompress_chunk,
};
const struct ntfs_codec_ops ntfs_xpress8k_codec_ops = {
.id = NTFS_CODEC_XPRESS8K,
.name = "xpress8k",
.scratch_size = xpress_scratch_size,
.decompress_chunk = xpress_decompress_chunk,
};
const struct ntfs_codec_ops ntfs_xpress16k_codec_ops = {
.id = NTFS_CODEC_XPRESS16K,
.name = "xpress16k",
.scratch_size = xpress_scratch_size,
.decompress_chunk = xpress_decompress_chunk,
};

View File

@ -44,5 +44,11 @@ struct ntfs_codec_ops {
};
extern const struct ntfs_codec_ops ntfs_lznt1_codec_ops;
#ifdef CONFIG_NTFS_FS_WOF_COMPRESSION
extern const struct ntfs_codec_ops ntfs_xpress4k_codec_ops;
extern const struct ntfs_codec_ops ntfs_xpress8k_codec_ops;
extern const struct ntfs_codec_ops ntfs_xpress16k_codec_ops;
extern const struct ntfs_codec_ops ntfs_lzx32k_codec_ops;
#endif
#endif /* _NTFS_CODEC_H */