Add support for POSIX_FADV_STREAMID
authorJens Axboe <axboe@fb.com>
Tue, 24 Mar 2015 16:20:22 +0000 (10:20 -0600)
committerJens Axboe <axboe@fb.com>
Tue, 24 Mar 2015 16:20:22 +0000 (10:20 -0600)
Signed-off-by: Jens Axboe <axboe@fb.com>
HOWTO
fio.1
ioengines.c
options.c
os/os-linux.h
server.h
thread_options.h

diff --git a/HOWTO b/HOWTO
index f43f3ec34748e369350f00e9ea2b2b17250c1cd6..3f258db8cf94178da849d75d4a8fb4c028e5367f 100644 (file)
--- 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.
 
                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,
 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 3859753ded17edd6bb6c676ccd5915ce6606e334..0164f42b958a574f4340427b4e3b73a173e8e06d 100644 (file)
--- 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
 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,
 .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,
index 00098d6739daf8da3183476e98927395cba20e8c..b42e2c48c7a5d4fe9f660b49a136fc88b69aa06f 100644 (file)
@@ -468,6 +468,17 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f)
                        goto err;
                }
        }
                        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
        /*
 
 #ifdef FIO_OS_DIRECTIO
        /*
index ab6e399db5208d81689c0ec9752fa0a7e4adeda1..337fecdb54231fca391b837cf363f0552d03d84b 100644 (file)
--- 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,
        },
                .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",
        {
                .name   = "fsync",
                .lname  = "Fsync",
index e1936342bd54fceac5b61d765a86adfacfdcf970..b786393f77d9ed6e596de5b63d20b7b1707d9a51 100644 (file)
@@ -282,4 +282,10 @@ static inline int fio_set_sched_idle(void)
 }
 #endif
 
 }
 #endif
 
+#ifndef POSIX_FADV_STREAMID
+#define POSIX_FADV_STREAMID    8
+#endif
+
+#define FIO_HAVE_STREAMID
+
 #endif
 #endif
index dc5a69e82ad6821d96e7a7c5f9e5ca2d6b9524cd..da12ae0d10cb8fdee00933d279c8e3720db66214 100644 (file)
--- a/server.h
+++ b/server.h
@@ -38,7 +38,7 @@ struct fio_net_cmd_reply {
 };
 
 enum {
 };
 
 enum {
-       FIO_SERVER_VER                  = 42,
+       FIO_SERVER_VER                  = 43,
 
        FIO_SERVER_MAX_FRAGMENT_PDU     = 1024,
        FIO_SERVER_MAX_CMD_MB           = 2048,
 
        FIO_SERVER_MAX_FRAGMENT_PDU     = 1024,
        FIO_SERVER_MAX_CMD_MB           = 2048,
index 611f8e7376fab6eff15272bb08adb62ec09270ab..5a2428a41bb4c6b48971130d678e911de02c1e95 100644 (file)
@@ -178,6 +178,7 @@ struct thread_options {
        unsigned int file_service_type;
        unsigned int group_reporting;
        unsigned int fadvise_hint;
        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;
        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 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;
        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;
        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];
        fio_fp64_t percentile_list[FIO_IO_U_LIST_MAX_LEN];
 
        uint8_t read_iolog_file[FIO_TOP_STR_MAX];