X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=backend.c;h=367910ecda2a08d88dc6e57823b5e80f3c726d9a;hp=a92b1e3c025e1f7f2d4a5500a669f6bea0f7166e;hb=a80cb54b6df815c5121f84d5126e2550e5f259cc;hpb=ec2ea18e87fad6c42d6875cd4ee1bb25ef9b4627 diff --git a/backend.c b/backend.c index a92b1e3c..367910ec 100644 --- a/backend.c +++ b/backend.c @@ -288,8 +288,7 @@ requeue: put_io_u(td, io_u); return true; } else if (ret == FIO_Q_QUEUED) { - if (td_io_commit(td)) - return true; + td_io_commit(td); if (io_u_queued_complete(td, 1) < 0) return true; } else if (ret == FIO_Q_COMPLETED) { @@ -301,8 +300,7 @@ requeue: if (io_u_sync_complete(td, io_u) < 0) return true; } else if (ret == FIO_Q_BUSY) { - if (td_io_commit(td)) - return true; + td_io_commit(td); goto requeue; } @@ -453,8 +451,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) { - int ret2; - switch (*ret) { case FIO_Q_COMPLETED: if (io_u->error) { @@ -530,9 +526,7 @@ sync_done: 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); @@ -723,6 +717,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; + populate_verify_io_u(td, io_u); break; } else { put_io_u(td, io_u); @@ -995,6 +990,9 @@ static void do_io(struct thread_data *td, uint64_t *bytes_done) break; } + if (io_u->ddir == DDIR_WRITE && td->flags & TD_F_DO_VERIFY) + populate_verify_io_u(td, io_u); + ddir = io_u->ddir; /* @@ -1328,7 +1326,7 @@ static int init_io_u(struct thread_data *td) 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; @@ -1364,17 +1362,19 @@ static int switch_ioscheduler(struct thread_data *td) /* * 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; } + 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. @@ -1543,7 +1543,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->next_rand_list); td->io_hist_tree = RB_ROOT; ret = mutex_cond_init_pshared(&td->io_u_lock, &td->free_cond); @@ -2477,7 +2476,8 @@ int fio_backend(struct sk_out *sk_out) 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); @@ -2507,8 +2507,10 @@ int fio_backend(struct sk_out *sk_out) } 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);