From 37659335ac616d7c13bf8bfbb76366424b50ea67 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 24 Mar 2015 10:20:22 -0600 Subject: [PATCH] Add support for POSIX_FADV_STREAMID Signed-off-by: Jens Axboe --- HOWTO | 4 ++++ fio.1 | 5 +++++ ioengines.c | 11 +++++++++++ options.c | 11 +++++++++++ os/os-linux.h | 6 ++++++ server.h | 2 +- thread_options.h | 3 ++- 7 files changed, 40 insertions(+), 2 deletions(-) diff --git a/HOWTO b/HOWTO index f43f3ec3..3f258db8 100644 --- a/HOWTO +++ b/HOWTO @@ -460,6 +460,10 @@ fadvise_hint=bool By default, fio will use fadvise() to advise the kernel If set, fio will use POSIX_FADV_SEQUENTIAL for sequential IO and POSIX_FADV_RANDOM for random IO. +fadvise_stream=int Notify the kernel what write stream ID to place these + writes under. Only supported on Linux. Note, this option + may change going forward. + size=int The total size of file io for this job. Fio will run until this many bytes has been transferred, unless runtime is limited by other options (such as 'runtime', for instance, diff --git a/fio.1 b/fio.1 index 3859753d..0164f42b 100644 --- a/fio.1 +++ b/fio.1 @@ -378,6 +378,11 @@ because ZFS doesn't support it. Default: 'posix'. Use \fBposix_fadvise\fR\|(2) to advise the kernel what I/O patterns are likely to be issued. Default: true. .TP +.BI fadvise_stream \fR=\fPint +Use \fBposix_fadvise\fR\|(2) to advise the kernel what stream ID the +writes issued belong to. Only supported on Linux. Note, this option +may change going forward. +.TP .BI size \fR=\fPint Total size of I/O for this job. \fBfio\fR will run until this many bytes have been transferred, unless limited by other options (\fBruntime\fR, for instance, diff --git a/ioengines.c b/ioengines.c index 00098d67..b42e2c48 100644 --- a/ioengines.c +++ b/ioengines.c @@ -468,6 +468,17 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f) goto err; } } +#ifdef FIO_HAVE_STREAMID + if (td->o.fadvise_stream && + (f->filetype == FIO_TYPE_BD || f->filetype == FIO_TYPE_FILE)) { + off_t stream = td->o.fadvise_stream; + + if (posix_fadvise(f->fd, stream, f->io_size, POSIX_FADV_STREAMID) < 0) { + td_verror(td, errno, "fadvise streamid"); + goto err; + } + } +#endif #ifdef FIO_OS_DIRECTIO /* diff --git a/options.c b/options.c index ab6e399d..337fecdb 100644 --- a/options.c +++ b/options.c @@ -2005,6 +2005,17 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .category = FIO_OPT_C_FILE, .group = FIO_OPT_G_INVALID, }, +#ifdef FIO_HAVE_STREAMID + { + .name = "fadvise_stream", + .lname = "Fadvise stream", + .type = FIO_OPT_INT, + .off1 = td_var_offset(fadvise_stream), + .help = "Use fadvise() to set stream ID", + .category = FIO_OPT_C_FILE, + .group = FIO_OPT_G_INVALID, + }, +#endif { .name = "fsync", .lname = "Fsync", diff --git a/os/os-linux.h b/os/os-linux.h index e1936342..b786393f 100644 --- a/os/os-linux.h +++ b/os/os-linux.h @@ -282,4 +282,10 @@ static inline int fio_set_sched_idle(void) } #endif +#ifndef POSIX_FADV_STREAMID +#define POSIX_FADV_STREAMID 8 +#endif + +#define FIO_HAVE_STREAMID + #endif diff --git a/server.h b/server.h index dc5a69e8..da12ae0d 100644 --- a/server.h +++ b/server.h @@ -38,7 +38,7 @@ struct fio_net_cmd_reply { }; enum { - FIO_SERVER_VER = 42, + FIO_SERVER_VER = 43, FIO_SERVER_MAX_FRAGMENT_PDU = 1024, FIO_SERVER_MAX_CMD_MB = 2048, diff --git a/thread_options.h b/thread_options.h index 611f8e73..5a2428a4 100644 --- a/thread_options.h +++ b/thread_options.h @@ -178,6 +178,7 @@ struct thread_options { unsigned int file_service_type; unsigned int group_reporting; unsigned int fadvise_hint; + unsigned int fadvise_stream; enum fio_fallocate_mode fallocate_mode; unsigned int zero_buffers; unsigned int refill_buffers; @@ -401,6 +402,7 @@ struct thread_options_pack { uint32_t file_service_type; uint32_t group_reporting; uint32_t fadvise_hint; + uint32_t fadvise_stream; uint32_t fallocate_mode; uint32_t zero_buffers; uint32_t refill_buffers; @@ -426,7 +428,6 @@ struct thread_options_pack { uint64_t trim_backlog; uint32_t clat_percentiles; uint32_t percentile_precision; - uint32_t pad2; fio_fp64_t percentile_list[FIO_IO_U_LIST_MAX_LEN]; uint8_t read_iolog_file[FIO_TOP_STR_MAX]; -- 2.25.1