]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: allow internal RT devices for zoned mode
authorChristoph Hellwig <hch@lst.de>
Tue, 8 Apr 2025 07:09:44 +0000 (09:09 +0200)
committerChristoph Hellwig <hch@lst.de>
Tue, 8 Apr 2025 07:09:44 +0000 (09:09 +0200)
Source kernel commit: bdc03eb5f98f6f1ae4bd5e020d1582a23efb7799

Allow creating an RT subvolume on the same device as the main data
device.  This is mostly used for SMR HDDs where the conventional zones
are used for the data device and the sequential write required zones
for the zoned RT section.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
libxfs/xfs_group.h
libxfs/xfs_rtgroup.h
libxfs/xfs_sb.c

index 242b05627c7a6ea862c8dc0b30fc4a93281d0682..a70096113384e019ae0b095d2458d3aba379c496 100644 (file)
@@ -107,9 +107,11 @@ xfs_gbno_to_daddr(
        xfs_agblock_t           gbno)
 {
        struct xfs_mount        *mp = xg->xg_mount;
-       uint32_t                blocks = mp->m_groups[xg->xg_type].blocks;
+       struct xfs_groups       *g = &mp->m_groups[xg->xg_type];
+       xfs_fsblock_t           fsbno;
 
-       return XFS_FSB_TO_BB(mp, (xfs_fsblock_t)xg->xg_gno * blocks + gbno);
+       fsbno = (xfs_fsblock_t)xg->xg_gno * g->blocks + gbno;
+       return XFS_FSB_TO_BB(mp, g->start_fsb + fsbno);
 }
 
 static inline uint32_t
index 9c7e03f913cb5322fb16ec3fa3d699e1a111c83e..e35d1d7983275ca8e8a6e2e65fb4d738b0b87459 100644 (file)
@@ -230,7 +230,8 @@ xfs_rtb_to_daddr(
        xfs_rgnumber_t          rgno = xfs_rtb_to_rgno(mp, rtbno);
        uint64_t                start_bno = (xfs_rtblock_t)rgno * g->blocks;
 
-       return XFS_FSB_TO_BB(mp, start_bno + (rtbno & g->blkmask));
+       return XFS_FSB_TO_BB(mp,
+               g->start_fsb + start_bno + (rtbno & g->blkmask));
 }
 
 static inline xfs_rtblock_t
@@ -238,10 +239,11 @@ xfs_daddr_to_rtb(
        struct xfs_mount        *mp,
        xfs_daddr_t             daddr)
 {
-       xfs_rfsblock_t          bno = XFS_BB_TO_FSBT(mp, daddr);
+       struct xfs_groups       *g = &mp->m_groups[XG_TYPE_RTG];
+       xfs_rfsblock_t          bno;
 
+       bno = XFS_BB_TO_FSBT(mp, daddr) - g->start_fsb;
        if (xfs_has_rtgroups(mp)) {
-               struct xfs_groups *g = &mp->m_groups[XG_TYPE_RTG];
                xfs_rgnumber_t  rgno;
                uint32_t        rgbno;
 
index bc84792c565cbcb94fa2c0253f1aedbde83bda7c..a95d712363fa2b396e151e5fe1567811f1457162 100644 (file)
@@ -1201,6 +1201,7 @@ xfs_sb_mount_rextsize(
                rgs->blocks = sbp->sb_rgextents * sbp->sb_rextsize;
                rgs->blklog = mp->m_sb.sb_rgblklog;
                rgs->blkmask = xfs_mask32lo(mp->m_sb.sb_rgblklog);
+               rgs->start_fsb = mp->m_sb.sb_rtstart;
        } else {
                rgs->blocks = 0;
                rgs->blklog = 0;