diff options
author | David Sterba <dsterba@suse.com> | 2017-02-14 13:45:05 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2017-02-28 08:26:36 -0500 |
commit | e5d74902362f1a06ea3674042d09f1af178c0a20 (patch) | |
tree | 18b3bf38ac7e1d72923e423156f5e1843317f695 | |
parent | 069eac7850890acf0d3c21a6c8ca9f33ddb34a0d (diff) |
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 <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/compression.c | 6 | ||||
-rw-r--r-- | fs/btrfs/compression.h | 6 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 3 | ||||
-rw-r--r-- | fs/btrfs/lzo.c | 4 | ||||
-rw-r--r-- | fs/btrfs/zlib.c | 4 |
5 files changed, 9 insertions, 14 deletions
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index 11dcda57e15c..c7721a6aa3bb 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c | |||
@@ -932,8 +932,7 @@ int btrfs_compress_pages(int type, struct address_space *mapping, | |||
932 | u64 start, struct page **pages, | 932 | u64 start, struct page **pages, |
933 | unsigned long *out_pages, | 933 | unsigned long *out_pages, |
934 | unsigned long *total_in, | 934 | unsigned long *total_in, |
935 | unsigned long *total_out, | 935 | unsigned long *total_out) |
936 | unsigned long max_out) | ||
937 | { | 936 | { |
938 | struct list_head *workspace; | 937 | struct list_head *workspace; |
939 | int ret; | 938 | int ret; |
@@ -943,8 +942,7 @@ int btrfs_compress_pages(int type, struct address_space *mapping, | |||
943 | ret = btrfs_compress_op[type-1]->compress_pages(workspace, mapping, | 942 | ret = btrfs_compress_op[type-1]->compress_pages(workspace, mapping, |
944 | start, pages, | 943 | start, pages, |
945 | out_pages, | 944 | out_pages, |
946 | total_in, total_out, | 945 | total_in, total_out); |
947 | max_out); | ||
948 | free_workspace(type, workspace); | 946 | free_workspace(type, workspace); |
949 | return ret; | 947 | return ret; |
950 | } | 948 | } |
diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h index 619e64c27444..39ec43ab8df1 100644 --- a/fs/btrfs/compression.h +++ b/fs/btrfs/compression.h | |||
@@ -41,8 +41,7 @@ int btrfs_compress_pages(int type, struct address_space *mapping, | |||
41 | u64 start, struct page **pages, | 41 | u64 start, struct page **pages, |
42 | unsigned long *out_pages, | 42 | unsigned long *out_pages, |
43 | unsigned long *total_in, | 43 | unsigned long *total_in, |
44 | unsigned long *total_out, | 44 | unsigned long *total_out); |
45 | unsigned long max_out); | ||
46 | int btrfs_decompress(int type, unsigned char *data_in, struct page *dest_page, | 45 | int btrfs_decompress(int type, unsigned char *data_in, struct page *dest_page, |
47 | unsigned long start_byte, size_t srclen, size_t destlen); | 46 | unsigned long start_byte, size_t srclen, size_t destlen); |
48 | int btrfs_decompress_buf2page(const char *buf, unsigned long buf_start, | 47 | int btrfs_decompress_buf2page(const char *buf, unsigned long buf_start, |
@@ -76,8 +75,7 @@ struct btrfs_compress_op { | |||
76 | struct page **pages, | 75 | struct page **pages, |
77 | unsigned long *out_pages, | 76 | unsigned long *out_pages, |
78 | unsigned long *total_in, | 77 | unsigned long *total_in, |
79 | unsigned long *total_out, | 78 | unsigned long *total_out); |
80 | unsigned long max_out); | ||
81 | 79 | ||
82 | int (*decompress_bio)(struct list_head *workspace, | 80 | int (*decompress_bio)(struct list_head *workspace, |
83 | struct page **pages_in, | 81 | struct page **pages_in, |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 11a4eeadf662..0d932b9594de 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -510,8 +510,7 @@ again: | |||
510 | pages, | 510 | pages, |
511 | &nr_pages, | 511 | &nr_pages, |
512 | &total_in, | 512 | &total_in, |
513 | &total_compressed, | 513 | &total_compressed); |
514 | BTRFS_MAX_COMPRESSED); | ||
515 | 514 | ||
516 | if (!ret) { | 515 | if (!ret) { |
517 | unsigned long offset = total_compressed & | 516 | unsigned long offset = total_compressed & |
diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c index 0baf978fbcaf..f48c8c14dc14 100644 --- a/fs/btrfs/lzo.c +++ b/fs/btrfs/lzo.c | |||
@@ -90,8 +90,7 @@ static int lzo_compress_pages(struct list_head *ws, | |||
90 | struct page **pages, | 90 | struct page **pages, |
91 | unsigned long *out_pages, | 91 | unsigned long *out_pages, |
92 | unsigned long *total_in, | 92 | unsigned long *total_in, |
93 | unsigned long *total_out, | 93 | unsigned long *total_out) |
94 | unsigned long max_out) | ||
95 | { | 94 | { |
96 | struct workspace *workspace = list_entry(ws, struct workspace, list); | 95 | struct workspace *workspace = list_entry(ws, struct workspace, list); |
97 | int ret = 0; | 96 | int ret = 0; |
@@ -103,6 +102,7 @@ static int lzo_compress_pages(struct list_head *ws, | |||
103 | unsigned long bytes_left; | 102 | unsigned long bytes_left; |
104 | unsigned long len = *total_out; | 103 | unsigned long len = *total_out; |
105 | unsigned long nr_dest_pages = *out_pages; | 104 | unsigned long nr_dest_pages = *out_pages; |
105 | const unsigned long max_out = nr_dest_pages * PAGE_SIZE; | ||
106 | size_t in_len; | 106 | size_t in_len; |
107 | size_t out_len; | 107 | size_t out_len; |
108 | char *buf; | 108 | char *buf; |
diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c index e7f2020f8ee7..135b10823c6d 100644 --- a/fs/btrfs/zlib.c +++ b/fs/btrfs/zlib.c | |||
@@ -77,8 +77,7 @@ static int zlib_compress_pages(struct list_head *ws, | |||
77 | struct page **pages, | 77 | struct page **pages, |
78 | unsigned long *out_pages, | 78 | unsigned long *out_pages, |
79 | unsigned long *total_in, | 79 | unsigned long *total_in, |
80 | unsigned long *total_out, | 80 | unsigned long *total_out) |
81 | unsigned long max_out) | ||
82 | { | 81 | { |
83 | struct workspace *workspace = list_entry(ws, struct workspace, list); | 82 | struct workspace *workspace = list_entry(ws, struct workspace, list); |
84 | int ret; | 83 | int ret; |
@@ -90,6 +89,7 @@ static int zlib_compress_pages(struct list_head *ws, | |||
90 | unsigned long bytes_left; | 89 | unsigned long bytes_left; |
91 | unsigned long len = *total_out; | 90 | unsigned long len = *total_out; |
92 | unsigned long nr_dest_pages = *out_pages; | 91 | unsigned long nr_dest_pages = *out_pages; |
92 | const unsigned long max_out = nr_dest_pages * PAGE_SIZE; | ||
93 | 93 | ||
94 | *out_pages = 0; | 94 | *out_pages = 0; |
95 | *total_out = 0; | 95 | *total_out = 0; |