OSDN Git Service

xfs: fix swapext ilock deadlock
authorDave Chinner <dchinner@redhat.com>
Mon, 4 Aug 2014 03:29:32 +0000 (13:29 +1000)
committerDave Chinner <david@fromorbit.com>
Mon, 4 Aug 2014 03:29:32 +0000 (13:29 +1000)
commit812176832169c77b4bacddd01edc3e55340263fd
tree6f3bde524887cb6f8e66f3d86c89b28118ab795b
parentb92cc59f69537f26d5a42e4171ccc864ae4d9383
xfs: fix swapext ilock deadlock

xfs_swap_extents() holds the ilock over a call to
filemap_write_and_wait(), which can then try to write data and take
the ilock. That causes a self-deadlock.

Fix the deadlock and clean up the code by separating the locking
appropriately. Add a lockflags variable to track what locks we are
holding as we gain and drop them and cleanup the error handling to
always use "out_unlock" with the lockflags variable.

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