Update write_hint mechanism to latest API
authorJens Axboe <axboe@kernel.dk>
Mon, 19 Jun 2017 16:31:11 +0000 (10:31 -0600)
committerJens Axboe <axboe@kernel.dk>
Mon, 19 Jun 2017 16:31:11 +0000 (10:31 -0600)
Kill the fadvise stream stuff, we never used it. Also dump the
pvsync2 options.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
cconv.c
engines/sync.c
ioengines.c
options.c
os/os-linux.h
server.h
thread_options.h

diff --git a/cconv.c b/cconv.c
index bf4c5175fa4c7bbe09eeb4dcbe099d46f4e3d913..b8d9ddca77c02d549174a99f33fc886719f5ee87 100644 (file)
--- a/cconv.c
+++ b/cconv.c
@@ -156,6 +156,7 @@ void convert_thread_options_to_cpu(struct thread_options *o,
        o->end_fsync = le32_to_cpu(top->end_fsync);
        o->pre_read = le32_to_cpu(top->pre_read);
        o->sync_io = le32_to_cpu(top->sync_io);
        o->end_fsync = le32_to_cpu(top->end_fsync);
        o->pre_read = le32_to_cpu(top->pre_read);
        o->sync_io = le32_to_cpu(top->sync_io);
+       o->write_hint = le32_to_cpu(top->write_hint);
        o->verify = le32_to_cpu(top->verify);
        o->do_verify = le32_to_cpu(top->do_verify);
        o->verifysort = le32_to_cpu(top->verifysort);
        o->verify = le32_to_cpu(top->verify);
        o->do_verify = le32_to_cpu(top->do_verify);
        o->verifysort = le32_to_cpu(top->verifysort);
@@ -365,6 +366,7 @@ void convert_thread_options_to_net(struct thread_options_pack *top,
        top->end_fsync = cpu_to_le32(o->end_fsync);
        top->pre_read = cpu_to_le32(o->pre_read);
        top->sync_io = cpu_to_le32(o->sync_io);
        top->end_fsync = cpu_to_le32(o->end_fsync);
        top->pre_read = cpu_to_le32(o->pre_read);
        top->sync_io = cpu_to_le32(o->sync_io);
+       top->write_hint = cpu_to_le32(o->write_hint);
        top->verify = cpu_to_le32(o->verify);
        top->do_verify = cpu_to_le32(o->do_verify);
        top->verifysort = cpu_to_le32(o->verifysort);
        top->verify = cpu_to_le32(o->verify);
        top->do_verify = cpu_to_le32(o->do_verify);
        top->verifysort = cpu_to_le32(o->verifysort);
index 69d5e2156c34c7ae25c2a6b0fefc434169319320..e76bbbb49e237b807c855d74dd0e40995ef7c0ad 100644 (file)
@@ -36,7 +36,6 @@ struct syncio_data {
 struct psyncv2_options {
        void *pad;
        unsigned int hipri;
 struct psyncv2_options {
        void *pad;
        unsigned int hipri;
-       unsigned int stream;
 };
 
 static struct fio_option options[] = {
 };
 
 static struct fio_option options[] = {
@@ -49,29 +48,6 @@ static struct fio_option options[] = {
                .category = FIO_OPT_C_ENGINE,
                .group  = FIO_OPT_G_INVALID,
        },
                .category = FIO_OPT_C_ENGINE,
                .group  = FIO_OPT_G_INVALID,
        },
-       {
-               .name   = "stream",
-               .lname  = "Stream ID",
-               .type   = FIO_OPT_STR,
-               .off1   = offsetof(struct psyncv2_options, stream),
-               .help   = "Set expected write life time",
-               .category = FIO_OPT_C_ENGINE,
-               .group  = FIO_OPT_G_INVALID,
-               .posval = {
-                         { .ival = "short",
-                           .oval = RWF_WRITE_LIFE_SHORT,
-                         },
-                         { .ival = "medium",
-                           .oval = RWF_WRITE_LIFE_MEDIUM,
-                         },
-                         { .ival = "long",
-                           .oval = RWF_WRITE_LIFE_LONG,
-                         },
-                         { .ival = "extreme",
-                           .oval = RWF_WRITE_LIFE_EXTREME,
-                         },
-               },
-       },
        {
                .name   = NULL,
        },
        {
                .name   = NULL,
        },
@@ -158,8 +134,6 @@ static int fio_pvsyncio2_queue(struct thread_data *td, struct io_u *io_u)
 
        if (o->hipri)
                flags |= RWF_HIPRI;
 
        if (o->hipri)
                flags |= RWF_HIPRI;
-       if (o->stream)
-               flags |= o->stream;
 
        iov->iov_base = io_u->xfer_buf;
        iov->iov_len = io_u->xfer_buflen;
 
        iov->iov_base = io_u->xfer_buf;
        iov->iov_len = io_u->xfer_buflen;
index c90a2ca5bde30e75dec5261130b6b77fb6a1999b..2d55065bb3e5e2b4c2dc5c72f6d6cad2dc0dcd7f 100644 (file)
@@ -472,13 +472,13 @@ 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 &&
+#ifdef FIO_HAVE_WRITE_HINT
+       if (fio_option_is_set(&td->o, write_hint) &&
            (f->filetype == FIO_TYPE_BLOCK || f->filetype == FIO_TYPE_FILE)) {
            (f->filetype == FIO_TYPE_BLOCK || f->filetype == FIO_TYPE_FILE)) {
-               off_t stream = td->o.fadvise_stream;
+               uint64_t hint = td->o.write_hint;
 
 
-               if (posix_fadvise(f->fd, stream, f->io_size, POSIX_FADV_STREAMID) < 0) {
-                       td_verror(td, errno, "fadvise streamid");
+               if (fcntl(f->fd, F_SET_RW_HINT, &hint) < 0) {
+                       td_verror(td, errno, "fcntl write hint");
                        goto err;
                }
        }
                        goto err;
                }
        }
index 6d799bfe0e67871f5b3345148f0cc525a5624916..a8fdde448bdaa4ded1d022a28a0d517d19217ae5 100644 (file)
--- a/options.c
+++ b/options.c
@@ -2355,24 +2355,6 @@ 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   = offsetof(struct thread_options, fadvise_stream),
-               .help   = "Use fadvise() to set stream ID",
-               .category = FIO_OPT_C_FILE,
-               .group  = FIO_OPT_G_INVALID,
-       },
-#else
-       {
-               .name   = "fadvise_stream",
-               .lname  = "Fadvise stream",
-               .type   = FIO_OPT_UNSUPPORTED,
-               .help   = "Your platform does not support fadvise stream ID",
-       },
-#endif
        {
                .name   = "fsync",
                .lname  = "Fsync",
        {
                .name   = "fsync",
                .lname  = "Fsync",
@@ -3434,6 +3416,34 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .category = FIO_OPT_C_IO,
                .group  = FIO_OPT_G_IO_TYPE,
        },
                .category = FIO_OPT_C_IO,
                .group  = FIO_OPT_G_IO_TYPE,
        },
+#ifdef FIO_HAVE_WRITE_HINT
+       {
+               .name   = "write_hint",
+               .lname  = "Write hint",
+               .type   = FIO_OPT_STR,
+               .off1   = offsetof(struct thread_options, write_hint),
+               .help   = "Set expected write life time",
+               .category = FIO_OPT_C_ENGINE,
+               .group  = FIO_OPT_G_INVALID,
+               .posval = {
+                         { .ival = "none",
+                           .oval = RWH_WRITE_LIFE_NONE,
+                         },
+                         { .ival = "short",
+                           .oval = RWH_WRITE_LIFE_SHORT,
+                         },
+                         { .ival = "medium",
+                           .oval = RWH_WRITE_LIFE_MEDIUM,
+                         },
+                         { .ival = "long",
+                           .oval = RWH_WRITE_LIFE_LONG,
+                         },
+                         { .ival = "extreme",
+                           .oval = RWH_WRITE_LIFE_EXTREME,
+                         },
+               },
+       },
+#endif
        {
                .name   = "create_serialize",
                .lname  = "Create serialize",
        {
                .name   = "create_serialize",
                .lname  = "Create serialize",
index 09e741353826545933aa277d5eb0acdba91ff210..3e7a2fc3303639564d47e06595c932f3b6322fb2 100644 (file)
@@ -303,11 +303,23 @@ static inline int fio_set_sched_idle(void)
 }
 #endif
 
 }
 #endif
 
-#ifndef POSIX_FADV_STREAMID
-#define POSIX_FADV_STREAMID    8
+#ifndef F_GET_RW_HINT
+#ifndef F_LINUX_SPECIFIC_BASE
+#define F_LINUX_SPECIFIC_BASE  1024
+#endif
+#define F_GET_RW_HINT          (F_LINUX_SPECIFIC_BASE + 11)
+#define F_SET_RW_HINT          (F_LINUX_SPECIFIC_BASE + 12)
+#endif
+
+#ifndef RWH_WRITE_LIFE_NONE
+#define RWH_WRITE_LIFE_NONE    0
+#define RWH_WRITE_LIFE_SHORT   1
+#define RWH_WRITE_LIFE_MEDIUM  2
+#define RWH_WRITE_LIFE_LONG    3
+#define RWH_WRITE_LIFE_EXTREME 4
 #endif
 
 #endif
 
-#define FIO_HAVE_STREAMID
+#define FIO_HAVE_WRITE_HINT
 
 #ifndef RWF_HIPRI
 #define RWF_HIPRI      0x00000001
 
 #ifndef RWF_HIPRI
 #define RWF_HIPRI      0x00000001
index fff680405d2a7220e904c8d3714f337d9e4c4059..f002f3bdec016fdbf8b1226b4749a85fe5f8d94b 100644 (file)
--- a/server.h
+++ b/server.h
@@ -49,7 +49,7 @@ struct fio_net_cmd_reply {
 };
 
 enum {
 };
 
 enum {
-       FIO_SERVER_VER                  = 62,
+       FIO_SERVER_VER                  = 63,
 
        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 493e92ec2ae36e9cfa9aca95129bdf5057cb2681..72d86cfe49f7022c64006a2c7c7421c47f1eba11 100644 (file)
@@ -102,6 +102,7 @@ struct thread_options {
        unsigned int end_fsync;
        unsigned int pre_read;
        unsigned int sync_io;
        unsigned int end_fsync;
        unsigned int pre_read;
        unsigned int sync_io;
+       unsigned int write_hint;
        unsigned int verify;
        unsigned int do_verify;
        unsigned int verifysort;
        unsigned int verify;
        unsigned int do_verify;
        unsigned int verifysort;
@@ -376,6 +377,7 @@ struct thread_options_pack {
        uint32_t end_fsync;
        uint32_t pre_read;
        uint32_t sync_io;
        uint32_t end_fsync;
        uint32_t pre_read;
        uint32_t sync_io;
+       uint32_t write_hint;
        uint32_t verify;
        uint32_t do_verify;
        uint32_t verifysort;
        uint32_t verify;
        uint32_t do_verify;
        uint32_t verifysort;
@@ -417,6 +419,7 @@ struct thread_options_pack {
 
        uint32_t random_distribution;
        uint32_t exitall_error;
 
        uint32_t random_distribution;
        uint32_t exitall_error;
+       uint32_t pad;
 
        struct zone_split zone_split[DDIR_RWDIR_CNT][ZONESPLIT_MAX];
        uint32_t zone_split_nr[DDIR_RWDIR_CNT];
 
        struct zone_split zone_split[DDIR_RWDIR_CNT][ZONESPLIT_MAX];
        uint32_t zone_split_nr[DDIR_RWDIR_CNT];