]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: add a xfs_rtrmap_highest_rgbno helper
authorChristoph Hellwig <hch@lst.de>
Sat, 21 Dec 2024 08:40:17 +0000 (08:40 +0000)
committerChristoph Hellwig <hch@lst.de>
Mon, 3 Feb 2025 04:49:08 +0000 (05:49 +0100)
Add a helper to find the last offset mapped in the rtrmap.  This will be
used by the zoned code to find out where to start writing again on
conventional devices without hardware zone support.

Signed-off-by: Christoph Hellwig <hch@lst.de>
fs/xfs/libxfs/xfs_rtrmap_btree.c
fs/xfs/libxfs/xfs_rtrmap_btree.h

index e4ec36943cb7cb82bc2e0783a4b20c088a55f6ee..9bdc2cbfc1137ab2a92c8c60a9d93b3a2f03a7e4 100644 (file)
@@ -1033,3 +1033,22 @@ xfs_rtrmapbt_init_rtsb(
        xfs_btree_del_cursor(cur, error);
        return error;
 }
+
+/*
+ * Return the highest rgbno currently tracked by the rmap for this rtg.
+ */
+xfs_rgblock_t
+xfs_rtrmap_highest_rgbno(
+       struct xfs_rtgroup      *rtg)
+{
+       struct xfs_btree_block  *block = rtg_rmap(rtg)->i_df.if_broot;
+       union xfs_btree_key     key = {};
+       struct xfs_btree_cur    *cur;
+
+       if (block->bb_numrecs == 0)
+               return NULLRGBLOCK;
+       cur = xfs_rtrmapbt_init_cursor(NULL, rtg);
+       xfs_btree_get_keys(cur, block, &key);
+       xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
+       return be32_to_cpu(key.__rmap_bigkey[1].rm_startblock);
+}
index 9d0915089891a5edc77c9c170ed83e10cb1ff21d..e328fd62a149d12bd52cbb08cb9387ef24adc8f3 100644 (file)
@@ -207,4 +207,6 @@ struct xfs_btree_cur *xfs_rtrmapbt_mem_cursor(struct xfs_rtgroup *rtg,
 int xfs_rtrmapbt_mem_init(struct xfs_mount *mp, struct xfbtree *xfbtree,
                struct xfs_buftarg *btp, xfs_rgnumber_t rgno);
 
+xfs_rgblock_t xfs_rtrmap_highest_rgbno(struct xfs_rtgroup *rtg);
+
 #endif /* __XFS_RTRMAP_BTREE_H__ */