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
commit4d3a800ebb1299944408f3b40b5b6b996477fba2 (patch)
tree165a58136bd55ad94dec5154f6e03a47bf4763a9
parent38c31464089f639630b7c28ce933a4d60e135a02 (diff)
btrfs: merge nr_pages input and output parameter in compress_pages
The parameter saying how many pages can be allocated at maximum can be merged with the output page counter, to save some stack space. The compression implementation will sink the parameter to a local variable so everything works as before. The nr_pages variables can also be simply merged in compress_file_range into one. Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/compression.c7
-rw-r--r--fs/btrfs/compression.h2
-rw-r--r--fs/btrfs/inode.c13
-rw-r--r--fs/btrfs/lzo.c2
-rw-r--r--fs/btrfs/zlib.c2
5 files changed, 11 insertions, 15 deletions
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 7e214fd254e4..11dcda57e15c 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -914,8 +914,8 @@ static void free_workspaces(void)
914 * Given an address space and start and length, compress the bytes into @pages 914 * Given an address space and start and length, compress the bytes into @pages
915 * that are allocated on demand. 915 * that are allocated on demand.
916 * 916 *
917 * @out_pages is used to return the number of pages allocated. There 917 * @out_pages is an in/out parameter, holds maximum number of pages to allocate
918 * may be pages allocated even if we return an error. 918 * and returns number of actually allocated pages
919 * 919 *
920 * @total_in is used to return the number of bytes actually read. It 920 * @total_in is used to return the number of bytes actually read. It
921 * may be smaller than the input length if we had to exit early because we 921 * may be smaller than the input length if we had to exit early because we
@@ -930,7 +930,6 @@ static void free_workspaces(void)
930 */ 930 */
931int btrfs_compress_pages(int type, struct address_space *mapping, 931int btrfs_compress_pages(int type, struct address_space *mapping,
932 u64 start, struct page **pages, 932 u64 start, struct page **pages,
933 unsigned long nr_dest_pages,
934 unsigned long *out_pages, 933 unsigned long *out_pages,
935 unsigned long *total_in, 934 unsigned long *total_in,
936 unsigned long *total_out, 935 unsigned long *total_out,
@@ -943,7 +942,7 @@ int btrfs_compress_pages(int type, struct address_space *mapping,
943 942
944 ret = btrfs_compress_op[type-1]->compress_pages(workspace, mapping, 943 ret = btrfs_compress_op[type-1]->compress_pages(workspace, mapping,
945 start, pages, 944 start, pages,
946 nr_dest_pages, out_pages, 945 out_pages,
947 total_in, total_out, 946 total_in, total_out,
948 max_out); 947 max_out);
949 free_workspace(type, workspace); 948 free_workspace(type, workspace);
diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h
index 725d1e0bd25d..cfcec709c61b 100644
--- a/fs/btrfs/compression.h
+++ b/fs/btrfs/compression.h
@@ -24,7 +24,6 @@ void 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, struct page **pages, 26 u64 start, struct page **pages,
27 unsigned long nr_dest_pages,
28 unsigned long *out_pages, 27 unsigned long *out_pages,
29 unsigned long *total_in, 28 unsigned long *total_in,
30 unsigned long *total_out, 29 unsigned long *total_out,
@@ -60,7 +59,6 @@ struct btrfs_compress_op {
60 struct address_space *mapping, 59 struct address_space *mapping,
61 u64 start, 60 u64 start,
62 struct page **pages, 61 struct page **pages,
63 unsigned long nr_dest_pages,
64 unsigned long *out_pages, 62 unsigned long *out_pages,
65 unsigned long *total_in, 63 unsigned long *total_in,
66 unsigned long *total_out, 64 unsigned long *total_out,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 8b9eac33d431..83bbe1e31869 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -430,7 +430,6 @@ static noinline void compress_file_range(struct inode *inode,
430 int ret = 0; 430 int ret = 0;
431 struct page **pages = NULL; 431 struct page **pages = NULL;
432 unsigned long nr_pages; 432 unsigned long nr_pages;
433 unsigned long nr_pages_ret = 0;
434 unsigned long total_compressed = 0; 433 unsigned long total_compressed = 0;
435 unsigned long total_in = 0; 434 unsigned long total_in = 0;
436 unsigned long max_compressed = SZ_128K; 435 unsigned long max_compressed = SZ_128K;
@@ -518,7 +517,7 @@ again:
518 ret = btrfs_compress_pages(compress_type, 517 ret = btrfs_compress_pages(compress_type,
519 inode->i_mapping, start, 518 inode->i_mapping, start,
520 pages, 519 pages,
521 nr_pages, &nr_pages_ret, 520 &nr_pages,
522 &total_in, 521 &total_in,
523 &total_compressed, 522 &total_compressed,
524 max_compressed); 523 max_compressed);
@@ -526,7 +525,7 @@ again:
526 if (!ret) { 525 if (!ret) {
527 unsigned long offset = total_compressed & 526 unsigned long offset = total_compressed &
528 (PAGE_SIZE - 1); 527 (PAGE_SIZE - 1);
529 struct page *page = pages[nr_pages_ret - 1]; 528 struct page *page = pages[nr_pages - 1];
530 char *kaddr; 529 char *kaddr;
531 530
532 /* zero the tail end of the last page, we might be 531 /* zero the tail end of the last page, we might be
@@ -607,7 +606,7 @@ cont:
607 * will submit them to the elevator. 606 * will submit them to the elevator.
608 */ 607 */
609 add_async_extent(async_cow, start, num_bytes, 608 add_async_extent(async_cow, start, num_bytes,
610 total_compressed, pages, nr_pages_ret, 609 total_compressed, pages, nr_pages,
611 compress_type); 610 compress_type);
612 611
613 if (start + num_bytes < end) { 612 if (start + num_bytes < end) {
@@ -624,14 +623,14 @@ cont:
624 * the compression code ran but failed to make things smaller, 623 * the compression code ran but failed to make things smaller,
625 * free any pages it allocated and our page pointer array 624 * free any pages it allocated and our page pointer array
626 */ 625 */
627 for (i = 0; i < nr_pages_ret; i++) { 626 for (i = 0; i < nr_pages; i++) {
628 WARN_ON(pages[i]->mapping); 627 WARN_ON(pages[i]->mapping);
629 put_page(pages[i]); 628 put_page(pages[i]);
630 } 629 }
631 kfree(pages); 630 kfree(pages);
632 pages = NULL; 631 pages = NULL;
633 total_compressed = 0; 632 total_compressed = 0;
634 nr_pages_ret = 0; 633 nr_pages = 0;
635 634
636 /* flag the file so we don't compress in the future */ 635 /* flag the file so we don't compress in the future */
637 if (!btrfs_test_opt(fs_info, FORCE_COMPRESS) && 636 if (!btrfs_test_opt(fs_info, FORCE_COMPRESS) &&
@@ -660,7 +659,7 @@ cleanup_and_bail_uncompressed:
660 return; 659 return;
661 660
662free_pages_out: 661free_pages_out:
663 for (i = 0; i < nr_pages_ret; i++) { 662 for (i = 0; i < nr_pages; i++) {
664 WARN_ON(pages[i]->mapping); 663 WARN_ON(pages[i]->mapping);
665 put_page(pages[i]); 664 put_page(pages[i]);
666 } 665 }
diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c
index 489f78c4e5ec..0baf978fbcaf 100644
--- a/fs/btrfs/lzo.c
+++ b/fs/btrfs/lzo.c
@@ -88,7 +88,6 @@ static int lzo_compress_pages(struct list_head *ws,
88 struct address_space *mapping, 88 struct address_space *mapping,
89 u64 start, 89 u64 start,
90 struct page **pages, 90 struct page **pages,
91 unsigned long nr_dest_pages,
92 unsigned long *out_pages, 91 unsigned long *out_pages,
93 unsigned long *total_in, 92 unsigned long *total_in,
94 unsigned long *total_out, 93 unsigned long *total_out,
@@ -103,6 +102,7 @@ static int lzo_compress_pages(struct list_head *ws,
103 struct page *out_page = NULL; 102 struct page *out_page = NULL;
104 unsigned long bytes_left; 103 unsigned long bytes_left;
105 unsigned long len = *total_out; 104 unsigned long len = *total_out;
105 unsigned long nr_dest_pages = *out_pages;
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 42d76b7824c3..e7f2020f8ee7 100644
--- a/fs/btrfs/zlib.c
+++ b/fs/btrfs/zlib.c
@@ -75,7 +75,6 @@ static int zlib_compress_pages(struct list_head *ws,
75 struct address_space *mapping, 75 struct address_space *mapping,
76 u64 start, 76 u64 start,
77 struct page **pages, 77 struct page **pages,
78 unsigned long nr_dest_pages,
79 unsigned long *out_pages, 78 unsigned long *out_pages,
80 unsigned long *total_in, 79 unsigned long *total_in,
81 unsigned long *total_out, 80 unsigned long *total_out,
@@ -90,6 +89,7 @@ static int zlib_compress_pages(struct list_head *ws,
90 struct page *out_page = NULL; 89 struct page *out_page = NULL;
91 unsigned long bytes_left; 90 unsigned long bytes_left;
92 unsigned long len = *total_out; 91 unsigned long len = *total_out;
92 unsigned long nr_dest_pages = *out_pages;
93 93
94 *out_pages = 0; 94 *out_pages = 0;
95 *total_out = 0; 95 *total_out = 0;