From 040238ec861c6cf3ac3afdf2a6735ca23ef1cee5 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 May 2016 15:35:18 -0600 Subject: [PATCH] iolog: fix bug with ret != Z_STREAM_END Before adding more chunks, adjust the previous chunk size. This fixes an inflate issue, where we'd get Z_DATA_ERROR because the middle chunk did not have the correct length. Signed-off-by: Jens Axboe --- iolog.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/iolog.c b/iolog.c index 234910ae..e2300a52 100644 --- a/iolog.c +++ b/iolog.c @@ -1023,7 +1023,7 @@ size_t log_chunk_sizes(struct io_log *log) static int gz_work(struct iolog_flush_data *data) { - struct iolog_compress *c; + struct iolog_compress *c = NULL; struct flist_head list; unsigned int seq; z_stream stream; @@ -1052,6 +1052,8 @@ static int gz_work(struct iolog_flush_data *data) (unsigned long) stream.avail_in, seq, data->log->filename); do { + if (c) + dprint(FD_COMPRESS, "seq=%d, chunk=%lu\n", seq, c->len); c = get_new_chunk(seq); stream.avail_out = GZ_CHUNK; stream.next_out = c->buf; @@ -1077,6 +1079,11 @@ static int gz_work(struct iolog_flush_data *data) total += c->len; dprint(FD_COMPRESS, "seq=%d, chunk=%lu\n", seq, c->len); } else { + total -= c->len; + c->len = GZ_CHUNK - stream.avail_out; + total += c->len; + dprint(FD_COMPRESS, "seq=%d, chunk=%lu\n", seq, c->len); + do { c = get_new_chunk(seq); stream.avail_out = GZ_CHUNK; -- 2.25.1