summaryrefslogtreecommitdiff
path: root/server.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2016-05-27 11:01:15 -0600
committerJens Axboe <axboe@fb.com>2016-05-27 11:01:15 -0600
commite35fb4c43ecc5b9d35cb5d980e811d3408fc5a4e (patch)
treedd48aeb4d2b0aef09eabdf4bae8f4e18f09fcbf5 /server.c
parent34febb23fa9c7b9b0d54c324effff1a808a8fe6e (diff)
downloadfio-e35fb4c43ecc5b9d35cb5d980e811d3408fc5a4e.tar.gz
fio-e35fb4c43ecc5b9d35cb5d980e811d3408fc5a4e.tar.bz2
server: ensure that we flush compressed logs correctly
Do chunkwise block compression, and flush at the end, adding more space as needed. Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'server.c')
-rw-r--r--server.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/server.c b/server.c
index d36c5113..667a66c0 100644
--- a/server.c
+++ b/server.c
@@ -1656,7 +1656,7 @@ void fio_server_send_du(void)
static int __fio_append_iolog_gz(struct sk_entry *first, struct io_log *log,
struct io_logs *cur_log, z_stream *stream)
{
- struct sk_entry *entry;
+ unsigned int this_len;
void *out_pdu;
int ret;
@@ -1664,7 +1664,7 @@ static int __fio_append_iolog_gz(struct sk_entry *first, struct io_log *log,
stream->avail_in = cur_log->nr_samples * log_entry_sz(log);
do {
- unsigned int this_len;
+ struct sk_entry *entry;
/*
* Dirty - since the log is potentially huge, compress it into
@@ -1675,7 +1675,7 @@ static int __fio_append_iolog_gz(struct sk_entry *first, struct io_log *log,
stream->avail_out = FIO_SERVER_MAX_FRAGMENT_PDU;
stream->next_out = out_pdu;
- ret = deflate(stream, Z_FINISH);
+ ret = deflate(stream, Z_BLOCK);
/* may be Z_OK, or Z_STREAM_END */
if (ret < 0) {
free(out_pdu);
@@ -1716,8 +1716,36 @@ static int fio_append_iolog_gz(struct sk_entry *first, struct io_log *log)
break;
}
- deflateEnd(&stream);
- return ret;
+ ret = deflate(&stream, Z_FINISH);
+
+ while (ret != Z_STREAM_END) {
+ struct sk_entry *entry;
+ unsigned int this_len;
+ void *out_pdu;
+
+ out_pdu = malloc(FIO_SERVER_MAX_FRAGMENT_PDU);
+ stream.avail_out = FIO_SERVER_MAX_FRAGMENT_PDU;
+ stream.next_out = out_pdu;
+
+ ret = deflate(&stream, Z_FINISH);
+ /* may be Z_OK, or Z_STREAM_END */
+ if (ret < 0) {
+ free(out_pdu);
+ break;
+ }
+
+ this_len = FIO_SERVER_MAX_FRAGMENT_PDU - stream.avail_out;
+
+ entry = fio_net_prep_cmd(FIO_NET_CMD_IOLOG, out_pdu, this_len,
+ NULL, SK_F_VEC | SK_F_INLINE | SK_F_FREE);
+ flist_add_tail(&entry->list, &first->next);
+ } while (ret != Z_STREAM_END);
+
+ ret = deflateEnd(&stream);
+ if (ret == Z_OK)
+ return 0;
+
+ return 1;
}
#else
static int fio_append_iolog_gz(struct sk_entry *first, struct io_log *log)