sync: add support for write life time hint
authorJens Axboe <axboe@kernel.dk>
Wed, 14 Jun 2017 15:55:40 +0000 (09:55 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 14 Jun 2017 15:55:40 +0000 (09:55 -0600)
Not documented yet, as the interface may change. This matches
what I currently have implemented on the kernel side.

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

index e76bbbb49e237b807c855d74dd0e40995ef7c0ad..69d5e2156c34c7ae25c2a6b0fefc434169319320 100644 (file)
@@ -36,6 +36,7 @@ struct syncio_data {
 struct psyncv2_options {
        void *pad;
        unsigned int hipri;
+       unsigned int stream;
 };
 
 static struct fio_option options[] = {
@@ -48,6 +49,29 @@ static struct fio_option options[] = {
                .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,
        },
@@ -134,6 +158,8 @@ static int fio_pvsyncio2_queue(struct thread_data *td, struct io_u *io_u)
 
        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;
index 008ce2d0af1c15e78d0bcf19574f5d0ba0a0df02..09e741353826545933aa277d5eb0acdba91ff210 100644 (file)
@@ -319,6 +319,14 @@ static inline int fio_set_sched_idle(void)
 #define RWF_SYNC       0x00000004
 #endif
 
+#ifndef RWF_WRITE_LIFE_SHIFT
+#define RWF_WRITE_LIFE_SHIFT           4
+#define RWF_WRITE_LIFE_SHORT           (1 << RWF_WRITE_LIFE_SHIFT)
+#define RWF_WRITE_LIFE_MEDIUM          (2 << RWF_WRITE_LIFE_SHIFT)
+#define RWF_WRITE_LIFE_LONG            (3 << RWF_WRITE_LIFE_SHIFT)
+#define RWF_WRITE_LIFE_EXTREME         (4 << RWF_WRITE_LIFE_SHIFT)
+#endif
+
 #ifndef CONFIG_PWRITEV2
 #ifdef __NR_preadv2
 static inline void make_pos_h_l(unsigned long *pos_h, unsigned long *pos_l,