The following changes since commit c0e75abff75f2fd11107c9da7c34f9265b6303e1: Fix compile warning on platforms with posix_fallocate (2010-10-14 14:34:05 +0200) are available in the git repository at: git://git.kernel.dk/fio.git master Jens Axboe (1): Fix segfault when passing in size < block_size io_u.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-) --- Diff of recent changes: diff --git a/io_u.c b/io_u.c index 6d539a0..8cc348a 100644 --- a/io_u.c +++ b/io_u.c @@ -126,16 +126,20 @@ static unsigned long long last_block(struct thread_data *td, struct fio_file *f, static int get_next_free_block(struct thread_data *td, struct fio_file *f, enum fio_ddir ddir, unsigned long long *b) { - unsigned long long min_bs = td->o.rw_min_bs; + unsigned long long min_bs = td->o.rw_min_bs, lastb; int i; + lastb = last_block(td, f, ddir); + if (!lastb) + return 1; + i = f->last_free_lookup; *b = (i * BLOCKS_PER_MAP); while ((*b) * min_bs < f->real_file_size && (*b) * min_bs < f->io_size) { if (f->file_map[i] != (unsigned int) -1) { *b += ffz(f->file_map[i]); - if (*b > last_block(td, f, ddir)) + if (*b > lastb) break; f->last_free_lookup = i; return 0; @@ -152,14 +156,17 @@ static int get_next_free_block(struct thread_data *td, struct fio_file *f, static int get_next_rand_offset(struct thread_data *td, struct fio_file *f, enum fio_ddir ddir, unsigned long long *b) { - unsigned long long r; + unsigned long long r, lastb; int loops = 5; + lastb = last_block(td, f, ddir); + if (!lastb) + return 1; + do { r = os_random_long(&td->random_state); dprint(FD_RANDOM, "off rand %llu\n", r); - *b = (last_block(td, f, ddir) - 1) - * (r / ((unsigned long long) OS_RAND_MAX + 1.0)); + *b = (lastb - 1) * (r / ((unsigned long long) OS_RAND_MAX + 1.0)); /* * if we are not maintaining a random map, we are done. -- To unsubscribe from this list: send the line "unsubscribe fio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html