Author: arekm Date: Sat Mar 6 23:16:56 2010 GMT Module: packages Tag: HEAD ---- Log message: - update squashfs-lzma
---- Files affected: packages/kernel: kernel-squashfs-lzma.patch (1.2 -> 1.3) , kernel.spec (1.762 -> 1.763) ---- Diffs: ================================================================ Index: packages/kernel/kernel-squashfs-lzma.patch diff -u packages/kernel/kernel-squashfs-lzma.patch:1.2 packages/kernel/kernel-squashfs-lzma.patch:1.3 --- packages/kernel/kernel-squashfs-lzma.patch:1.2 Fri Feb 26 00:09:40 2010 +++ packages/kernel/kernel-squashfs-lzma.patch Sun Mar 7 00:16:51 2010 @@ -1,54 +1,36 @@ -diff --git a/fs/squashfs/Kconfig b/fs/squashfs/Kconfig -index 25a00d1..7ec5d7e 100644 ---- a/fs/squashfs/Kconfig -+++ b/fs/squashfs/Kconfig -@@ -26,6 +26,12 @@ config SQUASHFS - - If unsure, say N. - -+config SQUASHFS_LZMA -+ bool "Include support for LZMA compressed file systems" -+ depends on SQUASHFS -+ select DECOMPRESS_LZMA -+ select DECOMPRESS_LZMA_NEEDED -+ - config SQUASHFS_EMBEDDED - - bool "Additional option for memory-constrained systems" -diff --git a/fs/squashfs/Makefile b/fs/squashfs/Makefile -index 70e3244..45aaefd 100644 +From 6c4419d997d4431bb62e73475cd6b084e83efbd1 Mon Sep 17 00:00:00 2001 +From: Phillip Lougher <[email protected]> +Date: Tue, 22 Sep 2009 19:25:24 +0100 +Subject: [PATCH] Squashfs: move zlib decompression wrapper code into a separate file + +Signed-off-by: Phillip Lougher <[email protected]> +--- + fs/squashfs/Makefile | 2 +- + fs/squashfs/block.c | 74 ++---------------------------- + fs/squashfs/squashfs.h | 4 ++ + fs/squashfs/zlib_wrapper.c | 109 ++++++++++++++++++++++++++++++++++++++++++++ + 4 files changed, 118 insertions(+), 71 deletions(-) + create mode 100644 fs/squashfs/zlib_wrapper.c + --- a/fs/squashfs/Makefile +++ b/fs/squashfs/Makefile -@@ -4,4 +4,5 @@ +@@ -4,4 +4,4 @@ obj-$(CONFIG_SQUASHFS) += squashfs.o squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o -squashfs-y += namei.o super.o symlink.o -+squashfs-y += namei.o super.o symlink.o zlib_wrapper.o decompressor.o -+squashfs-$(CONFIG_SQUASHFS_LZMA) += lzma_wrapper.o -diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c -index 2a79603..6f9914d 100644 ++squashfs-y += namei.o super.o symlink.o zlib_wrapper.o --- a/fs/squashfs/block.c +++ b/fs/squashfs/block.c -@@ -29,16 +29,14 @@ +@@ -29,7 +29,6 @@ #include <linux/fs.h> #include <linux/vfs.h> #include <linux/slab.h> -#include <linux/mutex.h> #include <linux/string.h> #include <linux/buffer_head.h> --#include <linux/zlib.h> - - #include "squashfs_fs.h" - #include "squashfs_fs_sb.h" - #include "squashfs_fs_i.h" - #include "squashfs.h" -- -+#include "decompressor.h" - /* - * Read the metadata block length, this is stored in the first two - * bytes of the metadata block. -@@ -153,72 +151,10 @@ int squashfs_read_data(struct super_block *sb, void **buffer, u64 index, + #include <linux/zlib.h> +@@ -153,72 +152,10 @@ int squashfs_read_data(struct super_bloc } if (compressed) { @@ -118,14 +100,14 @@ - } - length = msblk->stream.total_out; - mutex_unlock(&msblk->read_data_mutex); -+ length = squashfs_decompress(msblk, buffer, bh, b, offset, -+ length, srclength, pages); ++ length = zlib_uncompress(msblk, buffer, bh, b, offset, length, ++ srclength, pages); + if (length < 0) + goto read_failure; } else { /* * Block is uncompressed. -@@ -255,9 +191,6 @@ int squashfs_read_data(struct super_block *sb, void **buffer, u64 index, +@@ -255,9 +192,6 @@ int squashfs_read_data(struct super_bloc kfree(bh); return length; @@ -135,24 +117,22 @@ block_release: for (; k < b; k++) put_bh(bh[k]); -diff --git a/fs/squashfs/cache.c b/fs/squashfs/cache.c -index 40c98fa..57314be 100644 ---- a/fs/squashfs/cache.c -+++ b/fs/squashfs/cache.c -@@ -51,7 +51,6 @@ - #include <linux/sched.h> - #include <linux/spinlock.h> - #include <linux/wait.h> --#include <linux/zlib.h> - #include <linux/pagemap.h> +--- a/fs/squashfs/squashfs.h ++++ b/fs/squashfs/squashfs.h +@@ -70,6 +70,10 @@ extern struct inode *squashfs_iget(struc + unsigned int); + extern int squashfs_read_inode(struct inode *, long long); - #include "squashfs_fs.h" -diff --git a/fs/squashfs/decompressor.c b/fs/squashfs/decompressor.c -new file mode 100644 -index 0000000..0b6ad9b ++/* zlib_wrapper.c */ ++extern int zlib_uncompress(struct squashfs_sb_info *, void **, ++ struct buffer_head **, int, int, int, int, int); ++ + /* + * Inodes and files operations + */ --- /dev/null -+++ b/fs/squashfs/decompressor.c -@@ -0,0 +1,72 @@ ++++ b/fs/squashfs/zlib_wrapper.c +@@ -0,0 +1,109 @@ +/* + * Squashfs - a compressed read only filesystem for Linux + * @@ -173,121 +153,142 @@ + * along with this program; if not, write to the Free Software + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * -+ * decompressor.c ++ * zlib_wrapper.c + */ + -+#include <linux/types.h> ++ +#include <linux/mutex.h> +#include <linux/buffer_head.h> ++#include <linux/zlib.h> + +#include "squashfs_fs.h" +#include "squashfs_fs_sb.h" +#include "squashfs_fs_i.h" -+#include "decompressor.h" +#include "squashfs.h" + -+/* -+ * This file (and decompressor.h) implements a decompressor framework for -+ * Squashfs, allowing multiple decompressors to be easily supported -+ */ ++int zlib_uncompress(struct squashfs_sb_info *msblk, void **buffer, ++ struct buffer_head **bh, int b, int offset, int length, int srclength, ++ int pages) ++{ ++ int zlib_err = 0, zlib_init = 0; ++ int avail, bytes, k = 0, page = 0; + -+static const struct squashfs_decompressor squashfs_lzma_unsupported_comp_ops = { -+ NULL, NULL, NULL, LZMA_COMPRESSION, "lzma", 0 -+}; ++ mutex_lock(&msblk->read_data_mutex); + -+static const struct squashfs_decompressor squashfs_lzo_unsupported_comp_ops = { -+ NULL, NULL, NULL, LZO_COMPRESSION, "lzo", 0 -+}; ++ msblk->stream.avail_out = 0; ++ msblk->stream.avail_in = 0; + -+static const struct squashfs_decompressor squashfs_unknown_comp_ops = { -+ NULL, NULL, NULL, 0, "unknown", 0 -+}; ++ bytes = length; ++ do { ++ if (msblk->stream.avail_in == 0 && k < b) { ++ avail = min(bytes, msblk->devblksize - offset); ++ bytes -= avail; ++ wait_on_buffer(bh[k]); ++ if (!buffer_uptodate(bh[k])) ++ goto release_mutex; + -+static const struct squashfs_decompressor *decompressor[] = { -+ &squashfs_zlib_comp_ops, -+#ifdef CONFIG_SQUASHFS_LZMA -+ &squashfs_lzma_comp_ops, -+#else -+ &squashfs_lzma_unsupported_comp_ops, -+#endif -+ &squashfs_lzo_unsupported_comp_ops, -+ &squashfs_unknown_comp_ops -+}; ++ if (avail == 0) { ++ offset = 0; ++ put_bh(bh[k++]); ++ continue; ++ } + ++ msblk->stream.next_in = bh[k]->b_data + offset; ++ msblk->stream.avail_in = avail; ++ offset = 0; ++ } + -+const struct squashfs_decompressor *squashfs_lookup_decompressor(int id) -+{ -+ int i; ++ if (msblk->stream.avail_out == 0 && page < pages) { ++ msblk->stream.next_out = buffer[page++]; ++ msblk->stream.avail_out = PAGE_CACHE_SIZE; ++ } + -+ for (i = 0; decompressor[i]->id; i++) -+ if (id == decompressor[i]->id) -+ break; ++ if (!zlib_init) { ++ zlib_err = zlib_inflateInit(&msblk->stream); ++ if (zlib_err != Z_OK) { ++ ERROR("zlib_inflateInit returned unexpected " ++ "result 0x%x, srclength %d\n", ++ zlib_err, srclength); ++ goto release_mutex; ++ } ++ zlib_init = 1; ++ } + -+ return decompressor[i]; -+} -diff --git a/fs/squashfs/decompressor.h b/fs/squashfs/decompressor.h -new file mode 100644 -index 0000000..7425f80 ---- /dev/null -+++ b/fs/squashfs/decompressor.h -@@ -0,0 +1,55 @@ -+#ifndef DECOMPRESSOR_H -+#define DECOMPRESSOR_H -+/* -+ * Squashfs - a compressed read only filesystem for Linux -+ * -+ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 -+ * Phillip Lougher <[email protected]> -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * as published by the Free Software Foundation; either version 2, -+ * or (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -+ * -+ * decompressor.h -+ */ ++ zlib_err = zlib_inflate(&msblk->stream, Z_SYNC_FLUSH); + -+struct squashfs_decompressor { -+ void *(*init)(struct squashfs_sb_info *); -+ void (*free)(void *); -+ int (*decompress)(struct squashfs_sb_info *, void **, -+ struct buffer_head **, int, int, int, int, int); -+ int id; -+ char *name; -+ int supported; -+}; ++ if (msblk->stream.avail_in == 0 && k < b) ++ put_bh(bh[k++]); ++ } while (zlib_err == Z_OK); + -+static inline void *squashfs_decompressor_init(struct squashfs_sb_info *msblk) -+{ -+ return msblk->decompressor->init(msblk); -+} ++ if (zlib_err != Z_STREAM_END) { ++ ERROR("zlib_inflate error, data probably corrupt\n"); ++ goto release_mutex; ++ } + -+static inline void squashfs_decompressor_free(struct squashfs_sb_info *msblk, -+ void *s) -+{ -+ if (msblk->decompressor) -+ msblk->decompressor->free(s); -+} ++ zlib_err = zlib_inflateEnd(&msblk->stream); ++ if (zlib_err != Z_OK) { ++ ERROR("zlib_inflate error, data probably corrupt\n"); ++ goto release_mutex; ++ } + -+static inline int squashfs_decompress(struct squashfs_sb_info *msblk, -+ void **buffer, struct buffer_head **bh, int b, int offset, int length, -+ int srclength, int pages) -+{ -+ return msblk->decompressor->decompress(msblk, buffer, bh, b, offset, -+ length, srclength, pages); ++ mutex_unlock(&msblk->read_data_mutex); ++ return msblk->stream.total_out; ++ ++release_mutex: ++ mutex_unlock(&msblk->read_data_mutex); ++ ++ for (; k < b; k++) ++ put_bh(bh[k]); ++ ++ return -EIO; +} -+#endif -diff --git a/fs/squashfs/dir.c b/fs/squashfs/dir.c -index 566b0ea..12b933a 100644 +From 37c44e85fd49676ec15ccaeea065662c1fbcda7d Mon Sep 17 00:00:00 2001 +From: Phillip Lougher <[email protected]> +Date: Wed, 23 Sep 2009 19:04:49 +0100 +Subject: [PATCH] Squashfs: Factor out remaining zlib dependencies into separate wrapper file + +Move zlib buffer init/destroy code into separate wrapper file. Also +make zlib z_stream field a void * removing the need to include zlib.h +for most files. + +Signed-off-by: Phillip Lougher <[email protected]> +--- + fs/squashfs/block.c | 1 - + fs/squashfs/cache.c | 1 - + fs/squashfs/dir.c | 1 - + fs/squashfs/export.c | 1 - + fs/squashfs/file.c | 1 - + fs/squashfs/fragment.c | 1 - + fs/squashfs/id.c | 1 - + fs/squashfs/inode.c | 1 - + fs/squashfs/namei.c | 1 - + fs/squashfs/squashfs.h | 2 + + fs/squashfs/squashfs_fs_sb.h | 2 +- + fs/squashfs/super.c | 14 +++------ + fs/squashfs/symlink.c | 1 - + fs/squashfs/zlib_wrapper.c | 56 ++++++++++++++++++++++++++++++++--------- + 14 files changed, 51 insertions(+), 33 deletions(-) + +--- a/fs/squashfs/block.c ++++ b/fs/squashfs/block.c +@@ -31,7 +31,6 @@ + #include <linux/slab.h> + #include <linux/string.h> + #include <linux/buffer_head.h> +-#include <linux/zlib.h> + + #include "squashfs_fs.h" + #include "squashfs_fs_sb.h" +--- a/fs/squashfs/cache.c ++++ b/fs/squashfs/cache.c +@@ -51,7 +51,6 @@ + #include <linux/sched.h> + #include <linux/spinlock.h> + #include <linux/wait.h> +-#include <linux/zlib.h> + #include <linux/pagemap.h> + + #include "squashfs_fs.h" --- a/fs/squashfs/dir.c +++ b/fs/squashfs/dir.c @@ -30,7 +30,6 @@ @@ -298,8 +299,6 @@ #include "squashfs_fs.h" #include "squashfs_fs_sb.h" -diff --git a/fs/squashfs/export.c b/fs/squashfs/export.c -index 2b1b8fe..7f93d5a 100644 --- a/fs/squashfs/export.c +++ b/fs/squashfs/export.c @@ -39,7 +39,6 @@ @@ -310,8 +309,6 @@ #include <linux/slab.h> #include "squashfs_fs.h" -diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c -index 717767d..a25c506 100644 --- a/fs/squashfs/file.c +++ b/fs/squashfs/file.c @@ -47,7 +47,6 @@ @@ -322,8 +319,6 @@ #include "squashfs_fs.h" #include "squashfs_fs_sb.h" -diff --git a/fs/squashfs/fragment.c b/fs/squashfs/fragment.c -index b5a2c15..7c90bbd 100644 --- a/fs/squashfs/fragment.c +++ b/fs/squashfs/fragment.c @@ -36,7 +36,6 @@ @@ -334,8 +329,6 @@ #include "squashfs_fs.h" #include "squashfs_fs_sb.h" -diff --git a/fs/squashfs/id.c b/fs/squashfs/id.c -index 3795b83..b7f64bc 100644 --- a/fs/squashfs/id.c +++ b/fs/squashfs/id.c @@ -34,7 +34,6 @@ @@ -346,8 +339,6 @@ #include "squashfs_fs.h" #include "squashfs_fs_sb.h" -diff --git a/fs/squashfs/inode.c b/fs/squashfs/inode.c -index 9101dbd..49daaf6 100644 --- a/fs/squashfs/inode.c +++ b/fs/squashfs/inode.c @@ -40,7 +40,6 @@ @@ -358,180 +349,392 @@ #include "squashfs_fs.h" #include "squashfs_fs_sb.h" -diff --git a/fs/squashfs/lzma_wrapper.c b/fs/squashfs/lzma_wrapper.c -new file mode 100644 -index 0000000..9fa617d ---- /dev/null -+++ b/fs/squashfs/lzma_wrapper.c -@@ -0,0 +1,151 @@ -+/* -+ * Squashfs - a compressed read only filesystem for Linux -+ * -+ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 -+ * Phillip Lougher <[email protected]> -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * as published by the Free Software Foundation; either version 2, -+ * or (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -+ * -+ * lzma_wrapper.c -+ */ -+ -+#include <asm/unaligned.h> -+#include <linux/buffer_head.h> -+#include <linux/mutex.h> -+#include <linux/vmalloc.h> -+#include <linux/decompress/unlzma.h> -+ -+#include "squashfs_fs.h" -+#include "squashfs_fs_sb.h" -+#include "squashfs_fs_i.h" -+#include "squashfs.h" -+#include "decompressor.h" -+ -+struct squashfs_lzma { -+ void *input; -+ void *output; -+}; -+ -+/* decompress_unlzma.c is currently non re-entrant... */ -+DEFINE_MUTEX(lzma_mutex); -+ -+/* decompress_unlzma.c doesn't provide any context in its callbacks... */ -+static int lzma_error; -+ -+static void error(char *m) -+{ -+ ERROR("unlzma error: %s\n", m); -+ lzma_error = 1; -+} -+ -+ -+static void *lzma_init(struct squashfs_sb_info *msblk) +--- a/fs/squashfs/namei.c ++++ b/fs/squashfs/namei.c +@@ -57,7 +57,6 @@ + #include <linux/slab.h> + #include <linux/string.h> + #include <linux/dcache.h> +-#include <linux/zlib.h> + + #include "squashfs_fs.h" + #include "squashfs_fs_sb.h" +--- a/fs/squashfs/squashfs.h ++++ b/fs/squashfs/squashfs.h +@@ -71,6 +71,8 @@ extern struct inode *squashfs_iget(struc + extern int squashfs_read_inode(struct inode *, long long); + + /* zlib_wrapper.c */ ++extern void *zlib_init(void); ++extern void zlib_free(void *); + extern int zlib_uncompress(struct squashfs_sb_info *, void **, + struct buffer_head **, int, int, int, int, int); + +--- a/fs/squashfs/squashfs_fs_sb.h ++++ b/fs/squashfs/squashfs_fs_sb.h +@@ -64,7 +64,7 @@ struct squashfs_sb_info { + struct mutex read_data_mutex; + struct mutex meta_index_mutex; + struct meta_index *meta_index; +- z_stream stream; ++ void *stream; + __le64 *inode_lookup_table; + u64 inode_table; + u64 directory_table; +--- a/fs/squashfs/super.c ++++ b/fs/squashfs/super.c +@@ -35,7 +35,6 @@ + #include <linux/pagemap.h> + #include <linux/init.h> + #include <linux/module.h> +-#include <linux/zlib.h> + #include <linux/magic.h> + + #include "squashfs_fs.h" +@@ -87,12 +86,9 @@ static int squashfs_fill_super(struct su + } + msblk = sb->s_fs_info; + +- msblk->stream.workspace = kmalloc(zlib_inflate_workspacesize(), +- GFP_KERNEL); +- if (msblk->stream.workspace == NULL) { +- ERROR("Failed to allocate zlib workspace\n"); ++ msblk->stream = zlib_init(); ++ if (msblk->stream == NULL) + goto failure; +- } + + sblk = kzalloc(sizeof(*sblk), GFP_KERNEL); + if (sblk == NULL) { +@@ -292,17 +288,17 @@ failed_mount: + squashfs_cache_delete(msblk->block_cache); + squashfs_cache_delete(msblk->fragment_cache); + squashfs_cache_delete(msblk->read_page); ++ zlib_free(msblk->stream); + kfree(msblk->inode_lookup_table); + kfree(msblk->fragment_index); + kfree(msblk->id_table); +- kfree(msblk->stream.workspace); + kfree(sb->s_fs_info); + sb->s_fs_info = NULL; + kfree(sblk); + return err; + + failure: +- kfree(msblk->stream.workspace); ++ zlib_free(msblk->stream); + kfree(sb->s_fs_info); + sb->s_fs_info = NULL; + return -ENOMEM; +@@ -346,10 +342,10 @@ static void squashfs_put_super(struct su + squashfs_cache_delete(sbi->block_cache); + squashfs_cache_delete(sbi->fragment_cache); + squashfs_cache_delete(sbi->read_page); ++ zlib_free(sbi->stream); + kfree(sbi->id_table); + kfree(sbi->fragment_index); + kfree(sbi->meta_index); +- kfree(sbi->stream.workspace); + kfree(sb->s_fs_info); + sb->s_fs_info = NULL; + } +--- a/fs/squashfs/symlink.c ++++ b/fs/squashfs/symlink.c +@@ -36,7 +36,6 @@ + #include <linux/slab.h> + #include <linux/string.h> + #include <linux/pagemap.h> +-#include <linux/zlib.h> + + #include "squashfs_fs.h" + #include "squashfs_fs_sb.h" +--- a/fs/squashfs/zlib_wrapper.c ++++ b/fs/squashfs/zlib_wrapper.c +@@ -31,21 +31,51 @@ + #include "squashfs_fs_i.h" + #include "squashfs.h" + ++void *zlib_init() +{ -+ struct squashfs_lzma *stream = kzalloc(sizeof(*stream), GFP_KERNEL); ++ z_stream *stream = kmalloc(sizeof(z_stream), GFP_KERNEL); + if (stream == NULL) + goto failed; -+ stream->input = vmalloc(msblk->block_size); -+ if (stream->input == NULL) ++ stream->workspace = kmalloc(zlib_inflate_workspacesize(), ++ GFP_KERNEL); ++ if (stream->workspace == NULL) + goto failed; <<Diff was trimmed, longer than 597 lines>> ---- CVS-web: http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/kernel/kernel-squashfs-lzma.patch?r1=1.2&r2=1.3&f=u http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/kernel/kernel.spec?r1=1.762&r2=1.763&f=u _______________________________________________ pld-cvs-commit mailing list [email protected] http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit
