~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/erofs/compress.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-only */
  2 /*
  3  * Copyright (C) 2019 HUAWEI, Inc.
  4  *             https://www.huawei.com/
  5  */
  6 #ifndef __EROFS_FS_COMPRESS_H
  7 #define __EROFS_FS_COMPRESS_H
  8 
  9 #include "internal.h"
 10 
 11 struct z_erofs_decompress_req {
 12         struct super_block *sb;
 13         struct page **in, **out;
 14         unsigned short pageofs_in, pageofs_out;
 15         unsigned int inputsize, outputsize;
 16 
 17         unsigned int alg;       /* the algorithm for decompression */
 18         bool inplace_io, partial_decoding, fillgaps;
 19         gfp_t gfp;      /* allocation flags for extra temporary buffers */
 20 };
 21 
 22 struct z_erofs_decompressor {
 23         int (*config)(struct super_block *sb, struct erofs_super_block *dsb,
 24                       void *data, int size);
 25         int (*decompress)(struct z_erofs_decompress_req *rq,
 26                           struct page **pagepool);
 27         int (*init)(void);
 28         void (*exit)(void);
 29         char *name;
 30 };
 31 
 32 /* some special page->private (unsigned long, see below) */
 33 #define Z_EROFS_SHORTLIVED_PAGE         (-1UL << 2)
 34 #define Z_EROFS_PREALLOCATED_PAGE       (-2UL << 2)
 35 
 36 /*
 37  * For all pages in a pcluster, page->private should be one of
 38  * Type                         Last 2bits      page->private
 39  * short-lived page             00              Z_EROFS_SHORTLIVED_PAGE
 40  * preallocated page (tryalloc) 00              Z_EROFS_PREALLOCATED_PAGE
 41  * cached/managed page          00              pointer to z_erofs_pcluster
 42  * online page (file-backed,    01/10/11        sub-index << 2 | count
 43  *              some pages can be used for inplace I/O)
 44  *
 45  * page->mapping should be one of
 46  * Type                 page->mapping
 47  * short-lived page     NULL
 48  * preallocated page    NULL
 49  * cached/managed page  non-NULL or NULL (invalidated/truncated page)
 50  * online page          non-NULL
 51  *
 52  * For all managed pages, PG_private should be set with 1 extra refcount,
 53  * which is used for page reclaim / migration.
 54  */
 55 
 56 /*
 57  * Currently, short-lived pages are pages directly from buddy system
 58  * with specific page->private (Z_EROFS_SHORTLIVED_PAGE).
 59  * In the future world of Memdescs, it should be type 0 (Misc) memory
 60  * which type can be checked with a new helper.
 61  */
 62 static inline bool z_erofs_is_shortlived_page(struct page *page)
 63 {
 64         return page->private == Z_EROFS_SHORTLIVED_PAGE;
 65 }
 66 
 67 static inline bool z_erofs_put_shortlivedpage(struct page **pagepool,
 68                                               struct page *page)
 69 {
 70         if (!z_erofs_is_shortlived_page(page))
 71                 return false;
 72         erofs_pagepool_add(pagepool, page);
 73         return true;
 74 }
 75 
 76 extern const struct z_erofs_decompressor z_erofs_lzma_decomp;
 77 extern const struct z_erofs_decompressor z_erofs_deflate_decomp;
 78 extern const struct z_erofs_decompressor z_erofs_zstd_decomp;
 79 extern const struct z_erofs_decompressor *z_erofs_decomp[];
 80 
 81 struct z_erofs_stream_dctx {
 82         struct z_erofs_decompress_req *rq;
 83         unsigned int inpages, outpages; /* # of {en,de}coded pages */
 84         int no, ni;                     /* the current {en,de}coded page # */
 85 
 86         unsigned int avail_out;         /* remaining bytes in the decoded buffer */
 87         unsigned int inbuf_pos, inbuf_sz;
 88                                         /* current status of the encoded buffer */
 89         u8 *kin, *kout;                 /* buffer mapped pointers */
 90         void *bounce;                   /* bounce buffer for inplace I/Os */
 91         bool bounced;                   /* is the bounce buffer used now? */
 92 };
 93 
 94 int z_erofs_stream_switch_bufs(struct z_erofs_stream_dctx *dctx, void **dst,
 95                                void **src, struct page **pgpl);
 96 int z_erofs_fixup_insize(struct z_erofs_decompress_req *rq, const char *padbuf,
 97                          unsigned int padbufsize);
 98 int __init z_erofs_init_decompressor(void);
 99 void z_erofs_exit_decompressor(void);
100 #endif
101 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php