aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2017-02-14 13:04:07 -0500
committerDavid Sterba <dsterba@suse.com>2017-02-28 08:26:35 -0500
commit38c31464089f639630b7c28ce933a4d60e135a02 (patch)
treefd39ede7261635ac2f47ece7139c668820cf9db0
parent52f75f4fe74ce86376d68b30c94d5fb11cb4019e (diff)
btrfs: merge length input and output parameter in compress_pages
The length parameter is basically duplicated for input and output in the top level caller of the compress_pages chain. We can simply use one variable for that and reduce stack consumption. The compression implementation will sink the parameter to a local variable so everything works as before. Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/compression.c24
-rw-r--r--fs/btrfs/compression.h5
-rw-r--r--fs/btrfs/inode.c2
-rw-r--r--fs/btrfs/lzo.c4
-rw-r--r--fs/btrfs/zlib.c3
5 files changed, 18 insertions, 20 deletions
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index d426e4a10b2b..7e214fd254e4 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -911,27 +911,25 @@ static void free_workspaces(void)
911} 911}
912 912
913/* 913/*
914 * given an address space and start/len, compress the bytes. 914 * Given an address space and start and length, compress the bytes into @pages
915 * that are allocated on demand.
915 * 916 *
916 * pages are allocated to hold the compressed result and stored 917 * @out_pages is used to return the number of pages allocated. There
917 * in 'pages' 918 * may be pages allocated even if we return an error.
918 * 919 *
919 * out_pages is used to return the number of pages allocated. There 920 * @total_in is used to return the number of bytes actually read. It
920 * may be pages allocated even if we return an error 921 * may be smaller than the input length if we had to exit early because we
921 *
922 * total_in is used to return the number of bytes actually read. It
923 * may be smaller then len if we had to exit early because we
924 * ran out of room in the pages array or because we cross the 922 * ran out of room in the pages array or because we cross the
925 * max_out threshold. 923 * max_out threshold.
926 * 924 *
927 * total_out is used to return the total number of compressed bytes 925 * @total_out is an in/out parameter, must be set to the input length and will
926 * be also used to return the total number of compressed bytes
928 * 927 *
929 * max_out tells us the max number of bytes that we're allowed to 928 * @max_out tells us the max number of bytes that we're allowed to
930 * stuff into pages 929 * stuff into pages
931 */ 930 */
932int btrfs_compress_pages(int type, struct address_space *mapping, 931int btrfs_compress_pages(int type, struct address_space *mapping,
933 u64 start, unsigned long len, 932 u64 start, struct page **pages,
934 struct page **pages,
935 unsigned long nr_dest_pages, 933 unsigned long nr_dest_pages,
936 unsigned long *out_pages, 934 unsigned long *out_pages,
937 unsigned long *total_in, 935 unsigned long *total_in,
@@ -944,7 +942,7 @@ int btrfs_compress_pages(int type, struct address_space *mapping,
944 workspace = find_workspace(type); 942 workspace = find_workspace(type);
945 943
946 ret = btrfs_compress_op[type-1]->compress_pages(workspace, mapping, 944 ret = btrfs_compress_op[type-1]->compress_pages(workspace, mapping,
947 start, len, pages, 945 start, pages,
948 nr_dest_pages, out_pages, 946 nr_dest_pages, out_pages,
949 total_in, total_out, 947 total_in, total_out,
950 max_out); 948 max_out);
diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h
index 1c700bb20b52..725d1e0bd25d 100644
--- a/fs/btrfs/compression.h
+++ b/fs/btrfs/compression.h
@@ -23,8 +23,7 @@ void btrfs_init_compress(void);
23void btrfs_exit_compress(void); 23void btrfs_exit_compress(void);
24 24
25int btrfs_compress_pages(int type, struct address_space *mapping, 25int btrfs_compress_pages(int type, struct address_space *mapping,
26 u64 start, unsigned long len, 26 u64 start, struct page **pages,
27 struct page **pages,
28 unsigned long nr_dest_pages, 27 unsigned long nr_dest_pages,
29 unsigned long *out_pages, 28 unsigned long *out_pages,
30 unsigned long *total_in, 29 unsigned long *total_in,
@@ -59,7 +58,7 @@ struct btrfs_compress_op {
59 58
60 int (*compress_pages)(struct list_head *workspace, 59 int (*compress_pages)(struct list_head *workspace,
61 struct address_space *mapping, 60 struct address_space *mapping,
62 u64 start, unsigned long len, 61 u64 start,
63 struct page **pages, 62 struct page **pages,
64 unsigned long nr_dest_pages, 63 unsigned long nr_dest_pages,
65 unsigned long *out_pages, 64 unsigned long *out_pages,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 596e5cb4bfa2..8b9eac33d431 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -517,7 +517,7 @@ again:
517 redirty = 1; 517 redirty = 1;
518 ret = btrfs_compress_pages(compress_type, 518 ret = btrfs_compress_pages(compress_type,
519 inode->i_mapping, start, 519 inode->i_mapping, start,
520 total_compressed, pages, 520 pages,
521 nr_pages, &nr_pages_ret, 521 nr_pages, &nr_pages_ret,
522 &total_in, 522 &total_in,
523 &total_compressed, 523 &total_compressed,
diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c
index e074b85aa054..489f78c4e5ec 100644
--- a/fs/btrfs/lzo.c
+++ b/fs/btrfs/lzo.c
@@ -86,7 +86,7 @@ static inline size_t read_compress_length(const char *buf)
86 86
87static int lzo_compress_pages(struct list_head *ws, 87static int lzo_compress_pages(struct list_head *ws,
88 struct address_space *mapping, 88 struct address_space *mapping,
89 u64 start, unsigned long len, 89 u64 start,
90 struct page **pages, 90 struct page **pages,
91 unsigned long nr_dest_pages, 91 unsigned long nr_dest_pages,
92 unsigned long *out_pages, 92 unsigned long *out_pages,
@@ -102,7 +102,7 @@ static int lzo_compress_pages(struct list_head *ws,
102 struct page *in_page = NULL; 102 struct page *in_page = NULL;
103 struct page *out_page = NULL; 103 struct page *out_page = NULL;
104 unsigned long bytes_left; 104 unsigned long bytes_left;
105 105 unsigned long len = *total_out;
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 da497f184ff4..42d76b7824c3 100644
--- a/fs/btrfs/zlib.c
+++ b/fs/btrfs/zlib.c
@@ -73,7 +73,7 @@ fail:
73 73
74static int zlib_compress_pages(struct list_head *ws, 74static int zlib_compress_pages(struct list_head *ws,
75 struct address_space *mapping, 75 struct address_space *mapping,
76 u64 start, unsigned long len, 76 u64 start,
77 struct page **pages, 77 struct page **pages,
78 unsigned long nr_dest_pages, 78 unsigned long nr_dest_pages,
79 unsigned long *out_pages, 79 unsigned long *out_pages,
@@ -89,6 +89,7 @@ static int zlib_compress_pages(struct list_head *ws,
89 struct page *in_page = NULL; 89 struct page *in_page = NULL;
90 struct page *out_page = NULL; 90 struct page *out_page = NULL;
91 unsigned long bytes_left; 91 unsigned long bytes_left;
92 unsigned long len = *total_out;
92 93
93 *out_pages = 0; 94 *out_pages = 0;
94 *total_out = 0; 95 *total_out = 0;