[PATCH] Add name=x option to name jobs
authorJens Axboe <axboe@suse.de>
Wed, 7 Jun 2006 08:29:47 +0000 (10:29 +0200)
committerJens Axboe <axboe@suse.de>
Wed, 7 Jun 2006 08:29:47 +0000 (10:29 +0200)
This makes it easier to see what is going on with large job files.

README
fio.c
fio.h
init.c
stat.c

diff --git a/README b/README
index 24bf5a007a6c6c37537ab94d1fd8ab3ea4b21b8d..d27ee875b20b3296a807e06c460e1500d720eed1 100644 (file)
--- a/README
+++ b/README
@@ -43,6 +43,7 @@ $ fio
 
 The <jobs> format is as follows:
 
+       name=x          Use 'x' as the identifier for this job.
        directory=x     Use 'x' as the top level directory for storing files
        rw=x            'x' may be: read, randread, write, randwrite,
                        rw (read-write mix), randrw (read-write random mix)
diff --git a/fio.c b/fio.c
index 8ac44522990f46819dcfc90720fb43d167eb376c..d3f9cc038b277f124d027396c4a44c7fdf959ba7 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -221,7 +221,7 @@ static int check_min_rate(struct thread_data *td, struct timeval *now)
 
                rate = (td->this_io_bytes[ddir] - td->rate_bytes) / spent;
                if (rate < td->ratemin) {
-                       printf("Client%d: min rate %d not met, got %ldKiB/sec\n", td->thread_number, td->ratemin, rate);
+                       printf("%s: min rate %d not met, got %ldKiB/sec\n", td->name, td->ratemin, rate);
                        if (rate_quit)
                                terminate_threads(td->groupid);
                        return 1;
@@ -966,10 +966,10 @@ static int create_file(struct thread_data *td, unsigned long long size,
 
        if (!extend) {
                oflags = O_CREAT | O_TRUNC;
-               printf("Client%d: Laying out IO file (%LuMiB)\n", td->thread_number, size >> 20);
+               printf("%s: Laying out IO file (%LuMiB)\n", td->name, size >> 20);
        } else {
                oflags = O_APPEND;
-               printf("Client%d: Extending IO file (%Lu -> %LuMiB)\n", td->thread_number, (td->file_size - size) >> 20, td->file_size >> 20);
+               printf("%s: Extending IO file (%Lu -> %LuMiB)\n", td->name, (td->file_size - size) >> 20, td->file_size >> 20);
        }
 
        td->fd = open(td->file_name, O_WRONLY | oflags, 0644);
@@ -1075,13 +1075,13 @@ static int get_file_size(struct thread_data *td)
                return ret;
 
        if (td->file_offset > td->real_file_size) {
-               fprintf(stderr, "Client%d: offset extends end (%Lu > %Lu)\n", td->thread_number, td->file_offset, td->real_file_size);
+               fprintf(stderr, "%s: offset extends end (%Lu > %Lu)\n", td->name, td->file_offset, td->real_file_size);
                return 1;
        }
 
        td->io_size = td->file_size;
        if (td->io_size == 0) {
-               fprintf(stderr, "Client%d: no io blocks\n", td->thread_number);
+               fprintf(stderr, "%s: no io blocks\n", td->name);
                td_verror(td, EINVAL);
                return 1;
        }
diff --git a/fio.h b/fio.h
index 045fd012127e6b6ebd50f6520095f5cb2b462e00..f2e3adf26273b2cfa3dfaa0a48bdcb00a826f565 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -102,6 +102,7 @@ struct group_run_stats {
 };
 
 struct thread_data {
+       char name[64];
        char file_name[256];
        char *directory;
        char verror[80];
diff --git a/init.c b/init.c
index d2122e3fd3c7f17361b0f1d7ced0dab4fcabc510..46c513223481238e41dd10791007c646b89e9e7f 100644 (file)
--- a/init.c
+++ b/init.c
@@ -251,10 +251,13 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
        if (write_bw_log)
                setup_log(&td->bw_log);
 
+       if (td->name[0] == '\0')
+               snprintf(td->name, sizeof(td->name)-1, "client%d", td->thread_number);
+
        ddir = td->ddir + (!td->sequential << 1) + (td->iomix << 2);
 
        if (!job_add_num)
-               printf("Client%d (g=%d): rw=%s, odir=%d, bs=%d-%d, rate=%d, ioengine=%s, iodepth=%d\n", td->thread_number, td->groupid, ddir_str[ddir], td->odirect, td->min_bs, td->max_bs, td->rate, td->io_engine_name, td->iodepth);
+               printf("%s: (g=%d): rw=%s, odir=%d, bs=%d-%d, rate=%d, ioengine=%s, iodepth=%d\n", td->name, td->groupid, ddir_str[ddir], td->odirect, td->min_bs, td->max_bs, td->rate, td->io_engine_name, td->iodepth);
        else if (job_add_num == 1)
                printf("...\n");
 
@@ -877,6 +880,11 @@ int parse_jobs_ini(char *file)
                                fgetpos(f, &off);
                                continue;
                        }
+                       if (!check_strstore(p, "name", tmpbuf)) {
+                               snprintf(td->name, sizeof(td->name)-1, "%s%d", tmpbuf, td->thread_number);
+                               fgetpos(f, &off);
+                               continue;
+                       }
                        if (!check_str(p, "mem", str_mem_cb, td)) {
                                fgetpos(f, &off);
                                continue;
diff --git a/stat.c b/stat.c
index 5452716942145f41122c22be01e186a5d9f4bfed..60d5260058b134506eee5aba2d5a22593ae44f7c 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -351,7 +351,7 @@ static void show_thread_status(struct thread_data *td,
        if (!(td->io_bytes[0] + td->io_bytes[1]) && !td->error)
                return;
 
-       printf("Client%d (groupid=%d): err=%2d:\n", td->thread_number, td->groupid, td->error);
+       printf("%s: (groupid=%d): err=%2d:\n",td->name, td->groupid, td->error);
 
        show_ddir_status(td, rs, td->ddir);
        if (td->io_bytes[td->ddir ^ 1])
@@ -392,7 +392,7 @@ void show_run_stats(void)
                td = &threads[i];
 
                if (td->error) {
-                       printf("Client%d: %s\n", td->thread_number, td->verror);
+                       printf("%s: %s\n", td->name, td->verror);
                        continue;
                }