From mboxrd@z Thu Jan 1 00:00:00 1970 From: Artem Bityutskiy Subject: [PATCHv3 05/14] writeback: do not lose wake-ups in bdi threads Date: Thu, 22 Jul 2010 16:56:19 +0300 Message-ID: <1279806988-14100-6-git-send-email-dedekind1@gmail.com> References: <1279806988-14100-1-git-send-email-dedekind1@gmail.com> Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org To: Jens Axboe Return-path: Received: from smtp.nokia.com ([192.100.122.233]:20437 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759498Ab0GVN4t (ORCPT ); Thu, 22 Jul 2010 09:56:49 -0400 In-Reply-To: <1279806988-14100-1-git-send-email-dedekind1@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: From: Artem Bityutskiy Currently, bdi threads ('bdi_writeback_thread()') can lose wake-ups. For example, if 'bdi_queue_work()' is executed after the bdi thread have had finished 'wb_do_writeback()' but before it called 'schedule_timeout_interruptible()'. To fix this issue, we have to check whether we have works to process after we have changed the task state to 'TASK_INTERRUPTIBLE'. This patch also clean-ups handling of the cases when 'dirty_writeback_interval' is zero or non-zero. Additionally, this patch also removes unneeded 'list_empty_careful()' call. Signed-off-by: Artem Bityutskiy Reviewed-by: Christoph Hellwig --- fs/fs-writeback.c | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 5e6b7fc..8cf53ba 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -848,17 +848,18 @@ int bdi_writeback_thread(void *data) break; } - if (dirty_writeback_interval) { - wait_jiffies = msecs_to_jiffies(dirty_writeback_interval * 10); - schedule_timeout_interruptible(wait_jiffies); - } else { - set_current_state(TASK_INTERRUPTIBLE); - if (list_empty_careful(&wb->bdi->work_list) && - !kthread_should_stop()) - schedule(); + set_current_state(TASK_INTERRUPTIBLE); + if (!list_empty(&bdi->work_list)) { __set_current_state(TASK_RUNNING); + continue; } + if (dirty_writeback_interval) { + wait_jiffies = msecs_to_jiffies(dirty_writeback_interval * 10); + schedule_timeout(wait_jiffies); + } else + schedule(); + try_to_freeze(); } -- 1.7.1.1