Add thread number ID to appropriate network commands
authorJens Axboe <axboe@kernel.dk>
Thu, 15 Mar 2012 12:10:19 +0000 (13:10 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 15 Mar 2012 12:10:19 +0000 (13:10 +0100)
The client doesn't necessarily have a 1:1 mapping between jobs
and its internal job representation, so allow it to tell the
various jobs apart.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
client.c
fio.h
gfio.c
init.c
server.c
server.h
stat.c
stat.h

index 678a62753021035568cec1fb54ac1f23e8d7bcca..6230a66e032258f338c55fa8c05e72bf4d6ad833 100644 (file)
--- a/client.c
+++ b/client.c
@@ -628,10 +628,11 @@ static void convert_ts(struct thread_stat *dst, struct thread_stat *src)
 {
        int i, j;
 
 {
        int i, j;
 
-       dst->error      = le32_to_cpu(src->error);
-       dst->groupid    = le32_to_cpu(src->groupid);
-       dst->pid        = le32_to_cpu(src->pid);
-       dst->members    = le32_to_cpu(src->members);
+       dst->error              = le32_to_cpu(src->error);
+       dst->thread_number      = le32_to_cpu(src->thread_number);
+       dst->groupid            = le32_to_cpu(src->groupid);
+       dst->pid                = le32_to_cpu(src->pid);
+       dst->members            = le32_to_cpu(src->members);
 
        for (i = 0; i < 2; i++) {
                convert_io_stat(&dst->clat_stat[i], &src->clat_stat[i]);
 
        for (i = 0; i < 2; i++) {
                convert_io_stat(&dst->clat_stat[i], &src->clat_stat[i]);
@@ -719,6 +720,7 @@ static void handle_ts(struct fio_client *client, struct fio_net_cmd *cmd)
        sum_group_stats(&client_gs, &p->rs);
 
        client_ts.members++;
        sum_group_stats(&client_gs, &p->rs);
 
        client_ts.members++;
+       client_ts.thread_number = p->ts.thread_number;
        client_ts.groupid = p->ts.groupid;
 
        if (++sum_stat_nr == sum_stat_clients) {
        client_ts.groupid = p->ts.groupid;
 
        if (++sum_stat_nr == sum_stat_clients) {
@@ -981,6 +983,7 @@ static struct cmd_iolog_pdu *convert_iolog(struct fio_net_cmd *cmd)
 
        total = nr_samples * sizeof(struct io_sample);
        ret = malloc(total + sizeof(*pdu));
 
        total = nr_samples * sizeof(struct io_sample);
        ret = malloc(total + sizeof(*pdu));
+       ret->thread_number = le32_to_cpu(pdu->thread_number);
        ret->nr_samples = nr_samples;
        ret->log_type = le32_to_cpu(pdu->log_type);
        strcpy((char *) ret->name, (char *) pdu->name);
        ret->nr_samples = nr_samples;
        ret->log_type = le32_to_cpu(pdu->log_type);
        strcpy((char *) ret->name, (char *) pdu->name);
diff --git a/fio.h b/fio.h
index db0e8756fe71c0ddcfc0e9394b111ba521dddcb9..6e1175406f8dd0ed0671f6651a87198686993440 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -66,8 +66,8 @@ struct thread_data {
        void *eo;
        char verror[FIO_VERROR_SIZE];
        pthread_t thread;
        void *eo;
        char verror[FIO_VERROR_SIZE];
        pthread_t thread;
-       int thread_number;
-       int groupid;
+       unsigned int thread_number;
+       unsigned int groupid;
        struct thread_stat ts;
 
        int client_type;
        struct thread_stat ts;
 
        int client_type;
diff --git a/gfio.c b/gfio.c
index be0a4ac3df28f97c5f053017c18cc36ed109316f..7dcb18822db81516830fd2def5c0865be5190fb1 100644 (file)
--- a/gfio.c
+++ b/gfio.c
@@ -1461,6 +1461,7 @@ static void gfio_thread_status_op(struct fio_client *client,
        sum_group_stats(&client_gs, &p->rs);
 
        client_ts.members++;
        sum_group_stats(&client_gs, &p->rs);
 
        client_ts.members++;
+       client_ts.thread_number = p->ts.thread_number;
        client_ts.groupid = p->ts.groupid;
 
        if (++sum_stat_nr == sum_stat_clients) {
        client_ts.groupid = p->ts.groupid;
 
        if (++sum_stat_nr == sum_stat_clients) {
@@ -1788,6 +1789,8 @@ static void gfio_add_job_op(struct fio_client *client, struct fio_net_cmd *cmd)
        struct gui_entry *ge = gc->ge;
        char tmp[8];
 
        struct gui_entry *ge = gc->ge;
        char tmp[8];
 
+       p->thread_number = le32_to_cpu(p->thread_number);
+       p->groupid = le32_to_cpu(p->groupid);
        convert_thread_options_to_cpu(o, &p->top);
 
        gdk_threads_enter();
        convert_thread_options_to_cpu(o, &p->top);
 
        gdk_threads_enter();
diff --git a/init.c b/init.c
index 820c30c5d0151cc2b789e16f39e20b64209d0f11..d4a4f339d2a8358de22850fa59f523dca9632181 100644 (file)
--- a/init.c
+++ b/init.c
@@ -861,7 +861,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num,
        if (!terse_output) {
                if (!job_add_num) {
                        if (is_backend && !recursed)
        if (!terse_output) {
                if (!job_add_num) {
                        if (is_backend && !recursed)
-                               fio_server_send_add_job(&td->o, td->io_ops->name);
+                               fio_server_send_add_job(td);
 
                        if (!strcmp(td->io_ops->name, "cpuio")) {
                                log_info("%s: ioengine=cpu, cpuload=%u,"
 
                        if (!strcmp(td->io_ops->name, "cpuio")) {
                                log_info("%s: ioengine=cpu, cpuload=%u,"
index 9110707656ad3e2ca4f8166521b9d407efe57551..899b230274b1133dd54c3aacdb0020acf70056ba 100644 (file)
--- a/server.c
+++ b/server.c
@@ -752,10 +752,11 @@ void fio_server_send_ts(struct thread_stat *ts, struct group_run_stats *rs)
        strcpy(p.ts.verror, ts->verror);
        strcpy(p.ts.description, ts->description);
 
        strcpy(p.ts.verror, ts->verror);
        strcpy(p.ts.description, ts->description);
 
-       p.ts.error      = cpu_to_le32(ts->error);
-       p.ts.groupid    = cpu_to_le32(ts->groupid);
-       p.ts.pid        = cpu_to_le32(ts->pid);
-       p.ts.members    = cpu_to_le32(ts->members);
+       p.ts.error              = cpu_to_le32(ts->error);
+       p.ts.thread_number      = cpu_to_le32(ts->thread_number);
+       p.ts.groupid            = cpu_to_le32(ts->groupid);
+       p.ts.pid                = cpu_to_le32(ts->pid);
+       p.ts.members            = cpu_to_le32(ts->members);
 
        for (i = 0; i < 2; i++) {
                convert_io_stat(&p.ts.clat_stat[i], &ts->clat_stat[i]);
 
        for (i = 0; i < 2; i++) {
                convert_io_stat(&p.ts.clat_stat[i], &ts->clat_stat[i]);
@@ -910,6 +911,7 @@ int fio_send_iolog(struct thread_data *td, struct io_log *log, const char *name)
        void *out_pdu;
        int i, ret = 0;
 
        void *out_pdu;
        int i, ret = 0;
 
+       pdu.thread_number = cpu_to_le32(td->thread_number);
        pdu.nr_samples = __cpu_to_le32(log->nr_samples);
        pdu.log_type = cpu_to_le32(log->log_type);
        strcpy((char *) pdu.name, name);
        pdu.nr_samples = __cpu_to_le32(log->nr_samples);
        pdu.log_type = cpu_to_le32(log->log_type);
        strcpy((char *) pdu.name, name);
@@ -979,12 +981,14 @@ err:
        return ret;
 }
 
        return ret;
 }
 
-void fio_server_send_add_job(struct thread_options *o, const char *ioengine)
+void fio_server_send_add_job(struct thread_data *td)
 {
        struct cmd_add_job_pdu pdu;
 
        memset(&pdu, 0, sizeof(pdu));
 {
        struct cmd_add_job_pdu pdu;
 
        memset(&pdu, 0, sizeof(pdu));
-       convert_thread_options_to_net(&pdu.top, o);
+       pdu.thread_number = cpu_to_le32(td->thread_number);
+       pdu.groupid = cpu_to_le32(td->groupid);
+       convert_thread_options_to_net(&pdu.top, &td->o);
 
        fio_net_send_cmd(server_fd, FIO_NET_CMD_ADD_JOB, &pdu, sizeof(pdu), 0);
 }
 
        fio_net_send_cmd(server_fd, FIO_NET_CMD_ADD_JOB, &pdu, sizeof(pdu), 0);
 }
index 27e552320c221d9fea252f73e161ce47934c7f8e..3c66ecbee403c254fc1a8993372ca270f1c58181 100644 (file)
--- a/server.h
+++ b/server.h
@@ -38,7 +38,7 @@ struct fio_net_int_cmd {
 };
 
 enum {
 };
 
 enum {
-       FIO_SERVER_VER                  = 12,
+       FIO_SERVER_VER                  = 13,
 
        FIO_SERVER_MAX_FRAGMENT_PDU     = 1024,
 
 
        FIO_SERVER_MAX_FRAGMENT_PDU     = 1024,
 
@@ -119,6 +119,8 @@ struct cmd_end_pdu {
 };
 
 struct cmd_add_job_pdu {
 };
 
 struct cmd_add_job_pdu {
+       uint32_t thread_number;
+       uint32_t groupid;
        struct thread_options_pack top;
 };
 
        struct thread_options_pack top;
 };
 
@@ -131,6 +133,7 @@ struct cmd_text_pdu {
 };
 
 struct cmd_iolog_pdu {
 };
 
 struct cmd_iolog_pdu {
+       uint32_t thread_number;
        uint32_t nr_samples;
        uint32_t log_type;
        uint8_t name[FIO_NET_NAME_MAX];
        uint32_t nr_samples;
        uint32_t log_type;
        uint8_t name[FIO_NET_NAME_MAX];
@@ -161,9 +164,7 @@ extern void fio_net_cmd_crc_pdu(struct fio_net_cmd *, const void *);
 extern struct fio_net_cmd *fio_net_recv_cmd(int sk);
 
 extern int fio_send_iolog(struct thread_data *, struct io_log *, const char *);
 extern struct fio_net_cmd *fio_net_recv_cmd(int sk);
 
 extern int fio_send_iolog(struct thread_data *, struct io_log *, const char *);
-
-struct thread_options;
-extern void fio_server_send_add_job(struct thread_options *, const char *);
+extern void fio_server_send_add_job(struct thread_data *);
 
 extern int exit_backend;
 extern int fio_net_port;
 
 extern int exit_backend;
 extern int fio_net_port;
diff --git a/stat.c b/stat.c
index 8b032b881d93d8fe1dc692a1c38898be42848bcd..70f9e0a1d75e24e5b355e1e9e58078351d364a1a 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -956,6 +956,11 @@ void show_run_stats(void)
                        else
                                memset(ts->description, 0, FIO_JOBNAME_SIZE);
 
                        else
                                memset(ts->description, 0, FIO_JOBNAME_SIZE);
 
+                       /*
+                        * If multiple entries in this group, this is
+                        * the first member.
+                        */
+                       ts->thread_number = td->thread_number;
                        ts->groupid = td->groupid;
 
                        /*
                        ts->groupid = td->groupid;
 
                        /*
diff --git a/stat.h b/stat.h
index 084724669bbb3ebed266933783d5a6478296af62..ce640d9c72071339def786b9e3bdb44891b8759c 100644 (file)
--- a/stat.h
+++ b/stat.h
@@ -118,6 +118,7 @@ struct thread_stat {
        char name[FIO_JOBNAME_SIZE];
        char verror[FIO_VERROR_SIZE];
        uint32_t error;
        char name[FIO_JOBNAME_SIZE];
        char verror[FIO_VERROR_SIZE];
        uint32_t error;
+       uint32_t thread_number;
        uint32_t groupid;
        uint32_t pid;
        char description[FIO_JOBNAME_SIZE];
        uint32_t groupid;
        uint32_t pid;
        char description[FIO_JOBNAME_SIZE];