X-Spam-Checker-Version: SpamAssassin 3.4.0-r929098 (2010-03-30) on oss.sgi.com X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.4.0-r929098 Received: from relay.sgi.com (relay2.corp.sgi.com [137.38.102.29]) by oss.sgi.com (8.14.3/8.14.3/SuSE Linux 0.8) with ESMTP id p3DJQZ9g210012 for ; Wed, 13 Apr 2011 14:26:35 -0500 Received: from cf--amer001e--3.americas.sgi.com (cf--amer001e--3.americas.sgi.com [137.38.100.5]) by relay2.corp.sgi.com (Postfix) with ESMTP id E6D79304071; Wed, 13 Apr 2011 12:29:54 -0700 (PDT) Received: from [127.0.0.1] ([128.162.232.50]) by cf--amer001e--3.americas.sgi.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 13 Apr 2011 14:29:24 -0500 Subject: Re: [PATCH 1/2] bdi: mark the bdi flusher busy when being forked From: Alex Elder Reply-To: aelder@sgi.com To: Dave Chinner Cc: xfs@oss.sgi.com, linux-fsdevel@vger.kernel.org In-Reply-To: <1302157196-1988-2-git-send-email-david@fromorbit.com> References: <1302157196-1988-1-git-send-email-david@fromorbit.com> <1302157196-1988-2-git-send-email-david@fromorbit.com> Content-Type: text/plain; charset="UTF-8" Date: Wed, 13 Apr 2011 14:29:23 -0500 Message-ID: <1302722963.2023.66.camel@doink> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 13 Apr 2011 19:29:24.0216 (UTC) FILETIME=[1878F780:01CBFA11] X-Virus-Scanned: ClamAV version 0.94.2, clamav-milter version 0.94.2 on oss.sgi.com X-Virus-Status: Clean On Thu, 2011-04-07 at 16:19 +1000, Dave Chinner wrote: > From: Dave Chinner > > Recetn attempts to use writeback_inode_sb_nr_if_idle() in XFs from > memory reclaim context have caused deadlocks because memory reclaim > call be called from a failed allocation during forking a flusher > thread. The shrinker then attempts to trigger writeback and the bdi > is considered idle because writeback is not in progress yet and then > deadlocks because bdi_queue_work() blocks waiting for the > BDI_Pending bit to clear which will never happen because it needs > the fork to complete. > > To avoid this deadlock, consider writeback to be in progress if the > flusher thread is being created. This prevents reclaim from blocking > waiting for it be forked and hence avoids the deadlock. I don't believe it matters, but BDI_pending is also set while a writeback flusher thread is being shut down. In any case, a handy use of that flag bit. Reviewed-by: Alex Elder > Signed-off-by: Dave Chinner