Beispiel #1
0
long do_units(unsigned long bytes)
{
	struct drand48_data rand_data;

	if (opt_detach)
		detach();

	if (opt_randomise)
		os_random_seed(time(0) ^ getpid(), &rand_data);

	if (!unit)
		unit = bytes;
	/*
	 * Allow a bytes=0 pass for pure fork bomb:
	 * usemem -n 10000 0 --detach --sleep 10
	 */
	do {
		unsigned long size = min(bytes, unit);

		do_unit(size, &rand_data);
		bytes -= size;
		if (runtime_exceeded())
			break;
	} while (bytes);

	if (opt_detach && up(sem_id))
		perror("up");

	if (sleep_secs)
		sleep(sleep_secs);

	return 0;
}
Beispiel #2
0
static void td_fill_rand_seeds_os(struct thread_data *td)
{
	os_random_seed(td->rand_seeds[FIO_RAND_BS_OFF], &td->bsrange_state);
	os_random_seed(td->rand_seeds[FIO_RAND_VER_OFF], &td->verify_state);
	os_random_seed(td->rand_seeds[FIO_RAND_MIX_OFF], &td->rwmix_state);

	if (td->o.file_service_type == FIO_FSERVICE_RANDOM)
		os_random_seed(td->rand_seeds[FIO_RAND_FILE_OFF], &td->next_file_state);

	os_random_seed(td->rand_seeds[FIO_RAND_FILE_SIZE_OFF], &td->file_size_state);
	os_random_seed(td->rand_seeds[FIO_RAND_TRIM_OFF], &td->trim_state);

	if (!td_random(td))
		return;

	if (td->o.rand_repeatable)
		td->rand_seeds[FIO_RAND_BLOCK_OFF] = FIO_RANDSEED * td->thread_number;

	os_random_seed(td->rand_seeds[FIO_RAND_BLOCK_OFF], &td->random_state);

	os_random_seed(td->rand_seeds[FIO_RAND_SEQ_RAND_READ_OFF], &td->seq_rand_state[DDIR_READ]);
	os_random_seed(td->rand_seeds[FIO_RAND_SEQ_RAND_WRITE_OFF], &td->seq_rand_state[DDIR_WRITE]);
	os_random_seed(td->rand_seeds[FIO_RAND_SEQ_RAND_TRIM_OFF], &td->seq_rand_state[DDIR_TRIM]);
}
Beispiel #3
0
Datei: init.c Projekt: rudyLi/fio
static void td_fill_rand_seeds_os(struct thread_data *td)
{
	os_random_seed(td->rand_seeds[0], &td->bsrange_state);
	os_random_seed(td->rand_seeds[1], &td->verify_state);
	os_random_seed(td->rand_seeds[2], &td->rwmix_state);

	if (td->o.file_service_type == FIO_FSERVICE_RANDOM)
		os_random_seed(td->rand_seeds[3], &td->next_file_state);

	os_random_seed(td->rand_seeds[5], &td->file_size_state);
	os_random_seed(td->rand_seeds[6], &td->trim_state);

	if (!td_random(td))
		return;

	if (td->o.rand_repeatable)
		td->rand_seeds[4] = FIO_RANDSEED * td->thread_number;

	os_random_seed(td->rand_seeds[4], &td->random_state);
}