Merge branch 'sgunmap2' of https://github.com/vincentkfu/fio
authorJens Axboe <axboe@kernel.dk>
Thu, 26 Jul 2018 17:47:28 +0000 (11:47 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 26 Jul 2018 17:47:28 +0000 (11:47 -0600)
* 'sgunmap2' of https://github.com/vincentkfu/fio:
  docs: update HOWTO and manpage for sg trim support
  testing: add test scripts for sg ioengine
  engines/sg: move asserts and debug statements behind a debug flag
  engines/sg: add cmdp and dxferp for trims to sg error string
  engines/sg: support trim operations via the UNMAP command
  stat: add IO submit and complete depths to JSON output
  ioengines: have ioengines with commit do own io accounting for trims

1  2 
ioengines.c
stat.c

diff --combined ioengines.c
index bce65ea3a68c2b3887af924a17dffaafd512e483,efefb0696e6cb14c70190c115fd81c2107d301ff..e5fbcd432ce78fb847148383ad03016966aab88d
@@@ -279,7 -279,7 +279,7 @@@ out
  enum fio_q_status td_io_queue(struct thread_data *td, struct io_u *io_u)
  {
        const enum fio_ddir ddir = acct_ddir(io_u);
 -      unsigned long buflen = io_u->xfer_buflen;
 +      unsigned long long buflen = io_u->xfer_buflen;
        enum fio_q_status ret;
  
        dprint_io_u(io_u, "queue");
                         "invalid block size. Try setting direct=0.\n");
        }
  
-       if (!td->io_ops->commit || io_u->ddir == DDIR_TRIM) {
+       if (!td->io_ops->commit) {
                io_u_mark_submit(td, 1);
                io_u_mark_complete(td, 1);
        }
diff --combined stat.c
index 8de48354b7715f97064ba9f3947fd9baf4d79e95,428590e795a7f8a9db2fa76ce06ff8b69e134165..82e79dfcf1885b7cbcf3e2ad1212be29e79877c2
--- 1/stat.c
--- 2/stat.c
+++ b/stat.c
@@@ -619,8 -619,8 +619,8 @@@ static int block_state_category(int blo
  
  static int compare_block_infos(const void *bs1, const void *bs2)
  {
 -      uint32_t block1 = *(uint32_t *)bs1;
 -      uint32_t block2 = *(uint32_t *)bs2;
 +      uint64_t block1 = *(uint64_t *)bs1;
 +      uint64_t block2 = *(uint64_t *)bs2;
        int state1 = BLOCK_INFO_STATE(block1);
        int state2 = BLOCK_INFO_STATE(block2);
        int bscat1 = block_state_category(state1);
@@@ -1295,13 -1295,8 +1295,8 @@@ static struct json_object *show_thread_
        json_object_add_value_int(root, "majf", ts->majf);
        json_object_add_value_int(root, "minf", ts->minf);
  
-       /* Calc % distribution of IO depths, usecond, msecond latency */
+       /* Calc % distribution of IO depths */
        stat_calc_dist(ts->io_u_map, ddir_rw_sum(ts->total_io_u), io_u_dist);
-       stat_calc_lat_n(ts, io_u_lat_n);
-       stat_calc_lat_u(ts, io_u_lat_u);
-       stat_calc_lat_m(ts, io_u_lat_m);
        tmp = json_create_object();
        json_object_add_value_object(root, "iodepth_level", tmp);
        /* Only show fixed 7 I/O depth levels*/
                json_object_add_value_float(tmp, (const char *)name, io_u_dist[i]);
        }
  
+       /* Calc % distribution of submit IO depths */
+       stat_calc_dist(ts->io_u_submit, ts->total_submit, io_u_dist);
+       tmp = json_create_object();
+       json_object_add_value_object(root, "iodepth_submit", tmp);
+       /* Only show fixed 7 I/O depth levels*/
+       for (i = 0; i < 7; i++) {
+               char name[20];
+               if (i == 0)
+                       snprintf(name, 20, "0");
+               else if (i < 6)
+                       snprintf(name, 20, "%d", 1 << (i+1));
+               else
+                       snprintf(name, 20, ">=%d", 1 << i);
+               json_object_add_value_float(tmp, (const char *)name, io_u_dist[i]);
+       }
+       /* Calc % distribution of completion IO depths */
+       stat_calc_dist(ts->io_u_complete, ts->total_complete, io_u_dist);
+       tmp = json_create_object();
+       json_object_add_value_object(root, "iodepth_complete", tmp);
+       /* Only show fixed 7 I/O depth levels*/
+       for (i = 0; i < 7; i++) {
+               char name[20];
+               if (i == 0)
+                       snprintf(name, 20, "0");
+               else if (i < 6)
+                       snprintf(name, 20, "%d", 1 << (i+1));
+               else
+                       snprintf(name, 20, ">=%d", 1 << i);
+               json_object_add_value_float(tmp, (const char *)name, io_u_dist[i]);
+       }
+       /* Calc % distribution of nsecond, usecond, msecond latency */
+       stat_calc_dist(ts->io_u_map, ddir_rw_sum(ts->total_io_u), io_u_dist);
+       stat_calc_lat_n(ts, io_u_lat_n);
+       stat_calc_lat_u(ts, io_u_lat_u);
+       stat_calc_lat_m(ts, io_u_lat_m);
        /* Nanosecond latency */
        tmp = json_create_object();
        json_object_add_value_object(root, "latency_ns", tmp);
@@@ -2220,7 -2253,7 +2253,7 @@@ static struct io_logs *get_cur_log(stru
  }
  
  static void __add_log_sample(struct io_log *iolog, union io_sample_data data,
 -                           enum fio_ddir ddir, unsigned int bs,
 +                           enum fio_ddir ddir, unsigned long long bs,
                             unsigned long t, uint64_t offset)
  {
        struct io_logs *cur_log;
@@@ -2338,7 -2371,7 +2371,7 @@@ static void _add_stat_to_log(struct io_
  static unsigned long add_log_sample(struct thread_data *td,
                                    struct io_log *iolog,
                                    union io_sample_data data,
 -                                  enum fio_ddir ddir, unsigned int bs,
 +                                  enum fio_ddir ddir, unsigned long long bs,
                                    uint64_t offset)
  {
        unsigned long elapsed, this_window;
@@@ -2400,7 -2433,7 +2433,7 @@@ void finalize_logs(struct thread_data *
                _add_stat_to_log(td->iops_log, elapsed, td->o.log_max != 0);
  }
  
 -void add_agg_sample(union io_sample_data data, enum fio_ddir ddir, unsigned int bs)
 +void add_agg_sample(union io_sample_data data, enum fio_ddir ddir, unsigned long long bs)
  {
        struct io_log *iolog;
  
@@@ -2430,8 -2463,7 +2463,8 @@@ static void add_clat_percentile_sample(
  }
  
  void add_clat_sample(struct thread_data *td, enum fio_ddir ddir,
 -                   unsigned long long nsec, unsigned int bs, uint64_t offset)
 +                   unsigned long long nsec, unsigned long long bs,
 +                   uint64_t offset)
  {
        unsigned long elapsed, this_window;
        struct thread_stat *ts = &td->ts;
  }
  
  void add_slat_sample(struct thread_data *td, enum fio_ddir ddir,
 -                   unsigned long usec, unsigned int bs, uint64_t offset)
 +                   unsigned long usec, unsigned long long bs, uint64_t offset)
  {
        struct thread_stat *ts = &td->ts;
  
  }
  
  void add_lat_sample(struct thread_data *td, enum fio_ddir ddir,
 -                  unsigned long long nsec, unsigned int bs, uint64_t offset)
 +                  unsigned long long nsec, unsigned long long bs,
 +                  uint64_t offset)
  {
        struct thread_stat *ts = &td->ts;
  
@@@ -2592,7 -2623,7 +2625,7 @@@ static int __add_samples(struct thread_
                add_stat_sample(&stat[ddir], rate);
  
                if (log) {
 -                      unsigned int bs = 0;
 +                      unsigned long long bs = 0;
  
                        if (td->o.min_bs[ddir] == td->o.max_bs[ddir])
                                bs = td->o.min_bs[ddir];