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>
This commit is contained in:
Родитель
43feeea88c
Коммит
bc9f2b7c8a
|
@ -172,7 +172,13 @@
|
|||
* reoccur.
|
||||
*/
|
||||
|
||||
static const struct xfs_defer_op_type *defer_op_types[XFS_DEFER_OPS_TYPE_MAX];
|
||||
static const struct xfs_defer_op_type *defer_op_types[] = {
|
||||
[XFS_DEFER_OPS_TYPE_BMAP] = &xfs_bmap_update_defer_type,
|
||||
[XFS_DEFER_OPS_TYPE_REFCOUNT] = &xfs_refcount_update_defer_type,
|
||||
[XFS_DEFER_OPS_TYPE_RMAP] = &xfs_rmap_update_defer_type,
|
||||
[XFS_DEFER_OPS_TYPE_FREE] = &xfs_extent_free_defer_type,
|
||||
[XFS_DEFER_OPS_TYPE_AGFL_FREE] = &xfs_agfl_free_defer_type,
|
||||
};
|
||||
|
||||
/*
|
||||
* For each pending item in the intake list, log its intent item and the
|
||||
|
@ -488,6 +494,7 @@ xfs_defer_add(
|
|||
struct xfs_defer_pending *dfp = NULL;
|
||||
|
||||
ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
|
||||
BUILD_BUG_ON(ARRAY_SIZE(defer_op_types) != XFS_DEFER_OPS_TYPE_MAX);
|
||||
|
||||
/*
|
||||
* Add the item to a pending item at the end of the intake list.
|
||||
|
@ -517,14 +524,6 @@ xfs_defer_add(
|
|||
dfp->dfp_count++;
|
||||
}
|
||||
|
||||
/* Initialize a deferred operation list. */
|
||||
void
|
||||
xfs_defer_init_op_type(
|
||||
const struct xfs_defer_op_type *type)
|
||||
{
|
||||
defer_op_types[type->type] = type;
|
||||
}
|
||||
|
||||
/*
|
||||
* Move deferred ops from one transaction to another and reset the source to
|
||||
* initial state. This is primarily used to carry state forward across
|
||||
|
|
|
@ -56,6 +56,10 @@ struct xfs_defer_op_type {
|
|||
void (*log_item)(struct xfs_trans *, void *, struct list_head *);
|
||||
};
|
||||
|
||||
void xfs_defer_init_op_type(const struct xfs_defer_op_type *type);
|
||||
extern const struct xfs_defer_op_type xfs_bmap_update_defer_type;
|
||||
extern const struct xfs_defer_op_type xfs_refcount_update_defer_type;
|
||||
extern const struct xfs_defer_op_type xfs_rmap_update_defer_type;
|
||||
extern const struct xfs_defer_op_type xfs_extent_free_defer_type;
|
||||
extern const struct xfs_defer_op_type xfs_agfl_free_defer_type;
|
||||
|
||||
#endif /* __XFS_DEFER_H__ */
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "xfs_refcount_item.h"
|
||||
#include "xfs_bmap_item.h"
|
||||
#include "xfs_reflink.h"
|
||||
#include "xfs_defer.h"
|
||||
|
||||
#include <linux/namei.h>
|
||||
#include <linux/dax.h>
|
||||
|
@ -2085,11 +2086,6 @@ init_xfs_fs(void)
|
|||
printk(KERN_INFO XFS_VERSION_STRING " with "
|
||||
XFS_BUILD_OPTIONS " enabled\n");
|
||||
|
||||
xfs_extent_free_init_defer_op();
|
||||
xfs_rmap_update_init_defer_op();
|
||||
xfs_refcount_update_init_defer_op();
|
||||
xfs_bmap_update_init_defer_op();
|
||||
|
||||
xfs_dir_startup();
|
||||
|
||||
error = xfs_init_zones();
|
||||
|
|
|
@ -223,7 +223,6 @@ void xfs_trans_dirty_buf(struct xfs_trans *, struct xfs_buf *);
|
|||
bool xfs_trans_buf_is_dirty(struct xfs_buf *bp);
|
||||
void xfs_trans_log_inode(xfs_trans_t *, struct xfs_inode *, uint);
|
||||
|
||||
void xfs_extent_free_init_defer_op(void);
|
||||
struct xfs_efd_log_item *xfs_trans_get_efd(struct xfs_trans *,
|
||||
struct xfs_efi_log_item *,
|
||||
uint);
|
||||
|
@ -248,7 +247,6 @@ extern kmem_zone_t *xfs_trans_zone;
|
|||
/* rmap updates */
|
||||
enum xfs_rmap_intent_type;
|
||||
|
||||
void xfs_rmap_update_init_defer_op(void);
|
||||
struct xfs_rud_log_item *xfs_trans_get_rud(struct xfs_trans *tp,
|
||||
struct xfs_rui_log_item *ruip);
|
||||
int xfs_trans_log_finish_rmap_update(struct xfs_trans *tp,
|
||||
|
@ -260,7 +258,6 @@ int xfs_trans_log_finish_rmap_update(struct xfs_trans *tp,
|
|||
/* refcount updates */
|
||||
enum xfs_refcount_intent_type;
|
||||
|
||||
void xfs_refcount_update_init_defer_op(void);
|
||||
struct xfs_cud_log_item *xfs_trans_get_cud(struct xfs_trans *tp,
|
||||
struct xfs_cui_log_item *cuip);
|
||||
int xfs_trans_log_finish_refcount_update(struct xfs_trans *tp,
|
||||
|
@ -272,7 +269,6 @@ int xfs_trans_log_finish_refcount_update(struct xfs_trans *tp,
|
|||
/* mapping updates */
|
||||
enum xfs_bmap_intent_type;
|
||||
|
||||
void xfs_bmap_update_init_defer_op(void);
|
||||
struct xfs_bud_log_item *xfs_trans_get_bud(struct xfs_trans *tp,
|
||||
struct xfs_bui_log_item *buip);
|
||||
int xfs_trans_log_finish_bmap_update(struct xfs_trans *tp,
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "xfs_alloc.h"
|
||||
#include "xfs_bmap.h"
|
||||
#include "xfs_inode.h"
|
||||
#include "xfs_defer.h"
|
||||
|
||||
/*
|
||||
* This routine is called to allocate a "bmap update done"
|
||||
|
@ -220,7 +221,7 @@ xfs_bmap_update_cancel_item(
|
|||
kmem_free(bmap);
|
||||
}
|
||||
|
||||
static const struct xfs_defer_op_type xfs_bmap_update_defer_type = {
|
||||
const struct xfs_defer_op_type xfs_bmap_update_defer_type = {
|
||||
.type = XFS_DEFER_OPS_TYPE_BMAP,
|
||||
.max_items = XFS_BUI_MAX_FAST_EXTENTS,
|
||||
.diff_items = xfs_bmap_update_diff_items,
|
||||
|
@ -231,10 +232,3 @@ static const struct xfs_defer_op_type xfs_bmap_update_defer_type = {
|
|||
.finish_item = xfs_bmap_update_finish_item,
|
||||
.cancel_item = xfs_bmap_update_cancel_item,
|
||||
};
|
||||
|
||||
/* Register the deferred op type. */
|
||||
void
|
||||
xfs_bmap_update_init_defer_op(void)
|
||||
{
|
||||
xfs_defer_init_op_type(&xfs_bmap_update_defer_type);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "xfs_alloc.h"
|
||||
#include "xfs_bmap.h"
|
||||
#include "xfs_trace.h"
|
||||
#include "xfs_defer.h"
|
||||
|
||||
/*
|
||||
* This routine is called to allocate an "extent free done"
|
||||
|
@ -206,7 +207,7 @@ xfs_extent_free_cancel_item(
|
|||
kmem_free(free);
|
||||
}
|
||||
|
||||
static const struct xfs_defer_op_type xfs_extent_free_defer_type = {
|
||||
const struct xfs_defer_op_type xfs_extent_free_defer_type = {
|
||||
.type = XFS_DEFER_OPS_TYPE_FREE,
|
||||
.max_items = XFS_EFI_MAX_FAST_EXTENTS,
|
||||
.diff_items = xfs_extent_free_diff_items,
|
||||
|
@ -274,7 +275,7 @@ xfs_agfl_free_finish_item(
|
|||
|
||||
|
||||
/* sub-type with special handling for AGFL deferred frees */
|
||||
static const struct xfs_defer_op_type xfs_agfl_free_defer_type = {
|
||||
const struct xfs_defer_op_type xfs_agfl_free_defer_type = {
|
||||
.type = XFS_DEFER_OPS_TYPE_AGFL_FREE,
|
||||
.max_items = XFS_EFI_MAX_FAST_EXTENTS,
|
||||
.diff_items = xfs_extent_free_diff_items,
|
||||
|
@ -285,11 +286,3 @@ static const struct xfs_defer_op_type xfs_agfl_free_defer_type = {
|
|||
.finish_item = xfs_agfl_free_finish_item,
|
||||
.cancel_item = xfs_extent_free_cancel_item,
|
||||
};
|
||||
|
||||
/* Register the deferred op type. */
|
||||
void
|
||||
xfs_extent_free_init_defer_op(void)
|
||||
{
|
||||
xfs_defer_init_op_type(&xfs_extent_free_defer_type);
|
||||
xfs_defer_init_op_type(&xfs_agfl_free_defer_type);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "xfs_refcount_item.h"
|
||||
#include "xfs_alloc.h"
|
||||
#include "xfs_refcount.h"
|
||||
#include "xfs_defer.h"
|
||||
|
||||
/*
|
||||
* This routine is called to allocate a "refcount update done"
|
||||
|
@ -227,7 +228,7 @@ xfs_refcount_update_cancel_item(
|
|||
kmem_free(refc);
|
||||
}
|
||||
|
||||
static const struct xfs_defer_op_type xfs_refcount_update_defer_type = {
|
||||
const struct xfs_defer_op_type xfs_refcount_update_defer_type = {
|
||||
.type = XFS_DEFER_OPS_TYPE_REFCOUNT,
|
||||
.max_items = XFS_CUI_MAX_FAST_EXTENTS,
|
||||
.diff_items = xfs_refcount_update_diff_items,
|
||||
|
@ -239,10 +240,3 @@ static const struct xfs_defer_op_type xfs_refcount_update_defer_type = {
|
|||
.finish_cleanup = xfs_refcount_update_finish_cleanup,
|
||||
.cancel_item = xfs_refcount_update_cancel_item,
|
||||
};
|
||||
|
||||
/* Register the deferred op type. */
|
||||
void
|
||||
xfs_refcount_update_init_defer_op(void)
|
||||
{
|
||||
xfs_defer_init_op_type(&xfs_refcount_update_defer_type);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "xfs_rmap_item.h"
|
||||
#include "xfs_alloc.h"
|
||||
#include "xfs_rmap.h"
|
||||
#include "xfs_defer.h"
|
||||
|
||||
/* Set the map extent flags for this reverse mapping. */
|
||||
static void
|
||||
|
@ -244,7 +245,7 @@ xfs_rmap_update_cancel_item(
|
|||
kmem_free(rmap);
|
||||
}
|
||||
|
||||
static const struct xfs_defer_op_type xfs_rmap_update_defer_type = {
|
||||
const struct xfs_defer_op_type xfs_rmap_update_defer_type = {
|
||||
.type = XFS_DEFER_OPS_TYPE_RMAP,
|
||||
.max_items = XFS_RUI_MAX_FAST_EXTENTS,
|
||||
.diff_items = xfs_rmap_update_diff_items,
|
||||
|
@ -256,10 +257,3 @@ static const struct xfs_defer_op_type xfs_rmap_update_defer_type = {
|
|||
.finish_cleanup = xfs_rmap_update_finish_cleanup,
|
||||
.cancel_item = xfs_rmap_update_cancel_item,
|
||||
};
|
||||
|
||||
/* Register the deferred op type. */
|
||||
void
|
||||
xfs_rmap_update_init_defer_op(void)
|
||||
{
|
||||
xfs_defer_init_op_type(&xfs_rmap_update_defer_type);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче