1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2016 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
6 #ifndef __XFS_DEFER_H__
7 #define __XFS_DEFER_H__
9 struct xfs_defer_op_type
;
13 * Save a log intent item and a list of extents, so that we can replay
14 * whatever action had to happen to the extent list and file the log done
17 struct xfs_defer_pending
{
18 const struct xfs_defer_op_type
*dfp_type
; /* function pointers */
19 struct list_head dfp_list
; /* pending items */
20 void *dfp_intent
; /* log intent item */
21 void *dfp_done
; /* log done item */
22 struct list_head dfp_work
; /* work items */
23 unsigned int dfp_count
; /* # extent items */
27 * Header for deferred operation list.
29 enum xfs_defer_ops_type
{
30 XFS_DEFER_OPS_TYPE_BMAP
,
31 XFS_DEFER_OPS_TYPE_REFCOUNT
,
32 XFS_DEFER_OPS_TYPE_RMAP
,
33 XFS_DEFER_OPS_TYPE_FREE
,
34 XFS_DEFER_OPS_TYPE_AGFL_FREE
,
35 XFS_DEFER_OPS_TYPE_MAX
,
38 void xfs_defer_add(struct xfs_defer_ops
*dop
, enum xfs_defer_ops_type type
,
40 int xfs_defer_finish_noroll(struct xfs_trans
**tp
);
41 int xfs_defer_finish(struct xfs_trans
**tp
);
42 void xfs_defer_cancel(struct xfs_trans
*);
43 void xfs_defer_init(struct xfs_trans
*tp
, struct xfs_defer_ops
*dop
);
44 bool xfs_defer_has_unfinished_work(struct xfs_defer_ops
*dop
);
45 int xfs_defer_ijoin(struct xfs_defer_ops
*dop
, struct xfs_inode
*ip
);
46 int xfs_defer_bjoin(struct xfs_defer_ops
*dop
, struct xfs_buf
*bp
);
47 void xfs_defer_move(struct xfs_trans
*dtp
, struct xfs_trans
*stp
);
49 /* Description of a deferred type. */
50 struct xfs_defer_op_type
{
51 enum xfs_defer_ops_type type
;
52 unsigned int max_items
;
53 void (*abort_intent
)(void *);
54 void *(*create_done
)(struct xfs_trans
*, void *, unsigned int);
55 int (*finish_item
)(struct xfs_trans
*, struct xfs_defer_ops
*,
56 struct list_head
*, void *, void **);
57 void (*finish_cleanup
)(struct xfs_trans
*, void *, int);
58 void (*cancel_item
)(struct list_head
*);
59 int (*diff_items
)(void *, struct list_head
*, struct list_head
*);
60 void *(*create_intent
)(struct xfs_trans
*, uint
);
61 void (*log_item
)(struct xfs_trans
*, void *, struct list_head
*);
64 void xfs_defer_init_op_type(const struct xfs_defer_op_type
*type
);
66 #endif /* __XFS_DEFER_H__ */