public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH 1/2] bdi: mark the bdi flusher busy when being forked
Date: Thu,  7 Apr 2011 16:19:55 +1000	[thread overview]
Message-ID: <1302157196-1988-2-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1302157196-1988-1-git-send-email-david@fromorbit.com>

From: Dave Chinner <dchinner@redhat.com>

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.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 fs/fs-writeback.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index b5ed541..64e2aba 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -62,11 +62,14 @@ int nr_pdflush_threads;
  * @bdi: the device's backing_dev_info structure.
  *
  * Determine whether there is writeback waiting to be handled against a
- * backing device.
+ * backing device. If the flusher thread is being created, then writeback is in
+ * the process of being started, so indicate that it writeback is not idle at
+ * this point in time.
  */
 int writeback_in_progress(struct backing_dev_info *bdi)
 {
-	return test_bit(BDI_writeback_running, &bdi->state);
+	return test_bit(BDI_writeback_running, &bdi->state) ||
+		test_bit(BDI_pending, &bdi->state);
 }
 
 static inline struct backing_dev_info *inode_to_bdi(struct inode *inode)
-- 
1.7.2.3

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2011-04-07  6:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-07  6:19 [PATCH 0/2] xfs: write back inodes during reclaim Dave Chinner
2011-04-07  6:19 ` Dave Chinner [this message]
2011-04-11 18:34   ` [PATCH 1/2] bdi: mark the bdi flusher busy when being forked Christoph Hellwig
2011-04-13 19:29   ` Alex Elder
2011-04-07  6:19 ` [PATCH 2/2] xfs: kick inode writeback when low on memory Dave Chinner
2011-04-11 18:36   ` Christoph Hellwig
2011-04-11 21:14     ` Dave Chinner
2011-04-13 20:33   ` Alex Elder
2011-04-14  5:08     ` Dave Chinner
2011-04-15  8:09       ` Christoph Hellwig
2011-04-15  7:23 ` [PATCH 0/2] xfs: write back inodes during reclaim Yann Dupont
2011-04-15  7:54   ` Dave Chinner
2011-04-15  9:13     ` Yann Dupont

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1302157196-1988-2-git-send-email-david@fromorbit.com \
    --to=david@fromorbit.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox