diff mbox series

[19/19] xfs: move xlog_recover_intent_pass2 up in the file

Message ID 158752128537.2140829.17923623833043582709.stgit@magnolia (mailing list archive)
State New, archived
Headers show
Series xfs: refactor log recovery | expand

Commit Message

Darrick J. Wong April 22, 2020, 2:08 a.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Move xlog_recover_intent_pass2 up in the file so that we don't have to
have a forward declaration of a static function.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/xfs_log_recover.c |  110 ++++++++++++++++++++++------------------------
 1 file changed, 53 insertions(+), 57 deletions(-)

Comments

Christoph Hellwig April 25, 2020, 6:36 p.m. UTC | #1
On Tue, Apr 21, 2020 at 07:08:05PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Move xlog_recover_intent_pass2 up in the file so that we don't have to
> have a forward declaration of a static function.

FYI, I'd expect IS_INTENT and IS_INTENT_DONE to simply be flags in the
xlog_recover_item_type structure.
Darrick J. Wong April 28, 2020, 10:38 p.m. UTC | #2
On Sat, Apr 25, 2020 at 11:36:44AM -0700, Christoph Hellwig wrote:
> On Tue, Apr 21, 2020 at 07:08:05PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Move xlog_recover_intent_pass2 up in the file so that we don't have to
> > have a forward declaration of a static function.
> 
> FYI, I'd expect IS_INTENT and IS_INTENT_DONE to simply be flags in the
> xlog_recover_item_type structure.

If I simply gave every XFS_LI_* type code its own
xlog_recover_item_type, there wouldn't even be a need for that.

Though I dunno, an entire xlog_recover_item_type for each of the done
item types might be a lot of NULL space.  <shrug> Maybe I'm stressing
out too much over 8 * 6 pointers == 400 bytes.

--D
diff mbox series

Patch

diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 250f04419035..5a20a95c5dad 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -1814,9 +1814,59 @@  xlog_recover_insert_ail(
 	xfs_trans_ail_update(log->l_ailp, lip, lsn);
 }
 
-STATIC int xlog_recover_intent_pass2(struct xlog *log,
-		struct list_head *buffer_list, struct xlog_recover_item *item,
-		xfs_lsn_t current_lsn);
+static inline const struct xlog_recover_intent_type *
+xlog_intent_for_type(
+	unsigned short			type)
+{
+	switch (type) {
+	case XFS_LI_EFD:
+	case XFS_LI_EFI:
+		return &xlog_recover_extfree_type;
+	case XFS_LI_RUD:
+	case XFS_LI_RUI:
+		return &xlog_recover_rmap_type;
+	case XFS_LI_CUI:
+	case XFS_LI_CUD:
+		return &xlog_recover_refcount_type;
+	case XFS_LI_BUI:
+	case XFS_LI_BUD:
+		return &xlog_recover_bmap_type;
+	default:
+		return NULL;
+	}
+}
+
+static inline bool
+xlog_is_intent_done_item(
+	struct xlog_recover_item	*item)
+{
+	switch (ITEM_TYPE(item)) {
+	case XFS_LI_EFD:
+	case XFS_LI_RUD:
+	case XFS_LI_CUD:
+	case XFS_LI_BUD:
+		return true;
+	default:
+		return false;
+	}
+}
+
+STATIC int
+xlog_recover_intent_pass2(
+	struct xlog			*log,
+	struct list_head		*buffer_list,
+	struct xlog_recover_item	*item,
+	xfs_lsn_t			current_lsn)
+{
+	const struct xlog_recover_intent_type *type;
+
+	type = xlog_intent_for_type(ITEM_TYPE(item));
+	if (!type)
+		return -EFSCORRUPTED;
+	if (xlog_is_intent_done_item(item))
+		return type->recover_done(log, item);
+	return type->recover_intent(log, item, current_lsn);
+}
 
 const struct xlog_recover_item_type xlog_intent_item_type = {
 	.reorder		= XLOG_REORDER_INODE_LIST,
@@ -2075,60 +2125,6 @@  xlog_recover_commit_pass1(
 	return item->ri_type->commit_pass1_fn(log, item);
 }
 
-static inline const struct xlog_recover_intent_type *
-xlog_intent_for_type(
-	unsigned short			type)
-{
-	switch (type) {
-	case XFS_LI_EFD:
-	case XFS_LI_EFI:
-		return &xlog_recover_extfree_type;
-	case XFS_LI_RUD:
-	case XFS_LI_RUI:
-		return &xlog_recover_rmap_type;
-	case XFS_LI_CUI:
-	case XFS_LI_CUD:
-		return &xlog_recover_refcount_type;
-	case XFS_LI_BUI:
-	case XFS_LI_BUD:
-		return &xlog_recover_bmap_type;
-	default:
-		return NULL;
-	}
-}
-
-static inline bool
-xlog_is_intent_done_item(
-	struct xlog_recover_item	*item)
-{
-	switch (ITEM_TYPE(item)) {
-	case XFS_LI_EFD:
-	case XFS_LI_RUD:
-	case XFS_LI_CUD:
-	case XFS_LI_BUD:
-		return true;
-	default:
-		return false;
-	}
-}
-
-STATIC int
-xlog_recover_intent_pass2(
-	struct xlog			*log,
-	struct list_head		*buffer_list,
-	struct xlog_recover_item	*item,
-	xfs_lsn_t			current_lsn)
-{
-	const struct xlog_recover_intent_type *type;
-
-	type = xlog_intent_for_type(ITEM_TYPE(item));
-	if (!type)
-		return -EFSCORRUPTED;
-	if (xlog_is_intent_done_item(item))
-		return type->recover_done(log, item);
-	return type->recover_intent(log, item, current_lsn);
-}
-
 STATIC int
 xlog_recover_commit_pass2(
 	struct xlog			*log,