A few min/max cleanups
[fio.git] / io_u.c
diff --git a/io_u.c b/io_u.c
index 6dda5790a7f1d494fd46758ecc9b3b6406e4a11a..dd4502f1cfccb7c532480bd45fc13785578f9912 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -13,6 +13,7 @@
 #include "lib/axmap.h"
 #include "err.h"
 #include "lib/pow2.h"
+#include "minmax.h"
 
 struct io_completion_data {
        int nr;                         /* input */
@@ -488,7 +489,7 @@ static unsigned int __get_next_buflen(struct thread_data *td, struct io_u *io_u,
                        }
                }
 
-               if (td->o.do_verify && td->o.verify != VERIFY_NONE)
+               if (td->o.verify != VERIFY_NONE)
                        buflen = (buflen + td->o.verify_interval - 1) &
                                ~(td->o.verify_interval - 1);
 
@@ -1919,6 +1920,7 @@ void fill_io_buffer(struct thread_data *td, void *buf, unsigned int min_write,
                unsigned int perc = td->o.compress_percentage;
                struct frand_state *rs;
                unsigned int left = max_bs;
+               unsigned int this_write;
 
                do {
                        rs = get_buf_state(td);
@@ -1926,20 +1928,20 @@ void fill_io_buffer(struct thread_data *td, void *buf, unsigned int min_write,
                        min_write = min(min_write, left);
 
                        if (perc) {
-                               unsigned int seg = min_write;
+                               this_write = min_not_zero(min_write,
+                                                       td->o.compress_chunk);
 
-                               seg = min(min_write, td->o.compress_chunk);
-                               if (!seg)
-                                       seg = min_write;
-
-                               fill_random_buf_percentage(rs, buf, perc, seg,
-                                       min_write, o->buffer_pattern,
-                                                  o->buffer_pattern_bytes);
-                       } else
+                               fill_random_buf_percentage(rs, buf, perc,
+                                       this_write, this_write,
+                                       o->buffer_pattern,
+                                       o->buffer_pattern_bytes);
+                       } else {
                                fill_random_buf(rs, buf, min_write);
+                               this_write = min_write;
+                       }
 
-                       buf += min_write;
-                       left -= min_write;
+                       buf += this_write;
+                       left -= this_write;
                        save_buf_state(td, rs);
                } while (left);
        } else if (o->buffer_pattern_bytes)