Skip to content

Commit 7bd6f89

Browse files
djwonggregkh
authored andcommitted
xfs: don't free rt blocks when we're doing a REMAP bunmapi call
[ Upstream commit 8df0fa3 ] When callers pass XFS_BMAPI_REMAP into xfs_bunmapi, they want the extent to be unmapped from the given file fork without the extent being freed. We do this for non-rt files, but we forgot to do this for realtime files. So far this isn't a big deal since nobody makes a bunmapi call to a rt file with the REMAP flag set, but don't leave a logic bomb. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 66b70f6 commit 7bd6f89

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5046,20 +5046,25 @@ xfs_bmap_del_extent_real(
50465046

50475047
flags = XFS_ILOG_CORE;
50485048
if (whichfork == XFS_DATA_FORK && XFS_IS_REALTIME_INODE(ip)) {
5049-
xfs_fsblock_t bno;
50505049
xfs_filblks_t len;
50515050
xfs_extlen_t mod;
50525051

5053-
bno = div_u64_rem(del->br_startblock, mp->m_sb.sb_rextsize,
5054-
&mod);
5055-
ASSERT(mod == 0);
50565052
len = div_u64_rem(del->br_blockcount, mp->m_sb.sb_rextsize,
50575053
&mod);
50585054
ASSERT(mod == 0);
50595055

5060-
error = xfs_rtfree_extent(tp, bno, (xfs_extlen_t)len);
5061-
if (error)
5062-
goto done;
5056+
if (!(bflags & XFS_BMAPI_REMAP)) {
5057+
xfs_fsblock_t bno;
5058+
5059+
bno = div_u64_rem(del->br_startblock,
5060+
mp->m_sb.sb_rextsize, &mod);
5061+
ASSERT(mod == 0);
5062+
5063+
error = xfs_rtfree_extent(tp, bno, (xfs_extlen_t)len);
5064+
if (error)
5065+
goto done;
5066+
}
5067+
50635068
do_fx = 0;
50645069
nblks = len * mp->m_sb.sb_rextsize;
50655070
qfield = XFS_TRANS_DQ_RTBCOUNT;

0 commit comments

Comments
 (0)