2020-05-12 23:54:17 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
2016-08-03 01:12:25 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2016 Oracle. All Rights Reserved.
|
|
|
|
* Author: Darrick J. Wong <darrick.wong@oracle.com>
|
|
|
|
*/
|
|
|
|
#ifndef __XFS_DEFER_H__
|
|
|
|
#define __XFS_DEFER_H__
|
|
|
|
|
2020-04-30 19:52:22 +00:00
|
|
|
struct xfs_btree_cur;
|
2016-08-03 01:12:25 +00:00
|
|
|
struct xfs_defer_op_type;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Header for deferred operation list.
|
|
|
|
*/
|
|
|
|
enum xfs_defer_ops_type {
|
2016-10-03 16:11:28 +00:00
|
|
|
XFS_DEFER_OPS_TYPE_BMAP,
|
2016-10-03 16:11:22 +00:00
|
|
|
XFS_DEFER_OPS_TYPE_REFCOUNT,
|
2016-08-03 02:11:01 +00:00
|
|
|
XFS_DEFER_OPS_TYPE_RMAP,
|
2016-08-03 01:14:35 +00:00
|
|
|
XFS_DEFER_OPS_TYPE_FREE,
|
2018-05-08 00:38:47 +00:00
|
|
|
XFS_DEFER_OPS_TYPE_AGFL_FREE,
|
2016-08-03 01:12:25 +00:00
|
|
|
XFS_DEFER_OPS_TYPE_MAX,
|
|
|
|
};
|
|
|
|
|
2018-12-12 16:46:22 +00:00
|
|
|
/*
|
|
|
|
* Save a log intent item and a list of extents, so that we can replay
|
|
|
|
* whatever action had to happen to the extent list and file the log done
|
|
|
|
* item.
|
|
|
|
*/
|
|
|
|
struct xfs_defer_pending {
|
|
|
|
struct list_head dfp_list; /* pending items */
|
|
|
|
struct list_head dfp_work; /* work items */
|
2020-04-30 19:52:21 +00:00
|
|
|
struct xfs_log_item *dfp_intent; /* log intent item */
|
2020-04-30 19:52:22 +00:00
|
|
|
struct xfs_log_item *dfp_done; /* log done item */
|
2018-12-12 16:46:22 +00:00
|
|
|
unsigned int dfp_count; /* # extent items */
|
|
|
|
enum xfs_defer_ops_type dfp_type;
|
|
|
|
};
|
|
|
|
|
2018-08-01 14:20:34 +00:00
|
|
|
void xfs_defer_add(struct xfs_trans *tp, enum xfs_defer_ops_type type,
|
2016-08-03 01:12:25 +00:00
|
|
|
struct list_head *h);
|
2018-07-24 20:43:15 +00:00
|
|
|
int xfs_defer_finish_noroll(struct xfs_trans **tp);
|
2018-07-24 20:43:15 +00:00
|
|
|
int xfs_defer_finish(struct xfs_trans **tp);
|
2018-08-01 14:20:30 +00:00
|
|
|
void xfs_defer_cancel(struct xfs_trans *);
|
2018-08-01 14:20:30 +00:00
|
|
|
void xfs_defer_move(struct xfs_trans *dtp, struct xfs_trans *stp);
|
2016-08-03 01:12:25 +00:00
|
|
|
|
|
|
|
/* Description of a deferred type. */
|
|
|
|
struct xfs_defer_op_type {
|
2020-04-30 19:52:21 +00:00
|
|
|
struct xfs_log_item *(*create_intent)(struct xfs_trans *tp,
|
|
|
|
struct list_head *items, unsigned int count, bool sort);
|
|
|
|
void (*abort_intent)(struct xfs_log_item *intent);
|
2020-04-30 19:52:22 +00:00
|
|
|
struct xfs_log_item *(*create_done)(struct xfs_trans *tp,
|
|
|
|
struct xfs_log_item *intent, unsigned int count);
|
|
|
|
int (*finish_item)(struct xfs_trans *tp, struct xfs_log_item *done,
|
2020-04-30 19:52:22 +00:00
|
|
|
struct list_head *item, struct xfs_btree_cur **state);
|
|
|
|
void (*finish_cleanup)(struct xfs_trans *tp,
|
|
|
|
struct xfs_btree_cur *state, int error);
|
2020-04-30 19:52:23 +00:00
|
|
|
void (*cancel_item)(struct list_head *item);
|
2018-12-12 16:46:22 +00:00
|
|
|
unsigned int max_items;
|
2016-08-03 01:12:25 +00:00
|
|
|
};
|
|
|
|
|
2018-12-12 16:46:22 +00:00
|
|
|
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;
|
2016-08-03 01:12:25 +00:00
|
|
|
|
2020-09-21 16:15:09 +00:00
|
|
|
/*
|
|
|
|
* Functions to capture a chain of deferred operations and continue them later.
|
|
|
|
* This doesn't normally happen except log recovery.
|
|
|
|
*/
|
|
|
|
void xfs_defer_capture(struct xfs_trans *dtp, struct xfs_trans *stp);
|
|
|
|
|
2016-08-03 01:12:25 +00:00
|
|
|
#endif /* __XFS_DEFER_H__ */
|