Skip to content

Commit 069eac7

Browse files
committed
btrfs: use predefined limits for calculating maximum number of pages for compression
Signed-off-by: David Sterba <[email protected]>
1 parent ff76386 commit 069eac7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

fs/btrfs/inode.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,6 @@ static noinline void compress_file_range(struct inode *inode,
432432
unsigned long nr_pages;
433433
unsigned long total_compressed = 0;
434434
unsigned long total_in = 0;
435-
unsigned long max_compressed = SZ_128K;
436-
unsigned long max_uncompressed = SZ_128K;
437435
int i;
438436
int will_compress;
439437
int compress_type = fs_info->compress_type;
@@ -446,7 +444,9 @@ static noinline void compress_file_range(struct inode *inode,
446444
again:
447445
will_compress = 0;
448446
nr_pages = (end >> PAGE_SHIFT) - (start >> PAGE_SHIFT) + 1;
449-
nr_pages = min_t(unsigned long, nr_pages, SZ_128K / PAGE_SIZE);
447+
BUILD_BUG_ON((BTRFS_MAX_COMPRESSED % PAGE_SIZE) != 0);
448+
nr_pages = min_t(unsigned long, nr_pages,
449+
BTRFS_MAX_COMPRESSED / PAGE_SIZE);
450450

451451
/*
452452
* we don't want to send crud past the end of i_size through
@@ -471,7 +471,8 @@ 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-
total_compressed = min(total_compressed, max_uncompressed);
474+
total_compressed = min_t(unsigned long, total_compressed,
475+
BTRFS_MAX_UNCOMPRESSED);
475476
num_bytes = ALIGN(end - start + 1, blocksize);
476477
num_bytes = max(blocksize, num_bytes);
477478
total_in = 0;
@@ -510,7 +511,7 @@ static noinline void compress_file_range(struct inode *inode,
510511
&nr_pages,
511512
&total_in,
512513
&total_compressed,
513-
max_compressed);
514+
BTRFS_MAX_COMPRESSED);
514515

515516
if (!ret) {
516517
unsigned long offset = total_compressed &

0 commit comments

Comments
 (0)