From 8d916c942bb088204ab5c0438c297903c9160698 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 25 Apr 2013 10:11:41 -0600 Subject: [PATCH] Catch the case where size= is less than the minimum block size Fio will currently just attempt to start and immediately exit, with no clue as to what went wrong. The behaviour is correct in the sense that there's nothing to output, but it can be a little confusing. Signed-off-by: Jens Axboe --- fio.h | 8 ++++++++ init.c | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/fio.h b/fio.h index ebf6309b..5438b768 100644 --- a/fio.h +++ b/fio.h @@ -535,6 +535,14 @@ static inline unsigned int td_max_bs(struct thread_data *td) return max(td->o.max_bs[DDIR_TRIM], max_bs); } +static inline unsigned int td_min_bs(struct thread_data *td) +{ + unsigned int min_bs; + + min_bs = min(td->o.min_bs[DDIR_READ], td->o.min_bs[DDIR_WRITE]); + return min(td->o.min_bs[DDIR_TRIM], min_bs); +} + static inline int is_power_of_2(unsigned int val) { return (val != 0 && ((val & (val - 1)) == 0)); diff --git a/init.c b/init.c index b330925c..aba7671c 100644 --- a/init.c +++ b/init.c @@ -621,6 +621,14 @@ static int fixup_options(struct thread_data *td) if (td->o.random_distribution != FIO_RAND_DIST_RANDOM) td->o.norandommap = 1; + /* + * If size is set but less than the min block size, complain + */ + if (o->size && o->size < td_min_bs(td)) { + log_err("fio: size too small, must be larger than the IO size: %llu\n", (unsigned long long) o->size); + ret = 1; + } + return ret; } -- 2.25.1