Skip to content

Commit

Permalink
xfs: unlock i_mutex in xfs_break_layouts
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Dave Chinner <[email protected]>
Signed-off-by: Dave Chinner <[email protected]>
  • Loading branch information
Christoph Hellwig authored and dchinner committed Apr 13, 2015
1 parent 66db810 commit 21c3ea1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions fs/xfs/xfs_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ xfs_file_aio_write_checks(
if (error)
return error;

error = xfs_break_layouts(inode, iolock);
error = xfs_break_layouts(inode, iolock, true);
if (error)
return error;

Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/xfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/xfs_iops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion fs/xfs/xfs_pnfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down
5 changes: 3 additions & 2 deletions fs/xfs/xfs_pnfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 21c3ea1

Please sign in to comment.