提交 4df0f7f1 编写于 作者: D Dave Chinner 提交者: Darrick J. Wong

xfs: fix transaction allocation deadlock in IO path

xfs_trans_alloc() does GFP_KERNEL allocation, and we can call it
while holding pages locked for writeback in the ->writepages path.
The memory allocation is allowed to wait on pages under writeback,
and so can wait on pages that are tagged as writeback by the
caller.

This affects both pre-IO submission and post-IO submission paths.
Hence xfs_setsize_trans_alloc(), xfs_reflink_end_cow(),
xfs_iomap_write_unwritten() and xfs_reflink_cancel_cow_range().
xfs_iomap_write_unwritten() already does the right thing, but the
others don't. Fix them.
Signed-Off-By: NDave Chinner <dchinner@redhat.com>
Fixes: 281627df ("xfs: log file size updates at I/O completion time")
Fixes: 43caeb18 ("xfs: move mappings from cow fork to data fork after copy-write)"
Reviewed-by: NEric Sandeen <sandeen@redhat.com>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
上级 c3b1b131
...@@ -209,7 +209,8 @@ xfs_setfilesize_trans_alloc( ...@@ -209,7 +209,8 @@ xfs_setfilesize_trans_alloc(
struct xfs_trans *tp; struct xfs_trans *tp;
int error; int error;
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp); error = xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0,
XFS_TRANS_NOFS, &tp);
if (error) if (error)
return error; return error;
......
...@@ -668,7 +668,7 @@ xfs_reflink_cancel_cow_range( ...@@ -668,7 +668,7 @@ xfs_reflink_cancel_cow_range(
/* Start a rolling transaction to remove the mappings */ /* Start a rolling transaction to remove the mappings */
error = xfs_trans_alloc(ip->i_mount, &M_RES(ip->i_mount)->tr_write, error = xfs_trans_alloc(ip->i_mount, &M_RES(ip->i_mount)->tr_write,
0, 0, 0, &tp); 0, 0, XFS_TRANS_NOFS, &tp);
if (error) if (error)
goto out; goto out;
...@@ -741,7 +741,7 @@ xfs_reflink_end_cow( ...@@ -741,7 +741,7 @@ xfs_reflink_end_cow(
(unsigned int)(end_fsb - offset_fsb), (unsigned int)(end_fsb - offset_fsb),
XFS_DATA_FORK); XFS_DATA_FORK);
error = xfs_trans_alloc(ip->i_mount, &M_RES(ip->i_mount)->tr_write, error = xfs_trans_alloc(ip->i_mount, &M_RES(ip->i_mount)->tr_write,
resblks, 0, XFS_TRANS_RESERVE, &tp); resblks, 0, XFS_TRANS_RESERVE | XFS_TRANS_NOFS, &tp);
if (error) if (error)
goto out; goto out;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册