OOM fixes
[fio.git] / init.c
diff --git a/init.c b/init.c
index 62080f74949f09a9abbdb1ce2fa40ee2b9a7731d..bca8424a9e49348c05b99a272c9d96789b469559 100644 (file)
--- a/init.c
+++ b/init.c
@@ -997,6 +997,10 @@ int init_random_state(struct thread_data *td)
                        blocks = (f->real_file_size + td->rw_min_bs - 1) / td->rw_min_bs;
                        num_maps = (blocks + BLOCKS_PER_MAP-1)/ BLOCKS_PER_MAP;
                        f->file_map = malloc(num_maps * sizeof(long));
                        blocks = (f->real_file_size + td->rw_min_bs - 1) / td->rw_min_bs;
                        num_maps = (blocks + BLOCKS_PER_MAP-1)/ BLOCKS_PER_MAP;
                        f->file_map = malloc(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;
+                       }
                        f->num_maps = num_maps;
                        memset(f->file_map, 0, num_maps * sizeof(long));
                }
                        f->num_maps = num_maps;
                        memset(f->file_map, 0, num_maps * sizeof(long));
                }