xfs: hoist multi-fsb allocation unit detection to a helper
authorDarrick J. Wong <djwong@kernel.org>
Mon, 15 Apr 2024 21:54:11 +0000 (14:54 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 15 Apr 2024 21:54:11 +0000 (14:54 -0700)
Replace the open-coded logic to decide if a file has a multi-fsb
allocation unit to a helper to make the code easier to read.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_bmap_util.c
fs/xfs/xfs_inode.h

index 19e11d1da66074a61f464a8300fc56bb4b186277..53aa90a0ee3a857eb00090ace1947b5667e82eaf 100644 (file)
@@ -542,7 +542,7 @@ xfs_can_free_eofblocks(
         * forever.
         */
        end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_ISIZE(ip));
-       if (XFS_IS_REALTIME_INODE(ip) && mp->m_sb.sb_rextsize > 1)
+       if (xfs_inode_has_bigrtalloc(ip))
                end_fsb = xfs_rtb_roundup_rtx(mp, end_fsb);
        last_fsb = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes);
        if (last_fsb <= end_fsb)
@@ -843,7 +843,7 @@ xfs_free_file_space(
        endoffset_fsb = XFS_B_TO_FSBT(mp, offset + len);
 
        /* We can only free complete realtime extents. */
-       if (XFS_IS_REALTIME_INODE(ip) && mp->m_sb.sb_rextsize > 1) {
+       if (xfs_inode_has_bigrtalloc(ip)) {
                startoffset_fsb = xfs_rtb_roundup_rtx(mp, startoffset_fsb);
                endoffset_fsb = xfs_rtb_rounddown_rtx(mp, endoffset_fsb);
        }
index fa3e605901e24269033deeebce2cb3da8d0adc9c..f559e68ee7077656674f9f9ffa7e944b46fa1305 100644 (file)
@@ -311,6 +311,15 @@ static inline bool xfs_inode_has_large_extent_counts(struct xfs_inode *ip)
        return ip->i_diflags2 & XFS_DIFLAG2_NREXT64;
 }
 
+/*
+ * Decide if this file is a realtime file whose data allocation unit is larger
+ * than a single filesystem block.
+ */
+static inline bool xfs_inode_has_bigrtalloc(struct xfs_inode *ip)
+{
+       return XFS_IS_REALTIME_INODE(ip) && ip->i_mount->m_sb.sb_rextsize > 1;
+}
+
 /*
  * Return the buftarg used for data allocations on a given inode.
  */