]> git.apps.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs: pass the xfs_bmbt_irec directly through the log intent code
authorDarrick J. Wong <djwong@kernel.org>
Tue, 2 May 2023 12:29:04 +0000 (14:29 +0200)
committerCarlos Maiolino <cem@kernel.org>
Tue, 9 May 2023 16:09:39 +0000 (18:09 +0200)
Source kernel commit: ddccb81b26ec021ae1f3366aa996cc4c68dd75ce

Instead of repeatedly boxing and unboxing the incore extent mapping
structure as it passes through the BUI code, pass the pointer directly
through.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
libxfs/defer_item.c
libxfs/xfs_bmap.c
libxfs/xfs_bmap.h

index 01f0e163ef4ce70403a7fa7aa03fd62b482d807d..8181a5d95e4d23394fb7423aef8f47e8f251cad8 100644 (file)
@@ -413,25 +413,16 @@ xfs_bmap_update_finish_item(
        struct list_head                *item,
        struct xfs_btree_cur            **state)
 {
-       struct xfs_bmap_intent          *bmap;
-       xfs_filblks_t                   count;
+       struct xfs_bmap_intent          *bi;
        int                             error;
 
-       bmap = container_of(item, struct xfs_bmap_intent, bi_list);
-       count = bmap->bi_bmap.br_blockcount;
-       error = xfs_bmap_finish_one(tp,
-                       bmap->bi_owner,
-                       bmap->bi_type, bmap->bi_whichfork,
-                       bmap->bi_bmap.br_startoff,
-                       bmap->bi_bmap.br_startblock,
-                       &count,
-                       bmap->bi_bmap.br_state);
-       if (!error && count > 0) {
-               ASSERT(bmap->bi_type == XFS_BMAP_UNMAP);
-               bmap->bi_bmap.br_blockcount = count;
+       bi = container_of(item, struct xfs_bmap_intent, bi_list);
+       error = xfs_bmap_finish_one(tp, bi);
+       if (!error && bi->bi_bmap.br_blockcount > 0) {
+               ASSERT(bi->bi_type == XFS_BMAP_UNMAP);
                return -EAGAIN;
        }
-       kmem_cache_free(xfs_bmap_intent_cache, bmap);
+       kmem_cache_free(xfs_bmap_intent_cache, bi);
        return error;
 }
 
@@ -447,10 +438,10 @@ STATIC void
 xfs_bmap_update_cancel_item(
        struct list_head                *item)
 {
-       struct xfs_bmap_intent          *bmap;
+       struct xfs_bmap_intent          *bi;
 
-       bmap = container_of(item, struct xfs_bmap_intent, bi_list);
-       kmem_cache_free(xfs_bmap_intent_cache, bmap);
+       bi = container_of(item, struct xfs_bmap_intent, bi_list);
+       kmem_cache_free(xfs_bmap_intent_cache, bi);
 }
 
 const struct xfs_defer_op_type xfs_bmap_update_defer_type = {
index b9a43039a65b96f583816bbd459c694493291b18..2778d85ad72ed7948e51bbb3e3035c9b95b4cf92 100644 (file)
@@ -6139,39 +6139,37 @@ xfs_bmap_unmap_extent(
 int
 xfs_bmap_finish_one(
        struct xfs_trans                *tp,
-       struct xfs_inode                *ip,
-       enum xfs_bmap_intent_type       type,
-       int                             whichfork,
-       xfs_fileoff_t                   startoff,
-       xfs_fsblock_t                   startblock,
-       xfs_filblks_t                   *blockcount,
-       xfs_exntst_t                    state)
+       struct xfs_bmap_intent          *bi)
 {
+       struct xfs_bmbt_irec            *bmap = &bi->bi_bmap;
        int                             error = 0;
 
        ASSERT(tp->t_firstblock == NULLFSBLOCK);
 
        trace_xfs_bmap_deferred(tp->t_mountp,
-                       XFS_FSB_TO_AGNO(tp->t_mountp, startblock), type,
-                       XFS_FSB_TO_AGBNO(tp->t_mountp, startblock),
-                       ip->i_ino, whichfork, startoff, *blockcount, state);
+                       XFS_FSB_TO_AGNO(tp->t_mountp, bmap->br_startblock),
+                       bi->bi_type,
+                       XFS_FSB_TO_AGBNO(tp->t_mountp, bmap->br_startblock),
+                       bi->bi_owner->i_ino, bi->bi_whichfork,
+                       bmap->br_startoff, bmap->br_blockcount,
+                       bmap->br_state);
 
-       if (WARN_ON_ONCE(whichfork != XFS_DATA_FORK))
+       if (WARN_ON_ONCE(bi->bi_whichfork != XFS_DATA_FORK))
                return -EFSCORRUPTED;
 
        if (XFS_TEST_ERROR(false, tp->t_mountp,
                        XFS_ERRTAG_BMAP_FINISH_ONE))
                return -EIO;
 
-       switch (type) {
+       switch (bi->bi_type) {
        case XFS_BMAP_MAP:
-               error = xfs_bmapi_remap(tp, ip, startoff, *blockcount,
-                               startblock, 0);
-               *blockcount = 0;
+               error = xfs_bmapi_remap(tp, bi->bi_owner, bmap->br_startoff,
+                               bmap->br_blockcount, bmap->br_startblock, 0);
+               bmap->br_blockcount = 0;
                break;
        case XFS_BMAP_UNMAP:
-               error = __xfs_bunmapi(tp, ip, startoff, blockcount,
-                               XFS_BMAPI_REMAP, 1);
+               error = __xfs_bunmapi(tp, bi->bi_owner, bmap->br_startoff,
+                               &bmap->br_blockcount, XFS_BMAPI_REMAP, 1);
                break;
        default:
                ASSERT(0);
index 16db95b115891ce285fe3be44359b3c2e9eeb4cb..01c2df35c3e35a5bfac25b164b39b45b317ea544 100644 (file)
@@ -234,10 +234,7 @@ struct xfs_bmap_intent {
        struct xfs_bmbt_irec                    bi_bmap;
 };
 
-int    xfs_bmap_finish_one(struct xfs_trans *tp, struct xfs_inode *ip,
-               enum xfs_bmap_intent_type type, int whichfork,
-               xfs_fileoff_t startoff, xfs_fsblock_t startblock,
-               xfs_filblks_t *blockcount, xfs_exntst_t state);
+int    xfs_bmap_finish_one(struct xfs_trans *tp, struct xfs_bmap_intent *bi);
 void   xfs_bmap_map_extent(struct xfs_trans *tp, struct xfs_inode *ip,
                struct xfs_bmbt_irec *imap);
 void   xfs_bmap_unmap_extent(struct xfs_trans *tp, struct xfs_inode *ip,