LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
To: Jens Axboe <jens.axboe@oracle.com>
Cc: JFS Discussion <jfs-discussion@lists.sourceforge.net>,
	fsdevel <linux-fsdevel@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Nick Piggin <nickpiggin@yahoo.com.au>
Subject: [PATCH: 2.6.20-rc4-mm1] JFS: Avoid deadlock introduced by explicit I/O plugging
Date: Wed, 17 Jan 2007 16:55:49 -0600	[thread overview]
Message-ID: <1169074549.10560.10.camel@kleikamp.austin.ibm.com> (raw)

Jens,
Can you please take a look at this patch, and if you think it's sane,
add it to your explicit i/o plugging patchset?  Would it make sense in
any of these paths to use io_schedule() instead of schedule()?

I hadn't looked at your patchset until I discovered that jfs was easy to
hang in the -mm kernel.  I think jfs may be able to add explicit
plugging and unplugging in a couple of places, but I'd like to fix the
hang right away and take my time with any later patches.

Thanks,
Shaggy

JFS: Avoid deadlock introduced by explicit I/O plugging

jfs is pretty easy to deadlock with Jens' explicit i/o plugging patchset.
Just try building a kernel.

The problem occurs when a synchronous transaction initiates some I/O, then
waits in lmGroupCommit for the transaction to be committed to the journal.
This requires action by the commit thread, which ends up waiting on a page
to complete writeback.  The commit thread did not initiate the I/O, so it
cannot unplug the io queue, and deadlock occurs.

The fix is for the first thread to call blk_replug_current_nested() before
going to sleep.  This patch also adds the call to a couple other places that
look like they need it.

Signed-off-by: Dave Kleikamp <shaggy@linux.vnet.ibm.com>

diff -Nurp linux-2.6.20-rc4-mm1/fs/jfs/jfs_lock.h linux/fs/jfs/jfs_lock.h
--- linux-2.6.20-rc4-mm1/fs/jfs/jfs_lock.h	2006-11-29 15:57:37.000000000 -0600
+++ linux/fs/jfs/jfs_lock.h	2007-01-17 15:30:19.000000000 -0600
@@ -22,6 +22,7 @@
 #include <linux/spinlock.h>
 #include <linux/mutex.h>
 #include <linux/sched.h>
+#include <linux/blkdev.h>
 
 /*
  *	jfs_lock.h
@@ -42,6 +43,7 @@ do {							\
 		if (cond)				\
 			break;				\
 		unlock_cmd;				\
+		blk_replug_current_nested();		\
 		schedule();				\
 		lock_cmd;				\
 	}						\
diff -Nurp linux-2.6.20-rc4-mm1/fs/jfs/jfs_metapage.c linux/fs/jfs/jfs_metapage.c
--- linux-2.6.20-rc4-mm1/fs/jfs/jfs_metapage.c	2007-01-12 09:50:45.000000000 -0600
+++ linux/fs/jfs/jfs_metapage.c	2007-01-17 15:28:46.000000000 -0600
@@ -23,6 +23,7 @@
 #include <linux/init.h>
 #include <linux/buffer_head.h>
 #include <linux/mempool.h>
+#include <linux/blkdev.h>
 #include "jfs_incore.h"
 #include "jfs_superblock.h"
 #include "jfs_filsys.h"
@@ -56,6 +57,7 @@ static inline void __lock_metapage(struc
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		if (metapage_locked(mp)) {
 			unlock_page(mp->page);
+			blk_replug_current_nested();
 			schedule();
 			lock_page(mp->page);
 		}
diff -Nurp linux-2.6.20-rc4-mm1/fs/jfs/jfs_txnmgr.c linux/fs/jfs/jfs_txnmgr.c
--- linux-2.6.20-rc4-mm1/fs/jfs/jfs_txnmgr.c	2007-01-12 09:50:45.000000000 -0600
+++ linux/fs/jfs/jfs_txnmgr.c	2007-01-17 15:29:04.000000000 -0600
@@ -50,6 +50,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/kthread.h>
+#include <linux/blkdev.h>
 #include "jfs_incore.h"
 #include "jfs_inode.h"
 #include "jfs_filsys.h"
@@ -135,6 +136,7 @@ static inline void TXN_SLEEP_DROP_LOCK(w
 	add_wait_queue(event, &wait);
 	set_current_state(TASK_UNINTERRUPTIBLE);
 	TXN_UNLOCK();
+	blk_replug_current_nested();
 	schedule();
 	current->state = TASK_RUNNING;
 	remove_wait_queue(event, &wait);

-- 
David Kleikamp
IBM Linux Technology Center


             reply	other threads:[~2007-01-17 22:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-17 22:55 Dave Kleikamp [this message]
2007-01-17 23:18 ` Jens Axboe
2007-01-17 23:39   ` Dave Kleikamp
2007-01-17 23:46     ` Jens Axboe
2007-01-18  3:23       ` Dave Kleikamp
2007-01-18  6:30 ` Josef Sipek
2007-01-18 14:15   ` Dave Kleikamp

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=1169074549.10560.10.camel@kleikamp.austin.ibm.com \
    --to=shaggy@linux.vnet.ibm.com \
    --cc=jens.axboe@oracle.com \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nickpiggin@yahoo.com.au \
    --subject='Re: [PATCH: 2.6.20-rc4-mm1] JFS: Avoid deadlock introduced by explicit I/O plugging' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).