aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2018-12-12 11:46:22 -0500
committerDarrick J. Wong <darrick.wong@oracle.com>2018-12-12 11:47:16 -0500
commitbc9f2b7c8a732d896753709cc9d495780ba7e9f9 (patch)
tree9ad8b75bee6b0d834503127f5e7dc4f3fe01bbf3 /fs/xfs/libxfs
parent43feeea88c9cb2955b9f7ba8152ec5abeea42810 (diff)
xfs: idiotproof defer op type configuration
Recently, we forgot to port a new defer op type to xfsprogs, which caused us some userspace pain. Reorganize the way we make libxfs clients supply defer op type information so that all type information has to be provided at build time instead of risky runtime dynamic configuration. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com>
Diffstat (limited to 'fs/xfs/libxfs')
-rw-r--r--fs/xfs/libxfs/xfs_defer.c17
-rw-r--r--fs/xfs/libxfs/xfs_defer.h6
2 files changed, 13 insertions, 10 deletions
diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c
index e792b167150a..277117a8ad13 100644
--- a/fs/xfs/libxfs/xfs_defer.c
+++ b/fs/xfs/libxfs/xfs_defer.c
@@ -172,7 +172,13 @@
172 * reoccur. 172 * reoccur.
173 */ 173 */
174 174
175static const struct xfs_defer_op_type *defer_op_types[XFS_DEFER_OPS_TYPE_MAX]; 175static const struct xfs_defer_op_type *defer_op_types[] = {
176 [XFS_DEFER_OPS_TYPE_BMAP] = &xfs_bmap_update_defer_type,
177 [XFS_DEFER_OPS_TYPE_REFCOUNT] = &xfs_refcount_update_defer_type,
178 [XFS_DEFER_OPS_TYPE_RMAP] = &xfs_rmap_update_defer_type,
179 [XFS_DEFER_OPS_TYPE_FREE] = &xfs_extent_free_defer_type,
180 [XFS_DEFER_OPS_TYPE_AGFL_FREE] = &xfs_agfl_free_defer_type,
181};
176 182
177/* 183/*
178 * For each pending item in the intake list, log its intent item and the 184 * For each pending item in the intake list, log its intent item and the
@@ -488,6 +494,7 @@ xfs_defer_add(
488 struct xfs_defer_pending *dfp = NULL; 494 struct xfs_defer_pending *dfp = NULL;
489 495
490 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); 496 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
497 BUILD_BUG_ON(ARRAY_SIZE(defer_op_types) != XFS_DEFER_OPS_TYPE_MAX);
491 498
492 /* 499 /*
493 * Add the item to a pending item at the end of the intake list. 500 * Add the item to a pending item at the end of the intake list.
@@ -517,14 +524,6 @@ xfs_defer_add(
517 dfp->dfp_count++; 524 dfp->dfp_count++;
518} 525}
519 526
520/* Initialize a deferred operation list. */
521void
522xfs_defer_init_op_type(
523 const struct xfs_defer_op_type *type)
524{
525 defer_op_types[type->type] = type;
526}
527
528/* 527/*
529 * Move deferred ops from one transaction to another and reset the source to 528 * Move deferred ops from one transaction to another and reset the source to
530 * initial state. This is primarily used to carry state forward across 529 * initial state. This is primarily used to carry state forward across
diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h
index 2584a5b95b0d..0a4b88e3df74 100644
--- a/fs/xfs/libxfs/xfs_defer.h
+++ b/fs/xfs/libxfs/xfs_defer.h
@@ -56,6 +56,10 @@ struct xfs_defer_op_type {
56 void (*log_item)(struct xfs_trans *, void *, struct list_head *); 56 void (*log_item)(struct xfs_trans *, void *, struct list_head *);
57}; 57};
58 58
59void xfs_defer_init_op_type(const struct xfs_defer_op_type *type); 59extern const struct xfs_defer_op_type xfs_bmap_update_defer_type;
60extern const struct xfs_defer_op_type xfs_refcount_update_defer_type;
61extern const struct xfs_defer_op_type xfs_rmap_update_defer_type;
62extern const struct xfs_defer_op_type xfs_extent_free_defer_type;
63extern const struct xfs_defer_op_type xfs_agfl_free_defer_type;
60 64
61#endif /* __XFS_DEFER_H__ */ 65#endif /* __XFS_DEFER_H__ */