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