Skip to content

Commit aeb6d88

Browse files
Li Zetaokdave
authored andcommitted
btrfs: convert btrfs_decompress() to take a folio
The old page API is being gradually replaced and converted to use folio to improve code readability and avoid repeated conversion between page and folio. Based on the previous patch, the compression path can be directly used in folio without converting to page. Signed-off-by: Li Zetao <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent b70f3a4 commit aeb6d88

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

fs/btrfs/compression.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ static int compression_decompress_bio(struct list_head *ws,
138138
}
139139

140140
static int compression_decompress(int type, struct list_head *ws,
141-
const u8 *data_in, struct page *dest_page,
141+
const u8 *data_in, struct folio *dest_folio,
142142
unsigned long dest_pgoff, size_t srclen, size_t destlen)
143143
{
144144
switch (type) {
145-
case BTRFS_COMPRESS_ZLIB: return zlib_decompress(ws, data_in, page_folio(dest_page),
145+
case BTRFS_COMPRESS_ZLIB: return zlib_decompress(ws, data_in, dest_folio,
146146
dest_pgoff, srclen, destlen);
147-
case BTRFS_COMPRESS_LZO: return lzo_decompress(ws, data_in, page_folio(dest_page),
147+
case BTRFS_COMPRESS_LZO: return lzo_decompress(ws, data_in, dest_folio,
148148
dest_pgoff, srclen, destlen);
149-
case BTRFS_COMPRESS_ZSTD: return zstd_decompress(ws, data_in, page_folio(dest_page),
149+
case BTRFS_COMPRESS_ZSTD: return zstd_decompress(ws, data_in, dest_folio,
150150
dest_pgoff, srclen, destlen);
151151
case BTRFS_COMPRESS_NONE:
152152
default:
@@ -1061,10 +1061,10 @@ static int btrfs_decompress_bio(struct compressed_bio *cb)
10611061
* single page, and we want to read a single page out of it.
10621062
* start_byte tells us the offset into the compressed data we're interested in
10631063
*/
1064-
int btrfs_decompress(int type, const u8 *data_in, struct page *dest_page,
1064+
int btrfs_decompress(int type, const u8 *data_in, struct folio *dest_folio,
10651065
unsigned long dest_pgoff, size_t srclen, size_t destlen)
10661066
{
1067-
struct btrfs_fs_info *fs_info = page_to_fs_info(dest_page);
1067+
struct btrfs_fs_info *fs_info = folio_to_fs_info(dest_folio);
10681068
struct list_head *workspace;
10691069
const u32 sectorsize = fs_info->sectorsize;
10701070
int ret;
@@ -1077,7 +1077,7 @@ int btrfs_decompress(int type, const u8 *data_in, struct page *dest_page,
10771077
ASSERT(dest_pgoff + destlen <= PAGE_SIZE && destlen <= sectorsize);
10781078

10791079
workspace = get_workspace(type, 0);
1080-
ret = compression_decompress(type, workspace, data_in, dest_page,
1080+
ret = compression_decompress(type, workspace, data_in, dest_folio,
10811081
dest_pgoff, srclen, destlen);
10821082
put_workspace(type, workspace);
10831083

fs/btrfs/compression.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void __cold btrfs_exit_compress(void);
9696
int btrfs_compress_folios(unsigned int type_level, struct address_space *mapping,
9797
u64 start, struct folio **folios, unsigned long *out_folios,
9898
unsigned long *total_in, unsigned long *total_out);
99-
int btrfs_decompress(int type, const u8 *data_in, struct page *dest_page,
99+
int btrfs_decompress(int type, const u8 *data_in, struct folio *dest_folio,
100100
unsigned long start_byte, size_t srclen, size_t destlen);
101101
int btrfs_decompress_buf2page(const char *buf, u32 buf_len,
102102
struct compressed_bio *cb, u32 decompressed);

fs/btrfs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6746,7 +6746,7 @@ static noinline int uncompress_inline(struct btrfs_path *path,
67466746
read_extent_buffer(leaf, tmp, ptr, inline_size);
67476747

67486748
max_size = min_t(unsigned long, PAGE_SIZE, max_size);
6749-
ret = btrfs_decompress(compress_type, tmp, &folio->page, 0, inline_size,
6749+
ret = btrfs_decompress(compress_type, tmp, folio, 0, inline_size,
67506750
max_size);
67516751

67526752
/*

fs/btrfs/reflink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static int copy_inline_to_page(struct btrfs_inode *inode,
118118
memcpy_to_page(page, offset_in_page(file_offset), data_start,
119119
datal);
120120
} else {
121-
ret = btrfs_decompress(comp_type, data_start, page,
121+
ret = btrfs_decompress(comp_type, data_start, page_folio(page),
122122
offset_in_page(file_offset),
123123
inline_size, datal);
124124
if (ret)

0 commit comments

Comments
 (0)