From 303032ae4e13c7ac10b8198c40df98d95a4524a6 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 26 Mar 2008 10:11:10 +0100 Subject: [PATCH] Allow randommap allocation to fail It's not that critical, so just print a warning and continue without randommap. Signed-off-by: Jens Axboe --- filesetup.c | 13 +++++++------ fio.h | 1 + io_u.c | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/filesetup.c b/filesetup.c index 4774d842..6c5770b4 100644 --- a/filesetup.c +++ b/filesetup.c @@ -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)); - 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; diff --git a/fio.h b/fio.h index 34f02d69..55717c79 100644 --- 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 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) { diff --git a/io_u.c b/io_u.c index 1e60eee5..7a23d2cf 100644 --- 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 (td->o.norandommap) + if (!file_randommap(td, f)) 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 */ - if (td_random(td) && !td->o.norandommap) + if (td_random(td) && file_randommap(td, io_u->file)) mark_random_map(td, io_u); /* -- 2.25.1