change fio_set_odirect() prototype not to use int fd
[fio.git] / stat.c
diff --git a/stat.c b/stat.c
index b3b2cb35445259dc84b9bfeea81def9a8cdc64e7..91c74abef420f8fb0e8453e5a9be1fecff1e6f56 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -100,7 +100,8 @@ static unsigned int plat_val_to_idx(unsigned long long val)
  */
 static unsigned long long plat_idx_to_val(unsigned int idx)
 {
-       unsigned int error_bits, k, base;
+       unsigned int error_bits;
+       unsigned long long k, base;
 
        assert(idx < FIO_IO_U_PLAT_NR);
 
@@ -111,7 +112,7 @@ static unsigned long long plat_idx_to_val(unsigned int idx)
 
        /* Find the group and compute the minimum value of that group */
        error_bits = (idx >> FIO_IO_U_PLAT_BITS) - 1;
-       base = 1 << (error_bits + FIO_IO_U_PLAT_BITS);
+       base = ((unsigned long long) 1) << (error_bits + FIO_IO_U_PLAT_BITS);
 
        /* Find its bucket number of the group */
        k = idx % FIO_IO_U_PLAT_VAL;
@@ -475,6 +476,12 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts,
                else
                        bw_str = "kB";
 
+               if (rs->agg[ddir]) {
+                       p_of_agg = mean * 100 / (double) (rs->agg[ddir] / 1024);
+                       if (p_of_agg > 100.0)
+                               p_of_agg = 100.0;
+               }
+
                if (rs->unit_base == 1) {
                        min *= 8.0;
                        max *= 8.0;
@@ -482,12 +489,6 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts,
                        dev *= 8.0;
                }
 
-               if (rs->agg[ddir]) {
-                       p_of_agg = mean * 100 / (double) rs->agg[ddir];
-                       if (p_of_agg > 100.0)
-                               p_of_agg = 100.0;
-               }
-
                if (mean > fkb_base * fkb_base) {
                        min /= fkb_base;
                        max /= fkb_base;
@@ -497,13 +498,13 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts,
                }
 
                log_buf(out, "   bw (%5s/s): min=%5llu, max=%5llu, per=%3.2f%%, "
-                       "avg=%5.02f, stdev=%5.02f, samples=%5lu\n",
+                       "avg=%5.02f, stdev=%5.02f, samples=%" PRIu64 "\n",
                        bw_str, min, max, p_of_agg, mean, dev,
                        (&ts->bw_stat[ddir])->samples);
        }
        if (calc_lat(&ts->iops_stat[ddir], &min, &max, &mean, &dev)) {
-               log_buf(out, "   iops : min=%5llu, max=%5llu, avg=%5.02f, "
-                       "stdev=%5.02f, samples=%5lu\n",
+               log_buf(out, "   iops        : min=%5llu, max=%5llu, "
+                       "avg=%5.02f, stdev=%5.02f, samples=%" PRIu64 "\n",
                        min, max, mean, dev, (&ts->iops_stat[ddir])->samples);
        }
 }
@@ -520,7 +521,7 @@ static int show_lat(double *io_u_lat, int nr, const char **ranges,
                if (new_line) {
                        if (line)
                                log_buf(out, "\n");
-                       log_buf(out, "    lat (%s) : ", msg);
+                       log_buf(out, "  lat (%s)   : ", msg);
                        new_line = 0;
                        line = 0;
                }
@@ -924,7 +925,7 @@ static void show_ddir_status_terse(struct thread_stat *ts,
                double p_of_agg = 100.0;
 
                if (rs->agg[ddir]) {
-                       p_of_agg = mean * 100 / (double) rs->agg[ddir];
+                       p_of_agg = mean * 100 / (double) (rs->agg[ddir] / 1024);
                        if (p_of_agg > 100.0)
                                p_of_agg = 100.0;
                }
@@ -935,12 +936,12 @@ static void show_ddir_status_terse(struct thread_stat *ts,
 
        if (ver == 5) {
                if (bw_stat)
-                       log_buf(out, ";%lu", (&ts->bw_stat[ddir])->samples);
+                       log_buf(out, ";%" PRIu64, (&ts->bw_stat[ddir])->samples);
                else
                        log_buf(out, ";%lu", 0UL);
 
                if (calc_lat(&ts->iops_stat[ddir], &min, &max, &mean, &dev))
-                       log_buf(out, ";%llu;%llu;%f;%f;%lu", min, max,
+                       log_buf(out, ";%llu;%llu;%f;%f;%" PRIu64, min, max,
                                mean, dev, (&ts->iops_stat[ddir])->samples);
                else
                        log_buf(out, ";%llu;%llu;%f;%f;%lu", 0ULL, 0ULL, 0.0, 0.0, 0UL);
@@ -1055,7 +1056,7 @@ static void add_ddir_status_json(struct thread_stat *ts,
 
        if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) {
                if (rs->agg[ddir]) {
-                       p_of_agg = mean * 100 / (double) rs->agg[ddir];
+                       p_of_agg = mean * 100 / (double) (rs->agg[ddir] / 1024);
                        if (p_of_agg > 100.0)
                                p_of_agg = 100.0;
                }