From 690adba373bb8c97a365c67da369e265953c4b4c Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 30 Oct 2006 15:25:09 +0100 Subject: [PATCH] [PATCH] Add 'bs_unaligned' option If this is specified with 'bsrange', fio will use any byte size value in the bs range for an io unit buffer length. Normally fio defaults to using a multiple of the minimum bs size, as that is required for any type of raw io. Signed-off-by: Jens Axboe --- HOWTO | 6 +++++- fio.h | 1 + init.c | 13 ++++++++++--- io_u.c | 3 ++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/HOWTO b/HOWTO index 6d215ac5..79d31dff 100644 --- a/HOWTO +++ b/HOWTO @@ -223,7 +223,11 @@ bs=siint The block size used for the io units. Defaults to 4k. bsrange=irange Instead of giving a single block size, specify a range and fio will mix the issued io block sizes. The issued io unit will always be a multiple of the minimum value - given. + given (also see bs_unaligned). + +bs_unaligned If this option is given, any byte size value within bsrange + may be used as a block range. This typically wont work with + direct IO, as that normally requires sector alignment. nrfiles=int Number of files to use for this job. Defaults to 1. diff --git a/fio.h b/fio.h index b48ef70a..b30dec59 100644 --- a/fio.h +++ b/fio.h @@ -203,6 +203,7 @@ struct thread_data { unsigned int write_lat_log; unsigned int write_bw_log; unsigned int norandommap; + unsigned int bs_unaligned; unsigned int bs; unsigned int min_bs; diff --git a/init.c b/init.c index e4f866a3..6ad3c64c 100644 --- a/init.c +++ b/init.c @@ -348,6 +348,11 @@ static struct fio_option options[] = { .type = FIO_OPT_STR_SET, .off1 = td_var_offset(norandommap), }, + { + .name = "bs_unaligned", + .type = FIO_OPT_STR_SET, + .off1 = td_var_offset(bs_unaligned), + }, { .name = NULL, }, @@ -490,6 +495,8 @@ static void fixup_options(struct thread_data *td) log_err("fio: norandommap given, verify disabled\n"); td->verify = VERIFY_NONE; } + if (td->bs_unaligned && (td->odirect || td->io_ops->flags & FIO_RAWIO)) + log_err("fio: bs_unaligned may not work with raw io\n"); } /* @@ -535,6 +542,9 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) } } + if (td->odirect) + td->io_ops->flags |= FIO_RAWIO; + fixup_options(td); td->filetype = FIO_TYPE_FILE; @@ -545,9 +555,6 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) td->filetype = FIO_TYPE_CHAR; } - if (td->odirect) - td->io_ops->flags |= FIO_RAWIO; - if (td->filename) td->nr_uniq_files = 1; else diff --git a/io_u.c b/io_u.c index 04320794..3000ea7a 100644 --- a/io_u.c +++ b/io_u.c @@ -121,7 +121,8 @@ static unsigned int get_next_buflen(struct thread_data *td) else { r = os_random_long(&td->bsrange_state); buflen = (1 + (double) (td->max_bs - 1) * r / (RAND_MAX + 1.0)); - buflen = (buflen + td->min_bs - 1) & ~(td->min_bs - 1); + if (!td->bs_unaligned) + buflen = (buflen + td->min_bs - 1) & ~(td->min_bs - 1); } if (buflen > td->io_size - td->this_io_bytes[td->ddir]) { -- 2.25.1