Make completion wakeup dependent on active status
authorJens Axboe <jaxboe@fusionio.com>
Fri, 8 Oct 2010 18:21:08 +0000 (20:21 +0200)
committerJens Axboe <jaxboe@fusionio.com>
Fri, 8 Oct 2010 18:21:08 +0000 (20:21 +0200)
This way we can avoid grabbing a per-dev lock completely
on IO completion.

Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
main.c

diff --git a/main.c b/main.c
index 7261999e44af59b42c6651c3da1e729dc0b549a7..0981b36c0860cba5e038c8d66b722945d17793c4 100644 (file)
--- a/main.c
+++ b/main.c
@@ -326,7 +326,9 @@ static void b_cmd_endio(struct bio *bio, int error)
 
        atomic_dec(&bd->in_flight);
 
-       wake_up(&bd->wq_done);
+       smp_mb();
+       if (waitqueue_active(&bd->wq_done))
+               wake_up(&bd->wq_done);
 }
 
 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18)