Commit de37dbd0 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Chandan Babu R

xfs: move RT inode locking out of __xfs_bunmapi

__xfs_bunmapi is a bit of an odd place to lock the rtbitmap and rtsummary
inodes given that it is very high level code.  While this only looks ugly
right now, it will become a problem when supporting delayed allocations
for RT inodes as __xfs_bunmapi might end up deleting only delalloc extents
and thus never unlock the rt inodes.

Move the locking into xfs_bmap_del_extent_real just before the call to
xfs_rtfree_blocks instead and use a new flag in the transaction to ensure
that the locking happens only once.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
parent 9871d096
...@@ -5307,6 +5307,14 @@ xfs_bmap_del_extent_real( ...@@ -5307,6 +5307,14 @@ xfs_bmap_del_extent_real(
if (xfs_is_reflink_inode(ip) && whichfork == XFS_DATA_FORK) { if (xfs_is_reflink_inode(ip) && whichfork == XFS_DATA_FORK) {
xfs_refcount_decrease_extent(tp, del); xfs_refcount_decrease_extent(tp, del);
} else if (xfs_ifork_is_realtime(ip, whichfork)) { } else if (xfs_ifork_is_realtime(ip, whichfork)) {
/*
* Ensure the bitmap and summary inodes are locked
* and joined to the transaction before modifying them.
*/
if (!(tp->t_flags & XFS_TRANS_RTBITMAP_LOCKED)) {
tp->t_flags |= XFS_TRANS_RTBITMAP_LOCKED;
xfs_rtbitmap_lock(tp, mp);
}
error = xfs_rtfree_blocks(tp, del->br_startblock, error = xfs_rtfree_blocks(tp, del->br_startblock,
del->br_blockcount); del->br_blockcount);
} else { } else {
...@@ -5408,13 +5416,6 @@ __xfs_bunmapi( ...@@ -5408,13 +5416,6 @@ __xfs_bunmapi(
} else } else
cur = NULL; cur = NULL;
if (isrt) {
/*
* Synchronize by locking the realtime bitmap.
*/
xfs_rtbitmap_lock(tp, mp);
}
extno = 0; extno = 0;
while (end != (xfs_fileoff_t)-1 && end >= start && while (end != (xfs_fileoff_t)-1 && end >= start &&
(nexts == 0 || extno < nexts)) { (nexts == 0 || extno < nexts)) {
......
...@@ -137,6 +137,9 @@ void xfs_log_get_max_trans_res(struct xfs_mount *mp, ...@@ -137,6 +137,9 @@ void xfs_log_get_max_trans_res(struct xfs_mount *mp,
*/ */
#define XFS_TRANS_LOWMODE (1u << 8) #define XFS_TRANS_LOWMODE (1u << 8)
/* Transaction has locked the rtbitmap and rtsum inodes */
#define XFS_TRANS_RTBITMAP_LOCKED (1u << 9)
/* /*
* Field values for xfs_trans_mod_sb. * Field values for xfs_trans_mod_sb.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment