Skip to content

Commit ff76386

Browse files
committed
btrfs: export compression buffer limits in a header
Move the buffer limit definitions out of compress_file_range. Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 4d3a800 commit ff76386

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

fs/btrfs/compression.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@
1919
#ifndef __BTRFS_COMPRESSION_
2020
#define __BTRFS_COMPRESSION_
2121

22+
/*
23+
* We want to make sure that amount of RAM required to uncompress an extent is
24+
* reasonable, so we limit the total size in ram of a compressed extent to
25+
* 128k. This is a crucial number because it also controls how easily we can
26+
* spread reads across cpus for decompression.
27+
*
28+
* We also want to make sure the amount of IO required to do a random read is
29+
* reasonably small, so we limit the size of a compressed extent to 128k.
30+
*/
31+
32+
/* Maximum length of compressed data stored on disk */
33+
#define BTRFS_MAX_COMPRESSED (SZ_128K)
34+
/* Maximum size of data before compression */
35+
#define BTRFS_MAX_UNCOMPRESSED (SZ_128K)
36+
2237
void btrfs_init_compress(void);
2338
void btrfs_exit_compress(void);
2439

fs/btrfs/inode.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -471,16 +471,6 @@ static noinline void compress_file_range(struct inode *inode,
471471
(start > 0 || end + 1 < BTRFS_I(inode)->disk_i_size))
472472
goto cleanup_and_bail_uncompressed;
473473

474-
/* we want to make sure that amount of ram required to uncompress
475-
* an extent is reasonable, so we limit the total size in ram
476-
* of a compressed extent to 128k. This is a crucial number
477-
* because it also controls how easily we can spread reads across
478-
* cpus for decompression.
479-
*
480-
* We also want to make sure the amount of IO required to do
481-
* a random read is reasonably small, so we limit the size of
482-
* a compressed extent to 128k.
483-
*/
484474
total_compressed = min(total_compressed, max_uncompressed);
485475
num_bytes = ALIGN(end - start + 1, blocksize);
486476
num_bytes = max(blocksize, num_bytes);

0 commit comments

Comments
 (0)