Skip to contentSkip to conversation

Squashfs: add XZ compression support

PATCH In review Phillip Lougher 2 participants 2 messages Dec 9, 2010 – Dec 10, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Squashfs: add XZ compression support

Add XZ decompressor wrapper code.

---
 fs/squashfs/squashfs_fs.h |    1 +
 fs/squashfs/xz_wrapper.c  |  153 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 154 insertions(+), 0 deletions(-)
 create mode 100644 fs/squashfs/xz_wrapper.c
fs/squashfs/squashfs_fs.h +1 -0
index c5137fc..39533fe 100644
@@ -238,6 +238,7 @@ struct meta_index {
 #define ZLIB_COMPRESSION	1
 #define LZMA_COMPRESSION	2
 #define LZO_COMPRESSION		3
+#define XZ_COMPRESSION		4
 
 struct squashfs_super_block {
 	__le32			s_magic;
fs/squashfs/xz_wrapper.c new file +153 -0

153 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#1 lore raw

fs/squashfs/xz_wrapper.c line 48

Quoted 1 line · On 2010-12-09 Phillip Lougher wrote:
fs/squashfs/xz_wrapper.c new file +1 -0
+	stream->state = xz_dec_init(XZ_PREALLOC, block_size);

This sets the preallocated LZMA2 dictionary size to Squashfs block size, which allows the best compression ratio for the given block size (bigger values would be waste of memory). XZ decompressor needs about 30 KiB of memory plus the dictionary. So with 1 MiB Squashfs block size a little over 1 MiB of memory is needed by the XZ decompressor.

Would it be useful to support smaller dictionaries without reducing the Squashfs block size? It would save RAM while increasing the Squashfs image size less than if also the block size was reduced. Reasonable dictionary sizes could be e.g. 75 %, 50 %, or 25 % of the Squashfs block size. The size increase of the Squashfs image will vary a lot depending on the files in it, but e.g. dict_size = block_size / 2 won't necessarily increase the image size more than 1 %.

I don't know if this kind of RAM savings matter on embedded systems. I hope someone else can comment. My point in this email is only to let others know that reducing the RAM usage is possible without reducing the Squashfs block size.

Signature · 1 line
Lasse Collin  |  IRC: Larhzu @ IRCnet & Freenode