aboutsummaryrefslogtreecommitdiffstats
path: root/fs/squashfs/lzo_wrapper.c
diff options
context:
space:
mode:
authorPhillip Lougher <phillip@squashfs.org.uk>2013-11-17 21:59:12 -0500
committerPhillip Lougher <phillip@squashfs.org.uk>2013-11-19 22:59:01 -0500
commit846b730e99518a1c9945afcb2afbe4d08a02ed80 (patch)
treec70eb16cbec15e5bfa1db80c5f18e062673331a9 /fs/squashfs/lzo_wrapper.c
parentd208383d640727b70cd6689bc17e67e9b5ebf4ff (diff)
Squashfs: Generalise paging handling in the decompressors
Further generalise the decompressors by adding a page handler abstraction. This adds helpers to allow the decompressors to access and process the output buffers in an implementation independant manner. This allows different types of output buffer to be passed to the decompressors, with the implementation specific aspects handled at decompression time, but without the knowledge being held in the decompressor wrapper code. This will allow the decompressors to handle Squashfs cache buffers, and page cache pages. This patch adds the abstraction and an implementation for the caches. Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk> Reviewed-by: Minchan Kim <minchan@kernel.org>
Diffstat (limited to 'fs/squashfs/lzo_wrapper.c')
-rw-r--r--fs/squashfs/lzo_wrapper.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/fs/squashfs/lzo_wrapper.c b/fs/squashfs/lzo_wrapper.c
index 75c3b5779172..244b9fbfff7b 100644
--- a/fs/squashfs/lzo_wrapper.c
+++ b/fs/squashfs/lzo_wrapper.c
@@ -31,6 +31,7 @@
31#include "squashfs_fs_sb.h" 31#include "squashfs_fs_sb.h"
32#include "squashfs.h" 32#include "squashfs.h"
33#include "decompressor.h" 33#include "decompressor.h"
34#include "page_actor.h"
34 35
35struct squashfs_lzo { 36struct squashfs_lzo {
36 void *input; 37 void *input;
@@ -75,13 +76,13 @@ static void lzo_free(void *strm)
75 76
76 77
77static int lzo_uncompress(struct squashfs_sb_info *msblk, void *strm, 78static int lzo_uncompress(struct squashfs_sb_info *msblk, void *strm,
78 void **buffer, struct buffer_head **bh, int b, int offset, int length, 79 struct buffer_head **bh, int b, int offset, int length,
79 int srclength, int pages) 80 struct squashfs_page_actor *output)
80{ 81{
81 struct squashfs_lzo *stream = strm; 82 struct squashfs_lzo *stream = strm;
82 void *buff = stream->input; 83 void *buff = stream->input, *data;
83 int avail, i, bytes = length, res; 84 int avail, i, bytes = length, res;
84 size_t out_len = srclength; 85 size_t out_len = output->length;
85 86
86 for (i = 0; i < b; i++) { 87 for (i = 0; i < b; i++) {
87 avail = min(bytes, msblk->devblksize - offset); 88 avail = min(bytes, msblk->devblksize - offset);
@@ -98,12 +99,20 @@ static int lzo_uncompress(struct squashfs_sb_info *msblk, void *strm,
98 goto failed; 99 goto failed;
99 100
100 res = bytes = (int)out_len; 101 res = bytes = (int)out_len;
101 for (i = 0, buff = stream->output; bytes && i < pages; i++) { 102 data = squashfs_first_page(output);
102 avail = min_t(int, bytes, PAGE_CACHE_SIZE); 103 buff = stream->output;
103 memcpy(buffer[i], buff, avail); 104 while (data) {
104 buff += avail; 105 if (bytes <= PAGE_CACHE_SIZE) {
105 bytes -= avail; 106 memcpy(data, buff, bytes);
107 break;
108 } else {
109 memcpy(data, buff, PAGE_CACHE_SIZE);
110 buff += PAGE_CACHE_SIZE;
111 bytes -= PAGE_CACHE_SIZE;
112 data = squashfs_next_page(output);
113 }
106 } 114 }
115 squashfs_finish_page(output);
107 116
108 return res; 117 return res;
109 118