1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/drivers/staging/erofs/compress.h
5 * Copyright (C) 2019 HUAWEI, Inc.
6 * http://www.huawei.com/
7 * Created by Gao Xiang <gaoxiang25@huawei.com>
9 #ifndef __EROFS_FS_COMPRESS_H
10 #define __EROFS_FS_COMPRESS_H
15 Z_EROFS_COMPRESSION_SHIFTED = Z_EROFS_COMPRESSION_MAX,
16 Z_EROFS_COMPRESSION_RUNTIME_MAX
19 struct z_erofs_decompress_req {
20 struct super_block *sb;
21 struct page **in, **out;
23 unsigned short pageofs_out;
24 unsigned int inputsize, outputsize;
26 /* indicate the algorithm will be used for decompression */
28 bool inplace_io, partial_decoding;
32 * - 0x5A110C8D ('sallocated', Z_EROFS_MAPPING_STAGING) -
33 * used to mark temporary allocated pages from other
34 * file/cached pages and NULL mapping pages.
36 #define Z_EROFS_MAPPING_STAGING ((void *)0x5A110C8D)
38 /* check if a page is marked as staging */
39 static inline bool z_erofs_page_is_staging(struct page *page)
41 return page->mapping == Z_EROFS_MAPPING_STAGING;
44 static inline bool z_erofs_put_stagingpage(struct list_head *pagepool,
47 if (!z_erofs_page_is_staging(page))
50 /* staging pages should not be used by others at the same time */
51 if (page_ref_count(page) > 1)
54 list_add(&page->lru, pagepool);
58 int z_erofs_decompress(struct z_erofs_decompress_req *rq,
59 struct list_head *pagepool);