Kill unused parameters
[fio.git] / log.c
diff --git a/log.c b/log.c
index 8ac8ec3238c473c48bc34a68225d073b2ef2a9fb..15de3c24d10bf64698325479af7e5b45f80c81aa 100644 (file)
--- a/log.c
+++ b/log.c
@@ -61,35 +61,59 @@ static void iolog_delay(struct thread_data *td, unsigned long delay)
        usec_sleep(td, delay);
 }
 
+static int ipo_special(struct thread_data *td, struct io_piece *ipo)
+{
+       struct fio_file *f;
+       int ret;
+
+       /*
+        * Not a special ipo
+        */
+       if (ipo->ddir != DDIR_INVAL)
+               return 0;
+
+       f = td->files[ipo->fileno];
+
+       switch (ipo->file_action) {
+       case FIO_LOG_OPEN_FILE:
+               ret = td_io_open_file(td, f);
+               if (!ret) {
+                       free(ipo);
+                       break;
+               }
+               td_verror(td, ret, "iolog open file");
+               return -1;
+       case FIO_LOG_CLOSE_FILE:
+               td_io_close_file(td, f);
+               break;
+       case FIO_LOG_UNLINK_FILE:
+               unlink(f->file_name);
+               break;
+       default:
+               log_err("fio: bad file action %d\n", ipo->file_action);
+               break;
+       }
+
+       return 1;
+}
+
 int read_iolog_get(struct thread_data *td, struct io_u *io_u)
 {
        struct io_piece *ipo;
 
        while (!list_empty(&td->io_log_list)) {
+               int ret;
+
                ipo = list_entry(td->io_log_list.next, struct io_piece, list);
                list_del(&ipo->list);
 
-               /*
-                * invalid ddir, this is a file action
-                */
-               if (ipo->ddir == DDIR_INVAL) {
-                       struct fio_file *f = td->files[ipo->fileno];
-
-                       if (ipo->file_action == FIO_LOG_OPEN_FILE) {
-                               int ret;
-
-                               ret = td_io_open_file(td, f);
-                               if (!ret) {
-                                       free(ipo);
-                                       continue;
-                               }
-                               td_verror(td, ret, "iolog open file");
-                               return 1;
-                       } else if (ipo->file_action == FIO_LOG_CLOSE_FILE) {
-                               td_io_close_file(td, f);
-                               free(ipo);
-                               continue;
-                       }
+               ret = ipo_special(td, ipo);
+               if (ret < 0) {
+                       free(ipo);
+                       break;
+               } else if (ret > 0) {
+                       free(ipo);
+                       continue;
                }
 
                io_u->offset = ipo->offset;
@@ -310,15 +334,6 @@ static int read_iolog2(struct thread_data *td, FILE *f)
        return 0;
 }
 
-/*
- * Read version 1 iolog data.
- */
-static int read_iolog(struct thread_data *td, FILE *f)
-{
-       log_err("fio: iolog version 1 is no longer supported\n");
-       return 1;
-}
-
 /*
  * open iolog, check version, and call appropriate parser
  */
@@ -348,16 +363,8 @@ static int init_iolog_read(struct thread_data *td)
        if (!strncmp(iolog_ver2, buffer, strlen(iolog_ver2)))
                ret = read_iolog2(td, f);
        else {
-               /*
-                * seek back to the beginning
-                */
-               if (fseek(f, 0, SEEK_SET) < 0) {
-                       td_verror(td, errno, "iolog read");
-                       log_err("fio: unable to read iolog\n");
-                       return 1;
-               }
-
-               ret = read_iolog(td, f);
+               log_err("fio: iolog version 1 is no longer supported\n");
+               ret = 1;
        }
 
        fclose(f);
@@ -460,6 +467,6 @@ void finish_log(struct thread_data *td, struct io_log *log, const char *name)
 {
        char file_name[256];
 
-       snprintf(file_name, 200, "client%d_%s.log", td->thread_number, name);
+       snprintf(file_name, 200, "%s_%s.log", td->o.name, name);
        __finish_log(log, file_name);
 }