3
0
mirror of https://github.com/Qortal/Brooklyn.git synced 2025-02-08 07:13:06 +00:00
Brooklyn/fs/erofs/compress.h

61 lines
1.4 KiB
C
Raw Normal View History

2021-05-27 00:09:36 +05:00
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (C) 2019 HUAWEI, Inc.
* https://www.huawei.com/
2021-09-23 21:59:15 +05:00
* Created by Gao Xiang <gaoxiang25@huawei.com>
2021-05-27 00:09:36 +05:00
*/
#ifndef __EROFS_FS_COMPRESS_H
#define __EROFS_FS_COMPRESS_H
#include "internal.h"
enum {
Z_EROFS_COMPRESSION_SHIFTED = Z_EROFS_COMPRESSION_MAX,
Z_EROFS_COMPRESSION_RUNTIME_MAX
};
struct z_erofs_decompress_req {
struct super_block *sb;
struct page **in, **out;
unsigned short pageofs_out;
unsigned int inputsize, outputsize;
/* indicate the algorithm will be used for decompression */
unsigned int alg;
bool inplace_io, partial_decoding;
};
/*
2021-09-23 21:59:15 +05:00
* - 0x5A110C8D ('sallocated', Z_EROFS_MAPPING_STAGING) -
* used to mark temporary allocated pages from other
* file/cached pages and NULL mapping pages.
2021-05-27 00:09:36 +05:00
*/
2021-09-23 21:59:15 +05:00
#define Z_EROFS_MAPPING_STAGING ((void *)0x5A110C8D)
2021-05-27 00:09:36 +05:00
2021-09-23 21:59:15 +05:00
/* check if a page is marked as staging */
static inline bool z_erofs_page_is_staging(struct page *page)
2021-05-27 00:09:36 +05:00
{
2021-09-23 21:59:15 +05:00
return page->mapping == Z_EROFS_MAPPING_STAGING;
2021-05-27 00:09:36 +05:00
}
2021-09-23 21:59:15 +05:00
static inline bool z_erofs_put_stagingpage(struct list_head *pagepool,
struct page *page)
2021-05-27 00:09:36 +05:00
{
2021-09-23 21:59:15 +05:00
if (!z_erofs_page_is_staging(page))
2021-05-27 00:09:36 +05:00
return false;
2021-09-23 21:59:15 +05:00
/* staging pages should not be used by others at the same time */
if (page_ref_count(page) > 1)
2021-05-27 00:09:36 +05:00
put_page(page);
2021-09-23 21:59:15 +05:00
else
2021-05-27 00:09:36 +05:00
list_add(&page->lru, pagepool);
return true;
}
int z_erofs_decompress(struct z_erofs_decompress_req *rq,
struct list_head *pagepool);
#endif
2021-09-23 21:59:15 +05:00