Signed-off-by: Jens Axboe <axboe@fb.com>
struct inflate_chunk_iter {
unsigned int seq;
struct inflate_chunk_iter {
unsigned int seq;
void *buf;
size_t buf_size;
size_t buf_used;
void *buf;
size_t buf_size;
size_t buf_used;
err = inflate(stream, Z_NO_FLUSH);
if (err < 0) {
log_err("fio: failed inflating log: %d\n", err);
err = inflate(stream, Z_NO_FLUSH);
if (err < 0) {
log_err("fio: failed inflating log: %d\n", err);
* Inflate stored compressed chunks, or write them directly to the log
* file if so instructed.
*/
* Inflate stored compressed chunks, or write them directly to the log
* file if so instructed.
*/
-static void inflate_gz_chunks(struct io_log *log, FILE *f)
+static int inflate_gz_chunks(struct io_log *log, FILE *f)
{
struct inflate_chunk_iter iter = { .chunk_sz = log->log_gz, };
z_stream stream;
{
struct inflate_chunk_iter iter = { .chunk_sz = log->log_gz, };
z_stream stream;
size_t ret;
ret = fwrite(ic->buf, ic->len, 1, f);
size_t ret;
ret = fwrite(ic->buf, ic->len, 1, f);
- if (ret != 1 || ferror(f))
+ if (ret != 1 || ferror(f)) {
+ iter.err = errno;
log_err("fio: error writing compressed log\n");
log_err("fio: error writing compressed log\n");
} else
inflate_chunk(ic, log->log_gz_store, f, &stream, &iter);
} else
inflate_chunk(ic, log->log_gz_store, f, &stream, &iter);
finish_chunk(&stream, f, &iter);
free(iter.buf);
}
finish_chunk(&stream, f, &iter);
free(iter.buf);
}
total -= ret;
if (!total)
break;
total -= ret;
if (!total)
break;
-static void inflate_gz_chunks(struct io_log *log, FILE *f)
+static int inflate_gz_chunks(struct io_log *log, FILE *f)
ret = deflate(&stream, Z_NO_FLUSH);
if (ret < 0) {
log_err("fio: deflate log (%d)\n", ret);
ret = deflate(&stream, Z_NO_FLUSH);
if (ret < 0) {
log_err("fio: deflate log (%d)\n", ret);
+ free_chunk(c);
+ goto err;
}
c->len = GZ_CHUNK - stream.avail_out;
}
c->len = GZ_CHUNK - stream.avail_out;
pthread_mutex_unlock(&data->log->chunk_lock);
}
pthread_mutex_unlock(&data->log->chunk_lock);
}
if (work->wait) {
work->done = 1;
pthread_cond_signal(&work->cv);
} else
free(data);
if (work->wait) {
work->done = 1;
pthread_cond_signal(&work->cv);
} else
free(data);
+ return ret;
+err:
+ while (!flist_empty(&list)) {
+ c = flist_first_entry(list.next, struct iolog_compress, list);
+ flist_del(&c->list);
+ free_chunk(c);
+ }
+ ret = 1;
+ goto done;