Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xfs: add log item flags to indicate intents

We currently have a couple of helper functions that try to infer
whether the log item is an intent or intent done item from the
combinations of operations it supports. This is incredibly fragile
and not very efficient as it requires checking specific combinations
of ops.

We need to be able to identify intent and intent done items quickly
and easily in upcoming patches, so simply add intent and intent done
type flags to the log item ops flags. These are static flags to
begin with, so intent items should have been typed like this from
the start.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Dave Chinner <david@fromorbit.com>

authored by

Dave Chinner and committed by
Dave Chinner
f5b81200 5ddd658e

+25 -16
+3 -1
fs/xfs/xfs_bmap_item.c
··· 204 204 } 205 205 206 206 static const struct xfs_item_ops xfs_bud_item_ops = { 207 - .flags = XFS_ITEM_RELEASE_WHEN_COMMITTED, 207 + .flags = XFS_ITEM_RELEASE_WHEN_COMMITTED | 208 + XFS_ITEM_INTENT_DONE, 208 209 .iop_size = xfs_bud_item_size, 209 210 .iop_format = xfs_bud_item_format, 210 211 .iop_release = xfs_bud_item_release, ··· 589 588 } 590 589 591 590 static const struct xfs_item_ops xfs_bui_item_ops = { 591 + .flags = XFS_ITEM_INTENT, 592 592 .iop_size = xfs_bui_item_size, 593 593 .iop_format = xfs_bui_item_format, 594 594 .iop_unpin = xfs_bui_item_unpin,
+3 -1
fs/xfs/xfs_extfree_item.c
··· 307 307 } 308 308 309 309 static const struct xfs_item_ops xfs_efd_item_ops = { 310 - .flags = XFS_ITEM_RELEASE_WHEN_COMMITTED, 310 + .flags = XFS_ITEM_RELEASE_WHEN_COMMITTED | 311 + XFS_ITEM_INTENT_DONE, 311 312 .iop_size = xfs_efd_item_size, 312 313 .iop_format = xfs_efd_item_format, 313 314 .iop_release = xfs_efd_item_release, ··· 689 688 } 690 689 691 690 static const struct xfs_item_ops xfs_efi_item_ops = { 691 + .flags = XFS_ITEM_INTENT, 692 692 .iop_size = xfs_efi_item_size, 693 693 .iop_format = xfs_efi_item_format, 694 694 .iop_unpin = xfs_efi_item_unpin,
+3 -1
fs/xfs/xfs_refcount_item.c
··· 210 210 } 211 211 212 212 static const struct xfs_item_ops xfs_cud_item_ops = { 213 - .flags = XFS_ITEM_RELEASE_WHEN_COMMITTED, 213 + .flags = XFS_ITEM_RELEASE_WHEN_COMMITTED | 214 + XFS_ITEM_INTENT_DONE, 214 215 .iop_size = xfs_cud_item_size, 215 216 .iop_format = xfs_cud_item_format, 216 217 .iop_release = xfs_cud_item_release, ··· 603 602 } 604 603 605 604 static const struct xfs_item_ops xfs_cui_item_ops = { 605 + .flags = XFS_ITEM_INTENT, 606 606 .iop_size = xfs_cui_item_size, 607 607 .iop_format = xfs_cui_item_format, 608 608 .iop_unpin = xfs_cui_item_unpin,
+3 -1
fs/xfs/xfs_rmap_item.c
··· 233 233 } 234 234 235 235 static const struct xfs_item_ops xfs_rud_item_ops = { 236 - .flags = XFS_ITEM_RELEASE_WHEN_COMMITTED, 236 + .flags = XFS_ITEM_RELEASE_WHEN_COMMITTED | 237 + XFS_ITEM_INTENT_DONE, 237 238 .iop_size = xfs_rud_item_size, 238 239 .iop_format = xfs_rud_item_format, 239 240 .iop_release = xfs_rud_item_release, ··· 633 632 } 634 633 635 634 static const struct xfs_item_ops xfs_rui_item_ops = { 635 + .flags = XFS_ITEM_INTENT, 636 636 .iop_size = xfs_rui_item_size, 637 637 .iop_format = xfs_rui_item_format, 638 638 .iop_unpin = xfs_rui_item_unpin,
+13 -12
fs/xfs/xfs_trans.h
··· 80 80 struct xfs_trans *tp); 81 81 }; 82 82 83 - /* Is this log item a deferred action intent? */ 83 + /* 84 + * Log item ops flags 85 + */ 86 + /* 87 + * Release the log item when the journal commits instead of inserting into the 88 + * AIL for writeback tracking and/or log tail pinning. 89 + */ 90 + #define XFS_ITEM_RELEASE_WHEN_COMMITTED (1 << 0) 91 + #define XFS_ITEM_INTENT (1 << 1) 92 + #define XFS_ITEM_INTENT_DONE (1 << 2) 93 + 84 94 static inline bool 85 95 xlog_item_is_intent(struct xfs_log_item *lip) 86 96 { 87 - return lip->li_ops->iop_recover != NULL && 88 - lip->li_ops->iop_match != NULL; 97 + return lip->li_ops->flags & XFS_ITEM_INTENT; 89 98 } 90 99 91 - /* Is this a log intent-done item? */ 92 100 static inline bool 93 101 xlog_item_is_intent_done(struct xfs_log_item *lip) 94 102 { 95 - return lip->li_ops->iop_unpin == NULL && 96 - lip->li_ops->iop_push == NULL; 103 + return lip->li_ops->flags & XFS_ITEM_INTENT_DONE; 97 104 } 98 - 99 - /* 100 - * Release the log item as soon as committed. This is for items just logging 101 - * intents that never need to be written back in place. 102 - */ 103 - #define XFS_ITEM_RELEASE_WHEN_COMMITTED (1 << 0) 104 105 105 106 void xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item, 106 107 int type, const struct xfs_item_ops *ops);