struct inflate_chunk_iter {
unsigned int seq;
+ int err;
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);
+ iter->err = err;
break;
}
* 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;
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");
+ }
} else
inflate_chunk(ic, log->log_gz_store, f, &stream, &iter);
finish_chunk(&stream, f, &iter);
free(iter.buf);
}
+
+ return iter.err;
}
/*
total -= ret;
if (!total)
break;
+ if (iter.err)
+ break;
ic.seq++;
ic.len -= ret;
}
free(buf);
- return 0;
+ return iter.err;
}
#else
-static void inflate_gz_chunks(struct io_log *log, FILE *f)
+static int inflate_gz_chunks(struct io_log *log, FILE *f)
+{
+ return 0;
+}
+
+int iolog_file_inflate(const char *file)
{
+ log_err("fio: log inflation not possible without zlib\n");
+ return 1;
}
#endif
ret = deflate(&stream, Z_NO_FLUSH);
if (ret < 0) {
log_err("fio: deflate log (%d)\n", ret);
- break;
+ free_chunk(c);
+ goto err;
}
c->len = GZ_CHUNK - stream.avail_out;
pthread_mutex_unlock(&data->log->chunk_lock);
}
+ ret = 0;
+done:
if (work->wait) {
work->done = 1;
pthread_cond_signal(&work->cv);
} else
free(data);
- return 0;
+ 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;
}
/*
} else
data->work.wait = 0;
+ data->work.prio = 1;
tp_queue_work(tdat, &data->work);
if (wait) {