Writing an amount of data less than capacity at random to offsets from whole address range
Hello,
how can I nudge fio to write a certain amount of data (less than capacity of block device) to randomly generated offsets covering the whole address space of a block device (e.g. MD RAID device)?
Using the size parameter yields offsets from 0 to size (thus, not covering the whole address range). Using a time based job leads to the desired result, but I would like two write a defined amount of data. I have already tried this with fio 2.0.14, 2.1.6.1, 2.1.17, and 2.1.18 without success. I am using Gentoo Linux with kernel 3.13.6 and libaio 0.3.109. The job description looks as follows:
######################
[global]
name=rw-04k
ioengine=libaio
iodepth=512
direct=1
continue_on_error=1
rw=randwrite
norandommap
filename=/dev/md9
bs=4k
ba=4k
numjobs=1
stonewall
size=1G
[rand-writes-04k]
#####################
Thanks,
Nikolaus
Signature · 4 lines
Dipl.-Inf. Nikolaus Jeremic [email protected] Universitaet Rostock Tel: (+49) 381 / 498 - 7635 Albert-Einstein-Str. 22 Fax: (+49) 381 / 498 - 7482 18059 Rostock, Germany wwwava.informatik.uni-rostock.de
Quoted 6 lines · Nikolaus Jeremic
Hello,
how can I nudge fio to write a certain amount of data (less than capacity of block device) to randomly generated offsets covering the whole address space of a block device (e.g. MD RAID device)?
Quoted 6 lines
Using the size parameter yields offsets from 0 to size (thus, not covering the whole address range). Using a time based job leads to the desired result, but I would like two write a defined amount of data. I have already tried this with fio 2.0.14, 2.1.6.1, 2.1.17, and 2.1.18 without success. I am using Gentoo Linux with kernel 3.13.6 and libaio 0.3.109. The job description looks as follows:
Fio doesn't currently support that. Can you try the attached? It adds an option to separately define an io limit, io_limit. If io_limit is not set, size= behaves as it did before: if you don't give a size, size is defined by the files added. With this patch, if you do
filename=/dev/md9
size=40g
fio would read 40g between 0..40G
If you do:
filename=/dev/md9
fio would access the entire device.
If you do:
filename=/dev/md9
io_limit=10g
fio would access the entire device, quit when 10G of IO was done. Etc.
Signature · 1 line
Jens Axboe
backend.c +16 -4
@@ -641,7 +641,7 @@ static unsigned int exceeds_number_ios(struct thread_data *td)static int io_bytes_exceeded (struct thread_data *td) { -unsigned long long bytes; +unsigned long long bytes, limit;if (td_rw (td)) bytes = td->this_io_bytes[DDIR_READ ] + td->this_io_bytes[DDIR_WRITE ];
@@ -652,7 +652,12 @@ static int io_bytes_exceeded(struct thread_data *td)else bytes = td->this_io_bytes[DDIR_TRIM ]; -return bytes >= td->o.size ||exceeds_number_ios (td); +if (td->o.io_limit) + limit = td->o.io_limit; +else + limit = td->o.size; + +return bytes >= limit ||exceeds_number_ios (td); }/*
@@ -1137,6 +1142,8 @@ static int switch_ioscheduler(struct thread_data *td)static int keep_running (struct thread_data *td) { +unsigned long long limit; +if (td->done)return 0 ;if (td->o.time_based)
@@ -1148,14 +1155,19 @@ static int keep_running(struct thread_data *td)if (exceeds_number_ios (td))return 0 ; -if (td->o.size !=-1ULL &&ddir_rw_sum (td->io_bytes) < td->o.size) { +if (td->o.io_limit) + limit = td->o.io_limit; +else + limit = td->o.size; + +if (limit !=-1ULL &&ddir_rw_sum (td->io_bytes) < limit) {uint64_t diff;/* * If the difference is less than the minimum IO size, we * are done. */ - diff = td->o.size -ddir_rw_sum (td->io_bytes); + diff = limit -ddir_rw_sum (td->io_bytes);if (diff <td_max_bs (td))return 0 ;
cconv.c +2 -0
@@ -77,6 +77,7 @@ void convert_thread_options_to_cpu(struct thread_options *o, o->iodepth_batch =le32_to_cpu (top->iodepth_batch); o->iodepth_batch_complete =le32_to_cpu (top->iodepth_batch_complete); o->size =le64_to_cpu (top->size); + o->io_limit =le64_to_cpu (top->io_limit); o->size_percent =le32_to_cpu (top->size_percent); o->fill_device =le32_to_cpu (top->fill_device); o->file_append =le32_to_cpu (top->file_append);
@@ -425,6 +426,7 @@ void convert_thread_options_to_net(struct thread_options_pack *top,memcpy (top->buffer_pattern, o->buffer_pattern,MAX_PATTERN_SIZE ); top->size =__cpu_to_le64 (o->size); + top->io_limit =__cpu_to_le64 (o->io_limit); top->verify_backlog =__cpu_to_le64 (o->verify_backlog); top->start_delay =__cpu_to_le64 (o->start_delay); top->start_delay_high =__cpu_to_le64 (o->start_delay_high);
filesetup.c +6 -2
@@ -939,8 +939,12 @@ int setup_files(struct thread_data *td)* iolog already set the total io size, if we read back * stored entries. */ -if (!o->read_iolog_file) - td->total_io_size = o->size * o->loops; +if (!o->read_iolog_file) { +if (o->io_limit) + td->total_io_size = o->io_limit * o->loops; +else + td->total_io_size = o->size * o->loops; + } done:if (o->create_only)
options.c +9 -0
@@ -1595,6 +1595,15 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .group = FIO_OPT_G_INVALID, }, { + .name = "io_limit", + .lname = "IO Limit", + .type = FIO_OPT_STR_VAL, + .off1 = td_var_offset(io_limit), + .interval = 1024 * 1024, + .category = FIO_OPT_C_IO, + .group = FIO_OPT_G_INVALID, + }, + { .name = "fill_device", .lname = "Fill device", .alias = "fill_fs",
server.h +1 -1
@@ -38,7 +38,7 @@ struct fio_net_cmd_reply { };enum { -FIO_SERVER_VER =33 , +FIO_SERVER_VER =34 ,FIO_SERVER_MAX_FRAGMENT_PDU =1024 ,FIO_SERVER_MAX_CMD_MB =2048 ,
thread_options.h +2 -0
@@ -52,6 +52,7 @@ struct thread_options {unsigned int iodepth_batch_complete;unsigned long long size; +unsigned long long io_limit;unsigned int size_percent;unsigned int fill_device;unsigned int file_append;
@@ -280,6 +281,7 @@ struct thread_options_pack {uint32_t iodepth_batch_complete;uint64_t size; +uint64_t io_limit;uint32_t size_percent;uint32_t fill_device;uint32_t file_append;
Hello,
first of all, thank you very much. It works very well. I would be grateful if you could add this option to the next fio release.
Thanks,
Nikolaus
Am 14.04.2014 22:11, schrieb Jens Axboe:
Quoted 37 lines · Nikolaus Jeremic
Quoted 6 lines
Hello,
how can I nudge fio to write a certain amount of data (less than capacity of block device) to randomly generated offsets covering the whole address space of a block device (e.g. MD RAID device)?
Quoted 6 lines
Using the size parameter yields offsets from 0 to size (thus, not covering the whole address range). Using a time based job leads to the desired result, but I would like two write a defined amount of data. I have already tried this with fio 2.0.14, 2.1.6.1, 2.1.17, and 2.1.18 without success. I am using Gentoo Linux with kernel 3.13.6 and libaio 0.3.109. The job description looks as follows:
Fio doesn't currently support that. Can you try the attached? It adds an option to separately define an io limit,
io_limit. Ifio_limitis not set, size= behaves as it did before: if you don't give a size, size is defined by the files added. With this patch, if you dofilename=/dev/md9
size=40gfio would read 40g between 0..40G
If you do:
filename=/dev/md9
fio would access the entire device.
If you do:
filename=/dev/md9
io_limit=10gfio would access the entire device, quit when 10G of IO was done. Etc.
Signature · 4 lines
Dipl.-Inf. Nikolaus Jeremic [email protected] Universitaet Rostock Tel: (+49) 381 / 498 - 7635 Albert-Einstein-Str. 22 Fax: (+49) 381 / 498 - 7482 18059 Rostock, Germany wwwava.informatik.uni-rostock.de
Quoted 5 lines · Nikolaus Jeremic
Hello,
first of all, thank you very much. It works very well. I would be grateful if you could add this option to the next fio release.
It has been committed, so it will be available going forward.
Signature · 1 line
Jens Axboe