projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
iolog/blktrace: boolean conversion
[fio.git]
/
backend.c
diff --git
a/backend.c
b/backend.c
index a92b1e3c025e1f7f2d4a5500a669f6bea0f7166e..033d5a707f2a896f161eab84299e2b1bf6a23de0 100644
(file)
--- a/
backend.c
+++ b/
backend.c
@@
-268,7
+268,7
@@
static void cleanup_pending_aio(struct thread_data *td)
static bool fio_io_sync(struct thread_data *td, struct fio_file *f)
{
struct io_u *io_u = __get_io_u(td);
static bool fio_io_sync(struct thread_data *td, struct fio_file *f)
{
struct io_u *io_u = __get_io_u(td);
-
int
ret;
+
enum fio_q_status
ret;
if (!io_u)
return true;
if (!io_u)
return true;
@@
-283,16
+283,13
@@
static bool fio_io_sync(struct thread_data *td, struct fio_file *f)
requeue:
ret = td_io_queue(td, io_u);
requeue:
ret = td_io_queue(td, io_u);
- if (ret < 0) {
- td_verror(td, io_u->error, "td_io_queue");
- put_io_u(td, io_u);
- return true;
- } else if (ret == FIO_Q_QUEUED) {
- if (td_io_commit(td))
- return true;
+ switch (ret) {
+ case FIO_Q_QUEUED:
+ td_io_commit(td);
if (io_u_queued_complete(td, 1) < 0)
return true;
if (io_u_queued_complete(td, 1) < 0)
return true;
- } else if (ret == FIO_Q_COMPLETED) {
+ break;
+ case FIO_Q_COMPLETED:
if (io_u->error) {
td_verror(td, io_u->error, "td_io_queue");
return true;
if (io_u->error) {
td_verror(td, io_u->error, "td_io_queue");
return true;
@@
-300,9
+297,9
@@
requeue:
if (io_u_sync_complete(td, io_u) < 0)
return true;
if (io_u_sync_complete(td, io_u) < 0)
return true;
- } else if (ret == FIO_Q_BUSY) {
- if (td_io_commit(td))
-
return true
;
+ break;
+ case FIO_Q_BUSY:
+
td_io_commit(td)
;
goto requeue;
}
goto requeue;
}
@@
-453,8
+450,6
@@
int io_queue_event(struct thread_data *td, struct io_u *io_u, int *ret,
enum fio_ddir ddir, uint64_t *bytes_issued, int from_verify,
struct timespec *comp_time)
{
enum fio_ddir ddir, uint64_t *bytes_issued, int from_verify,
struct timespec *comp_time)
{
- int ret2;
-
switch (*ret) {
case FIO_Q_COMPLETED:
if (io_u->error) {
switch (*ret) {
case FIO_Q_COMPLETED:
if (io_u->error) {
@@
-530,9
+525,7
@@
sync_done:
if (!from_verify)
unlog_io_piece(td, io_u);
requeue_io_u(td, &io_u);
if (!from_verify)
unlog_io_piece(td, io_u);
requeue_io_u(td, &io_u);
- ret2 = td_io_commit(td);
- if (ret2 < 0)
- *ret = ret2;
+ td_io_commit(td);
break;
default:
assert(*ret < 0);
break;
default:
assert(*ret < 0);
@@
-605,7
+598,7
@@
static bool in_flight_overlap(struct io_u_queue *q, struct io_u *io_u)
return overlap;
}
return overlap;
}
-static
int
io_u_submit(struct thread_data *td, struct io_u *io_u)
+static
enum fio_q_status
io_u_submit(struct thread_data *td, struct io_u *io_u)
{
/*
* Check for overlap if the user asked us to, and we have
{
/*
* Check for overlap if the user asked us to, and we have
@@
-723,6
+716,7
@@
static void do_verify(struct thread_data *td, uint64_t verify_bytes)
break;
} else if (io_u->ddir == DDIR_WRITE) {
io_u->ddir = DDIR_READ;
break;
} else if (io_u->ddir == DDIR_WRITE) {
io_u->ddir = DDIR_READ;
+ populate_verify_io_u(td, io_u);
break;
} else {
put_io_u(td, io_u);
break;
} else {
put_io_u(td, io_u);
@@
-995,6
+989,9
@@
static void do_io(struct thread_data *td, uint64_t *bytes_done)
break;
}
break;
}
+ if (io_u->ddir == DDIR_WRITE && td->flags & TD_F_DO_VERIFY)
+ populate_verify_io_u(td, io_u);
+
ddir = io_u->ddir;
/*
ddir = io_u->ddir;
/*
@@
-1328,7
+1325,7
@@
static int init_io_u(struct thread_data *td)
static int switch_ioscheduler(struct thread_data *td)
{
#ifdef FIO_HAVE_IOSCHED_SWITCH
static int switch_ioscheduler(struct thread_data *td)
{
#ifdef FIO_HAVE_IOSCHED_SWITCH
- char tmp[256], tmp2[128];
+ char tmp[256], tmp2[128]
, *p
;
FILE *f;
int ret;
FILE *f;
int ret;
@@
-1364,17
+1361,19
@@
static int switch_ioscheduler(struct thread_data *td)
/*
* Read back and check that the selected scheduler is now the default.
*/
/*
* Read back and check that the selected scheduler is now the default.
*/
- memset(tmp, 0, sizeof(tmp));
- ret = fread(tmp, sizeof(tmp), 1, f);
+ ret = fread(tmp, 1, sizeof(tmp) - 1, f);
if (ferror(f) || ret < 0) {
td_verror(td, errno, "fread");
fclose(f);
return 1;
}
if (ferror(f) || ret < 0) {
td_verror(td, errno, "fread");
fclose(f);
return 1;
}
+ tmp[ret] = '\0';
/*
/*
- * either a list of io schedulers or "none\n" is expected.
+ * either a list of io schedulers or "none\n" is expected. Strip the
+ * trailing newline.
*/
*/
- tmp[strlen(tmp) - 1] = '\0';
+ p = tmp;
+ strsep(&p, "\n");
/*
* Write to "none" entry doesn't fail, so check the result here.
/*
* Write to "none" entry doesn't fail, so check the result here.
@@
-1543,7
+1542,6
@@
static void *thread_main(void *data)
INIT_FLIST_HEAD(&td->io_hist_list);
INIT_FLIST_HEAD(&td->verify_list);
INIT_FLIST_HEAD(&td->trim_list);
INIT_FLIST_HEAD(&td->io_hist_list);
INIT_FLIST_HEAD(&td->verify_list);
INIT_FLIST_HEAD(&td->trim_list);
- INIT_FLIST_HEAD(&td->next_rand_list);
td->io_hist_tree = RB_ROOT;
ret = mutex_cond_init_pshared(&td->io_u_lock, &td->free_cond);
td->io_hist_tree = RB_ROOT;
ret = mutex_cond_init_pshared(&td->io_u_lock, &td->free_cond);
@@
-1672,7
+1670,7
@@
static void *thread_main(void *data)
* May alter parameters that init_io_u() will use, so we need to
* do this first.
*/
* May alter parameters that init_io_u() will use, so we need to
* do this first.
*/
- if (init_iolog(td))
+ if (
!
init_iolog(td))
goto err;
if (init_io_u(td))
goto err;
if (init_io_u(td))
@@
-2477,7
+2475,8
@@
int fio_backend(struct sk_out *sk_out)
helper_thread_create(startup_sem, sk_out);
cgroup_list = smalloc(sizeof(*cgroup_list));
helper_thread_create(startup_sem, sk_out);
cgroup_list = smalloc(sizeof(*cgroup_list));
- INIT_FLIST_HEAD(cgroup_list);
+ if (cgroup_list)
+ INIT_FLIST_HEAD(cgroup_list);
run_threads(sk_out);
run_threads(sk_out);
@@
-2507,8
+2506,10
@@
int fio_backend(struct sk_out *sk_out)
}
free_disk_util();
}
free_disk_util();
- cgroup_kill(cgroup_list);
- sfree(cgroup_list);
+ if (cgroup_list) {
+ cgroup_kill(cgroup_list);
+ sfree(cgroup_list);
+ }
sfree(cgroup_mnt);
fio_sem_remove(startup_sem);
sfree(cgroup_mnt);
fio_sem_remove(startup_sem);