From: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
To: kumagai-atsushi@mxc.nes.nec.co.jp
Cc: kexec@lists.infradead.org, crash-utility@redhat.com
Subject: [PATCH makedumpfile v2 4/4] Add build condition for LZO support
Date: Thu, 23 Feb 2012 10:34:15 +0900 [thread overview]
Message-ID: <20120223013415.5041.53419.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20120223012940.5041.61104.stgit@localhost6.localdomain6>
To enable lzo compression support, build makedumpfile as:
$ make USELZO
To disable, as:
$ make
In default, lzo compression support is disabled.
Signed-off-by: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
---
Makefile | 5 +++++
makedumpfile.c | 18 ++++++++++++++++--
makedumpfile.h | 2 ++
3 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index e6b7b89..55082f7 100644
--- a/Makefile
+++ b/Makefile
@@ -34,6 +34,11 @@ ifneq ($(LINKTYPE), dynamic)
LIBS := -static $(LIBS)
endif
+ifeq ($(USELZO), on)
+LIBS := -llzo2 $(LIBS)
+CFLAGS += -DUSELZO
+endif
+
all: makedumpfile
$(OBJ_PART): $(SRC_PART)
diff --git a/makedumpfile.c b/makedumpfile.c
index e0079b8..717519a 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -266,6 +266,7 @@ readpmem_kdump_compressed(unsigned long long paddr, void *bufptr, size_t size)
goto error;
}
memcpy(bufptr, buf2 + page_offset, size);
+#ifdef USELZO
} else if (info->flag_lzo_support
&& (pd.flags & DUMP_DH_COMPRESSED_LZO)) {
retlen = info->page_size;
@@ -277,6 +278,7 @@ readpmem_kdump_compressed(unsigned long long paddr, void *bufptr, size_t size)
goto error;
}
memcpy(bufptr, buf2 + page_offset, size);
+#endif
} else
memcpy(bufptr, buf + page_offset, size);
@@ -2509,8 +2511,10 @@ initial(void)
unsigned long size;
int debug_info = FALSE;
+#ifdef USELZO
if (lzo_init() == LZO_E_OK)
info->flag_lzo_support = TRUE;
+#endif
if (!is_xen_memory() && info->flag_exclude_xen_dom) {
MSG("'-X' option is disable,");
@@ -4679,11 +4683,10 @@ write_kdump_pages(struct cache_data *cd_header, struct cache_data *cd_page)
off_t offset_data = 0;
struct disk_dump_header *dh = info->dump_header;
unsigned char buf[info->page_size], *buf_out = NULL;
- unsigned long len_buf_out, len_buf_out_zlib, len_buf_out_lzo;
+ unsigned long len_buf_out;
struct dump_bitmap bitmap2;
struct timeval tv_start;
const off_t failed = (off_t)-1;
- lzo_bytep wrkmem = NULL;
int ret = FALSE;
@@ -4692,6 +4695,10 @@ write_kdump_pages(struct cache_data *cd_header, struct cache_data *cd_page)
initialize_2nd_bitmap(&bitmap2);
+#ifdef USELZO
+ unsigned long len_buf_out_zlib, len_buf_out_lzo;
+ lzo_bytep wrkmem;
+
if ((wrkmem = malloc(LZO1X_1_MEM_COMPRESS)) == NULL) {
ERRMSG("Can't allocate memory for the working memory. %s\n",
strerror(errno));
@@ -4701,6 +4708,9 @@ write_kdump_pages(struct cache_data *cd_header, struct cache_data *cd_page)
len_buf_out_zlib = compressBound(info->page_size);
len_buf_out_lzo = info->page_size + info->page_size / 16 + 64 + 3;
len_buf_out = MAX(len_buf_out_zlib, len_buf_out_lzo);
+#else
+ len_buf_out = compressBound(info->page_size);
+#endif
if ((buf_out = malloc(len_buf_out)) == NULL) {
ERRMSG("Can't allocate memory for the compression buffer. %s\n",
@@ -4791,6 +4801,7 @@ write_kdump_pages(struct cache_data *cd_header, struct cache_data *cd_page)
pd.flags = DUMP_DH_COMPRESSED_ZLIB;
pd.size = size_out;
memcpy(buf, buf_out, pd.size);
+#ifdef USELZO
} else if (info->flag_lzo_support
&& (info->flag_compress & DUMP_DH_COMPRESSED_LZO)
&& ((size_out = info->page_size),
@@ -4800,6 +4811,7 @@ write_kdump_pages(struct cache_data *cd_header, struct cache_data *cd_page)
pd.flags = DUMP_DH_COMPRESSED_LZO;
pd.size = size_out;
memcpy(buf, buf_out, pd.size);
+#endif
} else {
pd.flags = 0;
pd.size = info->page_size;
@@ -4840,8 +4852,10 @@ write_kdump_pages(struct cache_data *cd_header, struct cache_data *cd_page)
out:
if (buf_out != NULL)
free(buf_out);
+#ifdef USELZO
if (wrkmem != NULL)
free(wrkmem);
+#endif
return ret;
}
diff --git a/makedumpfile.h b/makedumpfile.h
index 9594ca7..170ac82 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -31,7 +31,9 @@
#include <libelf.h>
#include <byteswap.h>
#include <getopt.h>
+#ifdef USELZO
#include <lzo/lzo1x.h>
+#endif
#include "common.h"
#include "dwarf_info.h"
#include "diskdump_mod.h"
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2012-02-23 1:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-23 1:33 [PATCH makedumpfile v2 0/4] LZO Compression Support HATAYAMA Daisuke
2012-02-23 1:33 ` [PATCH makedumpfile v2 1/4] Add LZO Support HATAYAMA Daisuke
2012-02-23 1:34 ` [PATCH makedumpfile v2 2/4] Avoid LONG_MAX/ULONG_MAX redefinitions HATAYAMA Daisuke
2012-02-23 1:34 ` [PATCH makedumpfile v2 3/4] Add help and manual messages about LZO compression support HATAYAMA Daisuke
2012-02-23 1:34 ` HATAYAMA Daisuke [this message]
2012-02-23 8:16 ` [PATCH makedumpfile v2 0/4] LZO Compression Support Atsushi Kumagai
2012-05-10 0:38 ` HATAYAMA Daisuke
2012-05-10 3:40 ` Atsushi Kumagai
2012-05-10 4:40 ` HATAYAMA Daisuke
2012-03-23 7:33 ` Atsushi Kumagai
2012-03-23 8:26 ` HATAYAMA Daisuke
2012-03-28 5:18 ` Atsushi Kumagai
2012-03-28 7:50 ` HATAYAMA Daisuke
2012-03-28 7:59 ` Bouchard Louis
2012-03-28 8:19 ` HATAYAMA Daisuke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120223013415.5041.53419.stgit@localhost6.localdomain6 \
--to=d.hatayama@jp.fujitsu.com \
--cc=crash-utility@redhat.com \
--cc=kexec@lists.infradead.org \
--cc=kumagai-atsushi@mxc.nes.nec.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.