Commit e5d74902 authored by David Sterba's avatar David Sterba

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: default avatarDavid Sterba <dsterba@suse.com>
parent 069eac78
...@@ -932,8 +932,7 @@ int btrfs_compress_pages(int type, struct address_space *mapping, ...@@ -932,8 +932,7 @@ int btrfs_compress_pages(int type, struct address_space *mapping,
u64 start, struct page **pages, u64 start, struct page **pages,
unsigned long *out_pages, unsigned long *out_pages,
unsigned long *total_in, unsigned long *total_in,
unsigned long *total_out, unsigned long *total_out)
unsigned long max_out)
{ {
struct list_head *workspace; struct list_head *workspace;
int ret; int ret;
...@@ -943,8 +942,7 @@ int btrfs_compress_pages(int type, struct address_space *mapping, ...@@ -943,8 +942,7 @@ int btrfs_compress_pages(int type, struct address_space *mapping,
ret = btrfs_compress_op[type-1]->compress_pages(workspace, mapping, ret = btrfs_compress_op[type-1]->compress_pages(workspace, mapping,
start, pages, start, pages,
out_pages, out_pages,
total_in, total_out, total_in, total_out);
max_out);
free_workspace(type, workspace); free_workspace(type, workspace);
return ret; return ret;
} }
......
...@@ -41,8 +41,7 @@ int btrfs_compress_pages(int type, struct address_space *mapping, ...@@ -41,8 +41,7 @@ int btrfs_compress_pages(int type, struct address_space *mapping,
u64 start, struct page **pages, u64 start, struct page **pages,
unsigned long *out_pages, unsigned long *out_pages,
unsigned long *total_in, unsigned long *total_in,
unsigned long *total_out, unsigned long *total_out);
unsigned long max_out);
int btrfs_decompress(int type, unsigned char *data_in, struct page *dest_page, int btrfs_decompress(int type, unsigned char *data_in, struct page *dest_page,
unsigned long start_byte, size_t srclen, size_t destlen); unsigned long start_byte, size_t srclen, size_t destlen);
int btrfs_decompress_buf2page(const char *buf, unsigned long buf_start, int btrfs_decompress_buf2page(const char *buf, unsigned long buf_start,
...@@ -76,8 +75,7 @@ struct btrfs_compress_op { ...@@ -76,8 +75,7 @@ struct btrfs_compress_op {
struct page **pages, struct page **pages,
unsigned long *out_pages, unsigned long *out_pages,
unsigned long *total_in, unsigned long *total_in,
unsigned long *total_out, unsigned long *total_out);
unsigned long max_out);
int (*decompress_bio)(struct list_head *workspace, int (*decompress_bio)(struct list_head *workspace,
struct page **pages_in, struct page **pages_in,
......
...@@ -510,8 +510,7 @@ static noinline void compress_file_range(struct inode *inode, ...@@ -510,8 +510,7 @@ static noinline void compress_file_range(struct inode *inode,
pages, pages,
&nr_pages, &nr_pages,
&total_in, &total_in,
&total_compressed, &total_compressed);
BTRFS_MAX_COMPRESSED);
if (!ret) { if (!ret) {
unsigned long offset = total_compressed & unsigned long offset = total_compressed &
......
...@@ -90,8 +90,7 @@ static int lzo_compress_pages(struct list_head *ws, ...@@ -90,8 +90,7 @@ static int lzo_compress_pages(struct list_head *ws,
struct page **pages, struct page **pages,
unsigned long *out_pages, unsigned long *out_pages,
unsigned long *total_in, unsigned long *total_in,
unsigned long *total_out, unsigned long *total_out)
unsigned long max_out)
{ {
struct workspace *workspace = list_entry(ws, struct workspace, list); struct workspace *workspace = list_entry(ws, struct workspace, list);
int ret = 0; int ret = 0;
...@@ -103,6 +102,7 @@ static int lzo_compress_pages(struct list_head *ws, ...@@ -103,6 +102,7 @@ static int lzo_compress_pages(struct list_head *ws,
unsigned long bytes_left; unsigned long bytes_left;
unsigned long len = *total_out; unsigned long len = *total_out;
unsigned long nr_dest_pages = *out_pages; unsigned long nr_dest_pages = *out_pages;
const unsigned long max_out = nr_dest_pages * PAGE_SIZE;
size_t in_len; size_t in_len;
size_t out_len; size_t out_len;
char *buf; char *buf;
......
...@@ -77,8 +77,7 @@ static int zlib_compress_pages(struct list_head *ws, ...@@ -77,8 +77,7 @@ static int zlib_compress_pages(struct list_head *ws,
struct page **pages, struct page **pages,
unsigned long *out_pages, unsigned long *out_pages,
unsigned long *total_in, unsigned long *total_in,
unsigned long *total_out, unsigned long *total_out)
unsigned long max_out)
{ {
struct workspace *workspace = list_entry(ws, struct workspace, list); struct workspace *workspace = list_entry(ws, struct workspace, list);
int ret; int ret;
...@@ -90,6 +89,7 @@ static int zlib_compress_pages(struct list_head *ws, ...@@ -90,6 +89,7 @@ static int zlib_compress_pages(struct list_head *ws,
unsigned long bytes_left; unsigned long bytes_left;
unsigned long len = *total_out; unsigned long len = *total_out;
unsigned long nr_dest_pages = *out_pages; unsigned long nr_dest_pages = *out_pages;
const unsigned long max_out = nr_dest_pages * PAGE_SIZE;
*out_pages = 0; *out_pages = 0;
*total_out = 0; *total_out = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment