コード例 #1
0
ファイル: io_u.c プロジェクト: vsharma13/fio
void put_io_u(struct thread_data *td, struct io_u *io_u)
{
	td_io_u_lock(td);

	if (io_u->file && !(io_u->flags & IO_U_F_FREE_DEF))
		put_file_log(td, io_u->file);
	io_u->file = NULL;
	io_u->flags &= ~IO_U_F_FREE_DEF;
	io_u->flags |= IO_U_F_FREE;

	if (io_u->flags & IO_U_F_IN_CUR_DEPTH)
		td->cur_depth--;
	io_u_qpush(&td->io_u_freelist, io_u);
	td_io_u_unlock(td);
	td_io_u_free_notify(td);
}
コード例 #2
0
ファイル: io_u.c プロジェクト: jeefke/fio
void put_io_u(struct thread_data *td, struct io_u *io_u)
{
	td_io_u_lock(td);

	io_u->flags |= IO_U_F_FREE;
	io_u->flags &= ~IO_U_F_FREE_DEF;

	if (io_u->file)
		put_file_log(td, io_u->file);

	io_u->file = NULL;
	if (io_u->flags & IO_U_F_IN_CUR_DEPTH)
		td->cur_depth--;
	flist_del_init(&io_u->list);
	flist_add(&io_u->list, &td->io_u_freelist);
	td_io_u_unlock(td);
	td_io_u_free_notify(td);
}
コード例 #3
0
ファイル: io_u.c プロジェクト: Neil693667/speedtest
void requeue_io_u(struct thread_data *td, struct io_u **io_u)
{
	struct io_u *__io_u = *io_u;

	dprint(FD_IO, "requeue %p\n", __io_u);

	td_io_u_lock(td);

	__io_u->flags |= IO_U_F_FREE;
	if ((__io_u->flags & IO_U_F_FLIGHT) && ddir_rw(__io_u->ddir))
		td->io_issues[__io_u->ddir]--;

	__io_u->flags &= ~IO_U_F_FLIGHT;
	if (__io_u->flags & IO_U_F_IN_CUR_DEPTH)
		td->cur_depth--;
	flist_del(&__io_u->list);
	flist_add_tail(&__io_u->list, &td->io_u_requeues);
	td_io_u_unlock(td);
	*io_u = NULL;
}
コード例 #4
0
ファイル: io_u.c プロジェクト: vsharma13/fio
struct io_u *__get_io_u(struct thread_data *td)
{
	struct io_u *io_u;

	td_io_u_lock(td);

again:
	if (!io_u_rempty(&td->io_u_requeues))
		io_u = io_u_rpop(&td->io_u_requeues);
	else if (!queue_full(td)) {
		io_u = io_u_qpop(&td->io_u_freelist);

		io_u->buflen = 0;
		io_u->resid = 0;
		io_u->file = NULL;
		io_u->end_io = NULL;
	}

	if (io_u) {
		assert(io_u->flags & IO_U_F_FREE);
		io_u->flags &= ~(IO_U_F_FREE | IO_U_F_FREE_DEF);
		io_u->flags &= ~(IO_U_F_TRIMMED | IO_U_F_BARRIER);
		io_u->flags &= ~IO_U_F_VER_LIST;

		io_u->error = 0;
		io_u->acct_ddir = -1;
		td->cur_depth++;
		io_u->flags |= IO_U_F_IN_CUR_DEPTH;
		io_u->ipo = NULL;
	} else if (td->o.verify_async) {
		/*
		 * We ran out, wait for async verify threads to finish and
		 * return one
		 */
		pthread_cond_wait(&td->free_cond, &td->io_u_lock);
		goto again;
	}

	td_io_u_unlock(td);
	return io_u;
}
コード例 #5
0
ファイル: io_u.c プロジェクト: vsharma13/fio
void requeue_io_u(struct thread_data *td, struct io_u **io_u)
{
	struct io_u *__io_u = *io_u;
	enum fio_ddir ddir = acct_ddir(__io_u);

	dprint(FD_IO, "requeue %p\n", __io_u);

	td_io_u_lock(td);

	__io_u->flags |= IO_U_F_FREE;
	if ((__io_u->flags & IO_U_F_FLIGHT) && ddir_rw(ddir))
		td->io_issues[ddir]--;

	__io_u->flags &= ~IO_U_F_FLIGHT;
	if (__io_u->flags & IO_U_F_IN_CUR_DEPTH)
		td->cur_depth--;

	io_u_rpush(&td->io_u_requeues, __io_u);
	td_io_u_unlock(td);
	*io_u = NULL;
}
コード例 #6
0
ファイル: io_u.c プロジェクト: vsharma13/fio
static void io_completed(struct thread_data *td, struct io_u *io_u,
			 struct io_completion_data *icd)
{
	struct fio_file *f;

	dprint_io_u(io_u, "io complete");

	td_io_u_lock(td);
	assert(io_u->flags & IO_U_F_FLIGHT);
	io_u->flags &= ~(IO_U_F_FLIGHT | IO_U_F_BUSY_OK);

	/*
	 * Mark IO ok to verify
	 */
	if (io_u->ipo) {
		io_u->ipo->flags &= ~IP_F_IN_FLIGHT;
		write_barrier();
	}

	td_io_u_unlock(td);

	if (ddir_sync(io_u->ddir)) {
		td->last_was_sync = 1;
		f = io_u->file;
		if (f) {
			f->first_write = -1ULL;
			f->last_write = -1ULL;
		}
		return;
	}

	td->last_was_sync = 0;
	td->last_ddir = io_u->ddir;

	if (!io_u->error && ddir_rw(io_u->ddir)) {
		unsigned int bytes = io_u->buflen - io_u->resid;
		const enum fio_ddir idx = io_u->ddir;
		const enum fio_ddir odx = io_u->ddir ^ 1;
		int ret;

		td->io_blocks[idx]++;
		td->this_io_blocks[idx]++;
		td->io_bytes[idx] += bytes;

		if (!(io_u->flags & IO_U_F_VER_LIST))
			td->this_io_bytes[idx] += bytes;

		if (idx == DDIR_WRITE) {
			f = io_u->file;
			if (f) {
				if (f->first_write == -1ULL ||
				    io_u->offset < f->first_write)
					f->first_write = io_u->offset;
				if (f->last_write == -1ULL ||
				    ((io_u->offset + bytes) > f->last_write))
					f->last_write = io_u->offset + bytes;
			}
		}

		if (ramp_time_over(td) && (td->runstate == TD_RUNNING ||
					   td->runstate == TD_VERIFYING)) {
			account_io_completion(td, io_u, icd, idx, bytes);

			if (__should_check_rate(td, idx)) {
				td->rate_pending_usleep[idx] =
					(usec_for_io(td, idx) -
					 utime_since_now(&td->start));
			}
			if (idx != DDIR_TRIM && __should_check_rate(td, odx))
				td->rate_pending_usleep[odx] =
					(usec_for_io(td, odx) -
					 utime_since_now(&td->start));
		}

		icd->bytes_done[idx] += bytes;

		if (io_u->end_io) {
			ret = io_u->end_io(td, io_u);
			if (ret && !icd->error)
				icd->error = ret;
		}
	} else if (io_u->error) {
		icd->error = io_u->error;
		io_u_log_error(td, io_u);
	}
	if (icd->error) {
		enum error_type_bit eb = td_error_type(io_u->ddir, icd->error);
		if (!td_non_fatal_error(td, eb, icd->error))
			return;
		/*
		 * If there is a non_fatal error, then add to the error count
		 * and clear all the errors.
		 */
		update_error_count(td, icd->error);
		td_clear_error(td);
		icd->error = 0;
		io_u->error = 0;
	}
}
コード例 #7
0
ファイル: io_u.c プロジェクト: hanhua/fio
static void io_completed(struct thread_data *td, struct io_u *io_u,
			 struct io_completion_data *icd)
{
	struct fio_file *f;

	dprint_io_u(io_u, "io complete");

	td_io_u_lock(td);
	assert(io_u->flags & IO_U_F_FLIGHT);
	io_u->flags &= ~(IO_U_F_FLIGHT | IO_U_F_BUSY_OK);
	td_io_u_unlock(td);

	if (ddir_sync(io_u->ddir)) {
		td->last_was_sync = 1;
		f = io_u->file;
		if (f) {
			f->first_write = -1ULL;
			f->last_write = -1ULL;
		}
		return;
	}

	td->last_was_sync = 0;
	td->last_ddir = io_u->ddir;

	if (!io_u->error && ddir_rw(io_u->ddir)) {
		unsigned int bytes = io_u->buflen - io_u->resid;
		const enum fio_ddir idx = io_u->ddir;
		const enum fio_ddir odx = io_u->ddir ^ 1;
		int ret;

		td->io_blocks[idx]++;
		td->this_io_blocks[idx]++;
		td->io_bytes[idx] += bytes;

		if (!(io_u->flags & IO_U_F_VER_LIST))
			td->this_io_bytes[idx] += bytes;

		if (idx == DDIR_WRITE) {
			f = io_u->file;
			if (f) {
				if (f->first_write == -1ULL ||
				    io_u->offset < f->first_write)
					f->first_write = io_u->offset;
				if (f->last_write == -1ULL ||
				    ((io_u->offset + bytes) > f->last_write))
					f->last_write = io_u->offset + bytes;
			}
		}

		if (ramp_time_over(td) && (td->runstate == TD_RUNNING ||
					   td->runstate == TD_VERIFYING)) {
			account_io_completion(td, io_u, icd, idx, bytes);

			if (__should_check_rate(td, idx)) {
				td->rate_pending_usleep[idx] =
					(usec_for_io(td, idx) -
					 utime_since_now(&td->start));
			}

			if (__should_check_latency(td, idx)) {
				unsigned long lusec = utime_since(
					&io_u->issue_time, &icd->time);
				/* Linear increase and logarithmic decrease */
				if (lusec > td->o.shed_latency[idx]) {
					if (td->shed_count[idx] < MAX_SHED_COUNT ) {
						td->shed_count[idx] += (1<<SHED_FRAC_BITS);
					}
				}
				else if (td->shed_count[idx]) {
					td->shed_count[idx] -= get_used_bits(td->shed_count[idx]);
				}
				if (td->shed_count[idx]) {
					lusec = (lusec * td->shed_count[idx]) >> SHED_FRAC_BITS;
					if (lusec > td->rate_pending_usleep[idx]) {
						td->rate_pending_usleep[idx] = lusec;
					}
				}
			}