Skip to content

Commit 6c66448

Browse files
author
Darrick J. Wong
committed
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: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
1 parent 9488062 commit 6c66448

File tree

3 files changed

+41
-16
lines changed

3 files changed

+41
-16
lines changed

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5057,33 +5057,20 @@ xfs_bmap_del_extent_real(
50575057

50585058
flags = XFS_ILOG_CORE;
50595059
if (whichfork == XFS_DATA_FORK && XFS_IS_REALTIME_INODE(ip)) {
5060-
xfs_filblks_t len;
5061-
xfs_extlen_t mod;
5062-
5063-
len = div_u64_rem(del->br_blockcount, mp->m_sb.sb_rextsize,
5064-
&mod);
5065-
ASSERT(mod == 0);
5066-
50675060
if (!(bflags & XFS_BMAPI_REMAP)) {
5068-
xfs_fsblock_t bno;
5069-
5070-
bno = div_u64_rem(del->br_startblock,
5071-
mp->m_sb.sb_rextsize, &mod);
5072-
ASSERT(mod == 0);
5073-
5074-
error = xfs_rtfree_extent(tp, bno, (xfs_extlen_t)len);
5061+
error = xfs_rtfree_blocks(tp, del->br_startblock,
5062+
del->br_blockcount);
50755063
if (error)
50765064
goto done;
50775065
}
50785066

50795067
do_fx = 0;
5080-
nblks = len * mp->m_sb.sb_rextsize;
50815068
qfield = XFS_TRANS_DQ_RTBCOUNT;
50825069
} else {
50835070
do_fx = 1;
5084-
nblks = del->br_blockcount;
50855071
qfield = XFS_TRANS_DQ_BCOUNT;
50865072
}
5073+
nblks = del->br_blockcount;
50875074

50885075
del_endblock = del->br_startblock + del->br_blockcount;
50895076
if (cur) {

fs/xfs/libxfs/xfs_rtbitmap.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,39 @@ xfs_rtfree_extent(
10051005
return 0;
10061006
}
10071007

1008+
/*
1009+
* Free some blocks in the realtime subvolume. rtbno and rtlen are in units of
1010+
* rt blocks, not rt extents; must be aligned to the rt extent size; and rtlen
1011+
* cannot exceed XFS_MAX_BMBT_EXTLEN.
1012+
*/
1013+
int
1014+
xfs_rtfree_blocks(
1015+
struct xfs_trans *tp,
1016+
xfs_fsblock_t rtbno,
1017+
xfs_filblks_t rtlen)
1018+
{
1019+
struct xfs_mount *mp = tp->t_mountp;
1020+
xfs_rtblock_t bno;
1021+
xfs_filblks_t len;
1022+
xfs_extlen_t mod;
1023+
1024+
ASSERT(rtlen <= XFS_MAX_BMBT_EXTLEN);
1025+
1026+
len = div_u64_rem(rtlen, mp->m_sb.sb_rextsize, &mod);
1027+
if (mod) {
1028+
ASSERT(mod == 0);
1029+
return -EIO;
1030+
}
1031+
1032+
bno = div_u64_rem(rtbno, mp->m_sb.sb_rextsize, &mod);
1033+
if (mod) {
1034+
ASSERT(mod == 0);
1035+
return -EIO;
1036+
}
1037+
1038+
return xfs_rtfree_extent(tp, bno, len);
1039+
}
1040+
10081041
/* Find all the free records within a given range. */
10091042
int
10101043
xfs_rtalloc_query_range(

fs/xfs/xfs_rtalloc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ xfs_rtfree_extent(
5858
xfs_rtblock_t bno, /* starting block number to free */
5959
xfs_extlen_t len); /* length of extent freed */
6060

61+
/* Same as above, but in units of rt blocks. */
62+
int xfs_rtfree_blocks(struct xfs_trans *tp, xfs_fsblock_t rtbno,
63+
xfs_filblks_t rtlen);
64+
6165
/*
6266
* Initialize realtime fields in the mount structure.
6367
*/
@@ -139,6 +143,7 @@ int xfs_rtalloc_reinit_frextents(struct xfs_mount *mp);
139143
#else
140144
# define xfs_rtallocate_extent(t,b,min,max,l,f,p,rb) (ENOSYS)
141145
# define xfs_rtfree_extent(t,b,l) (ENOSYS)
146+
# define xfs_rtfree_blocks(t,rb,rl) (ENOSYS)
142147
# define xfs_rtpick_extent(m,t,l,rb) (ENOSYS)
143148
# define xfs_growfs_rt(mp,in) (ENOSYS)
144149
# define xfs_rtalloc_query_range(t,l,h,f,p) (ENOSYS)

0 commit comments

Comments
 (0)