xfs: support recovering refcount intent items targetting realtime extents
authorDarrick J. Wong <djwong@kernel.org>
Wed, 29 May 2024 04:13:10 +0000 (21:13 -0700)
committerChristoph Hellwig <hch@lst.de>
Mon, 12 Aug 2024 11:53:05 +0000 (13:53 +0200)
Now that we have reflink on the realtime device, refcount intent items
have to support remapping extents on the realtime volume.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
fs/xfs/xfs_refcount_item.c

index cb99c16d8aaab6244760d3c97fc7c47a8d372a3b..04b3c0879cdff4a65c48713f28bb7510d1fae30d 100644 (file)
@@ -433,6 +433,7 @@ xfs_refcount_update_abort_intent(
 static inline bool
 xfs_cui_validate_phys(
        struct xfs_mount                *mp,
+       bool                            isrt,
        struct xfs_phys_extent          *pmap)
 {
        if (!xfs_has_reflink(mp))
@@ -451,6 +452,9 @@ xfs_cui_validate_phys(
                return false;
        }
 
+       if (isrt)
+               return xfs_verify_rtbext(mp, pmap->pe_startblock, pmap->pe_len);
+
        return xfs_verify_fsbext(mp, pmap->pe_startblock, pmap->pe_len);
 }
 
@@ -458,6 +462,7 @@ static inline void
 xfs_cui_recover_work(
        struct xfs_mount                *mp,
        struct xfs_defer_pending        *dfp,
+       bool                            isrt,
        struct xfs_phys_extent          *pmap)
 {
        struct xfs_refcount_intent      *ri;
@@ -467,7 +472,12 @@ xfs_cui_recover_work(
        ri->ri_type = pmap->pe_flags & XFS_REFCOUNT_EXTENT_TYPE_MASK;
        ri->ri_startblock = pmap->pe_startblock;
        ri->ri_blockcount = pmap->pe_len;
-       ri->ri_pag = xfs_perag_intent_get(mp, pmap->pe_startblock);
+       ri->ri_realtime = isrt;
+       if (isrt) {
+               ri->ri_rtg = xfs_rtgroup_intent_get(mp, pmap->pe_startblock);
+       } else {
+               ri->ri_pag = xfs_perag_intent_get(mp, pmap->pe_startblock);
+       }
 
        xfs_defer_add_item(dfp, &ri->ri_list);
 }
@@ -486,6 +496,7 @@ xfs_refcount_recover_work(
        struct xfs_cui_log_item         *cuip = CUI_ITEM(lip);
        struct xfs_trans                *tp;
        struct xfs_mount                *mp = lip->li_log->l_mp;
+       bool                            isrt = xfs_cui_item_isrt(lip);
        int                             i;
        int                             error = 0;
 
@@ -495,7 +506,7 @@ xfs_refcount_recover_work(
         * just toss the CUI.
         */
        for (i = 0; i < cuip->cui_format.cui_nextents; i++) {
-               if (!xfs_cui_validate_phys(mp,
+               if (!xfs_cui_validate_phys(mp, isrt,
                                        &cuip->cui_format.cui_extents[i])) {
                        XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
                                        &cuip->cui_format,
@@ -503,7 +514,8 @@ xfs_refcount_recover_work(
                        return -EFSCORRUPTED;
                }
 
-               xfs_cui_recover_work(mp, dfp, &cuip->cui_format.cui_extents[i]);
+               xfs_cui_recover_work(mp, dfp, isrt,
+                               &cuip->cui_format.cui_extents[i]);
        }
 
        /*