]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: support recovering rmap intent items targetting realtime extents
authorDarrick J. Wong <djwong@kernel.org>
Wed, 29 May 2024 04:11:50 +0000 (21:11 -0700)
committerChristoph Hellwig <hch@lst.de>
Mon, 12 Aug 2024 07:35:31 +0000 (09:35 +0200)
Now that we have rmap on the realtime device, log recovery has to
support remapping extents on the realtime volume.  Make this work.

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

index a7390413e970b9f47ecc5f3380c34a6c87bedb00..675a30574ea0dd9f3f2066c6fa4340765a6a8469 100644 (file)
@@ -452,6 +452,7 @@ xfs_rmap_update_abort_intent(
 static inline bool
 xfs_rui_validate_map(
        struct xfs_mount                *mp,
+       bool                            isrt,
        struct xfs_map_extent           *map)
 {
        if (!xfs_has_rmapbt(mp))
@@ -481,6 +482,9 @@ xfs_rui_validate_map(
        if (!xfs_verify_fileext(mp, map->me_startoff, map->me_len))
                return false;
 
+       if (isrt)
+               return xfs_verify_rtbext(mp, map->me_startblock, map->me_len);
+
        return xfs_verify_fsbext(mp, map->me_startblock, map->me_len);
 }
 
@@ -488,6 +492,7 @@ static inline void
 xfs_rui_recover_work(
        struct xfs_mount                *mp,
        struct xfs_defer_pending        *dfp,
+       bool                            isrt,
        const struct xfs_map_extent     *map)
 {
        struct xfs_rmap_intent          *ri;
@@ -532,7 +537,15 @@ xfs_rui_recover_work(
        ri->ri_bmap.br_blockcount = map->me_len;
        ri->ri_bmap.br_state = (map->me_flags & XFS_RMAP_EXTENT_UNWRITTEN) ?
                        XFS_EXT_UNWRITTEN : XFS_EXT_NORM;
-       ri->ri_pag = xfs_perag_intent_get(mp, map->me_startblock);
+       ri->ri_realtime = isrt;
+       if (isrt) {
+               xfs_rgnumber_t  rgno;
+
+               rgno = xfs_rtb_to_rgno(mp, map->me_startblock);
+               ri->ri_rtg = xfs_rtgroup_get(mp, rgno);
+       } else {
+               ri->ri_pag = xfs_perag_intent_get(mp, map->me_startblock);
+       }
 
        xfs_defer_add_item(dfp, &ri->ri_list);
 }
@@ -551,6 +564,7 @@ xfs_rmap_recover_work(
        struct xfs_rui_log_item         *ruip = RUI_ITEM(lip);
        struct xfs_trans                *tp;
        struct xfs_mount                *mp = lip->li_log->l_mp;
+       bool                            isrt = xfs_rui_item_isrt(lip);
        int                             i;
        int                             error = 0;
 
@@ -560,7 +574,7 @@ xfs_rmap_recover_work(
         * just toss the RUI.
         */
        for (i = 0; i < ruip->rui_format.rui_nextents; i++) {
-               if (!xfs_rui_validate_map(mp,
+               if (!xfs_rui_validate_map(mp, isrt,
                                        &ruip->rui_format.rui_extents[i])) {
                        XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
                                        &ruip->rui_format,
@@ -568,7 +582,8 @@ xfs_rmap_recover_work(
                        return -EFSCORRUPTED;
                }
 
-               xfs_rui_recover_work(mp, dfp, &ruip->rui_format.rui_extents[i]);
+               xfs_rui_recover_work(mp, dfp, isrt,
+                               &ruip->rui_format.rui_extents[i]);
        }
 
        resv = xlog_recover_resv(&M_RES(mp)->tr_itruncate);