2019-07-31 23:57:31 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2019-06-24 15:22:54 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 HUAWEI, Inc.
|
2020-07-13 21:09:44 +08:00
|
|
|
* https://www.huawei.com/
|
2019-06-24 15:22:54 +08:00
|
|
|
* Created by Gao Xiang <gaoxiang25@huawei.com>
|
|
|
|
*/
|
|
|
|
#ifndef __EROFS_FS_COMPRESS_H
|
|
|
|
#define __EROFS_FS_COMPRESS_H
|
|
|
|
|
2019-06-24 15:22:55 +08:00
|
|
|
#include "internal.h"
|
|
|
|
|
|
|
|
enum {
|
|
|
|
Z_EROFS_COMPRESSION_SHIFTED = Z_EROFS_COMPRESSION_MAX,
|
|
|
|
Z_EROFS_COMPRESSION_RUNTIME_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
struct z_erofs_decompress_req {
|
2019-06-24 15:22:56 +08:00
|
|
|
struct super_block *sb;
|
2019-06-24 15:22:55 +08:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2019-06-24 15:22:54 +08:00
|
|
|
/*
|
|
|
|
* - 0x5A110C8D ('sallocated', Z_EROFS_MAPPING_STAGING) -
|
|
|
|
* used to mark temporary allocated pages from other
|
|
|
|
* file/cached pages and NULL mapping pages.
|
|
|
|
*/
|
|
|
|
#define Z_EROFS_MAPPING_STAGING ((void *)0x5A110C8D)
|
|
|
|
|
|
|
|
/* check if a page is marked as staging */
|
|
|
|
static inline bool z_erofs_page_is_staging(struct page *page)
|
|
|
|
{
|
|
|
|
return page->mapping == Z_EROFS_MAPPING_STAGING;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool z_erofs_put_stagingpage(struct list_head *pagepool,
|
|
|
|
struct page *page)
|
|
|
|
{
|
|
|
|
if (!z_erofs_page_is_staging(page))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* staging pages should not be used by others at the same time */
|
|
|
|
if (page_ref_count(page) > 1)
|
|
|
|
put_page(page);
|
|
|
|
else
|
|
|
|
list_add(&page->lru, pagepool);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-06-24 15:22:55 +08:00
|
|
|
int z_erofs_decompress(struct z_erofs_decompress_req *rq,
|
|
|
|
struct list_head *pagepool);
|
|
|
|
|
2019-06-24 15:22:54 +08:00
|
|
|
#endif
|
|
|
|
|