xfs: refactor recovered EFI log item playback
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 1 May 2020 23:00:50 +0000 (16:00 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Fri, 8 May 2020 15:50:00 +0000 (08:50 -0700)
Move the code that processes the log items created from the recovered
log items into the per-item source code files and use dispatch functions
to call them.  No functional changes.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_extfree_item.c
fs/xfs/xfs_extfree_item.h
fs/xfs/xfs_log_recover.c
fs/xfs/xfs_trans.h

index 69f7e75a747e5247fde133b1b80e8353ba078865..307f71bdd398390e8387e9f6898edce28f33045c 100644 (file)
@@ -28,6 +28,8 @@
 kmem_zone_t    *xfs_efi_zone;
 kmem_zone_t    *xfs_efd_zone;
 
+static const struct xfs_item_ops xfs_efi_item_ops;
+
 static inline struct xfs_efi_log_item *EFI_ITEM(struct xfs_log_item *lip)
 {
        return container_of(lip, struct xfs_efi_log_item, efi_item);
@@ -51,7 +53,7 @@ xfs_efi_item_free(
  * committed vs unpin operations in bulk insert operations. Hence the reference
  * count to ensure only the last caller frees the EFI.
  */
-void
+STATIC void
 xfs_efi_release(
        struct xfs_efi_log_item *efip)
 {
@@ -141,14 +143,6 @@ xfs_efi_item_release(
        xfs_efi_release(EFI_ITEM(lip));
 }
 
-static const struct xfs_item_ops xfs_efi_item_ops = {
-       .iop_size       = xfs_efi_item_size,
-       .iop_format     = xfs_efi_item_format,
-       .iop_unpin      = xfs_efi_item_unpin,
-       .iop_release    = xfs_efi_item_release,
-};
-
-
 /*
  * Allocate and initialize an efi item with the given number of extents.
  */
@@ -586,7 +580,7 @@ const struct xfs_defer_op_type xfs_agfl_free_defer_type = {
  * Process an extent free intent item that was recovered from
  * the log.  We need to free the extents that it describes.
  */
-int
+STATIC int
 xfs_efi_recover(
        struct xfs_mount        *mp,
        struct xfs_efi_log_item *efip)
@@ -647,6 +641,38 @@ abort_error:
        return error;
 }
 
+/* Recover the EFI if necessary. */
+STATIC int
+xfs_efi_item_recover(
+       struct xfs_log_item             *lip,
+       struct xfs_trans                *tp)
+{
+       struct xfs_ail                  *ailp = lip->li_ailp;
+       struct xfs_efi_log_item         *efip;
+       int                             error;
+
+       /*
+        * Skip EFIs that we've already processed.
+        */
+       efip = container_of(lip, struct xfs_efi_log_item, efi_item);
+       if (test_bit(XFS_EFI_RECOVERED, &efip->efi_flags))
+               return 0;
+
+       spin_unlock(&ailp->ail_lock);
+       error = xfs_efi_recover(tp->t_mountp, efip);
+       spin_lock(&ailp->ail_lock);
+
+       return error;
+}
+
+static const struct xfs_item_ops xfs_efi_item_ops = {
+       .iop_size       = xfs_efi_item_size,
+       .iop_format     = xfs_efi_item_format,
+       .iop_unpin      = xfs_efi_item_unpin,
+       .iop_release    = xfs_efi_item_release,
+       .iop_recover    = xfs_efi_item_recover,
+};
+
 /*
  * This routine is called to create an in-core extent free intent
  * item from the efi format structure which was logged on disk.
index 876e3d237f489596f99a651edfb554d8a5e67d66..4b2c2c5c59850c0a932f7f833fc3c4db15070964 100644 (file)
@@ -78,9 +78,4 @@ struct xfs_efd_log_item {
 extern struct kmem_zone        *xfs_efi_zone;
 extern struct kmem_zone        *xfs_efd_zone;
 
-void                   xfs_efi_release(struct xfs_efi_log_item *);
-
-int                    xfs_efi_recover(struct xfs_mount *mp,
-                                       struct xfs_efi_log_item *efip);
-
 #endif /* __XFS_EXTFREE_ITEM_H__ */
index 02148e341760e667b74676acd5136167b02ef768..055a9c0c20b0aa877a47f54731d18429bc71be4c 100644 (file)
@@ -2546,46 +2546,6 @@ xlog_recover_process_data(
        return 0;
 }
 
-/* Recover the EFI if necessary. */
-STATIC int
-xlog_recover_process_efi(
-       struct xfs_mount                *mp,
-       struct xfs_ail                  *ailp,
-       struct xfs_log_item             *lip)
-{
-       struct xfs_efi_log_item         *efip;
-       int                             error;
-
-       /*
-        * Skip EFIs that we've already processed.
-        */
-       efip = container_of(lip, struct xfs_efi_log_item, efi_item);
-       if (test_bit(XFS_EFI_RECOVERED, &efip->efi_flags))
-               return 0;
-
-       spin_unlock(&ailp->ail_lock);
-       error = xfs_efi_recover(mp, efip);
-       spin_lock(&ailp->ail_lock);
-
-       return error;
-}
-
-/* Release the EFI since we're cancelling everything. */
-STATIC void
-xlog_recover_cancel_efi(
-       struct xfs_mount                *mp,
-       struct xfs_ail                  *ailp,
-       struct xfs_log_item             *lip)
-{
-       struct xfs_efi_log_item         *efip;
-
-       efip = container_of(lip, struct xfs_efi_log_item, efi_item);
-
-       spin_unlock(&ailp->ail_lock);
-       xfs_efi_release(efip);
-       spin_lock(&ailp->ail_lock);
-}
-
 /* Recover the RUI if necessary. */
 STATIC int
 xlog_recover_process_rui(
@@ -2829,9 +2789,6 @@ xlog_recover_process_intents(
                 * replayed in the wrong order!
                 */
                switch (lip->li_type) {
-               case XFS_LI_EFI:
-                       error = xlog_recover_process_efi(log->l_mp, ailp, lip);
-                       break;
                case XFS_LI_RUI:
                        error = xlog_recover_process_rui(log->l_mp, ailp, lip);
                        break;
@@ -2841,6 +2798,9 @@ xlog_recover_process_intents(
                case XFS_LI_BUI:
                        error = xlog_recover_process_bui(parent_tp, ailp, lip);
                        break;
+               default:
+                       error = lip->li_ops->iop_recover(lip, parent_tp);
+                       break;
                }
                if (error)
                        goto out;
@@ -2885,9 +2845,6 @@ xlog_recover_cancel_intents(
                }
 
                switch (lip->li_type) {
-               case XFS_LI_EFI:
-                       xlog_recover_cancel_efi(log->l_mp, ailp, lip);
-                       break;
                case XFS_LI_RUI:
                        xlog_recover_cancel_rui(log->l_mp, ailp, lip);
                        break;
@@ -2897,6 +2854,11 @@ xlog_recover_cancel_intents(
                case XFS_LI_BUI:
                        xlog_recover_cancel_bui(log->l_mp, ailp, lip);
                        break;
+               default:
+                       spin_unlock(&ailp->ail_lock);
+                       lip->li_ops->iop_release(lip);
+                       spin_lock(&ailp->ail_lock);
+                       break;
                }
 
                lip = xfs_trans_ail_cursor_next(ailp, &cur);
index 752c7fef9de75c52a2776f28b43af10ab36d3040..3f6a79108991b824b6de5e35c1d2c6822901b410 100644 (file)
@@ -77,6 +77,7 @@ struct xfs_item_ops {
        void (*iop_release)(struct xfs_log_item *);
        xfs_lsn_t (*iop_committed)(struct xfs_log_item *, xfs_lsn_t);
        void (*iop_error)(struct xfs_log_item *, xfs_buf_t *);
+       int (*iop_recover)(struct xfs_log_item *lip, struct xfs_trans *tp);
 };
 
 /*