+/*
+ * Sort the reads for a verify phase in batches of verifysort_nr, if
+ * specified.
+ */
+static inline int should_sort_io(struct thread_data *td)
+{
+ if (!td->o.verifysort_nr || !td->o.do_verify)
+ return 0;
+ if (!td_random(td))
+ return 0;
+ if (td->runstate != TD_VERIFYING)
+ return 0;
+ if (td->o.random_generator == FIO_RAND_GEN_TAUSWORTHE)
+ return 0;
+
+ return 1;
+}
+
+static int should_do_random(struct thread_data *td, enum fio_ddir ddir)
+{
+ unsigned int v;
+ unsigned long r;
+
+ if (td->o.perc_rand[ddir] == 100)
+ return 1;
+
+ if (td->o.use_os_rand) {
+ r = os_random_long(&td->seq_rand_state[ddir]);
+ v = 1 + (int) (100.0 * (r / (OS_RAND_MAX + 1.0)));
+ } else {
+ r = __rand(&td->__seq_rand_state[ddir]);
+ v = 1 + (int) (100.0 * (r / (FRAND_MAX + 1.0)));
+ }
+
+ return v <= td->o.perc_rand[ddir];
+}
+