xfs: create a helper to decide if a file mapping targets the rt volume
authorDarrick J. Wong <djwong@kernel.org>
Thu, 22 Feb 2024 20:43:36 +0000 (12:43 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 22 Feb 2024 20:43:36 +0000 (12:43 -0800)
Create a helper so that we can stop open-coding this decision
everywhere.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/libxfs/xfs_bmap.c
fs/xfs/libxfs/xfs_inode_fork.c
fs/xfs/libxfs/xfs_inode_fork.h
fs/xfs/scrub/bmap.c

index 2e0546eb80102e4ca91b14b75189fc42cc536bc9..b96807a53905d4a1e52bcca6bf6585e967c54e87 100644 (file)
@@ -4913,7 +4913,7 @@ xfs_bmap_del_extent_delay(
 
        XFS_STATS_INC(mp, xs_del_exlist);
 
-       isrt = (whichfork == XFS_DATA_FORK) && XFS_IS_REALTIME_INODE(ip);
+       isrt = xfs_ifork_is_realtime(ip, whichfork);
        del_endoff = del->br_startoff + del->br_blockcount;
        got_endoff = got->br_startoff + got->br_blockcount;
        da_old = startblockval(got->br_startblock);
@@ -5149,7 +5149,7 @@ xfs_bmap_del_extent_real(
                return -ENOSPC;
 
        *logflagsp = XFS_ILOG_CORE;
-       if (whichfork == XFS_DATA_FORK && XFS_IS_REALTIME_INODE(ip)) {
+       if (xfs_ifork_is_realtime(ip, whichfork)) {
                if (!(bflags & XFS_BMAPI_REMAP)) {
                        error = xfs_rtfree_blocks(tp, del->br_startblock,
                                        del->br_blockcount);
@@ -5396,7 +5396,7 @@ __xfs_bunmapi(
                return 0;
        }
        XFS_STATS_INC(mp, xs_blk_unmap);
-       isrt = (whichfork == XFS_DATA_FORK) && XFS_IS_REALTIME_INODE(ip);
+       isrt = xfs_ifork_is_realtime(ip, whichfork);
        end = start + len;
 
        if (!xfs_iext_lookup_extent_before(ip, ifp, &end, &icur, &got)) {
index 83194edcb0ba8143dbd6ef8d7cb5aae1fcf2b204..3ab0ea1335571a4059f0c508ca480c1af5194f04 100644 (file)
@@ -813,3 +813,12 @@ xfs_iext_count_upgrade(
 
        return 0;
 }
+
+/* Decide if a file mapping is on the realtime device or not. */
+bool
+xfs_ifork_is_realtime(
+       struct xfs_inode        *ip,
+       int                     whichfork)
+{
+       return XFS_IS_REALTIME_INODE(ip) && whichfork != XFS_ATTR_FORK;
+}
index 96303249d28ab444a23366e700224a93da05f486..bd53eb951b6515e1748cca91d2a926f81edf91d0 100644 (file)
@@ -260,6 +260,7 @@ int xfs_iext_count_may_overflow(struct xfs_inode *ip, int whichfork,
                int nr_to_add);
 int xfs_iext_count_upgrade(struct xfs_trans *tp, struct xfs_inode *ip,
                uint nr_to_add);
+bool xfs_ifork_is_realtime(struct xfs_inode *ip, int whichfork);
 
 /* returns true if the fork has extents but they are not read in yet. */
 static inline bool xfs_need_iread_extents(const struct xfs_ifork *ifp)
index b169cddde6da44ee6c62f06b66e2cda97ba558dd..24a15bf784f11b06ab0f46dae93d84099b14e1c8 100644 (file)
@@ -924,7 +924,7 @@ xchk_bmap(
        if (!ifp)
                return -ENOENT;
 
-       info.is_rt = whichfork == XFS_DATA_FORK && XFS_IS_REALTIME_INODE(ip);
+       info.is_rt = xfs_ifork_is_realtime(ip, whichfork);
        info.whichfork = whichfork;
        info.is_shared = whichfork == XFS_DATA_FORK && xfs_is_reflink_inode(ip);
        info.sc = sc;