xfs: move ->iop_relog to struct xfs_defer_op_type
authorDarrick J. Wong <djwong@kernel.org>
Thu, 30 Nov 2023 20:31:30 +0000 (12:31 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 7 Dec 2023 02:45:17 +0000 (18:45 -0800)
The only log items that need relogging are the ones created for deferred
work operations, and the only part of the code base that relogs log
items is the deferred work machinery.  Move the function pointers.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/libxfs/xfs_defer.c
fs/xfs/libxfs/xfs_defer.h
fs/xfs/xfs_attr_item.c
fs/xfs/xfs_bmap_item.c
fs/xfs/xfs_extfree_item.c
fs/xfs/xfs_refcount_item.c
fs/xfs/xfs_rmap_item.c
fs/xfs/xfs_trans.h

index 95f15a4b212602aca8acda7ef4fc106a4a79d897..54a6be06e6cdc5e941b55d64b380841f8d009318 100644 (file)
@@ -459,6 +459,25 @@ xfs_defer_cancel_list(
                xfs_defer_pending_cancel_work(mp, dfp);
 }
 
+static inline void
+xfs_defer_relog_intent(
+       struct xfs_trans                *tp,
+       struct xfs_defer_pending        *dfp)
+{
+       struct xfs_log_item             *lip;
+       const struct xfs_defer_op_type  *ops = defer_op_types[dfp->dfp_type];
+
+       xfs_defer_create_done(tp, dfp);
+
+       lip = ops->relog_intent(tp, dfp->dfp_intent, dfp->dfp_done);
+       if (lip) {
+               xfs_trans_add_item(tp, lip);
+               set_bit(XFS_LI_DIRTY, &lip->li_flags);
+       }
+       dfp->dfp_done = NULL;
+       dfp->dfp_intent = lip;
+}
+
 /*
  * Prevent a log intent item from pinning the tail of the log by logging a
  * done item to release the intent item; and then log a new intent item.
@@ -477,8 +496,6 @@ xfs_defer_relog(
        ASSERT((*tpp)->t_flags & XFS_TRANS_PERM_LOG_RES);
 
        list_for_each_entry(dfp, dfops, dfp_list) {
-               struct xfs_log_item     *lip;
-
                /*
                 * If the log intent item for this deferred op is not a part of
                 * the current log checkpoint, relog the intent item to keep
@@ -506,15 +523,7 @@ xfs_defer_relog(
                trace_xfs_defer_relog_intent((*tpp)->t_mountp, dfp);
                XFS_STATS_INC((*tpp)->t_mountp, defer_relog);
 
-               xfs_defer_create_done(*tpp, dfp);
-               lip = xfs_trans_item_relog(dfp->dfp_intent, dfp->dfp_done,
-                               *tpp);
-               if (lip) {
-                       xfs_trans_add_item(*tpp, lip);
-                       set_bit(XFS_LI_DIRTY, &lip->li_flags);
-               }
-               dfp->dfp_done = NULL;
-               dfp->dfp_intent = lip;
+               xfs_defer_relog_intent(*tpp, dfp);
        }
 
        if ((*tpp)->t_flags & XFS_TRANS_DIRTY)
index ef86a7f9b059508280d42994924210205b3f876d..78d6dcd1af2cd6649fa56e228abb5a2c3b1369f3 100644 (file)
@@ -59,6 +59,9 @@ struct xfs_defer_op_type {
        void (*cancel_item)(struct list_head *item);
        int (*recover_work)(struct xfs_defer_pending *dfp,
                            struct list_head *capture_list);
+       struct xfs_log_item *(*relog_intent)(struct xfs_trans *tp,
+                       struct xfs_log_item *intent,
+                       struct xfs_log_item *done_item);
        unsigned int            max_items;
 };
 
index 27553388da99cb93b6c1936cc6ef8738bc66edfb..988d395a48adc3c5c8f3c47dce20adf0ec803088 100644 (file)
@@ -625,10 +625,10 @@ out_unlock:
 
 /* Re-log an intent item to push the log tail forward. */
 static struct xfs_log_item *
-xfs_attri_item_relog(
+xfs_attr_relog_intent(
+       struct xfs_trans                *tp,
        struct xfs_log_item             *intent,
-       struct xfs_log_item             *done_item,
-       struct xfs_trans                *tp)
+       struct xfs_log_item             *done_item)
 {
        struct xfs_attri_log_item       *old_attrip;
        struct xfs_attri_log_item       *new_attrip;
@@ -763,6 +763,7 @@ const struct xfs_defer_op_type xfs_attr_defer_type = {
        .finish_item    = xfs_attr_finish_item,
        .cancel_item    = xfs_attr_cancel_item,
        .recover_work   = xfs_attr_recover_work,
+       .relog_intent   = xfs_attr_relog_intent,
 };
 
 /*
@@ -800,7 +801,6 @@ static const struct xfs_item_ops xfs_attri_item_ops = {
        .iop_unpin      = xfs_attri_item_unpin,
        .iop_release    = xfs_attri_item_release,
        .iop_match      = xfs_attri_item_match,
-       .iop_relog      = xfs_attri_item_relog,
 };
 
 const struct xlog_recover_item_ops xlog_attri_item_ops = {
index f3421e615e1c70fdab9945849850019d1070172b..bc48d733634a1f956068f1a92b8366308329b0ea 100644 (file)
@@ -541,30 +541,12 @@ err_rele:
        return error;
 }
 
-const struct xfs_defer_op_type xfs_bmap_update_defer_type = {
-       .max_items      = XFS_BUI_MAX_FAST_EXTENTS,
-       .create_intent  = xfs_bmap_update_create_intent,
-       .abort_intent   = xfs_bmap_update_abort_intent,
-       .create_done    = xfs_bmap_update_create_done,
-       .finish_item    = xfs_bmap_update_finish_item,
-       .cancel_item    = xfs_bmap_update_cancel_item,
-       .recover_work   = xfs_bmap_recover_work,
-};
-
-STATIC bool
-xfs_bui_item_match(
-       struct xfs_log_item     *lip,
-       uint64_t                intent_id)
-{
-       return BUI_ITEM(lip)->bui_format.bui_id == intent_id;
-}
-
 /* Relog an intent item to push the log tail forward. */
 static struct xfs_log_item *
-xfs_bui_item_relog(
+xfs_bmap_relog_intent(
+       struct xfs_trans                *tp,
        struct xfs_log_item             *intent,
-       struct xfs_log_item             *done_item,
-       struct xfs_trans                *tp)
+       struct xfs_log_item             *done_item)
 {
        struct xfs_bui_log_item         *buip;
        struct xfs_map_extent           *map;
@@ -580,6 +562,25 @@ xfs_bui_item_relog(
        return &buip->bui_item;
 }
 
+const struct xfs_defer_op_type xfs_bmap_update_defer_type = {
+       .max_items      = XFS_BUI_MAX_FAST_EXTENTS,
+       .create_intent  = xfs_bmap_update_create_intent,
+       .abort_intent   = xfs_bmap_update_abort_intent,
+       .create_done    = xfs_bmap_update_create_done,
+       .finish_item    = xfs_bmap_update_finish_item,
+       .cancel_item    = xfs_bmap_update_cancel_item,
+       .recover_work   = xfs_bmap_recover_work,
+       .relog_intent   = xfs_bmap_relog_intent,
+};
+
+STATIC bool
+xfs_bui_item_match(
+       struct xfs_log_item     *lip,
+       uint64_t                intent_id)
+{
+       return BUI_ITEM(lip)->bui_format.bui_id == intent_id;
+}
+
 static const struct xfs_item_ops xfs_bui_item_ops = {
        .flags          = XFS_ITEM_INTENT,
        .iop_size       = xfs_bui_item_size,
@@ -587,7 +588,6 @@ static const struct xfs_item_ops xfs_bui_item_ops = {
        .iop_unpin      = xfs_bui_item_unpin,
        .iop_release    = xfs_bui_item_release,
        .iop_match      = xfs_bui_item_match,
-       .iop_relog      = xfs_bui_item_relog,
 };
 
 static inline void
index 518569c64e9cb0cde367dbef5cdcd02198ae355d..3ca23ab8d92aced915527680cc89b38e2e05da05 100644 (file)
@@ -643,6 +643,31 @@ abort_error:
        return error;
 }
 
+/* Relog an intent item to push the log tail forward. */
+static struct xfs_log_item *
+xfs_extent_free_relog_intent(
+       struct xfs_trans                *tp,
+       struct xfs_log_item             *intent,
+       struct xfs_log_item             *done_item)
+{
+       struct xfs_efd_log_item         *efdp = EFD_ITEM(done_item);
+       struct xfs_efi_log_item         *efip;
+       struct xfs_extent               *extp;
+       unsigned int                    count;
+
+       count = EFI_ITEM(intent)->efi_format.efi_nextents;
+       extp = EFI_ITEM(intent)->efi_format.efi_extents;
+
+       efdp->efd_next_extent = count;
+       memcpy(efdp->efd_format.efd_extents, extp, count * sizeof(*extp));
+
+       efip = xfs_efi_init(tp->t_mountp, count);
+       memcpy(efip->efi_format.efi_extents, extp, count * sizeof(*extp));
+       atomic_set(&efip->efi_next_extent, count);
+
+       return &efip->efi_item;
+}
+
 const struct xfs_defer_op_type xfs_extent_free_defer_type = {
        .max_items      = XFS_EFI_MAX_FAST_EXTENTS,
        .create_intent  = xfs_extent_free_create_intent,
@@ -651,6 +676,7 @@ const struct xfs_defer_op_type xfs_extent_free_defer_type = {
        .finish_item    = xfs_extent_free_finish_item,
        .cancel_item    = xfs_extent_free_cancel_item,
        .recover_work   = xfs_extent_free_recover_work,
+       .relog_intent   = xfs_extent_free_relog_intent,
 };
 
 /* sub-type with special handling for AGFL deferred frees */
@@ -662,6 +688,7 @@ const struct xfs_defer_op_type xfs_agfl_free_defer_type = {
        .finish_item    = xfs_agfl_free_finish_item,
        .cancel_item    = xfs_extent_free_cancel_item,
        .recover_work   = xfs_extent_free_recover_work,
+       .relog_intent   = xfs_extent_free_relog_intent,
 };
 
 STATIC bool
@@ -672,31 +699,6 @@ xfs_efi_item_match(
        return EFI_ITEM(lip)->efi_format.efi_id == intent_id;
 }
 
-/* Relog an intent item to push the log tail forward. */
-static struct xfs_log_item *
-xfs_efi_item_relog(
-       struct xfs_log_item             *intent,
-       struct xfs_log_item             *done_item,
-       struct xfs_trans                *tp)
-{
-       struct xfs_efd_log_item         *efdp = EFD_ITEM(done_item);
-       struct xfs_efi_log_item         *efip;
-       struct xfs_extent               *extp;
-       unsigned int                    count;
-
-       count = EFI_ITEM(intent)->efi_format.efi_nextents;
-       extp = EFI_ITEM(intent)->efi_format.efi_extents;
-
-       efdp->efd_next_extent = count;
-       memcpy(efdp->efd_format.efd_extents, extp, count * sizeof(*extp));
-
-       efip = xfs_efi_init(tp->t_mountp, count);
-       memcpy(efip->efi_format.efi_extents, extp, count * sizeof(*extp));
-       atomic_set(&efip->efi_next_extent, count);
-
-       return &efip->efi_item;
-}
-
 static const struct xfs_item_ops xfs_efi_item_ops = {
        .flags          = XFS_ITEM_INTENT,
        .iop_size       = xfs_efi_item_size,
@@ -704,7 +706,6 @@ static const struct xfs_item_ops xfs_efi_item_ops = {
        .iop_unpin      = xfs_efi_item_unpin,
        .iop_release    = xfs_efi_item_release,
        .iop_match      = xfs_efi_item_match,
-       .iop_relog      = xfs_efi_item_relog,
 };
 
 /*
index d218a9ed4d820e8bc6a7bb5063f9461af9edbed7..9974be81cb2bae6ecf3f841bc1cb95a827d7ade9 100644 (file)
@@ -501,6 +501,27 @@ abort_error:
        return error;
 }
 
+/* Relog an intent item to push the log tail forward. */
+static struct xfs_log_item *
+xfs_refcount_relog_intent(
+       struct xfs_trans                *tp,
+       struct xfs_log_item             *intent,
+       struct xfs_log_item             *done_item)
+{
+       struct xfs_cui_log_item         *cuip;
+       struct xfs_phys_extent          *pmap;
+       unsigned int                    count;
+
+       count = CUI_ITEM(intent)->cui_format.cui_nextents;
+       pmap = CUI_ITEM(intent)->cui_format.cui_extents;
+
+       cuip = xfs_cui_init(tp->t_mountp, count);
+       memcpy(cuip->cui_format.cui_extents, pmap, count * sizeof(*pmap));
+       atomic_set(&cuip->cui_next_extent, count);
+
+       return &cuip->cui_item;
+}
+
 const struct xfs_defer_op_type xfs_refcount_update_defer_type = {
        .max_items      = XFS_CUI_MAX_FAST_EXTENTS,
        .create_intent  = xfs_refcount_update_create_intent,
@@ -510,6 +531,7 @@ const struct xfs_defer_op_type xfs_refcount_update_defer_type = {
        .finish_cleanup = xfs_refcount_finish_one_cleanup,
        .cancel_item    = xfs_refcount_update_cancel_item,
        .recover_work   = xfs_refcount_recover_work,
+       .relog_intent   = xfs_refcount_relog_intent,
 };
 
 STATIC bool
@@ -520,27 +542,6 @@ xfs_cui_item_match(
        return CUI_ITEM(lip)->cui_format.cui_id == intent_id;
 }
 
-/* Relog an intent item to push the log tail forward. */
-static struct xfs_log_item *
-xfs_cui_item_relog(
-       struct xfs_log_item             *intent,
-       struct xfs_log_item             *done_item,
-       struct xfs_trans                *tp)
-{
-       struct xfs_cui_log_item         *cuip;
-       struct xfs_phys_extent          *pmap;
-       unsigned int                    count;
-
-       count = CUI_ITEM(intent)->cui_format.cui_nextents;
-       pmap = CUI_ITEM(intent)->cui_format.cui_extents;
-
-       cuip = xfs_cui_init(tp->t_mountp, count);
-       memcpy(cuip->cui_format.cui_extents, pmap, count * sizeof(*pmap));
-       atomic_set(&cuip->cui_next_extent, count);
-
-       return &cuip->cui_item;
-}
-
 static const struct xfs_item_ops xfs_cui_item_ops = {
        .flags          = XFS_ITEM_INTENT,
        .iop_size       = xfs_cui_item_size,
@@ -548,7 +549,6 @@ static const struct xfs_item_ops xfs_cui_item_ops = {
        .iop_unpin      = xfs_cui_item_unpin,
        .iop_release    = xfs_cui_item_release,
        .iop_match      = xfs_cui_item_match,
-       .iop_relog      = xfs_cui_item_relog,
 };
 
 static inline void
index 96e0c2b0d0594cdcc28db2ff9e7a22d814f8206a..488c4a2a80a3bdf09d084542d0fb90b5a300dda2 100644 (file)
@@ -554,6 +554,27 @@ abort_error:
        return error;
 }
 
+/* Relog an intent item to push the log tail forward. */
+static struct xfs_log_item *
+xfs_rmap_relog_intent(
+       struct xfs_trans                *tp,
+       struct xfs_log_item             *intent,
+       struct xfs_log_item             *done_item)
+{
+       struct xfs_rui_log_item         *ruip;
+       struct xfs_map_extent           *map;
+       unsigned int                    count;
+
+       count = RUI_ITEM(intent)->rui_format.rui_nextents;
+       map = RUI_ITEM(intent)->rui_format.rui_extents;
+
+       ruip = xfs_rui_init(tp->t_mountp, count);
+       memcpy(ruip->rui_format.rui_extents, map, count * sizeof(*map));
+       atomic_set(&ruip->rui_next_extent, count);
+
+       return &ruip->rui_item;
+}
+
 const struct xfs_defer_op_type xfs_rmap_update_defer_type = {
        .max_items      = XFS_RUI_MAX_FAST_EXTENTS,
        .create_intent  = xfs_rmap_update_create_intent,
@@ -563,6 +584,7 @@ const struct xfs_defer_op_type xfs_rmap_update_defer_type = {
        .finish_cleanup = xfs_rmap_finish_one_cleanup,
        .cancel_item    = xfs_rmap_update_cancel_item,
        .recover_work   = xfs_rmap_recover_work,
+       .relog_intent   = xfs_rmap_relog_intent,
 };
 
 STATIC bool
@@ -573,27 +595,6 @@ xfs_rui_item_match(
        return RUI_ITEM(lip)->rui_format.rui_id == intent_id;
 }
 
-/* Relog an intent item to push the log tail forward. */
-static struct xfs_log_item *
-xfs_rui_item_relog(
-       struct xfs_log_item             *intent,
-       struct xfs_log_item             *done_item,
-       struct xfs_trans                *tp)
-{
-       struct xfs_rui_log_item         *ruip;
-       struct xfs_map_extent           *map;
-       unsigned int                    count;
-
-       count = RUI_ITEM(intent)->rui_format.rui_nextents;
-       map = RUI_ITEM(intent)->rui_format.rui_extents;
-
-       ruip = xfs_rui_init(tp->t_mountp, count);
-       memcpy(ruip->rui_format.rui_extents, map, count * sizeof(*map));
-       atomic_set(&ruip->rui_next_extent, count);
-
-       return &ruip->rui_item;
-}
-
 static const struct xfs_item_ops xfs_rui_item_ops = {
        .flags          = XFS_ITEM_INTENT,
        .iop_size       = xfs_rui_item_size,
@@ -601,7 +602,6 @@ static const struct xfs_item_ops xfs_rui_item_ops = {
        .iop_unpin      = xfs_rui_item_unpin,
        .iop_release    = xfs_rui_item_release,
        .iop_match      = xfs_rui_item_match,
-       .iop_relog      = xfs_rui_item_relog,
 };
 
 static inline void
index 25646e2b12f40aa34a5ca4f91929375ccdf0943a..2cb1e143fc4967179ed5a31aa54482cf7d17406a 100644 (file)
@@ -79,9 +79,6 @@ struct xfs_item_ops {
        uint (*iop_push)(struct xfs_log_item *, struct list_head *);
        void (*iop_release)(struct xfs_log_item *);
        bool (*iop_match)(struct xfs_log_item *item, uint64_t id);
-       struct xfs_log_item *(*iop_relog)(struct xfs_log_item *intent,
-                       struct xfs_log_item *done_item,
-                       struct xfs_trans *tp);
        struct xfs_log_item *(*iop_intent)(struct xfs_log_item *intent_done);
 };
 
@@ -246,15 +243,6 @@ void               xfs_trans_buf_copy_type(struct xfs_buf *dst_bp,
 
 extern struct kmem_cache       *xfs_trans_cache;
 
-static inline struct xfs_log_item *
-xfs_trans_item_relog(
-       struct xfs_log_item     *lip,
-       struct xfs_log_item     *done_lip,
-       struct xfs_trans        *tp)
-{
-       return lip->li_ops->iop_relog(lip, done_lip, tp);
-}
-
 struct xfs_dquot;
 
 int xfs_trans_alloc_inode(struct xfs_inode *ip, struct xfs_trans_res *resv,