Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

btrfs: extract the max compression chunk size into a macro

We have two locations using open-coded 512K size, as the async chunk
size.

For compression we have not only the max size a compressed extent can
represent (128K), but also how large an async chunk can be (512K).

Although we have a macro for the maximum compressed extent size, we do
not have any macro for the async chunk size.

Add such a macro and replace the two open-coded SZ_512K.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Qu Wenruo and committed by
David Sterba
cab4c8b5 45cc960f

+5 -2
+3
fs/btrfs/compression.h
··· 36 36 #define BTRFS_MAX_COMPRESSED_PAGES (BTRFS_MAX_COMPRESSED / PAGE_SIZE) 37 37 static_assert((BTRFS_MAX_COMPRESSED % PAGE_SIZE) == 0); 38 38 39 + /* The max size for a single worker to compress. */ 40 + #define BTRFS_COMPRESSION_CHUNK_SIZE (SZ_512K) 41 + 39 42 /* Maximum size of data before compression */ 40 43 #define BTRFS_MAX_UNCOMPRESSED (SZ_128K) 41 44
+2 -2
fs/btrfs/inode.c
··· 1691 1691 struct async_cow *ctx; 1692 1692 struct async_chunk *async_chunk; 1693 1693 unsigned long nr_pages; 1694 - u64 num_chunks = DIV_ROUND_UP(end - start, SZ_512K); 1694 + u64 num_chunks = DIV_ROUND_UP(end - start, BTRFS_COMPRESSION_CHUNK_SIZE); 1695 1695 int i; 1696 1696 unsigned nofs_flag; 1697 1697 const blk_opf_t write_flags = wbc_to_write_flags(wbc); ··· 1708 1708 atomic_set(&ctx->num_chunks, num_chunks); 1709 1709 1710 1710 for (i = 0; i < num_chunks; i++) { 1711 - u64 cur_end = min(end, start + SZ_512K - 1); 1711 + u64 cur_end = min(end, start + BTRFS_COMPRESSION_CHUNK_SIZE - 1); 1712 1712 1713 1713 /* 1714 1714 * igrab is called higher up in the call chain, take only the