From 2ecc1b57721e3cb72bbf558bc169c97037fe3d0a Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 4 Nov 2009 20:58:09 +0100 Subject: [PATCH] Fix race on io_u->flags Signed-off-by: Jens Axboe --- io_u.c | 6 +++--- verify.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/io_u.c b/io_u.c index 232f6a6f..4be958da 100644 --- a/io_u.c +++ b/io_u.c @@ -413,7 +413,6 @@ void put_io_u(struct thread_data *td, struct io_u *io_u) { td_io_u_lock(td); - assert((io_u->flags & IO_U_F_FREE) == 0); io_u->flags |= IO_U_F_FREE; io_u->flags &= ~IO_U_F_FREE_DEF; @@ -861,8 +860,7 @@ again: if (io_u) { assert(io_u->flags & IO_U_F_FREE); - io_u->flags &= ~IO_U_F_FREE; - io_u->flags &= ~IO_U_F_FREE_DEF; + io_u->flags &= ~(IO_U_F_FREE | IO_U_F_FREE_DEF); io_u->error = 0; flist_del(&io_u->list); @@ -971,8 +969,10 @@ static void io_completed(struct thread_data *td, struct io_u *io_u, 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; + td_io_u_unlock(td); if (ddir_sync(io_u->ddir)) { td->last_was_sync = 1; diff --git a/verify.c b/verify.c index 7d675e46..84e888b2 100644 --- a/verify.c +++ b/verify.c @@ -444,10 +444,10 @@ int verify_io_u_async(struct thread_data *td, struct io_u *io_u) } flist_del(&io_u->list); flist_add_tail(&io_u->list, &td->verify_list); + io_u->flags |= IO_U_F_FREE_DEF; pthread_mutex_unlock(&td->io_u_lock); pthread_cond_signal(&td->verify_cond); - io_u->flags |= IO_U_F_FREE_DEF; return 0; } -- 2.25.1