Commit 6c664484 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: hoist freeing of rt data fork extent mappings

Currently, xfs_bmap_del_extent_real contains a bunch of code to convert
the physical extent of a data fork mapping for a realtime file into rt
extents and pass that to the rt extent freeing function.  Since the
details of this aren't needed when CONFIG_XFS_REALTIME=n, move it to
xfs_rtbitmap.c to reduce code size when realtime isn't enabled.

This will (one day) enable realtime EFIs to reuse the same
unit-converting call with less code duplication.
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 94880628
...@@ -5057,33 +5057,20 @@ xfs_bmap_del_extent_real( ...@@ -5057,33 +5057,20 @@ xfs_bmap_del_extent_real(
flags = XFS_ILOG_CORE; flags = XFS_ILOG_CORE;
if (whichfork == XFS_DATA_FORK && XFS_IS_REALTIME_INODE(ip)) { if (whichfork == XFS_DATA_FORK && XFS_IS_REALTIME_INODE(ip)) {
xfs_filblks_t len;
xfs_extlen_t mod;
len = div_u64_rem(del->br_blockcount, mp->m_sb.sb_rextsize,
&mod);
ASSERT(mod == 0);
if (!(bflags & XFS_BMAPI_REMAP)) { if (!(bflags & XFS_BMAPI_REMAP)) {
xfs_fsblock_t bno; error = xfs_rtfree_blocks(tp, del->br_startblock,
del->br_blockcount);
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) if (error)
goto done; goto done;
} }
do_fx = 0; do_fx = 0;
nblks = len * mp->m_sb.sb_rextsize;
qfield = XFS_TRANS_DQ_RTBCOUNT; qfield = XFS_TRANS_DQ_RTBCOUNT;
} else { } else {
do_fx = 1; do_fx = 1;
nblks = del->br_blockcount;
qfield = XFS_TRANS_DQ_BCOUNT; qfield = XFS_TRANS_DQ_BCOUNT;
} }
nblks = del->br_blockcount;
del_endblock = del->br_startblock + del->br_blockcount; del_endblock = del->br_startblock + del->br_blockcount;
if (cur) { if (cur) {
......
...@@ -1005,6 +1005,39 @@ xfs_rtfree_extent( ...@@ -1005,6 +1005,39 @@ xfs_rtfree_extent(
return 0; return 0;
} }
/*
* Free some blocks in the realtime subvolume. rtbno and rtlen are in units of
* rt blocks, not rt extents; must be aligned to the rt extent size; and rtlen
* cannot exceed XFS_MAX_BMBT_EXTLEN.
*/
int
xfs_rtfree_blocks(
struct xfs_trans *tp,
xfs_fsblock_t rtbno,
xfs_filblks_t rtlen)
{
struct xfs_mount *mp = tp->t_mountp;
xfs_rtblock_t bno;
xfs_filblks_t len;
xfs_extlen_t mod;
ASSERT(rtlen <= XFS_MAX_BMBT_EXTLEN);
len = div_u64_rem(rtlen, mp->m_sb.sb_rextsize, &mod);
if (mod) {
ASSERT(mod == 0);
return -EIO;
}
bno = div_u64_rem(rtbno, mp->m_sb.sb_rextsize, &mod);
if (mod) {
ASSERT(mod == 0);
return -EIO;
}
return xfs_rtfree_extent(tp, bno, len);
}
/* Find all the free records within a given range. */ /* Find all the free records within a given range. */
int int
xfs_rtalloc_query_range( xfs_rtalloc_query_range(
......
...@@ -58,6 +58,10 @@ xfs_rtfree_extent( ...@@ -58,6 +58,10 @@ xfs_rtfree_extent(
xfs_rtblock_t bno, /* starting block number to free */ xfs_rtblock_t bno, /* starting block number to free */
xfs_extlen_t len); /* length of extent freed */ xfs_extlen_t len); /* length of extent freed */
/* Same as above, but in units of rt blocks. */
int xfs_rtfree_blocks(struct xfs_trans *tp, xfs_fsblock_t rtbno,
xfs_filblks_t rtlen);
/* /*
* Initialize realtime fields in the mount structure. * Initialize realtime fields in the mount structure.
*/ */
...@@ -139,6 +143,7 @@ int xfs_rtalloc_reinit_frextents(struct xfs_mount *mp); ...@@ -139,6 +143,7 @@ int xfs_rtalloc_reinit_frextents(struct xfs_mount *mp);
#else #else
# define xfs_rtallocate_extent(t,b,min,max,l,f,p,rb) (ENOSYS) # define xfs_rtallocate_extent(t,b,min,max,l,f,p,rb) (ENOSYS)
# define xfs_rtfree_extent(t,b,l) (ENOSYS) # define xfs_rtfree_extent(t,b,l) (ENOSYS)
# define xfs_rtfree_blocks(t,rb,rl) (ENOSYS)
# define xfs_rtpick_extent(m,t,l,rb) (ENOSYS) # define xfs_rtpick_extent(m,t,l,rb) (ENOSYS)
# define xfs_growfs_rt(mp,in) (ENOSYS) # define xfs_growfs_rt(mp,in) (ENOSYS)
# define xfs_rtalloc_query_range(t,l,h,f,p) (ENOSYS) # define xfs_rtalloc_query_range(t,l,h,f,p) (ENOSYS)
......
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