diff options
| author | Qu Wenruo <wqu@suse.com> | 2026-01-29 13:53:41 +1030 |
|---|---|---|
| committer | David Sterba <dsterba@suse.com> | 2026-02-03 07:59:06 +0100 |
| commit | c51173271d528561706a2ce3bacd4f6232f4375b (patch) | |
| tree | e50595889bd0d0f43226bf9efb62fb4735785317 /fs/btrfs/compression.h | |
| parent | 3d74a7556fbab89a3e78f514cf39d3413b9963d1 (diff) | |
| download | linux-next-c51173271d528561706a2ce3bacd4f6232f4375b.tar.gz linux-next-c51173271d528561706a2ce3bacd4f6232f4375b.zip | |
btrfs: introduce btrfs_compress_bio() helper
The helper will allocate a new compressed_bio, do the compression, and
return it to the caller.
This greatly simplifies the compression path, as we no longer need to
allocate a folio array thus no extra error path, furthermore the
compressed bio structure can be utilized for submission with very minor
modifications (like rounding up the bi_size and populate the bi_sector).
Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/compression.h')
| -rw-r--r-- | fs/btrfs/compression.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h index eee4190efa02..fd0cce5d07cf 100644 --- a/fs/btrfs/compression.h +++ b/fs/btrfs/compression.h @@ -146,6 +146,19 @@ int btrfs_compress_heuristic(struct btrfs_inode *inode, u64 start, u64 end); int btrfs_compress_filemap_get_folio(struct address_space *mapping, u64 start, struct folio **in_folio_ret); +struct compressed_bio *btrfs_compress_bio(struct btrfs_inode *inode, + u64 start, u32 len, unsigned int type, + int level, blk_opf_t write_flags); + +static inline void cleanup_compressed_bio(struct compressed_bio *cb) +{ + struct bio *bio = &cb->bbio.bio; + struct folio_iter fi; + + bio_for_each_folio_all(fi, bio) + btrfs_free_compr_folio(fi.folio); + bio_put(bio); +} int zlib_compress_folios(struct list_head *ws, struct btrfs_inode *inode, u64 start, struct folio **folios, unsigned long *out_folios, |
