Skip to content

Commit f5b8120

Browse files
dgchinnerdchinner
authored andcommitted
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>
1 parent 5ddd658 commit f5b8120

5 files changed

Lines changed: 25 additions & 16 deletions

File tree

fs/xfs/xfs_bmap_item.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ xfs_bud_item_release(
204204
}
205205

206206
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,
208209
.iop_size = xfs_bud_item_size,
209210
.iop_format = xfs_bud_item_format,
210211
.iop_release = xfs_bud_item_release,
@@ -588,6 +589,7 @@ xfs_bui_item_relog(
588589
}
589590

590591
static const struct xfs_item_ops xfs_bui_item_ops = {
592+
.flags = XFS_ITEM_INTENT,
591593
.iop_size = xfs_bui_item_size,
592594
.iop_format = xfs_bui_item_format,
593595
.iop_unpin = xfs_bui_item_unpin,

fs/xfs/xfs_extfree_item.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ xfs_efd_item_release(
307307
}
308308

309309
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,
311312
.iop_size = xfs_efd_item_size,
312313
.iop_format = xfs_efd_item_format,
313314
.iop_release = xfs_efd_item_release,
@@ -688,6 +689,7 @@ xfs_efi_item_relog(
688689
}
689690

690691
static const struct xfs_item_ops xfs_efi_item_ops = {
692+
.flags = XFS_ITEM_INTENT,
691693
.iop_size = xfs_efi_item_size,
692694
.iop_format = xfs_efi_item_format,
693695
.iop_unpin = xfs_efi_item_unpin,

fs/xfs/xfs_refcount_item.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ xfs_cud_item_release(
210210
}
211211

212212
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,
214215
.iop_size = xfs_cud_item_size,
215216
.iop_format = xfs_cud_item_format,
216217
.iop_release = xfs_cud_item_release,
@@ -602,6 +603,7 @@ xfs_cui_item_relog(
602603
}
603604

604605
static const struct xfs_item_ops xfs_cui_item_ops = {
606+
.flags = XFS_ITEM_INTENT,
605607
.iop_size = xfs_cui_item_size,
606608
.iop_format = xfs_cui_item_format,
607609
.iop_unpin = xfs_cui_item_unpin,

fs/xfs/xfs_rmap_item.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ xfs_rud_item_release(
233233
}
234234

235235
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,
237238
.iop_size = xfs_rud_item_size,
238239
.iop_format = xfs_rud_item_format,
239240
.iop_release = xfs_rud_item_release,
@@ -632,6 +633,7 @@ xfs_rui_item_relog(
632633
}
633634

634635
static const struct xfs_item_ops xfs_rui_item_ops = {
636+
.flags = XFS_ITEM_INTENT,
635637
.iop_size = xfs_rui_item_size,
636638
.iop_format = xfs_rui_item_format,
637639
.iop_unpin = xfs_rui_item_unpin,

fs/xfs/xfs_trans.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,28 +80,29 @@ struct xfs_item_ops {
8080
struct xfs_trans *tp);
8181
};
8282

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+
8494
static inline bool
8595
xlog_item_is_intent(struct xfs_log_item *lip)
8696
{
87-
return lip->li_ops->iop_recover != NULL &&
88-
lip->li_ops->iop_match != NULL;
97+
return lip->li_ops->flags & XFS_ITEM_INTENT;
8998
}
9099

91-
/* Is this a log intent-done item? */
92100
static inline bool
93101
xlog_item_is_intent_done(struct xfs_log_item *lip)
94102
{
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;
97104
}
98105

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-
105106
void xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item,
106107
int type, const struct xfs_item_ops *ops);
107108

0 commit comments

Comments
 (0)