[PATCH] xfs: do the assert for all the log done items in xfs_trans_cancel

xiakaixu1987
2020-09-16T21:00:55Z

From: Kaixu Xia <kaixuxia@tencent.com>

We should do the assert for all the log done items if they appear
here. This patch also add the XFS_ITEM_LOG_DONE flag to check if
the item is a log done item.

Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
---
fs/xfs/xfs_bmap_item.c | 2 +-
fs/xfs/xfs_extfree_item.c | 2 +-
fs/xfs/xfs_refcount_item.c | 2 +-
fs/xfs/xfs_rmap_item.c | 2 +-
fs/xfs/xfs_trans.c | 2 +-
fs/xfs/xfs_trans.h | 4 ++++
6 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
index ec3691372e7c..2e49f48666f1 100644
--- a/fs/xfs/xfs_bmap_item.c
+++ b/fs/xfs/xfs_bmap_item.c
@@ -202,7 +202,7 @@ xfs_bud_item_release(
}

static const struct xfs_item_ops xfs_bud_item_ops = {
- .flags = XFS_ITEM_RELEASE_WHEN_COMMITTED,
+ .flags = XFS_ITEM_LOG_DONE_FLAG,
.iop_size = xfs_bud_item_size,
.iop_format = xfs_bud_item_format,
.iop_release = xfs_bud_item_release,
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index 6cb8cd11072a..f2c6cb67262e 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -307,7 +307,7 @@ xfs_efd_item_release(
}

static const struct xfs_item_ops xfs_efd_item_ops = {
- .flags = XFS_ITEM_RELEASE_WHEN_COMMITTED,
+ .flags = XFS_ITEM_LOG_DONE_FLAG,
.iop_size = xfs_efd_item_size,
.iop_format = xfs_efd_item_format,
.iop_release = xfs_efd_item_release,
diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
index ca93b6488377..551bcc93acdd 100644
--- a/fs/xfs/xfs_refcount_item.c
+++ b/fs/xfs/xfs_refcount_item.c
@@ -208,7 +208,7 @@ xfs_cud_item_release(
}

static const struct xfs_item_ops xfs_cud_item_ops = {
- .flags = XFS_ITEM_RELEASE_WHEN_COMMITTED,
+ .flags = XFS_ITEM_LOG_DONE_FLAG,
.iop_size = xfs_cud_item_size,
.iop_format = xfs_cud_item_format,
.iop_release = xfs_cud_item_release,
diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
index dc5b0753cd51..427f90ef4509 100644
--- a/fs/xfs/xfs_rmap_item.c
+++ b/fs/xfs/xfs_rmap_item.c
@@ -231,7 +231,7 @@ xfs_rud_item_release(
}

static const struct xfs_item_ops xfs_rud_item_ops = {
- .flags = XFS_ITEM_RELEASE_WHEN_COMMITTED,
+ .flags = XFS_ITEM_LOG_DONE_FLAG,
.iop_size = xfs_rud_item_size,
.iop_format = xfs_rud_item_format,
.iop_release = xfs_rud_item_release,
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index 4257fdb03778..d33d0ba6f3bd 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -1050,7 +1050,7 @@ xfs_trans_cancel(
struct xfs_log_item *lip;

list_for_each_entry(lip, &tp->t_items, li_trans)
- ASSERT(!(lip->li_type == XFS_LI_EFD));
+ ASSERT(!(lip->li_ops->flags & XFS_ITEM_LOG_DONE));
}
#endif
xfs_trans_unreserve_and_mod_sb(tp);
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index 7fb82eb92e65..b92138b13c40 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -85,6 +85,10 @@ 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_DONE_FLAG (XFS_ITEM_RELEASE_WHEN_COMMITTED | \
+ XFS_ITEM_LOG_DONE)

void xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item,
int type, const struct xfs_item_ops *ops);
--
2.20.0