Skip to content

Commit 9f9a4e4

Browse files
Li Zetaokdave
authored andcommitted
btrfs: convert lzo_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. And memcpy_to_page() can be replaced with memcpy_to_folio(). But there is no memzero_folio(), but it can be replaced equivalently by folio_zero_range(). Signed-off-by: Li Zetao <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 54c78d4 commit 9f9a4e4

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

fs/btrfs/compression.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static int compression_decompress(int type, struct list_head *ws,
144144
switch (type) {
145145
case BTRFS_COMPRESS_ZLIB: return zlib_decompress(ws, data_in, page_folio(dest_page),
146146
dest_pgoff, srclen, destlen);
147-
case BTRFS_COMPRESS_LZO: return lzo_decompress(ws, data_in, dest_page,
147+
case BTRFS_COMPRESS_LZO: return lzo_decompress(ws, data_in, page_folio(dest_page),
148148
dest_pgoff, srclen, destlen);
149149
case BTRFS_COMPRESS_ZSTD: return zstd_decompress(ws, data_in, dest_page,
150150
dest_pgoff, srclen, destlen);

fs/btrfs/compression.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ int lzo_compress_folios(struct list_head *ws, struct address_space *mapping,
173173
unsigned long *total_in, unsigned long *total_out);
174174
int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb);
175175
int lzo_decompress(struct list_head *ws, const u8 *data_in,
176-
struct page *dest_page, unsigned long dest_pgoff, size_t srclen,
176+
struct folio *dest_folio, unsigned long dest_pgoff, size_t srclen,
177177
size_t destlen);
178178
struct list_head *lzo_alloc_workspace(unsigned int level);
179179
void lzo_free_workspace(struct list_head *ws);

fs/btrfs/lzo.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,11 @@ int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
438438
}
439439

440440
int lzo_decompress(struct list_head *ws, const u8 *data_in,
441-
struct page *dest_page, unsigned long dest_pgoff, size_t srclen,
441+
struct folio *dest_folio, unsigned long dest_pgoff, size_t srclen,
442442
size_t destlen)
443443
{
444444
struct workspace *workspace = list_entry(ws, struct workspace, list);
445-
struct btrfs_fs_info *fs_info = page_to_fs_info(dest_page);
445+
struct btrfs_fs_info *fs_info = folio_to_fs_info(dest_folio);
446446
const u32 sectorsize = fs_info->sectorsize;
447447
size_t in_len;
448448
size_t out_len;
@@ -467,22 +467,22 @@ int lzo_decompress(struct list_head *ws, const u8 *data_in,
467467
out_len = sectorsize;
468468
ret = lzo1x_decompress_safe(data_in, in_len, workspace->buf, &out_len);
469469
if (unlikely(ret != LZO_E_OK)) {
470-
struct btrfs_inode *inode = BTRFS_I(dest_page->mapping->host);
470+
struct btrfs_inode *inode = folio_to_inode(dest_folio);
471471

472472
btrfs_err(fs_info,
473473
"lzo decompression failed, error %d root %llu inode %llu offset %llu",
474474
ret, btrfs_root_id(inode->root), btrfs_ino(inode),
475-
page_offset(dest_page));
475+
folio_pos(dest_folio));
476476
ret = -EIO;
477477
goto out;
478478
}
479479

480480
ASSERT(out_len <= sectorsize);
481-
memcpy_to_page(dest_page, dest_pgoff, workspace->buf, out_len);
481+
memcpy_to_folio(dest_folio, dest_pgoff, workspace->buf, out_len);
482482
/* Early end, considered as an error. */
483483
if (unlikely(out_len < destlen)) {
484484
ret = -EIO;
485-
memzero_page(dest_page, dest_pgoff + out_len, destlen - out_len);
485+
folio_zero_range(dest_folio, dest_pgoff + out_len, destlen - out_len);
486486
}
487487
out:
488488
return ret;

0 commit comments

Comments
 (0)