]> asedeno.scripts.mit.edu Git - linux.git/blob - drivers/staging/erofs/compress.h
staging: rtl8192u: fix spacing in ieee80211
[linux.git] / drivers / staging / erofs / compress.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * linux/drivers/staging/erofs/compress.h
4  *
5  * Copyright (C) 2019 HUAWEI, Inc.
6  *             http://www.huawei.com/
7  * Created by Gao Xiang <gaoxiang25@huawei.com>
8  */
9 #ifndef __EROFS_FS_COMPRESS_H
10 #define __EROFS_FS_COMPRESS_H
11
12 #include "internal.h"
13
14 enum {
15         Z_EROFS_COMPRESSION_SHIFTED = Z_EROFS_COMPRESSION_MAX,
16         Z_EROFS_COMPRESSION_RUNTIME_MAX
17 };
18
19 struct z_erofs_decompress_req {
20         struct super_block *sb;
21         struct page **in, **out;
22
23         unsigned short pageofs_out;
24         unsigned int inputsize, outputsize;
25
26         /* indicate the algorithm will be used for decompression */
27         unsigned int alg;
28         bool inplace_io, partial_decoding;
29 };
30
31 /*
32  * - 0x5A110C8D ('sallocated', Z_EROFS_MAPPING_STAGING) -
33  * used to mark temporary allocated pages from other
34  * file/cached pages and NULL mapping pages.
35  */
36 #define Z_EROFS_MAPPING_STAGING         ((void *)0x5A110C8D)
37
38 /* check if a page is marked as staging */
39 static inline bool z_erofs_page_is_staging(struct page *page)
40 {
41         return page->mapping == Z_EROFS_MAPPING_STAGING;
42 }
43
44 static inline bool z_erofs_put_stagingpage(struct list_head *pagepool,
45                                            struct page *page)
46 {
47         if (!z_erofs_page_is_staging(page))
48                 return false;
49
50         /* staging pages should not be used by others at the same time */
51         if (page_ref_count(page) > 1)
52                 put_page(page);
53         else
54                 list_add(&page->lru, pagepool);
55         return true;
56 }
57
58 int z_erofs_decompress(struct z_erofs_decompress_req *rq,
59                        struct list_head *pagepool);
60
61 #endif
62