xfs: fix deadlock in xfs_rtfree_extent with kernel v3.x
PATCH 1/1 xfs: fix deadlock in xfs_rtfree_extent with kernel v3.x
To fix the deadlock caused by recursively calling xfs_rtfree_extent
- removed xfs_ilock() and xfs_trans_ijoin() from xfs_rtfree_extent(), instead added asserts that the inode is locked and has an inode_item attached to it.
- in xfs_bunmapi() when dealing with an inode with the rt flag call xfs_ilock() and xfs_trans_ijoin() so that the reference count is bumped on the inode and attached it to the transaction before calling into xfs_bmap_del_extent, similar to what we do in xfs_bmap_rtalloc.
--- fs/xfs/xfs_bmap.c | 9 +++++++++ fs/xfs/xfs_rtalloc.c | 9 ++++----- 2 files changed, 13 insertions(+), 5 deletions(-)
fs/xfs/xfs_bmap.c +9 -0
@@ -5124,6 +5124,15 @@ xfs_bunmapi( cur->bc_private.b.flags =0 ; }else cur =NULL ; + +if (isrt) { +/* +* Synchronize by locking the bitmap inode. +*/ +xfs_ilock (mp->m_rbmip,XFS_ILOCK_EXCL ); +xfs_trans_ijoin (tp, mp->m_rbmip,XFS_ILOCK_EXCL ); + } + extno =0 ;while (bno != (xfs_fileoff_t)-1 && bno >= start && lastx >=0 && (nexts ==0 || extno < nexts)) {
fs/xfs/xfs_rtalloc.c +4 -5
@@ -183,6 +183,7 @@ error_cancel: oblocks = map.br_startoff + map.br_blockcount; }return 0 ; + error:return error; }
@@ -2139,11 +2140,9 @@ xfs_rtfree_extent(xfs_buf_t *sumbp;/* summary file block buffer */ mp = tp->t_mountp; -/* -* Synchronize by locking the bitmap inode. -*/ -xfs_ilock (mp->m_rbmip,XFS_ILOCK_EXCL ); -xfs_trans_ijoin (tp, mp->m_rbmip,XFS_ILOCK_EXCL ); + +ASSERT (mp->m_rbmip->i_itemp !=NULL ); +ASSERT (xfs_isilocked (mp->m_rbmip,XFS_ILOCK_EXCL ));#if defined(__KERNEL__) && defined(DEBUG )/*
Signature · 7 lines
1.7.5.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Adding reference to the related thread for an older kernel :
<a href="http://old.nabble.com/forum/ViewPost.jtp?post=33405297&framed=y">http://old.nabble.com/forum/ViewPost.jtp?post=33405297&framed=y</a>
Kamal
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 11 lines · Kamal Dasu
To fix the deadlock caused by recursively calling
xfs_rtfree_extent- removed
xfs_ilock()andxfs_trans_ijoin()fromxfs_rtfree_extent(), instead added asserts that the inode is locked and has aninode_itemattached to it.
- inxfs_bunmapi()when dealing with an inode with the rt flag callxfs_ilock()andxfs_trans_ijoin()so that the reference count is bumped on the inode and attached it to the transaction before calling intoxfs_bmap_del_extent, similar to what we do inxfs_bmap_rtalloc.
Quoted 1 line
Signed-off-by Kamal Dasu <[email protected]>
Kamal, this looks good to me.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs