Skip to content

Commit e5d7490

Browse files
committed
btrfs: derive maximum output size in the compression implementation
The value of max_out can be calculated from the parameters passed to the compressors, which is number of pages and the page size, and we don't have to needlessly pass it around. Signed-off-by: David Sterba <[email protected]>
1 parent 069eac7 commit e5d7490

File tree

5 files changed

+9
-14
lines changed

5 files changed

+9
-14
lines changed

fs/btrfs/compression.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -932,8 +932,7 @@ int btrfs_compress_pages(int type, struct address_space *mapping,
932932
u64 start, struct page **pages,
933933
unsigned long *out_pages,
934934
unsigned long *total_in,
935-
unsigned long *total_out,
936-
unsigned long max_out)
935+
unsigned long *total_out)
937936
{
938937
struct list_head *workspace;
939938
int ret;
@@ -943,8 +942,7 @@ int btrfs_compress_pages(int type, struct address_space *mapping,
943942
ret = btrfs_compress_op[type-1]->compress_pages(workspace, mapping,
944943
start, pages,
945944
out_pages,
946-
total_in, total_out,
947-
max_out);
945+
total_in, total_out);
948946
free_workspace(type, workspace);
949947
return ret;
950948
}

fs/btrfs/compression.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ int btrfs_compress_pages(int type, struct address_space *mapping,
4141
u64 start, struct page **pages,
4242
unsigned long *out_pages,
4343
unsigned long *total_in,
44-
unsigned long *total_out,
45-
unsigned long max_out);
44+
unsigned long *total_out);
4645
int btrfs_decompress(int type, unsigned char *data_in, struct page *dest_page,
4746
unsigned long start_byte, size_t srclen, size_t destlen);
4847
int btrfs_decompress_buf2page(const char *buf, unsigned long buf_start,
@@ -76,8 +75,7 @@ struct btrfs_compress_op {
7675
struct page **pages,
7776
unsigned long *out_pages,
7877
unsigned long *total_in,
79-
unsigned long *total_out,
80-
unsigned long max_out);
78+
unsigned long *total_out);
8179

8280
int (*decompress_bio)(struct list_head *workspace,
8381
struct page **pages_in,

fs/btrfs/inode.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,7 @@ static noinline void compress_file_range(struct inode *inode,
510510
pages,
511511
&nr_pages,
512512
&total_in,
513-
&total_compressed,
514-
BTRFS_MAX_COMPRESSED);
513+
&total_compressed);
515514

516515
if (!ret) {
517516
unsigned long offset = total_compressed &

fs/btrfs/lzo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ static int lzo_compress_pages(struct list_head *ws,
9090
struct page **pages,
9191
unsigned long *out_pages,
9292
unsigned long *total_in,
93-
unsigned long *total_out,
94-
unsigned long max_out)
93+
unsigned long *total_out)
9594
{
9695
struct workspace *workspace = list_entry(ws, struct workspace, list);
9796
int ret = 0;
@@ -103,6 +102,7 @@ static int lzo_compress_pages(struct list_head *ws,
103102
unsigned long bytes_left;
104103
unsigned long len = *total_out;
105104
unsigned long nr_dest_pages = *out_pages;
105+
const unsigned long max_out = nr_dest_pages * PAGE_SIZE;
106106
size_t in_len;
107107
size_t out_len;
108108
char *buf;

fs/btrfs/zlib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ static int zlib_compress_pages(struct list_head *ws,
7777
struct page **pages,
7878
unsigned long *out_pages,
7979
unsigned long *total_in,
80-
unsigned long *total_out,
81-
unsigned long max_out)
80+
unsigned long *total_out)
8281
{
8382
struct workspace *workspace = list_entry(ws, struct workspace, list);
8483
int ret;
@@ -90,6 +89,7 @@ static int zlib_compress_pages(struct list_head *ws,
9089
unsigned long bytes_left;
9190
unsigned long len = *total_out;
9291
unsigned long nr_dest_pages = *out_pages;
92+
const unsigned long max_out = nr_dest_pages * PAGE_SIZE;
9393

9494
*out_pages = 0;
9595
*total_out = 0;

0 commit comments

Comments
 (0)