-static int get_rw_ddir(struct thread_data *td)
-{
- /*
- * perhaps cheasy, but use the hamming weight of the position
- * as a randomizer for data direction.
- */
- if (td_rw(td))
- return hweight64(td->last_pos) & 1;
- else if (td_read(td))
+ lrand48_r(&td->random_state, &r);
+ v = 100UL * r / (unsigned long) (RAND_MAX + 1.0);
+ if (v < td->rwmixread)
+ td->rwmix_ddir = DDIR_READ;
+ else
+ td->rwmix_ddir = DDIR_WRITE;
+ memcpy(&td->rwmix_switch, &now, sizeof(now));
+ }
+ return td->rwmix_ddir;
+ } else if (td_read(td))