]> git.karo-electronics.de Git - linux-beck.git/commitdiff
xfs: unlock i_mutex in xfs_break_layouts
authorChristoph Hellwig <hch@lst.de>
Mon, 13 Apr 2015 01:38:29 +0000 (11:38 +1000)
committerDave Chinner <david@fromorbit.com>
Mon, 13 Apr 2015 01:38:29 +0000 (11:38 +1000)
We want to drop all I/O path locks when recalling layouts, and that includes
i_mutex for the write path.  Without this we get stuck processe when recalls
take too long.

[dchinner: fix build with !CONFIG_PNFS]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/xfs_file.c
fs/xfs/xfs_ioctl.c
fs/xfs/xfs_iops.c
fs/xfs/xfs_pnfs.c
fs/xfs/xfs_pnfs.h

index edeaccc7961ae0bdb9d59750c0a80ea9d4946f3f..f63aeddd31d50c5c59c0b0a687ace20c9ffeaf6d 100644 (file)
@@ -555,7 +555,7 @@ restart:
        if (error)
                return error;
 
-       error = xfs_break_layouts(inode, iolock);
+       error = xfs_break_layouts(inode, iolock, true);
        if (error)
                return error;
 
@@ -842,7 +842,7 @@ xfs_file_fallocate(
                return -EOPNOTSUPP;
 
        xfs_ilock(ip, iolock);
-       error = xfs_break_layouts(inode, &iolock);
+       error = xfs_break_layouts(inode, &iolock, false);
        if (error)
                goto out_unlock;
 
index ac4feae45eb308c39629f177c0b6620fae77fb69..3a21cc71fda0bfb2d4ce7eb768629d35883d1f96 100644 (file)
@@ -639,7 +639,7 @@ xfs_ioc_space(
                return error;
 
        xfs_ilock(ip, iolock);
-       error = xfs_break_layouts(inode, &iolock);
+       error = xfs_break_layouts(inode, &iolock, false);
        if (error)
                goto out_unlock;
 
index d7782ae1af3c1b966ac6303ccfab64d36ceeed96..1d4efee4be17f5694e7070a561a9711f7cbf8cf7 100644 (file)
@@ -988,7 +988,7 @@ xfs_vn_setattr(
                uint            iolock = XFS_IOLOCK_EXCL;
 
                xfs_ilock(ip, iolock);
-               error = xfs_break_layouts(dentry->d_inode, &iolock);
+               error = xfs_break_layouts(dentry->d_inode, &iolock, true);
                if (!error)
                        error = xfs_setattr_size(ip, iattr);
                xfs_iunlock(ip, iolock);
index 4b33ef112400cc01507b96632d93775839573d99..cbb424f4d93ab1de3839a5db605026f801899f16 100644 (file)
@@ -31,7 +31,8 @@
 int
 xfs_break_layouts(
        struct inode            *inode,
-       uint                    *iolock)
+       uint                    *iolock,
+       bool                    with_imutex)
 {
        struct xfs_inode        *ip = XFS_I(inode);
        int                     error;
@@ -40,8 +41,12 @@ xfs_break_layouts(
 
        while ((error = break_layout(inode, false) == -EWOULDBLOCK)) {
                xfs_iunlock(ip, *iolock);
+               if (with_imutex && (*iolock & XFS_IOLOCK_EXCL))
+                       mutex_unlock(&inode->i_mutex);
                error = break_layout(inode, true);
                *iolock = XFS_IOLOCK_EXCL;
+               if (with_imutex)
+                       mutex_lock(&inode->i_mutex);
                xfs_ilock(ip, *iolock);
        }
 
index b7fbfce660f68516d261e56f2c0ea2c78291832c..8147ac1088203b285bb8ebd6462c00d0c916abc1 100644 (file)
@@ -8,9 +8,10 @@ int xfs_fs_map_blocks(struct inode *inode, loff_t offset, u64 length,
 int xfs_fs_commit_blocks(struct inode *inode, struct iomap *maps, int nr_maps,
                struct iattr *iattr);
 
-int xfs_break_layouts(struct inode *inode, uint *iolock);
+int xfs_break_layouts(struct inode *inode, uint *iolock, bool with_imutex);
 #else
-static inline int xfs_break_layouts(struct inode *inode, uint *iolock)
+static inline int
+xfs_break_layouts(struct inode *inode, uint *iolock, bool with_imutex)
 {
        return 0;
 }