]> git.neil.brown.name Git - history.git/commit
[PATCH] Fix an XFS direct I/O deadlock
authorNathan Scott <nathans@sgi.com>
Wed, 1 Dec 2004 09:09:39 +0000 (01:09 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Wed, 1 Dec 2004 09:09:39 +0000 (01:09 -0800)
commitd5432de8b724d8ddf5e39f11c0fb533c7a340eb4
treeb536c75d5505cc900826231838c0f53cca58c50f
parent26a4480e195e69c53d295746889619f9259e5369
[PATCH] Fix an XFS direct I/O deadlock

Here's a patch which fixes the deadlock Brad Fitzpatrick reported here:
http://lkml.org/lkml/2004/11/14/98

The meat of the problem is a locking order reversal between the XFS I/O
lock and the inode semaphore (i_sem).  When we mix a number of threads
doing both direct reads and writes, we hit an ABBA deadlock after a while
because direct-io.c is taking and dropping i_sem after the XFS read path
has already taken its I/O lock.  This is the wrong way around from XFS's
point of view, in particular its the opposite order to the XFS write path.
So this patch changes the logic for direct reads in the DIO_OWN_LOCKING
case (i.e.  XFS-only case), but leaves things as is for the other two types
of locking.

Not real pretty, but fixes up the lock ordering and deadlock.

Oh, I have tested direct reads and writes on ext3 and block devices as
well, to ensure they still function correctly with the change (i.e.  they
don't regress, should be a no-op there) which covers the other locking
cases in __blockdev_direct_IO.

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/direct-io.c
fs/xfs/linux-2.6/xfs_lrw.c