Like we already do for rtvol, only free full extents for forcealign in xfs_free_file_space(). Reviewed-by: "Darrick J. Wong" <djwong@xxxxxxxxxx> #earlier version Signed-off-by: John Garry <john.g.garry@xxxxxxxxxx> --- fs/xfs/xfs_bmap_util.c | 8 +++----- fs/xfs/xfs_inode.c | 12 ++++++++++++ fs/xfs/xfs_inode.h | 2 ++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 7a51859eaf84..317ce8947e8d 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -851,11 +851,9 @@ xfs_free_file_space( startoffset_fsb = XFS_B_TO_FSB(mp, offset); endoffset_fsb = XFS_B_TO_FSBT(mp, offset + len); - /* We can only free complete realtime extents. */ - if (xfs_inode_has_bigrtalloc(ip)) { - startoffset_fsb = xfs_rtb_roundup_rtx(mp, startoffset_fsb); - endoffset_fsb = xfs_rtb_rounddown_rtx(mp, endoffset_fsb); - } + /* Free only complete extents. */ + startoffset_fsb = xfs_inode_roundup_alloc_unit(ip, startoffset_fsb); + endoffset_fsb = xfs_inode_rounddown_alloc_unit(ip, endoffset_fsb); /* * Need to zero the stuff we're not freeing, on disk. diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 94ab3f4d6cef..73562c6f9a1d 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -3141,6 +3141,18 @@ xfs_inode_roundup_alloc_unit( return roundup_64(offset, rounding); } +xfs_fileoff_t +xfs_inode_rounddown_alloc_unit( + struct xfs_inode *ip, + xfs_fileoff_t offset) +{ + unsigned int rounding = xfs_inode_alloc_fsbsize(ip); + + if (rounding == 1) + return offset; + return rounddown_64(offset, rounding); +} + /* Should we always be using copy on write for file writes? */ bool xfs_is_always_cow_inode( diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 71acddb8061d..336124105c47 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -645,6 +645,8 @@ unsigned int xfs_inode_alloc_fsbsize(struct xfs_inode *ip); unsigned int xfs_inode_alloc_unitsize(struct xfs_inode *ip); xfs_fileoff_t xfs_inode_roundup_alloc_unit(struct xfs_inode *ip, xfs_fileoff_t offset); +xfs_fileoff_t xfs_inode_rounddown_alloc_unit(struct xfs_inode *ip, + xfs_fileoff_t offset); int xfs_icreate_dqalloc(const struct xfs_icreate_args *args, struct xfs_dquot **udqpp, struct xfs_dquot **gdqpp, -- 2.31.1