summaryrefslogtreecommitdiffstats
path: root/fs/squashfs/zlib_wrapper.c
diff options
context:
space:
mode:
authorPhillip Lougher <phillip@squashfs.org.uk>2013-11-18 02:59:12 +0000
committerPhillip Lougher <phillip@squashfs.org.uk>2013-11-20 03:59:01 +0000
commit846b730e99518a1c9945afcb2afbe4d08a02ed80 (patch)
treec70eb16cbec15e5bfa1db80c5f18e062673331a9 /fs/squashfs/zlib_wrapper.c
parentd208383d640727b70cd6689bc17e67e9b5ebf4ff (diff)
downloadlinux-846b730e99518a1c9945afcb2afbe4d08a02ed80.tar.bz2
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/zlib_wrapper.c')
-rw-r--r--fs/squashfs/zlib_wrapper.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/fs/squashfs/zlib_wrapper.c b/fs/squashfs/zlib_wrapper.c
index bb049027d15c..8727caba6882 100644
--- a/fs/squashfs/zlib_wrapper.c
+++ b/fs/squashfs/zlib_wrapper.c
@@ -32,6 +32,7 @@
#include "squashfs_fs_sb.h"
#include "squashfs.h"
#include "decompressor.h"
+#include "page_actor.h"
static void *zlib_init(struct squashfs_sb_info *dummy, void *buff)
{
@@ -62,14 +63,14 @@ static void zlib_free(void *strm)
static int zlib_uncompress(struct squashfs_sb_info *msblk, void *strm,
- void **buffer, struct buffer_head **bh, int b, int offset, int length,
- int srclength, int pages)
+ struct buffer_head **bh, int b, int offset, int length,
+ struct squashfs_page_actor *output)
{
- int zlib_err, zlib_init = 0;
- int k = 0, page = 0;
+ int zlib_err, zlib_init = 0, k = 0;
z_stream *stream = strm;
- stream->avail_out = 0;
+ stream->avail_out = PAGE_CACHE_SIZE;
+ stream->next_out = squashfs_first_page(output);
stream->avail_in = 0;
do {
@@ -81,15 +82,18 @@ static int zlib_uncompress(struct squashfs_sb_info *msblk, void *strm,
offset = 0;
}
- if (stream->avail_out == 0 && page < pages) {
- stream->next_out = buffer[page++];
- stream->avail_out = PAGE_CACHE_SIZE;
+ if (stream->avail_out == 0) {
+ stream->next_out = squashfs_next_page(output);
+ if (stream->next_out != NULL)
+ stream->avail_out = PAGE_CACHE_SIZE;
}
if (!zlib_init) {
zlib_err = zlib_inflateInit(stream);
- if (zlib_err != Z_OK)
+ if (zlib_err != Z_OK) {
+ squashfs_finish_page(output);
goto out;
+ }
zlib_init = 1;
}
@@ -99,6 +103,8 @@ static int zlib_uncompress(struct squashfs_sb_info *msblk, void *strm,
put_bh(bh[k++]);
} while (zlib_err == Z_OK);
+ squashfs_finish_page(output);
+
if (zlib_err != Z_STREAM_END)
goto out;