[PATCH 5/8] Add compression processing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: HATAYAMA Daisuke <d.hatayama at jp.fujitsu.com>
---

 makedumpfile.c |   30 +++++++++++++++++++++++++-----
 makedumpfile.h |    3 +++
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index a47a3ec..1525b30 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -4718,6 +4718,7 @@ write_kdump_pages(struct cache_data *cd_header, struct cache_data *cd_page)
 	struct dump_bitmap bitmap2;
 	struct timeval tv_start;
 	const off_t failed = (off_t)-1;
+	unsigned long len_buf_out_zlib, len_buf_out_lzo, len_buf_out_snappy;
 
 	int ret = FALSE;
 
@@ -4726,8 +4727,9 @@ write_kdump_pages(struct cache_data *cd_header, struct cache_data *cd_page)
 
 	initialize_2nd_bitmap(&bitmap2);
 
+	len_buf_out_zlib = len_buf_out_lzo = len_buf_out_snappy = 0;
+
 #ifdef USELZO
-	unsigned long len_buf_out_zlib, len_buf_out_lzo;
 	lzo_bytep wrkmem;
 
 	if ((wrkmem = malloc(LZO1X_1_MEM_COMPRESS)) == NULL) {
@@ -4736,13 +4738,19 @@ write_kdump_pages(struct cache_data *cd_header, struct cache_data *cd_page)
 		goto out;
 	}
 
-	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
 
+#ifdef USESNAPPY
+	len_buf_out_snappy = snappy_max_compressed_length(info->page_size);
+#endif
+
+	len_buf_out_zlib = compressBound(info->page_size);
+	
+	len_buf_out = MAX(len_buf_out_zlib,
+			  MAX(len_buf_out_lzo,
+			      len_buf_out_snappy));
+
 	if ((buf_out = malloc(len_buf_out)) == NULL) {
 		ERRMSG("Can't allocate memory for the compression buffer. %s\n",
 		    strerror(errno));
@@ -4843,6 +4851,18 @@ write_kdump_pages(struct cache_data *cd_header, struct cache_data *cd_page)
 			pd.size  = size_out;
 			memcpy(buf, buf_out, pd.size);
 #endif
+#ifdef USESNAPPY
+		} else if ((info->flag_compress & DUMP_DH_COMPRESSED_SNAPPY)
+			   && ((size_out = len_buf_out_snappy),
+			       snappy_compress((char *)buf, info->page_size,
+					       (char *)buf_out,
+					       (size_t *)&size_out)
+			       == SNAPPY_OK)
+			   && (size_out < info->page_size)) {
+			pd.flags = DUMP_DH_COMPRESSED_SNAPPY;
+			pd.size  = size_out;
+			memcpy(buf, buf_out, pd.size);
+#endif
 		} else {
 			pd.flags = 0;
 			pd.size  = info->page_size;
diff --git a/makedumpfile.h b/makedumpfile.h
index 6f5489d..72d8327 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -34,6 +34,9 @@
 #ifdef USELZO
 #include <lzo/lzo1x.h>
 #endif
+#ifdef USESNAPPY
+#include <snappy-c.h>
+#endif
 #include "common.h"
 #include "dwarf_info.h"
 #include "diskdump_mod.h"




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux