We need to grab and mark the file open before jumping to an error path
authorJens Axboe <jens.axboe@oracle.com>
Wed, 4 Jun 2008 13:13:02 +0000 (15:13 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 4 Jun 2008 13:13:02 +0000 (15:13 +0200)
The error path will close the file.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
ioengines.c

index 3e17897653f6a8d57a6a18a3b65297bfdd72653c..1a7a6301d0b6b4d42112e62b8c520813a3c4530b 100644 (file)
@@ -329,6 +329,13 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f)
                return 1;
        }
 
                return 1;
        }
 
+       fio_file_reset(f);
+       f->flags |= FIO_FILE_OPEN;
+       f->flags &= ~FIO_FILE_CLOSING;
+
+       td->nr_open_files++;
+       get_file(f);
+
        if (f->filetype == FIO_TYPE_PIPE) {
                if (td_random(td)) {
                        log_err("fio: can't seek on pipes (no random io)\n");
        if (f->filetype == FIO_TYPE_PIPE) {
                if (td_random(td)) {
                        log_err("fio: can't seek on pipes (no random io)\n");
@@ -336,10 +343,6 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f)
                }
        }
 
                }
        }
 
-       fio_file_reset(f);
-       f->flags |= FIO_FILE_OPEN;
-       f->flags &= ~FIO_FILE_CLOSING;
-
        if (td->io_ops->flags & FIO_DISKLESSIO)
                goto done;
 
        if (td->io_ops->flags & FIO_DISKLESSIO)
                goto done;
 
@@ -366,8 +369,6 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f)
 
 done:
        log_file(td, f, FIO_LOG_OPEN_FILE);
 
 done:
        log_file(td, f, FIO_LOG_OPEN_FILE);
-       td->nr_open_files++;
-       get_file(f);
        return 0;
 err:
        if (td->io_ops->close_file)
        return 0;
 err:
        if (td->io_ops->close_file)