diff options
author | Christoph Hellwig <hch@infradead.org> | 2009-10-19 00:00:03 -0400 |
---|---|---|
committer | Alex Elder <aelder@sgi.com> | 2009-12-11 16:11:20 -0500 |
commit | 80641dc66a2d6dfb22af4413227a92b8ab84c7bb (patch) | |
tree | f7353e4ca2bd4629b41c9ec79306d042d64f90f7 /fs | |
parent | c56c9631cbe88f08854a56ff9776c1f310916830 (diff) |
xfs: I/O completion handlers must use NOFS allocations
When completing I/O requests we must not allow the memory allocator to
recurse into the filesystem, as we might deadlock on waiting for the
I/O completion otherwise. The only thing currently allocating normal
GFP_KERNEL memory is the allocation of the transaction structure for
the unwritten extent conversion. Add a memflags argument to
_xfs_trans_alloc to allow controlling the allocator behaviour.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reported-by: Thomas Neumann <tneumann@users.sourceforge.net>
Tested-by: Thomas Neumann <tneumann@users.sourceforge.net>
Reviewed-by: Alex Elder <aelder@sgi.com>
Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/xfs_fsops.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_iomap.c | 9 | ||||
-rw-r--r-- | fs/xfs/xfs_mount.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_trans.c | 7 | ||||
-rw-r--r-- | fs/xfs/xfs_trans.h | 2 |
5 files changed, 15 insertions, 7 deletions
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index 2d0b3e1da9e6..6f83f58c099f 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c | |||
@@ -611,7 +611,7 @@ xfs_fs_log_dummy( | |||
611 | xfs_inode_t *ip; | 611 | xfs_inode_t *ip; |
612 | int error; | 612 | int error; |
613 | 613 | ||
614 | tp = _xfs_trans_alloc(mp, XFS_TRANS_DUMMY1); | 614 | tp = _xfs_trans_alloc(mp, XFS_TRANS_DUMMY1, KM_SLEEP); |
615 | error = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0); | 615 | error = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0); |
616 | if (error) { | 616 | if (error) { |
617 | xfs_trans_cancel(tp, 0); | 617 | xfs_trans_cancel(tp, 0); |
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 67ae5555a30a..7294abce6ef2 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c | |||
@@ -860,8 +860,15 @@ xfs_iomap_write_unwritten( | |||
860 | * set up a transaction to convert the range of extents | 860 | * set up a transaction to convert the range of extents |
861 | * from unwritten to real. Do allocations in a loop until | 861 | * from unwritten to real. Do allocations in a loop until |
862 | * we have covered the range passed in. | 862 | * we have covered the range passed in. |
863 | * | ||
864 | * Note that we open code the transaction allocation here | ||
865 | * to pass KM_NOFS--we can't risk to recursing back into | ||
866 | * the filesystem here as we might be asked to write out | ||
867 | * the same inode that we complete here and might deadlock | ||
868 | * on the iolock. | ||
863 | */ | 869 | */ |
864 | tp = xfs_trans_alloc(mp, XFS_TRANS_STRAT_WRITE); | 870 | xfs_wait_for_freeze(mp, SB_FREEZE_TRANS); |
871 | tp = _xfs_trans_alloc(mp, XFS_TRANS_STRAT_WRITE, KM_NOFS); | ||
865 | tp->t_flags |= XFS_TRANS_RESERVE; | 872 | tp->t_flags |= XFS_TRANS_RESERVE; |
866 | error = xfs_trans_reserve(tp, resblks, | 873 | error = xfs_trans_reserve(tp, resblks, |
867 | XFS_WRITE_LOG_RES(mp), 0, | 874 | XFS_WRITE_LOG_RES(mp), 0, |
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 8b6c9e807efb..4d509f742bd2 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c | |||
@@ -1471,7 +1471,7 @@ xfs_log_sbcount( | |||
1471 | if (!xfs_sb_version_haslazysbcount(&mp->m_sb)) | 1471 | if (!xfs_sb_version_haslazysbcount(&mp->m_sb)) |
1472 | return 0; | 1472 | return 0; |
1473 | 1473 | ||
1474 | tp = _xfs_trans_alloc(mp, XFS_TRANS_SB_COUNT); | 1474 | tp = _xfs_trans_alloc(mp, XFS_TRANS_SB_COUNT, KM_SLEEP); |
1475 | error = xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0, | 1475 | error = xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0, |
1476 | XFS_DEFAULT_LOG_COUNT); | 1476 | XFS_DEFAULT_LOG_COUNT); |
1477 | if (error) { | 1477 | if (error) { |
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 66b849358e62..237badcbac3b 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c | |||
@@ -236,19 +236,20 @@ xfs_trans_alloc( | |||
236 | uint type) | 236 | uint type) |
237 | { | 237 | { |
238 | xfs_wait_for_freeze(mp, SB_FREEZE_TRANS); | 238 | xfs_wait_for_freeze(mp, SB_FREEZE_TRANS); |
239 | return _xfs_trans_alloc(mp, type); | 239 | return _xfs_trans_alloc(mp, type, KM_SLEEP); |
240 | } | 240 | } |
241 | 241 | ||
242 | xfs_trans_t * | 242 | xfs_trans_t * |
243 | _xfs_trans_alloc( | 243 | _xfs_trans_alloc( |
244 | xfs_mount_t *mp, | 244 | xfs_mount_t *mp, |
245 | uint type) | 245 | uint type, |
246 | uint memflags) | ||
246 | { | 247 | { |
247 | xfs_trans_t *tp; | 248 | xfs_trans_t *tp; |
248 | 249 | ||
249 | atomic_inc(&mp->m_active_trans); | 250 | atomic_inc(&mp->m_active_trans); |
250 | 251 | ||
251 | tp = kmem_zone_zalloc(xfs_trans_zone, KM_SLEEP); | 252 | tp = kmem_zone_zalloc(xfs_trans_zone, memflags); |
252 | tp->t_magic = XFS_TRANS_MAGIC; | 253 | tp->t_magic = XFS_TRANS_MAGIC; |
253 | tp->t_type = type; | 254 | tp->t_type = type; |
254 | tp->t_mountp = mp; | 255 | tp->t_mountp = mp; |
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index ed47fc77759c..a0574f593f52 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h | |||
@@ -924,7 +924,7 @@ typedef struct xfs_trans { | |||
924 | * XFS transaction mechanism exported interfaces. | 924 | * XFS transaction mechanism exported interfaces. |
925 | */ | 925 | */ |
926 | xfs_trans_t *xfs_trans_alloc(struct xfs_mount *, uint); | 926 | xfs_trans_t *xfs_trans_alloc(struct xfs_mount *, uint); |
927 | xfs_trans_t *_xfs_trans_alloc(struct xfs_mount *, uint); | 927 | xfs_trans_t *_xfs_trans_alloc(struct xfs_mount *, uint, uint); |
928 | xfs_trans_t *xfs_trans_dup(xfs_trans_t *); | 928 | xfs_trans_t *xfs_trans_dup(xfs_trans_t *); |
929 | int xfs_trans_reserve(xfs_trans_t *, uint, uint, uint, | 929 | int xfs_trans_reserve(xfs_trans_t *, uint, uint, uint, |
930 | uint, uint); | 930 | uint, uint); |