Allow randommap allocation to fail
authorJens Axboe <jens.axboe@oracle.com>
Wed, 26 Mar 2008 09:11:10 +0000 (10:11 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 26 Mar 2008 09:11:10 +0000 (10:11 +0100)
It's not that critical, so just print a warning and continue
without randommap.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
filesetup.c
fio.h
io_u.c

index 4774d84213b37038ffc8284275fe3543787e7e80..6c5770b463b035b6a77cbe7300855a65967eff8f 100644 (file)
@@ -575,13 +575,14 @@ 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));
                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) {
-                       log_err("fio: failed allocating random map. If running"
-                               " a large number of jobs, try the 'norandommap'"
-                               " option\n");
-                       return 1;
+               if (f->file_map) {
+                       f->num_maps = num_maps;
+                       continue;
                }
                }
-               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;
        }
 
        return 0;
diff --git a/fio.h b/fio.h
index 34f02d697ced823364e06894aa2b84126fce8045..55717c798a08c9192bb8eae8533a97d92d7122dd 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -691,6 +691,7 @@ extern struct thread_data *threads;
 #define td_write(td)           ((td)->o.td_ddir & TD_DDIR_WRITE)
 #define td_rw(td)              (((td)->o.td_ddir & TD_DDIR_RW) == TD_DDIR_RW)
 #define td_random(td)          ((td)->o.td_ddir & TD_DDIR_RAND)
 #define td_write(td)           ((td)->o.td_ddir & TD_DDIR_WRITE)
 #define td_rw(td)              (((td)->o.td_ddir & TD_DDIR_RW) == TD_DDIR_RW)
 #define td_random(td)          ((td)->o.td_ddir & TD_DDIR_RAND)
+#define file_randommap(td, f)  (!(td)->o.norandommap && (f)->file_map)
 
 static inline void fio_ro_check(struct thread_data *td, struct io_u *io_u)
 {
 
 static inline void fio_ro_check(struct thread_data *td, struct io_u *io_u)
 {
diff --git a/io_u.c b/io_u.c
index 1e60eee5ccee03f20126a825ff9ad4989661c7cf..7a23d2cf7fdd4a9127ec09298b8548cbca60588c 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -130,7 +130,7 @@ static int get_next_rand_offset(struct thread_data *td, struct fio_file *f,
                /*
                 * if we are not maintaining a random map, we are done.
                 */
                /*
                 * if we are not maintaining a random map, we are done.
                 */
-               if (td->o.norandommap)
+               if (!file_randommap(td, f))
                        return 0;
 
                /*
                        return 0;
 
                /*
@@ -416,7 +416,7 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u)
        /*
         * mark entry before potentially trimming io_u
         */
        /*
         * mark entry before potentially trimming io_u
         */
-       if (td_random(td) && !td->o.norandommap)
+       if (td_random(td) && file_randommap(td, io_u->file))
                mark_random_map(td, io_u);
 
        /*
                mark_random_map(td, io_u);
 
        /*