1
2
3
4
5
6#ifndef __EROFS_FS_COMPRESS_H
7#define __EROFS_FS_COMPRESS_H
8
9#include "internal.h"
10
11struct z_erofs_decompress_req {
12 struct super_block *sb;
13 struct page **in, **out;
14
15 unsigned short pageofs_in, pageofs_out;
16 unsigned int inputsize, outputsize;
17
18
19 unsigned int alg;
20 bool inplace_io, partial_decoding;
21};
22
23struct z_erofs_decompressor {
24 int (*decompress)(struct z_erofs_decompress_req *rq,
25 struct page **pagepool);
26 char *name;
27};
28
29
30#define Z_EROFS_SHORTLIVED_PAGE (-1UL << 2)
31#define Z_EROFS_PREALLOCATED_PAGE (-2UL << 2)
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58static inline bool z_erofs_is_shortlived_page(struct page *page)
59{
60 if (page->private != Z_EROFS_SHORTLIVED_PAGE)
61 return false;
62
63 DBG_BUGON(page->mapping);
64 return true;
65}
66
67static inline bool z_erofs_put_shortlivedpage(struct page **pagepool,
68 struct page *page)
69{
70 if (!z_erofs_is_shortlived_page(page))
71 return false;
72
73
74 if (page_ref_count(page) > 1) {
75 put_page(page);
76 } else {
77
78 erofs_pagepool_add(pagepool, page);
79 }
80 return true;
81}
82
83#define MNGD_MAPPING(sbi) ((sbi)->managed_cache->i_mapping)
84static inline bool erofs_page_is_managed(const struct erofs_sb_info *sbi,
85 struct page *page)
86{
87 return page->mapping == MNGD_MAPPING(sbi);
88}
89
90int z_erofs_fixup_insize(struct z_erofs_decompress_req *rq, const char *padbuf,
91 unsigned int padbufsize);
92int z_erofs_decompress(struct z_erofs_decompress_req *rq,
93 struct page **pagepool);
94
95
96int z_erofs_lzma_decompress(struct z_erofs_decompress_req *rq,
97 struct page **pagepool);
98#endif
99