[RESEND][PATCH] crash: Add LZO Compression Support

HATAYAMA Daisuke d.hatayama at jp.fujitsu.com
Thu May 10 23:52:52 EDT 2012


I'm sorry that I wrongly sended the previous mail in html format. I
re-send the mail.

==
Hello Dave,

This is LZO patch for crash utility. makedumpfile will support LZO
compression in version 1.4.4, and it will be released this or next
month.

LZO patch for makedumpfile is here:

[PATCH makedumpfile 0/2] LZO Compression Support
http://lists.infradead.org/pipermail/kexec/2012-February/006075.html

Thanks.
HATAYAMA, Daisuke

-------------- next part --------------
From e216253f5985195fc6ebc40961b6f75d58121d07 Mon Sep 17 00:00:00 2001
From: HATAYAMA Daisuke <d.hatayama at jp.fujitsu.com>
Date: Fri, 11 May 2012 11:38:03 +0900
Subject: [PATCH] crash: Add LZO Compression Support

LZO is as good as in size but by far better in speed than ZLIB. This
can reduce the time required for generation of crash dump and
refiltering; LZO is even better in decompression speed, but it might
be difficult for crash users to be aware of this improvement.

This patch allows crash utility to read dumpfiles compressed by LZO
using makedumpfile version 1.4.4 or later.

This feature is disabled at default. To enable this feature, build
crash utility in the following way:

  1) Install LZO libraries by using package manager or by directly
  downloading libraries from author's website. The packages required
  are:

     - lzo
     - lzo-minilzo
     - lzo-devel

  The author's website is: http://www.oberhumer.com/opensource/lzo/.

  2) Create CFLAGS.extra file and LDFLAGS.extra file in top directory
  where source code of crash utility is expanded. Then, write -DLZO in
  CFLAGS.extra file and -llzo2 in LDFLAGS.extra file.

  3) Do make as always.

Signed-off-by: HATAYAMA Daisuke <d.hatayama at jp.fujitsu.com>
---
 defs.h     |    3 +++
 diskdump.c |   30 +++++++++++++++++++++++++++++-
 diskdump.h |    3 ++-
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/defs.h b/defs.h
index 77a623d..171c5b1 100755
--- a/defs.h
+++ b/defs.h
@@ -48,6 +48,9 @@
 #include <sys/time.h>
 #include <execinfo.h> /* backtrace() */
 #include <regex.h>
+#ifdef LZO
+#include <lzo/lzo1x.h>
+#endif
 
 #ifndef ATTRIBUTE_UNUSED
 #define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
diff --git a/diskdump.c b/diskdump.c
index d94bc49..24e212a 100644
--- a/diskdump.c
+++ b/diskdump.c
@@ -66,6 +66,7 @@ struct diskdump_data {
 	ulong	cached_reads;
 	ulong  *valid_pages;
 	ulong   accesses;
+	int	lzo_supported;
 };
 
 static struct diskdump_data diskdump_data = { 0 };
@@ -673,6 +674,11 @@ is_diskdump(char *file)
 	if (pc->flags2 & GET_OSRELEASE) 
 		diskdump_get_osrelease();
 
+#ifdef LZO
+	if (lzo_init() == LZO_E_OK)
+		dd->lzo_supported = TRUE;
+#endif
+
 	return TRUE;
 }
 
@@ -827,7 +833,7 @@ cache_page(physaddr_t paddr)
 			return READ_ERROR;
 	}
 
-	if (pd.flags & DUMP_DH_COMPRESSED) {
+	if (pd.flags & DUMP_DH_COMPRESSED_ZLIB) {
 		retlen = block_size;
 		ret = uncompress((unsigned char *)dd->page_cache_hdr[i].pg_bufptr,
 		                 &retlen,
@@ -839,6 +845,28 @@ cache_page(physaddr_t paddr)
 				ret);
 			return READ_ERROR;
 		}
+	} else if (pd.flags & DUMP_DH_COMPRESSED_LZO) {
+
+		if (!dd->lzo_supported) {
+			error(INFO, "%s: uncompress failed: no lzo compression support\n",
+			      DISKDUMP_VALID() ? "diskdump" : "compressed kdump");
+			return READ_ERROR;
+		}
+
+#ifdef LZO
+		retlen = block_size;
+		ret = lzo1x_decompress_safe((unsigned char *)dd->compressed_page,
+					    pd.size,
+					    (unsigned char *)dd->page_cache_hdr[i].pg_bufptr,
+					    &retlen,
+					    LZO1X_MEM_DECOMPRESS);
+		if ((ret != LZO_E_OK) || (retlen != block_size)) {
+			error(INFO, "%s: uncompress failed: %d\n", 
+				DISKDUMP_VALID() ? "diskdump" : "compressed kdump",
+				ret);
+			return READ_ERROR;
+		}
+#endif
 	} else
 		memcpy(dd->page_cache_hdr[i].pg_bufptr,
 		       dd->compressed_page, block_size);
diff --git a/diskdump.h b/diskdump.h
index c7cc4fc..bd99fbd 100644
--- a/diskdump.h
+++ b/diskdump.h
@@ -72,7 +72,8 @@ struct kdump_sub_header {
 };
 
 /* page flags */
-#define DUMP_DH_COMPRESSED	0x1	/* page is compressed               */
+#define DUMP_DH_COMPRESSED_ZLIB	0x1	/* page is compressed with zlib */
+#define DUMP_DH_COMPRESSED_LZO	0x2	/* page is compressed with lzo */
 
 /* descriptor of each page for vmcore */
 typedef struct page_desc {
-- 
1.7.4.4



More information about the kexec mailing list