mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-04 16:15:11 +00:00
xfs: avoid memory allocation under m_peraglock in growfs code
Allocate the memory for the larger m_perag array before taking the per-AG lock as the per-AG lock can be taken under the i_lock which can be taken from reclaim context. Reported by the new reclaim context tracing in lockdep. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Felix Blyakher <felixb@sgi.com> Signed-off-by: Felix Blyakher <felixb@sgi.com>
This commit is contained in:
parent
c8a4051c37
commit
0cc6eee130
1 changed files with 14 additions and 6 deletions
|
@ -167,17 +167,25 @@ xfs_growfs_data_private(
|
||||||
new = nb - mp->m_sb.sb_dblocks;
|
new = nb - mp->m_sb.sb_dblocks;
|
||||||
oagcount = mp->m_sb.sb_agcount;
|
oagcount = mp->m_sb.sb_agcount;
|
||||||
if (nagcount > oagcount) {
|
if (nagcount > oagcount) {
|
||||||
|
void *new_perag, *old_perag;
|
||||||
|
|
||||||
xfs_filestream_flush(mp);
|
xfs_filestream_flush(mp);
|
||||||
|
|
||||||
|
new_perag = kmem_zalloc(sizeof(xfs_perag_t) * nagcount,
|
||||||
|
KM_MAYFAIL);
|
||||||
|
if (!new_perag)
|
||||||
|
return XFS_ERROR(ENOMEM);
|
||||||
|
|
||||||
down_write(&mp->m_peraglock);
|
down_write(&mp->m_peraglock);
|
||||||
mp->m_perag = kmem_realloc(mp->m_perag,
|
memcpy(new_perag, mp->m_perag, sizeof(xfs_perag_t) * oagcount);
|
||||||
sizeof(xfs_perag_t) * nagcount,
|
old_perag = mp->m_perag;
|
||||||
sizeof(xfs_perag_t) * oagcount,
|
mp->m_perag = new_perag;
|
||||||
KM_SLEEP);
|
|
||||||
memset(&mp->m_perag[oagcount], 0,
|
|
||||||
(nagcount - oagcount) * sizeof(xfs_perag_t));
|
|
||||||
mp->m_flags |= XFS_MOUNT_32BITINODES;
|
mp->m_flags |= XFS_MOUNT_32BITINODES;
|
||||||
nagimax = xfs_initialize_perag(mp, nagcount);
|
nagimax = xfs_initialize_perag(mp, nagcount);
|
||||||
up_write(&mp->m_peraglock);
|
up_write(&mp->m_peraglock);
|
||||||
|
|
||||||
|
kmem_free(old_perag);
|
||||||
}
|
}
|
||||||
tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFS);
|
tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFS);
|
||||||
tp->t_flags |= XFS_TRANS_RESERVE;
|
tp->t_flags |= XFS_TRANS_RESERVE;
|
||||||
|
|
Loading…
Reference in a new issue