From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rajan Aggarwal Subject: Re: [PATCH 1/1] fs-writeback: Using spin_lock to check for work_list empty Date: Wed, 31 Aug 2011 12:16:29 +0530 Message-ID: References: <1314767509-17862-1-git-send-email-rajan.aggarwal85@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org To: KAMEZAWA Hiroyuk Return-path: Received: from mail-gx0-f174.google.com ([209.85.161.174]:38884 "EHLO mail-gx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754109Ab1HaGqa convert rfc822-to-8bit (ORCPT ); Wed, 31 Aug 2011 02:46:30 -0400 In-Reply-To: <1314767509-17862-1-git-send-email-rajan.aggarwal85@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Hi Kamezawa, I noticed that you are responding to emails right now. Can you please review the patch below and tell me whether it is technically correct ? Or, can you please suggest a suitable change for solving this ? Thanks. Kautuk On Wed, Aug 31, 2011 at 10:41 AM, Rajan Aggarwal wrote: > The bdi_writeback_thread function does not use spin_lock to > see if the work_list is empty. > > If the list is not empty, and if an interrupt happens before we > set the current->state to TASK_RUNNING then we could be stuck in > a schedule() due to kernel preemption. > > This patch acquires and releases the wb_lock to avoid this scenario. > > Signed-off-by: Rajan Aggarwal > --- > =A0fs/fs-writeback.c | =A0 =A03 +++ > =A01 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c > index 04cf3b9..e333898 100644 > --- a/fs/fs-writeback.c > +++ b/fs/fs-writeback.c > @@ -936,11 +936,14 @@ int bdi_writeback_thread(void *data) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (pages_written) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0wb->last_active =3D ji= ffies; > > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 spin_lock_bh(&bdi->wb_lock); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0set_current_state(TASK_INTERRUPTIBLE); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (!list_empty(&bdi->work_list) || kt= hread_should_stop()) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0__set_current_state(TA= SK_RUNNING); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 spin_unlock_bh(&bdi->wb= _lock); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0continue; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 spin_unlock_bh(&bdi->wb_lock); > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (wb_has_dirty_io(wb) && dirty_write= back_interval) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0schedule_timeout(msecs= _to_jiffies(dirty_writeback_interval * 10)); > -- > 1.7.4.1 > > -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html