[PATCH] xfs: add the XFS_ITEM_LOG_INTENT flag to mark the log intent item

xiakaixu1987
2020-09-16T19:49:23Z

From: Kaixu Xia <kaixuxia@tencent.com>

This patch add the XFS_ITEM_LOG_INTENT flag to mark the log intent
item, so maybe we can simplify the judgement of log intent item.

Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
---
fs/xfs/xfs_bmap_item.c | 1 +
fs/xfs/xfs_extfree_item.c | 1 +
fs/xfs/xfs_log_recover.c | 15 ++++-----------
fs/xfs/xfs_refcount_item.c | 1 +
fs/xfs/xfs_rmap_item.c | 1 +
fs/xfs/xfs_trans.h | 3 ++-
6 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
index 2e49f48666f1..86485dcc9813 100644
--- a/fs/xfs/xfs_bmap_item.c
+++ b/fs/xfs/xfs_bmap_item.c
@@ -560,6 +560,7 @@ xfs_bui_item_match(
}

static const struct xfs_item_ops xfs_bui_item_ops = {
+ .flags = XFS_ITEM_LOG_INTENT,
.iop_size = xfs_bui_item_size,
.iop_format = xfs_bui_item_format,
.iop_unpin = xfs_bui_item_unpin,
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index f2c6cb67262e..44242b2ac8c7 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -650,6 +650,7 @@ xfs_efi_item_match(
}

static const struct xfs_item_ops xfs_efi_item_ops = {
+ .flags = XFS_ITEM_LOG_INTENT,
.iop_size = xfs_efi_item_size,
.iop_format = xfs_efi_item_format,
.iop_unpin = xfs_efi_item_unpin,
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 1ca35b53d3b9..32eeed4f8661 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2475,13 +2475,6 @@ xlog_finish_defer_ops(
return xfs_trans_commit(tp);
}

-/* Is this log item a deferred action intent? */
-static inline bool xlog_item_is_intent(struct xfs_log_item *lip)
-{
- return lip->li_ops->iop_recover != NULL &&
- lip->li_ops->iop_match != NULL;
-}
-
/*
* When this is called, all of the log intent items which did not have
* corresponding log done items should be in the AIL. What we do now
@@ -2535,10 +2528,10 @@ xlog_recover_process_intents(
* We're done when we see something other than an intent.
* There should be no intents left in the AIL now.
*/
- if (!xlog_item_is_intent(lip)) {
+ if (!(lip->li_ops->flags & XFS_ITEM_LOG_INTENT)) {
#ifdef DEBUG
for (; lip; lip = xfs_trans_ail_cursor_next(ailp, &cur))
- ASSERT(!xlog_item_is_intent(lip));
+ ASSERT(!(lip->li_ops->flags & XFS_ITEM_LOG_INTENT));
#endif
break;
}
@@ -2595,10 +2588,10 @@ xlog_recover_cancel_intents(
* We're done when we see something other than an intent.
* There should be no intents left in the AIL now.
*/
- if (!xlog_item_is_intent(lip)) {
+ if (!(lip->li_ops->flags & XFS_ITEM_LOG_INTENT)) {
#ifdef DEBUG
for (; lip; lip = xfs_trans_ail_cursor_next(ailp, &cur))
- ASSERT(!xlog_item_is_intent(lip));
+ ASSERT(!(lip->li_ops->flags & XFS_ITEM_LOG_INTENT));
#endif
break;
}
diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
index 551bcc93acdd..a4d470af5f7b 100644
--- a/fs/xfs/xfs_refcount_item.c
+++ b/fs/xfs/xfs_refcount_item.c
@@ -575,6 +575,7 @@ xfs_cui_item_match(
}

static const struct xfs_item_ops xfs_cui_item_ops = {
+ .flags = XFS_ITEM_LOG_INTENT,
.iop_size = xfs_cui_item_size,
.iop_format = xfs_cui_item_format,
.iop_unpin = xfs_cui_item_unpin,
diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
index 427f90ef4509..335c76307383 100644
--- a/fs/xfs/xfs_rmap_item.c
+++ b/fs/xfs/xfs_rmap_item.c
@@ -591,6 +591,7 @@ xfs_rui_item_match(
}

static const struct xfs_item_ops xfs_rui_item_ops = {
+ .flags = XFS_ITEM_LOG_INTENT,
.iop_size = xfs_rui_item_size,
.iop_format = xfs_rui_item_format,
.iop_unpin = xfs_rui_item_unpin,
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index b92138b13c40..53cb5c5eda02 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -85,7 +85,8 @@ struct xfs_item_ops {
* intents that never need to be written back in place.
*/
#define XFS_ITEM_RELEASE_WHEN_COMMITTED (1 << 0)
-#define XFS_ITEM_LOG_DONE (1 << 1) /* log done item */
+#define XFS_ITEM_LOG_INTENT (1 << 1) /* log intent item */
+#define XFS_ITEM_LOG_DONE (1 << 2) /* log done item */

#define XFS_ITEM_LOG_DONE_FLAG (XFS_ITEM_RELEASE_WHEN_COMMITTED | \
XFS_ITEM_LOG_DONE)
--
2.20.0