Message ID | 20200918021450.GU7955@magnolia (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [v2,1/2] xfs: don't free rt blocks when we're doing a REMAP bunmapi call | expand |
On Thu, Sep 17, 2020 at 07:14:50PM -0700, Darrick J. Wong wrote: > From: Darrick J. Wong <darrick.wong@oracle.com> > > 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> Looks good, Reviewed-by: Christoph Hellwig <hch@lst.de>
On Thu, Sep 17, 2020 at 07:14:50PM -0700, Darrick J. Wong wrote: > From: Darrick J. Wong <darrick.wong@oracle.com> > > 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> > --- > v2: only compute bno if we're going to use it > --- > fs/xfs/libxfs/xfs_bmap.c | 19 ++++++++++++------- > 1 file changed, 12 insertions(+), 7 deletions(-) Looks fine. Reviewed-by: Dave Chinner <dchinner@redhat.com>
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 1b0a01b06a05..d9a692484eae 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -5046,20 +5046,25 @@ xfs_bmap_del_extent_real( flags = XFS_ILOG_CORE; if (whichfork == XFS_DATA_FORK && XFS_IS_REALTIME_INODE(ip)) { - xfs_fsblock_t bno; xfs_filblks_t len; xfs_extlen_t mod; - bno = div_u64_rem(del->br_startblock, mp->m_sb.sb_rextsize, - &mod); - ASSERT(mod == 0); len = div_u64_rem(del->br_blockcount, mp->m_sb.sb_rextsize, &mod); ASSERT(mod == 0); - error = xfs_rtfree_extent(tp, bno, (xfs_extlen_t)len); - if (error) - goto done; + if (!(bflags & XFS_BMAPI_REMAP)) { + xfs_fsblock_t bno; + + bno = div_u64_rem(del->br_startblock, + mp->m_sb.sb_rextsize, &mod); + ASSERT(mod == 0); + + error = xfs_rtfree_extent(tp, bno, (xfs_extlen_t)len); + if (error) + goto done; + } + do_fx = 0; nblks = len * mp->m_sb.sb_rextsize; qfield = XFS_TRANS_DQ_RTBCOUNT;