]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: create a helper to decide if a file mapping targets the rt volume
authorDarrick J. Wong <djwong@kernel.org>
Mon, 22 Apr 2024 17:01:11 +0000 (10:01 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 3 Jun 2024 18:37:40 +0000 (11:37 -0700)
Source kernel commit: 5049ff4d140c8f6545464811409302cab017321a

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>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
libxfs/xfs_bmap.c
libxfs/xfs_inode_fork.c
libxfs/xfs_inode_fork.h

index 4790efd3de28fcbe1ab9de5b199458e857573ff9..85f1deac280755705b97893b92af29d5adc4695c 100644 (file)
@@ -4907,7 +4907,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);
@@ -5143,7 +5143,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);
@@ -5390,7 +5390,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 53ff8267803b8285be293c4366e4450c72dd2d15..0527488148414f17be83ab29a7510365791908f8 100644 (file)
@@ -811,3 +811,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)