btrfs: derive maximum output size in the compression implementation
authorDavid Sterba <dsterba@suse.com>
Tue, 14 Feb 2017 18:45:05 +0000 (19:45 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 28 Feb 2017 13:26:36 +0000 (14:26 +0100)
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>
fs/btrfs/compression.c
fs/btrfs/compression.h
fs/btrfs/inode.c
fs/btrfs/lzo.c
fs/btrfs/zlib.c

index 11dcda57e15c51080e2081b2b9f5e24b26025c82..c7721a6aa3bb5346cbd9103b4ee3e9f4528a8c4e 100644 (file)
@@ -932,8 +932,7 @@ int btrfs_compress_pages(int type, struct address_space *mapping,
                         u64 start, struct page **pages,
                         unsigned long *out_pages,
                         unsigned long *total_in,
-                        unsigned long *total_out,
-                        unsigned long max_out)
+                        unsigned long *total_out)
 {
        struct list_head *workspace;
        int ret;
@@ -943,8 +942,7 @@ int btrfs_compress_pages(int type, struct address_space *mapping,
        ret = btrfs_compress_op[type-1]->compress_pages(workspace, mapping,
                                                      start, pages,
                                                      out_pages,
-                                                     total_in, total_out,
-                                                     max_out);
+                                                     total_in, total_out);
        free_workspace(type, workspace);
        return ret;
 }
index 619e64c274449a2ce8fe402384fc3a0b600a9a25..39ec43ab8df1b72bf9a7cc57b0a90ea4e5fb8602 100644 (file)
@@ -41,8 +41,7 @@ int btrfs_compress_pages(int type, struct address_space *mapping,
                         u64 start, struct page **pages,
                         unsigned long *out_pages,
                         unsigned long *total_in,
-                        unsigned long *total_out,
-                        unsigned long max_out);
+                        unsigned long *total_out);
 int btrfs_decompress(int type, unsigned char *data_in, struct page *dest_page,
                     unsigned long start_byte, size_t srclen, size_t destlen);
 int btrfs_decompress_buf2page(const char *buf, unsigned long buf_start,
@@ -76,8 +75,7 @@ struct btrfs_compress_op {
                              struct page **pages,
                              unsigned long *out_pages,
                              unsigned long *total_in,
-                             unsigned long *total_out,
-                             unsigned long max_out);
+                             unsigned long *total_out);
 
        int (*decompress_bio)(struct list_head *workspace,
                                 struct page **pages_in,
index 11a4eeadf662b29253d8915e382dc271b8c6335b..0d932b9594de5e005689dd678b5cca3d1cad8ffc 100644 (file)
@@ -510,8 +510,7 @@ again:
                                           pages,
                                           &nr_pages,
                                           &total_in,
-                                          &total_compressed,
-                                          BTRFS_MAX_COMPRESSED);
+                                          &total_compressed);
 
                if (!ret) {
                        unsigned long offset = total_compressed &
index 0baf978fbcaf157b8f8f474cff469d32eadaa0ca..f48c8c14dc144b63a5e4d1d8c355106649614bba 100644 (file)
@@ -90,8 +90,7 @@ static int lzo_compress_pages(struct list_head *ws,
                              struct page **pages,
                              unsigned long *out_pages,
                              unsigned long *total_in,
-                             unsigned long *total_out,
-                             unsigned long max_out)
+                             unsigned long *total_out)
 {
        struct workspace *workspace = list_entry(ws, struct workspace, list);
        int ret = 0;
@@ -103,6 +102,7 @@ static int lzo_compress_pages(struct list_head *ws,
        unsigned long bytes_left;
        unsigned long len = *total_out;
        unsigned long nr_dest_pages = *out_pages;
+       const unsigned long max_out = nr_dest_pages * PAGE_SIZE;
        size_t in_len;
        size_t out_len;
        char *buf;
index e7f2020f8ee7643c7d8fcb0262c2d41c444671bc..135b10823c6dbd1d20171234d5db60961aff1377 100644 (file)
@@ -77,8 +77,7 @@ static int zlib_compress_pages(struct list_head *ws,
                               struct page **pages,
                               unsigned long *out_pages,
                               unsigned long *total_in,
-                              unsigned long *total_out,
-                              unsigned long max_out)
+                              unsigned long *total_out)
 {
        struct workspace *workspace = list_entry(ws, struct workspace, list);
        int ret;
@@ -90,6 +89,7 @@ static int zlib_compress_pages(struct list_head *ws,
        unsigned long bytes_left;
        unsigned long len = *total_out;
        unsigned long nr_dest_pages = *out_pages;
+       const unsigned long max_out = nr_dest_pages * PAGE_SIZE;
 
        *out_pages = 0;
        *total_out = 0;