99#include "kerncompat.h"
1010#include "kernel-lib/sizes.h"
1111
12- struct btrfs_inode ;
13- struct btrfs_ordered_extent ;
1412struct address_space ;
13+ struct folio ;
14+ struct page ;
1515struct inode ;
16+ struct btrfs_inode ;
17+ struct btrfs_ordered_extent ;
1618struct bio ;
1719/* Stub for kernel-user parity. */
1820struct btrfs_bio { };
@@ -37,14 +39,12 @@ _static_assert((BTRFS_MAX_COMPRESSED % PAGE_SIZE) == 0);
3739
3840#define BTRFS_ZLIB_DEFAULT_LEVEL 3
3941
40- struct page ;
41-
4242struct compressed_bio {
43- /* Number of compressed pages in the array */
44- unsigned int nr_pages ;
43+ /* Number of compressed folios in the array. */
44+ unsigned int nr_folios ;
4545
46- /* the pages with the compressed data on them */
47- struct page * * compressed_pages ;
46+ /* The folios with the compressed data on them. */
47+ struct folio * * compressed_folios ;
4848
4949 /* starting offset in the inode for our pages */
5050 u64 start ;
@@ -84,34 +84,34 @@ static inline unsigned int btrfs_compress_level(unsigned int type_level)
8484int __init btrfs_init_compress (void );
8585void __cold btrfs_exit_compress (void );
8686
87- int btrfs_compress_pages (unsigned int type_level , struct address_space * mapping ,
88- u64 start , struct page * * pages ,
89- unsigned long * out_pages ,
90- unsigned long * total_in ,
91- unsigned long * total_out );
92- int btrfs_decompress (int type , const u8 * data_in , struct page * dest_page ,
87+ bool btrfs_compress_level_valid (unsigned int type , int level );
88+ int btrfs_compress_folios (unsigned int type , int level , struct address_space * mapping ,
89+ u64 start , struct folio * * folios , unsigned long * out_folios ,
90+ unsigned long * total_in , unsigned long * total_out );
91+ int btrfs_decompress (int type , const u8 * data_in , struct folio * dest_folio ,
9392 unsigned long start_byte , size_t srclen , size_t destlen );
9493int btrfs_decompress_buf2page (const char * buf , u32 buf_len ,
9594 struct compressed_bio * cb , u32 decompressed );
9695
9796void btrfs_submit_compressed_write (struct btrfs_ordered_extent * ordered ,
98- struct page * * compressed_pages ,
99- unsigned int nr_pages ,
100- blk_opf_t write_flags ,
101- bool writeback );
97+ struct folio * * compressed_folios ,
98+ unsigned int nr_folios , blk_opf_t write_flags ,
99+ bool writeback );
102100void btrfs_submit_compressed_read (struct btrfs_bio * bbio );
103101
104- unsigned int btrfs_compress_str2level (unsigned int type , const char * str );
102+ int btrfs_compress_str2level (unsigned int type , const char * str );
105103
106- struct page * btrfs_alloc_compr_page (void );
107- void btrfs_free_compr_page (struct page * page );
104+ struct folio * btrfs_alloc_compr_folio (void );
105+ void btrfs_free_compr_folio (struct folio * folio );
108106
109107enum btrfs_compression_type {
110108 BTRFS_COMPRESS_NONE = 0 ,
111109 BTRFS_COMPRESS_ZLIB = 1 ,
112110 BTRFS_COMPRESS_LZO = 2 ,
113111 BTRFS_COMPRESS_ZSTD = 3 ,
114112 BTRFS_NR_COMPRESS_TYPES = 4 ,
113+
114+ BTRFS_DEFRAG_DONT_COMPRESS ,
115115};
116116
117117struct workspace_manager {
@@ -125,14 +125,15 @@ struct workspace_manager {
125125 wait_queue_head_t ws_wait ;
126126};
127127
128- struct list_head * btrfs_get_workspace (int type , unsigned int level );
128+ struct list_head * btrfs_get_workspace (int type , int level );
129129void btrfs_put_workspace (int type , struct list_head * ws );
130130
131131struct btrfs_compress_op {
132132 struct workspace_manager * workspace_manager ;
133133 /* Maximum level supported by the compression algorithm */
134- unsigned int max_level ;
135- unsigned int default_level ;
134+ int min_level ;
135+ int max_level ;
136+ int default_level ;
136137};
137138
138139/* The heuristic workspaces are managed via the 0th workspace manager */
@@ -146,41 +147,44 @@ extern const struct btrfs_compress_op btrfs_zstd_compress;
146147const char * btrfs_compress_type2str (enum btrfs_compression_type type );
147148bool btrfs_compress_is_valid_type (const char * str , size_t len );
148149
149- int btrfs_compress_heuristic (struct inode * inode , u64 start , u64 end );
150+ int btrfs_compress_heuristic (struct btrfs_inode * inode , u64 start , u64 end );
151+
152+ int btrfs_compress_filemap_get_folio (struct address_space * mapping , u64 start ,
153+ struct folio * * in_folio_ret );
150154
151- int zlib_compress_pages (struct list_head * ws , struct address_space * mapping ,
152- u64 start , struct page * * pages , unsigned long * out_pages ,
155+ int zlib_compress_folios (struct list_head * ws , struct address_space * mapping ,
156+ u64 start , struct folio * * folios , unsigned long * out_folios ,
153157 unsigned long * total_in , unsigned long * total_out );
154158int zlib_decompress_bio (struct list_head * ws , struct compressed_bio * cb );
155159int zlib_decompress (struct list_head * ws , const u8 * data_in ,
156- struct page * dest_page , unsigned long dest_pgoff , size_t srclen ,
160+ struct folio * dest_folio , unsigned long dest_pgoff , size_t srclen ,
157161 size_t destlen );
158162struct list_head * zlib_alloc_workspace (unsigned int level );
159163void zlib_free_workspace (struct list_head * ws );
160164struct list_head * zlib_get_workspace (unsigned int level );
161165
162- int lzo_compress_pages (struct list_head * ws , struct address_space * mapping ,
163- u64 start , struct page * * pages , unsigned long * out_pages ,
166+ int lzo_compress_folios (struct list_head * ws , struct address_space * mapping ,
167+ u64 start , struct folio * * folios , unsigned long * out_folios ,
164168 unsigned long * total_in , unsigned long * total_out );
165169int lzo_decompress_bio (struct list_head * ws , struct compressed_bio * cb );
166170int lzo_decompress (struct list_head * ws , const u8 * data_in ,
167- struct page * dest_page , unsigned long dest_pgoff , size_t srclen ,
171+ struct folio * dest_folio , unsigned long dest_pgoff , size_t srclen ,
168172 size_t destlen );
169- struct list_head * lzo_alloc_workspace (unsigned int level );
173+ struct list_head * lzo_alloc_workspace (void );
170174void lzo_free_workspace (struct list_head * ws );
171175
172- int zstd_compress_pages (struct list_head * ws , struct address_space * mapping ,
173- u64 start , struct page * * pages , unsigned long * out_pages ,
176+ int zstd_compress_folios (struct list_head * ws , struct address_space * mapping ,
177+ u64 start , struct folio * * folios , unsigned long * out_folios ,
174178 unsigned long * total_in , unsigned long * total_out );
175179int zstd_decompress_bio (struct list_head * ws , struct compressed_bio * cb );
176180int zstd_decompress (struct list_head * ws , const u8 * data_in ,
177- struct page * dest_page , unsigned long start_byte , size_t srclen ,
181+ struct folio * dest_folio , unsigned long dest_pgoff , size_t srclen ,
178182 size_t destlen );
179183void zstd_init_workspace_manager (void );
180184void zstd_cleanup_workspace_manager (void );
181- struct list_head * zstd_alloc_workspace (unsigned int level );
185+ struct list_head * zstd_alloc_workspace (int level );
182186void zstd_free_workspace (struct list_head * ws );
183- struct list_head * zstd_get_workspace (unsigned int level );
187+ struct list_head * zstd_get_workspace (int level );
184188void zstd_put_workspace (struct list_head * ws );
185189
186190#endif
0 commit comments