Add softrandommap and --alloc-size options
[fio.git] / filesetup.c
index bb43ee5829f9dfff3231ebb3ca7f4b50ac1e7bab..b356b447ddaeadffa01f4d551ea868621cff3220 100644 (file)
@@ -37,6 +37,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
                unlink_file = 1;
 
        if (unlink_file || new_layout) {
+               dprint(FD_FILE, "layout unlink %s\n", f->file_name);
                if ((unlink(f->file_name) < 0) && (errno != ENOENT)) {
                        td_verror(td, errno, "unlink");
                        return 1;
@@ -116,7 +117,6 @@ err:
        return 1;
 }
 
-               dprint(FD_FILE, "layout unlink %s\n", f->file_name);
 static unsigned long long get_rand_file_size(struct thread_data *td)
 {
        unsigned long long ret, size_d;
@@ -575,13 +575,21 @@ int init_random_map(struct thread_data *td)
                num_maps = (blocks + BLOCKS_PER_MAP - 1) /
                                (unsigned long long) BLOCKS_PER_MAP;
                f->file_map = smalloc(num_maps * sizeof(long));
-               if (!f->file_map) {
+               if (f->file_map) {
+                       f->num_maps = num_maps;
+                       continue;
+               }
+               if (!td->o.softrandommap) {
                        log_err("fio: failed allocating random map. If running"
                                " a large number of jobs, try the 'norandommap'"
-                               " option\n");
+                               " option or set 'softrandommap'. Or give"
+                               " a larger --alloc-size to fio.\n");
                        return 1;
                }
-               f->num_maps = num_maps;
+
+               log_info("fio: file %s failed allocating random map. Running "
+                        "job without.\n", f->file_name);
+               f->num_maps = 0;
        }
 
        return 0;