xref: /openbmc/linux/fs/xfs/libxfs/xfs_defer.h (revision 9f7d35d9)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2016 Oracle.  All Rights Reserved.
4  * Author: Darrick J. Wong <darrick.wong@oracle.com>
5  */
6 #ifndef __XFS_DEFER_H__
7 #define	__XFS_DEFER_H__
8 
9 struct xfs_defer_op_type;
10 
11 /*
12  * Header for deferred operation list.
13  */
14 enum xfs_defer_ops_type {
15 	XFS_DEFER_OPS_TYPE_BMAP,
16 	XFS_DEFER_OPS_TYPE_REFCOUNT,
17 	XFS_DEFER_OPS_TYPE_RMAP,
18 	XFS_DEFER_OPS_TYPE_FREE,
19 	XFS_DEFER_OPS_TYPE_AGFL_FREE,
20 	XFS_DEFER_OPS_TYPE_MAX,
21 };
22 
23 /*
24  * Save a log intent item and a list of extents, so that we can replay
25  * whatever action had to happen to the extent list and file the log done
26  * item.
27  */
28 struct xfs_defer_pending {
29 	struct list_head		dfp_list;	/* pending items */
30 	struct list_head		dfp_work;	/* work items */
31 	void				*dfp_intent;	/* log intent item */
32 	void				*dfp_done;	/* log done item */
33 	unsigned int			dfp_count;	/* # extent items */
34 	enum xfs_defer_ops_type		dfp_type;
35 };
36 
37 void xfs_defer_add(struct xfs_trans *tp, enum xfs_defer_ops_type type,
38 		struct list_head *h);
39 int xfs_defer_finish_noroll(struct xfs_trans **tp);
40 int xfs_defer_finish(struct xfs_trans **tp);
41 void xfs_defer_cancel(struct xfs_trans *);
42 void xfs_defer_move(struct xfs_trans *dtp, struct xfs_trans *stp);
43 
44 /* Description of a deferred type. */
45 struct xfs_defer_op_type {
46 	void (*abort_intent)(void *);
47 	void *(*create_done)(struct xfs_trans *, void *, unsigned int);
48 	int (*finish_item)(struct xfs_trans *, struct list_head *, void *,
49 			void **);
50 	void (*finish_cleanup)(struct xfs_trans *, void *, int);
51 	void (*cancel_item)(struct list_head *);
52 	int (*diff_items)(void *, struct list_head *, struct list_head *);
53 	void *(*create_intent)(struct xfs_trans *, uint);
54 	void (*log_item)(struct xfs_trans *, void *, struct list_head *);
55 	unsigned int		max_items;
56 };
57 
58 extern const struct xfs_defer_op_type xfs_bmap_update_defer_type;
59 extern const struct xfs_defer_op_type xfs_refcount_update_defer_type;
60 extern const struct xfs_defer_op_type xfs_rmap_update_defer_type;
61 extern const struct xfs_defer_op_type xfs_extent_free_defer_type;
62 extern const struct xfs_defer_op_type xfs_agfl_free_defer_type;
63 
64 #endif /* __XFS_DEFER_H__ */
65