[PATCH] Only the posixaio engine needs to link against -lrt
[fio.git] / init.c
diff --git a/init.c b/init.c
index 967f0b50589d1fe431599fba7f6a6c1e35645012..c81dfddf76d8e2e7b29991cd8f2d2ff702ec62b4 100644 (file)
--- a/init.c
+++ b/init.c
@@ -28,7 +28,6 @@
 #define DEF_SEQUENTIAL         (1)
 #define DEF_RAND_REPEAT                (1)
 #define DEF_OVERWRITE          (1)
-#define DEF_CREATE             (1)
 #define DEF_INVALIDATE         (1)
 #define DEF_SYNCIO             (0)
 #define DEF_RANDSEED           (0xb1899bedUL)
@@ -47,6 +46,7 @@
 #define DEF_RWMIX_READ         (50)
 #define DEF_NICE               (0)
 #define DEF_NR_FILES           (1)
+#define DEF_UNLINK             (0)
 
 static int def_timeout = DEF_TIMEOUT;
 
@@ -140,7 +140,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                td->iodepth = 1;
        else {
                if (!td->iodepth)
-                       td->iodepth = 1;
+                       td->iodepth = td->nr_files;
        }
 
        /*
@@ -163,6 +163,9 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                        td->filetype = FIO_TYPE_CHAR;
        }
 
+       if (td->odirect)
+               td->io_ops->flags |= FIO_RAWIO;
+
        if (td->filetype == FIO_TYPE_FILE) {
                char tmp[PATH_MAX];
                int len = 0;
@@ -176,6 +179,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                for_each_file(td, f, i) {
                        memset(f, 0, sizeof(*f));
                        f->fd = -1;
+                       f->fileno = i;
 
                        sprintf(tmp + len, "%s.%d.%d", jobname, td->thread_number, i);
                        f->file_name = strdup(tmp);
@@ -270,6 +274,7 @@ int init_random_state(struct thread_data *td)
 {
        unsigned long seeds[4];
        int fd, num_maps, blocks, i;
+       struct fio_file *f;
 
        fd = open("/dev/urandom", O_RDONLY);
        if (fd == -1) {
@@ -295,9 +300,7 @@ int init_random_state(struct thread_data *td)
        if (td->rand_repeatable)
                seeds[3] = DEF_RANDSEED;
 
-       for (i = 0; i < td->nr_files; i++) {
-               struct fio_file *f = &td->files[i];
-
+       for_each_file(td, f, i) {
                blocks = (f->file_size + td->min_bs - 1) / td->min_bs;
                num_maps = blocks / BLOCKS_PER_MAP;
                f->file_map = malloc(num_maps * sizeof(long));
@@ -913,11 +916,6 @@ int parse_jobs_ini(char *file, int stonewall_flag)
                                fgetpos(f, &off);
                                continue;
                        }
-                       if (!check_strset(p, "create")) {
-                               td->create_file = 1;
-                               fgetpos(f, &off);
-                               continue;
-                       }
                        if (!check_strset(p, "exitall")) {
                                exitall_on_terminate = 1;
                                fgetpos(f, &off);
@@ -933,6 +931,11 @@ int parse_jobs_ini(char *file, int stonewall_flag)
                                fgetpos(f, &off);
                                continue;
                        }
+                       if (!check_strset(p, "unlink")) {
+                               td->unlink = 1;
+                               fgetpos(f, &off);
+                               continue;
+                       }
                        if (!check_strstore(p, "iolog", tmpbuf)) {
                                if (td->write_iolog) {
                                        log_err("fio: read iolog overrides given write_iolog\n");
@@ -1020,7 +1023,6 @@ static int fill_def_thread(void)
        def_thread.ratecycle = DEF_RATE_CYCLE;
        def_thread.sequential = DEF_SEQUENTIAL;
        def_thread.timeout = def_timeout;
-       def_thread.create_file = DEF_CREATE;
        def_thread.overwrite = DEF_OVERWRITE;
        def_thread.invalidate_cache = DEF_INVALIDATE;
        def_thread.sync_io = DEF_SYNCIO;
@@ -1038,6 +1040,7 @@ static int fill_def_thread(void)
        def_thread.nice = DEF_NICE;
        def_thread.rand_repeatable = DEF_RAND_REPEAT;
        def_thread.nr_files = DEF_NR_FILES;
+       def_thread.unlink = DEF_UNLINK;
 #ifdef FIO_HAVE_DISK_UTIL
        def_thread.do_disk_util = 1;
 #endif
@@ -1045,7 +1048,7 @@ static int fill_def_thread(void)
        return 0;
 }
 
-static void usage(char *name)
+static void usage(void)
 {
        printf("%s\n", fio_version_string);
        printf("\t-o Write output to file\n");
@@ -1088,7 +1091,7 @@ static int parse_cmd_line(int argc, char *argv[])
                                idx = optind;
                                break;
                        case 'h':
-                               usage(argv[0]);
+                               usage();
                                exit(0);
                        case 'v':
                                printf("%s\n", fio_version_string);
@@ -1172,7 +1175,7 @@ int parse_options(int argc, char *argv[])
        job_files = parse_cmd_line(argc, argv);
        if (!job_files) {
                log_err("Need job file(s)\n");
-               usage(argv[0]);
+               usage();
                return 1;
        }