ntfs: define LZNT1 codec ops under transparent codec interface

Define the ntfs_lznt1_codec_ops structure containing decompress_pages
and compress_subblock callbacks in compress.c, and export it in
ntfs_codec.h. This structure binds existing LZNT1 decompress and
compress helper functions under the unified transparent compression
interface.

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:51 +09:00 committed by Namjae Jeon
parent f2240a2ff4
commit c34e33a60f
2 changed files with 12 additions and 2 deletions

View File

@ -21,6 +21,7 @@
#include <linux/slab.h>
#include "attrib.h"
#include "ntfs_codec.h"
#include "inode.h"
#include "debug.h"
#include "ntfs.h"
@ -774,7 +775,7 @@ int ntfs_read_compressed_block(struct folio *folio)
unsigned int prev_cur_page = cur_page;
ntfs_debug("Found compressed compression block.");
err = ntfs_decompress(pages, completed_pages, &cur_page,
err = ntfs_lznt1_codec_ops.decompress_pages(pages, completed_pages, &cur_page,
&cur_ofs, cb_max_page, cb_max_ofs, xpage,
&xpage_done, cb_pos, cb_size - (cb_pos - cb),
i_size, initialized_size);
@ -1351,7 +1352,7 @@ static int ntfs_write_cb(struct ntfs_inode *ni, loff_t pos, struct page **pages,
pbuf = &outbuf[compsz];
addr = kmap_local_page(pages[page_idx]);
input = addr + offset_in_page(input_offset);
sz = ntfs_compress_block(ctx, input, bsz, pbuf);
sz = ntfs_lznt1_codec_ops.compress_subblock(ctx, input, bsz, pbuf);
kunmap_local(addr);
if (sz < 0) {
err = sz;
@ -1609,3 +1610,10 @@ int ntfs_compress_write(struct ntfs_inode *ni, loff_t pos, size_t count,
return written;
}
const struct ntfs_codec_ops ntfs_lznt1_codec_ops = {
.id = NTFS_CODEC_LZNT1,
.name = "lznt1",
.decompress_pages = ntfs_decompress,
.compress_subblock = ntfs_compress_block,
};

View File

@ -43,4 +43,6 @@ struct ntfs_codec_ops {
const char *inbuf, int bufsize, char *outbuf);
};
extern const struct ntfs_codec_ops ntfs_lznt1_codec_ops;
#endif /* _NTFS_CODEC_H */