Exemple #1
0
static int __get_next_rand_offset(struct thread_data *td, struct fio_file *f,
				  enum fio_ddir ddir, uint64_t *b)
{
	uint64_t r;

	if (td->o.random_generator == FIO_RAND_GEN_TAUSWORTHE ||
	    td->o.random_generator == FIO_RAND_GEN_TAUSWORTHE64) {
		uint64_t frand_max, lastb;

		lastb = last_block(td, f, ddir);
		if (!lastb)
			return 1;

		frand_max = rand_max(&td->random_state);
		r = __rand(&td->random_state);

		dprint(FD_RANDOM, "off rand %llu\n", (unsigned long long) r);

		*b = lastb * (r / ((uint64_t) frand_max + 1.0));
	} else {
		uint64_t off = 0;

		assert(fio_file_lfsr(f));

		if (lfsr_next(&f->lfsr, &off))
			return 1;

		*b = off;
	}

	/*
	 * if we are not maintaining a random map, we are done.
	 */
	if (!file_randommap(td, f))
		goto ret;

	/*
	 * calculate map offset and check if it's free
	 */
	if (random_map_free(f, *b))
		goto ret;

	dprint(FD_RANDOM, "get_next_rand_offset: offset %llu busy\n",
						(unsigned long long) *b);

	*b = axmap_next_free(f->io_axmap, *b);
	if (*b == (uint64_t) -1ULL)
		return 1;
ret:
	return 0;
}
Exemple #2
0
unsigned long long get_rand_file_size(struct thread_data *td)
{
	unsigned long long ret, sized;
	uint64_t frand_max;
	unsigned long r;

	frand_max = rand_max(&td->file_size_state);
	r = __rand(&td->file_size_state);
	sized = td->o.file_size_high - td->o.file_size_low;
	ret = (unsigned long long) ((double) sized * (r / (frand_max + 1.0)));
	ret += td->o.file_size_low;
	ret -= (ret % td->o.rw_min_bs);
	return ret;
}
Exemple #3
0
static bool should_do_random(struct thread_data *td, enum fio_ddir ddir)
{
	uint64_t frand_max;
	unsigned int v;
	unsigned long r;

	if (td->o.perc_rand[ddir] == 100)
		return true;

	frand_max = rand_max(&td->seq_rand_state[ddir]);
	r = __rand(&td->seq_rand_state[ddir]);
	v = 1 + (int) (100.0 * (r / (frand_max + 1.0)));

	return v <= td->o.perc_rand[ddir];
}