[PATCH] Add 'bs_unaligned' option
authorJens Axboe <jens.axboe@oracle.com>
Mon, 30 Oct 2006 14:25:09 +0000 (15:25 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 30 Oct 2006 14:25:09 +0000 (15:25 +0100)
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 <jens.axboe@oracle.com>
HOWTO
fio.h
init.c
io_u.c

diff --git a/HOWTO b/HOWTO
index 6d215ac5378db68e6406182f9ff4c8e21c8b7dfb..79d31dffde05e8002397b0771f2c87193f293c09 100644 (file)
--- 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
 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.
 
 
 nrfiles=int    Number of files to use for this job. Defaults to 1.
 
diff --git a/fio.h b/fio.h
index b48ef70a4a8f151518c0b78e2c6f8861b3d7d790..b30dec59c7244e357fe5371416159b8812575922 100644 (file)
--- 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 write_lat_log;
        unsigned int write_bw_log;
        unsigned int norandommap;
+       unsigned int bs_unaligned;
 
        unsigned int bs;
        unsigned int min_bs;
 
        unsigned int bs;
        unsigned int min_bs;
diff --git a/init.c b/init.c
index e4f866a3bc883151372b9b9b3bfd528ee7477775..6ad3c64c4221124d779ae982ac3b96ee12ced5bc 100644 (file)
--- 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),
        },
                .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,
        },
        {
                .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;
        }
                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;
        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;
        }
 
                        td->filetype = FIO_TYPE_CHAR;
        }
 
-       if (td->odirect)
-               td->io_ops->flags |= FIO_RAWIO;
-
        if (td->filename)
                td->nr_uniq_files = 1;
        else
        if (td->filename)
                td->nr_uniq_files = 1;
        else
diff --git a/io_u.c b/io_u.c
index 04320794337454c3b5b2e0bdae115fd613273e42..3000ea7a96c1c93f11969836b35718d9375c4c7d 100644 (file)
--- 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));
        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]) {
        }
 
        if (buflen > td->io_size - td->this_io_bytes[td->ddir]) {