dm log writes: don't use all the cpu while waiting to log blocks
authorJosef Bacik <jbacik@fb.com>
Fri, 28 Jul 2017 14:42:24 +0000 (10:42 -0400)
committerMike Snitzer <snitzer@redhat.com>
Mon, 11 Sep 2017 13:50:46 +0000 (09:50 -0400)
The check to see if the logging kthread needs to go to sleep is wrong,
it checks lc->pending_blocks, which will be non-0 if there are any
blocks that are pending, whether they are ready to be logged or not.
What we really want is to go to sleep until it's time to log blocks, so
change this check so we do actually go to sleep in between flushes.

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-log-writes.c

index a1da0eb58a93e51355c680bc3a056211042f3f54..9aab510a170958590833b8c5196c478e590620b0 100644 (file)
@@ -399,7 +399,7 @@ next:
                if (!try_to_freeze()) {
                        set_current_state(TASK_INTERRUPTIBLE);
                        if (!kthread_should_stop() &&
-                           !atomic_read(&lc->pending_blocks))
+                           list_empty(&lc->logging_blocks))
                                schedule();
                        __set_current_state(TASK_RUNNING);
                }