Add LZO1X compression support to the kernel
PATCH 1/5 Add LZO1X compression support to the kernel
Add LZO1X compression/decompression support to the kernel.
This is based on the standard userspace lzo library, particularly minilzo with the headers much trimmed down and simplified for kernel use. Its structured so that it diffs with the userspace version for ease of future updating. All the bad formatting is confined to a handful of files in lib/lzo/ and the kernel interface is clean.
Potential users include jffs2 (10% boot time speedup and 40% improvement on file read speed, with only a slight drop in the file compression ratio compared to zlib), crypto and reiser4.
--- include/linux/lzo.h | 59 ++ lib/Kconfig | 5 lib/Makefile | 1 lib/lzo/Makefile | 3 lib/lzo/lzoconf.h | 116 ++++ lib/lzo/lzodefs.h | 176 +++++++ lib/lzo/lzointf.c | 36 + lib/lzo/minilzo.c | 1228 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 1624 insertions(+)
include/linux/lzo.h new file +59 -0
@@ -0,0 +1,59 @@ +/* +* LZO Public Kernel Interface +* A mini subset of the LZO real-time data compression library +* +* Copyright (C) 2007 Nokia Corporation. All rights reserved. +* +* Author: Richard Purdie <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* version 2 as published by the Free Software Foundation. +* +* 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, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA +* +*/ + +#ifndef __LZO_H +#define __LZO_H + +#define LZO1X_MEM_COMPRESS (16384 * sizeof(unsigned char *)) +#define LZO1X_MEM_DECOMPRESS (0) +#define LZO1X_1_MEM_COMPRESS LZO1X_MEM_COMPRESS + +#define lzo1x_worst_compress (x) (x + (x / 64) + 16 + 3) + +const unsigned char *lzo_copyright (void ); + +int lzo1x_1_compress (const unsigned char *src,unsigned long src_len, +unsigned char *dst,unsigned long *dst_len, +void *wrkmem); + +/* safe decompression with overrun testing */ +int lzo1x_decompress_safe (const unsigned char *src,unsigned long src_len, +unsigned char *dst,unsigned long *dst_len, +void *wrkmem/* NOT USED */ ); + +/* +* Return values (< 0 = Error) +*/ +#define LZO_E_OK 0 +#define LZO_E_ERROR (-1) +#define LZO_E_OUT_OF_MEMORY (-2) +#define LZO_E_NOT_COMPRESSIBLE (-3) +#define LZO_E_INPUT_OVERRUN (-4) +#define LZO_E_OUTPUT_OVERRUN (-5) +#define LZO_E_LOOKBEHIND_OVERRUN (-6) +#define LZO_E_EOF_NOT_FOUND (-7) +#define LZO_E_INPUT_NOT_CONSUMED (-8) +#define LZO_E_NOT_YET_IMPLEMENTED (-9) + +#endif
lib/Kconfig +5 -0
@@ -71,6 +71,11 @@ config AUDIT_GENERIC depends on AUDIT && !AUDIT_ARCH default y +config LZO + tristate "LZO compressor/decompressor" + help + minilzo implementation in kernelspace. + # # compression support is select'ed if needed #
lib/Makefile +1 -0
@@ -51,6 +51,7 @@ obj-$(CONFIG_GENERIC_ALLOCATOR) += genal obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/ obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/ obj-$(CONFIG_REED_SOLOMON) += reed_solomon/ +obj-$(CONFIG_LZO) += lzo/ obj-$(CONFIG_TEXTSEARCH) += textsearch.o obj-$(CONFIG_TEXTSEARCH_KMP) += ts_kmp.o
lib/lzo/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +lzo-objs := minilzo.o lzointf.o + +obj-$(CONFIG_LZO) += lzo.o
lib/lzo/lzoconf.h new file +116 -0
116 lines not on this page · raw message
lib/lzo/lzodefs.h new file +176 -0
176 lines not on this page · raw message
lib/lzo/lzointf.c new file +36 -0
@@ -0,0 +1,36 @@ +/* +* LZO Public Kernel Interface +* +* Copyright (C) 2007 Nokia Corporation. All rights reserved. +* +* Author: Richard Purdie <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* version 2 as published by the Free Software Foundation. +* +* 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, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA +* +*/ + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/lzo.h> +#include "lzoconf.h" + +EXPORT_SYMBOL_GPL (lzo_copyright); +EXPORT_SYMBOL_GPL (lzo1x_1_compress); +EXPORT_SYMBOL_GPL (lzo1x_decompress_safe); + +MODULE_LICENSE ("GPL" ); +MODULE_DESCRIPTION ("LZO compression library" ); +
lib/lzo/minilzo.c new file +1228 -0
1,228 lines not on this page · raw message
Quoted 6 lines · Richard Purdie
Index: linux-2.6.21/lib/Kconfig
===================================================================lib/Kconfig +0
-0@@ -71,6 +71,11 @@ config AUDIT_GENERIC depends on AUDIT && !AUDIT_ARCH
lib/Kconfig config AUDIT_GENERIC · line 81
Quoted 10 lines
lib/Kconfig +5
-0default y +config LZO + tristate "LZO compressor/decompressor" + help + minilzo implementation in kernelspace. + # # compression support is select'ed if needed #
Can this support option be hidden please, with decompression and compression support Kconfig options separated out to support minimal compilation of just the decompressor for read-only filesystems.
Michael-Luke