Skip to content

Commit cab4c8b

Browse files
adam900710kdave
authored andcommitted
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 <[email protected]> Signed-off-by: Qu Wenruo <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 45cc960 commit cab4c8b

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

fs/btrfs/compression.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ struct btrfs_ordered_extent;
3636
#define BTRFS_MAX_COMPRESSED_PAGES (BTRFS_MAX_COMPRESSED / PAGE_SIZE)
3737
static_assert((BTRFS_MAX_COMPRESSED % PAGE_SIZE) == 0);
3838

39+
/* The max size for a single worker to compress. */
40+
#define BTRFS_COMPRESSION_CHUNK_SIZE (SZ_512K)
41+
3942
/* Maximum size of data before compression */
4043
#define BTRFS_MAX_UNCOMPRESSED (SZ_128K)
4144

fs/btrfs/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,7 @@ static bool run_delalloc_compressed(struct btrfs_inode *inode,
16911691
struct async_cow *ctx;
16921692
struct async_chunk *async_chunk;
16931693
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);
16951695
int i;
16961696
unsigned nofs_flag;
16971697
const blk_opf_t write_flags = wbc_to_write_flags(wbc);
@@ -1708,7 +1708,7 @@ static bool run_delalloc_compressed(struct btrfs_inode *inode,
17081708
atomic_set(&ctx->num_chunks, num_chunks);
17091709

17101710
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);
17121712

17131713
/*
17141714
* igrab is called higher up in the call chain, take only the

0 commit comments

Comments
 (0)