xfs: simplify the xfs_rmap_{alloc,free}_extent calling conventions
authorDarrick J. Wong <djwong@kernel.org>
Wed, 3 Jul 2024 21:22:15 +0000 (14:22 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 31 Jul 2024 01:46:54 +0000 (18:46 -0700)
Simplify the calling conventions by allowing callers to pass a fsbno
(xfs_fsblock_t) directly into these functions, since we're just going to
set it in a struct anyway.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
libxfs/xfs_refcount.c
libxfs/xfs_rmap.c
libxfs/xfs_rmap.h
repair/rmap.c

index 22f8afb27ece1cc7ebdab0a4b03d0167a2aba9dd..10309aa1ebb04ee6f33b5eb6afadbfaf24c60dbe 100644 (file)
@@ -1831,8 +1831,7 @@ xfs_refcount_alloc_cow_extent(
        __xfs_refcount_add(tp, XFS_REFCOUNT_ALLOC_COW, fsb, len);
 
        /* Add rmap entry */
-       xfs_rmap_alloc_extent(tp, XFS_FSB_TO_AGNO(mp, fsb),
-                       XFS_FSB_TO_AGBNO(mp, fsb), len, XFS_RMAP_OWN_COW);
+       xfs_rmap_alloc_extent(tp, fsb, len, XFS_RMAP_OWN_COW);
 }
 
 /* Forget a CoW staging event in the refcount btree. */
@@ -1848,8 +1847,7 @@ xfs_refcount_free_cow_extent(
                return;
 
        /* Remove rmap entry */
-       xfs_rmap_free_extent(tp, XFS_FSB_TO_AGNO(mp, fsb),
-                       XFS_FSB_TO_AGBNO(mp, fsb), len, XFS_RMAP_OWN_COW);
+       xfs_rmap_free_extent(tp, fsb, len, XFS_RMAP_OWN_COW);
        __xfs_refcount_add(tp, XFS_REFCOUNT_FREE_COW, fsb, len);
 }
 
index 22947e3c9ae31083c55d52dcc842c036525c4bb1..a55caf94dfce7ae5dec9ceb981492f9f9dfe1071 100644 (file)
@@ -526,7 +526,7 @@ xfs_rmap_free_check_owner(
        struct xfs_btree_cur    *cur,
        uint64_t                ltoff,
        struct xfs_rmap_irec    *rec,
-       xfs_filblks_t           len,
+       xfs_extlen_t            len,
        uint64_t                owner,
        uint64_t                offset,
        unsigned int            flags)
@@ -2726,8 +2726,7 @@ xfs_rmap_convert_extent(
 void
 xfs_rmap_alloc_extent(
        struct xfs_trans        *tp,
-       xfs_agnumber_t          agno,
-       xfs_agblock_t           bno,
+       xfs_fsblock_t           fsbno,
        xfs_extlen_t            len,
        uint64_t                owner)
 {
@@ -2736,7 +2735,7 @@ xfs_rmap_alloc_extent(
        if (!xfs_rmap_update_is_needed(tp->t_mountp, XFS_DATA_FORK))
                return;
 
-       bmap.br_startblock = XFS_AGB_TO_FSB(tp->t_mountp, agno, bno);
+       bmap.br_startblock = fsbno;
        bmap.br_blockcount = len;
        bmap.br_startoff = 0;
        bmap.br_state = XFS_EXT_NORM;
@@ -2748,8 +2747,7 @@ xfs_rmap_alloc_extent(
 void
 xfs_rmap_free_extent(
        struct xfs_trans        *tp,
-       xfs_agnumber_t          agno,
-       xfs_agblock_t           bno,
+       xfs_fsblock_t           fsbno,
        xfs_extlen_t            len,
        uint64_t                owner)
 {
@@ -2758,7 +2756,7 @@ xfs_rmap_free_extent(
        if (!xfs_rmap_update_is_needed(tp->t_mountp, XFS_DATA_FORK))
                return;
 
-       bmap.br_startblock = XFS_AGB_TO_FSB(tp->t_mountp, agno, bno);
+       bmap.br_startblock = fsbno;
        bmap.br_blockcount = len;
        bmap.br_startoff = 0;
        bmap.br_state = XFS_EXT_NORM;
index b783dd4dd95d1abe73c4697f50fdd05efb11d518..90553434eb3fc85e10c466c3f7bbe72ba5097b21 100644 (file)
@@ -184,10 +184,10 @@ void xfs_rmap_unmap_extent(struct xfs_trans *tp, struct xfs_inode *ip,
 void xfs_rmap_convert_extent(struct xfs_mount *mp, struct xfs_trans *tp,
                struct xfs_inode *ip, int whichfork,
                struct xfs_bmbt_irec *imap);
-void xfs_rmap_alloc_extent(struct xfs_trans *tp, xfs_agnumber_t agno,
-               xfs_agblock_t bno, xfs_extlen_t len, uint64_t owner);
-void xfs_rmap_free_extent(struct xfs_trans *tp, xfs_agnumber_t agno,
-               xfs_agblock_t bno, xfs_extlen_t len, uint64_t owner);
+void xfs_rmap_alloc_extent(struct xfs_trans *tp, xfs_fsblock_t fsbno,
+               xfs_extlen_t len, uint64_t owner);
+void xfs_rmap_free_extent(struct xfs_trans *tp, xfs_fsblock_t fsbno,
+               xfs_extlen_t len, uint64_t owner);
 
 int xfs_rmap_finish_one(struct xfs_trans *tp, struct xfs_rmap_intent *ri,
                struct xfs_btree_cur **pcur);
index 77f4f5661da18ffd9b203b9754452dcc56433635..b535249bbc75c6fc3dca50d4e9da1144999ac3f0 100644 (file)
@@ -1267,7 +1267,6 @@ rmap_diffkeys(
 {
        __u64                   oa;
        __u64                   ob;
-       int64_t                 d;
        struct xfs_rmap_irec    tmp;
 
        tmp = *kp1;
@@ -1277,9 +1276,10 @@ rmap_diffkeys(
        tmp.rm_flags &= ~XFS_RMAP_REC_FLAGS;
        ob = libxfs_rmap_irec_offset_pack(&tmp);
 
-       d = (int64_t)kp1->rm_startblock - kp2->rm_startblock;
-       if (d)
-               return d;
+       if (kp1->rm_startblock > kp2->rm_startblock)
+               return 1;
+       else if (kp2->rm_startblock > kp1->rm_startblock)
+               return -1;
 
        if (kp1->rm_owner > kp2->rm_owner)
                return 1;