0001
0002
0003
0004
0005
0006 #ifndef __EROFS_FS_COMPRESS_H
0007 #define __EROFS_FS_COMPRESS_H
0008
0009 #include "internal.h"
0010
0011 struct z_erofs_decompress_req {
0012 struct super_block *sb;
0013 struct page **in, **out;
0014
0015 unsigned short pageofs_in, pageofs_out;
0016 unsigned int inputsize, outputsize;
0017
0018
0019 unsigned int alg;
0020 bool inplace_io, partial_decoding, fillgaps;
0021 };
0022
0023 struct z_erofs_decompressor {
0024 int (*decompress)(struct z_erofs_decompress_req *rq,
0025 struct page **pagepool);
0026 char *name;
0027 };
0028
0029
0030 #define Z_EROFS_SHORTLIVED_PAGE (-1UL << 2)
0031 #define Z_EROFS_PREALLOCATED_PAGE (-2UL << 2)
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058 static inline bool z_erofs_is_shortlived_page(struct page *page)
0059 {
0060 if (page->private != Z_EROFS_SHORTLIVED_PAGE)
0061 return false;
0062
0063 DBG_BUGON(page->mapping);
0064 return true;
0065 }
0066
0067 static inline bool z_erofs_put_shortlivedpage(struct page **pagepool,
0068 struct page *page)
0069 {
0070 if (!z_erofs_is_shortlived_page(page))
0071 return false;
0072
0073
0074 if (page_ref_count(page) > 1) {
0075 put_page(page);
0076 } else {
0077
0078 erofs_pagepool_add(pagepool, page);
0079 }
0080 return true;
0081 }
0082
0083 #define MNGD_MAPPING(sbi) ((sbi)->managed_cache->i_mapping)
0084 static inline bool erofs_page_is_managed(const struct erofs_sb_info *sbi,
0085 struct page *page)
0086 {
0087 return page->mapping == MNGD_MAPPING(sbi);
0088 }
0089
0090 int z_erofs_fixup_insize(struct z_erofs_decompress_req *rq, const char *padbuf,
0091 unsigned int padbufsize);
0092 int z_erofs_decompress(struct z_erofs_decompress_req *rq,
0093 struct page **pagepool);
0094
0095
0096 int z_erofs_lzma_decompress(struct z_erofs_decompress_req *rq,
0097 struct page **pagepool);
0098 #endif