gfio: remove warning on g_type_init() being deprecated
[fio.git] / client.c
index af6621dc63d3e0ce7c196e1bd5daa0e747463a7d..1dded0966cf9bcba261fb1fe5282d20bc3b67c94 100644 (file)
--- a/client.c
+++ b/client.c
@@ -823,9 +823,11 @@ static void convert_gs(struct group_run_stats *dst, struct group_run_stats *src)
 }
 
 static void json_object_add_client_info(struct json_object *obj,
-struct fio_client *client)
+                                       struct fio_client *client)
 {
-       json_object_add_value_string(obj, "hostname", client->hostname);
+       const char *hostname = client->hostname ? client->hostname : "";
+
+       json_object_add_value_string(obj, "hostname", hostname);
        json_object_add_value_int(obj, "port", client->port);
 }
 
@@ -987,7 +989,12 @@ void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je)
                dst->eta_sec = je->eta_sec;
 
        dst->nr_threads         += je->nr_threads;
-       /* we need to handle je->run_str too ... */
+
+       /*
+        * This wont be correct for multiple strings, but at least it
+        * works for the basic cases.
+        */
+       strcpy((char *) dst->run_str, (char *) je->run_str);
 }
 
 void fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op eta_fn)
@@ -1149,9 +1156,9 @@ static struct cmd_iolog_pdu *convert_iolog_gz(struct fio_net_cmd *cmd,
        /*
         * Get header first, it's not compressed
         */
-       nr_samples = le32_to_cpu(pdu->nr_samples);
+       nr_samples = le64_to_cpu(pdu->nr_samples);
 
-       total = nr_samples * sizeof(struct io_sample);
+       total = nr_samples * __log_entry_sz(le32_to_cpu(pdu->log_offset));
        ret = malloc(total + sizeof(*pdu));
        ret->nr_samples = nr_samples;
 
@@ -1201,7 +1208,8 @@ static struct cmd_iolog_pdu *convert_iolog(struct fio_net_cmd *cmd)
 {
        struct cmd_iolog_pdu *pdu = (struct cmd_iolog_pdu *) cmd->payload;
        struct cmd_iolog_pdu *ret;
-       int i;
+       uint64_t i;
+       void *samples;
 
        /*
         * Convert if compressed and we support it. If it's not
@@ -1220,18 +1228,27 @@ static struct cmd_iolog_pdu *convert_iolog(struct fio_net_cmd *cmd)
        } else
                ret = pdu;
 
+       ret->nr_samples         = le64_to_cpu(ret->nr_samples);
        ret->thread_number      = le32_to_cpu(ret->thread_number);
-       ret->nr_samples         = le32_to_cpu(ret->nr_samples);
        ret->log_type           = le32_to_cpu(ret->log_type);
        ret->compressed         = le32_to_cpu(ret->compressed);
+       ret->log_offset         = le32_to_cpu(ret->log_offset);
 
+       samples = &ret->samples[0];
        for (i = 0; i < ret->nr_samples; i++) {
-               struct io_sample *s = &ret->samples[i];
+               struct io_sample *s;
+
+               s = __get_sample(samples, ret->log_offset, i);
+               s->time         = le64_to_cpu(s->time);
+               s->val          = le64_to_cpu(s->val);
+               s->__ddir       = le32_to_cpu(s->__ddir);
+               s->bs           = le32_to_cpu(s->bs);
 
-               s->time = le64_to_cpu(s->time);
-               s->val  = le64_to_cpu(s->val);
-               s->ddir = le32_to_cpu(s->ddir);
-               s->bs   = le32_to_cpu(s->bs);
+               if (ret->log_offset) {
+                       struct io_sample_offset *so = (void *) s;
+
+                       so->offset = le64_to_cpu(so->offset);
+               }
        }
 
        return ret;
@@ -1374,8 +1391,7 @@ static void request_client_etas(struct client_ops *ops)
 
        dprint(FD_NET, "client: request eta (%d)\n", nr_clients);
 
-       eta = malloc(sizeof(*eta));
-       memset(&eta->eta, 0, sizeof(eta->eta));
+       eta = calloc(1, sizeof(*eta) + __THREAD_RUNSTR_SZ(REAL_MAX_JOBS));
        eta->pending = nr_clients;
 
        flist_for_each(entry, &client_list) {