]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[XFS] Fix ABBA deadlock between i_mutex and iolock. Avoid calling
authorLachlan McIlroy <lachlan@sgi.com>
Thu, 7 Sep 2006 04:27:05 +0000 (14:27 +1000)
committerDavid Chatterton <chatz@sgi.com>
Thu, 7 Sep 2006 04:27:05 +0000 (14:27 +1000)
__blockdev_direct_IO for the DIO_OWN_LOCKING case for direct I/O reads
since it drops and reacquires the i_mutex while holding the iolock and
this violates the locking order.

SGI-PV: 955696
SGI-Modid: xfs-linux-melb:xfs-kern:26898a

Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Signed-off-by: David Chatterton <chatz@sgi.com>
fs/xfs/linux-2.6/xfs_aops.c
fs/xfs/linux-2.6/xfs_lrw.c

index c40f81ba9b130426125228e5bfac38d7059bfd1e..34dcb43a7837d8d9b602ba23199c8f6bbe429400 100644 (file)
@@ -1390,11 +1390,19 @@ xfs_vm_direct_IO(
 
        iocb->private = xfs_alloc_ioend(inode, IOMAP_UNWRITTEN);
 
-       ret = blockdev_direct_IO_own_locking(rw, iocb, inode,
-               iomap.iomap_target->bt_bdev,
-               iov, offset, nr_segs,
-               xfs_get_blocks_direct,
-               xfs_end_io_direct);
+       if (rw == WRITE) {
+               ret = blockdev_direct_IO_own_locking(rw, iocb, inode,
+                       iomap.iomap_target->bt_bdev,
+                       iov, offset, nr_segs,
+                       xfs_get_blocks_direct,
+                       xfs_end_io_direct);
+       } else {
+               ret = blockdev_direct_IO_no_locking(rw, iocb, inode,
+                       iomap.iomap_target->bt_bdev,
+                       iov, offset, nr_segs,
+                       xfs_get_blocks_direct,
+                       xfs_end_io_direct);
+       }
 
        if (unlikely(ret <= 0 && iocb->private))
                xfs_destroy_ioend(iocb->private);
index 5d9cfd91ad08638012b8365d7d46b4c27959e936..110c038910ff39580cabb45cf52f4f504c0b4332 100644 (file)
@@ -264,7 +264,9 @@ xfs_read(
                                        dmflags, &locktype);
                if (ret) {
                        xfs_iunlock(ip, XFS_IOLOCK_SHARED);
-                       goto unlock_mutex;
+                       if (unlikely(ioflags & IO_ISDIRECT))
+                               mutex_unlock(&inode->i_mutex);
+                       return ret;
                }
        }
 
@@ -272,6 +274,9 @@ xfs_read(
                bhv_vop_flushinval_pages(vp, ctooff(offtoct(*offset)),
                                                -1, FI_REMAPF_LOCKED);
 
+       if (unlikely(ioflags & IO_ISDIRECT))
+               mutex_unlock(&inode->i_mutex);
+
        xfs_rw_enter_trace(XFS_READ_ENTER, &ip->i_iocore,
                                (void *)iovp, segs, *offset, ioflags);
        ret = __generic_file_aio_read(iocb, iovp, segs, offset);
@@ -281,10 +286,6 @@ xfs_read(
                XFS_STATS_ADD(xs_read_bytes, ret);
 
        xfs_iunlock(ip, XFS_IOLOCK_SHARED);
-
-unlock_mutex:
-       if (unlikely(ioflags & IO_ISDIRECT))
-               mutex_unlock(&inode->i_mutex);
        return ret;
 }