• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 struct xfs_defer_capture;
11 
12 /*
13  * Header for deferred operation list.
14  */
15 enum xfs_defer_ops_type {
16 	XFS_DEFER_OPS_TYPE_BMAP,
17 	XFS_DEFER_OPS_TYPE_REFCOUNT,
18 	XFS_DEFER_OPS_TYPE_RMAP,
19 	XFS_DEFER_OPS_TYPE_FREE,
20 	XFS_DEFER_OPS_TYPE_AGFL_FREE,
21 	XFS_DEFER_OPS_TYPE_MAX,
22 };
23 
24 /*
25  * Save a log intent item and a list of extents, so that we can replay
26  * whatever action had to happen to the extent list and file the log done
27  * item.
28  */
29 struct xfs_defer_pending {
30 	struct list_head		dfp_list;	/* pending items */
31 	struct list_head		dfp_work;	/* work items */
32 	struct xfs_log_item		*dfp_intent;	/* log intent item */
33 	void				*dfp_done;	/* log done item */
34 	unsigned int			dfp_count;	/* # extent items */
35 	enum xfs_defer_ops_type		dfp_type;
36 };
37 
38 void xfs_defer_add(struct xfs_trans *tp, enum xfs_defer_ops_type type,
39 		struct list_head *h);
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_move(struct xfs_trans *dtp, struct xfs_trans *stp);
44 
45 /* Description of a deferred type. */
46 struct xfs_defer_op_type {
47 	struct xfs_log_item *(*create_intent)(struct xfs_trans *tp,
48 			struct list_head *items, unsigned int count, bool sort);
49 	void (*abort_intent)(struct xfs_log_item *intent);
50 	void *(*create_done)(struct xfs_trans *tp, struct xfs_log_item *intent,
51 			unsigned int count);
52 	int (*finish_item)(struct xfs_trans *, struct list_head *, void *,
53 			void **);
54 	void (*finish_cleanup)(struct xfs_trans *, void *, int);
55 	void (*cancel_item)(struct list_head *);
56 	unsigned int		max_items;
57 };
58 
59 extern const struct xfs_defer_op_type xfs_bmap_update_defer_type;
60 extern const struct xfs_defer_op_type xfs_refcount_update_defer_type;
61 extern const struct xfs_defer_op_type xfs_rmap_update_defer_type;
62 extern const struct xfs_defer_op_type xfs_extent_free_defer_type;
63 extern const struct xfs_defer_op_type xfs_agfl_free_defer_type;
64 
65 /*
66  * This structure enables a dfops user to detach the chain of deferred
67  * operations from a transaction so that they can be continued later.
68  */
69 struct xfs_defer_capture {
70 	/* List of other capture structures. */
71 	struct list_head	dfc_list;
72 
73 	/* Deferred ops state saved from the transaction. */
74 	struct list_head	dfc_dfops;
75 	unsigned int		dfc_tpflags;
76 
77 	/* Block reservations for the data and rt devices. */
78 	unsigned int		dfc_blkres;
79 	unsigned int		dfc_rtxres;
80 
81 	/* Log reservation saved from the transaction. */
82 	unsigned int		dfc_logres;
83 
84 	/*
85 	 * An inode reference that must be maintained to complete the deferred
86 	 * work.
87 	 */
88 	struct xfs_inode	*dfc_capture_ip;
89 };
90 
91 /*
92  * Functions to capture a chain of deferred operations and continue them later.
93  * This doesn't normally happen except log recovery.
94  */
95 int xfs_defer_ops_capture_and_commit(struct xfs_trans *tp,
96 		struct xfs_inode *capture_ip, struct list_head *capture_list);
97 void xfs_defer_ops_continue(struct xfs_defer_capture *d, struct xfs_trans *tp,
98 		struct xfs_inode **captured_ipp);
99 void xfs_defer_ops_release(struct xfs_mount *mp, struct xfs_defer_capture *d);
100 
101 #endif /* __XFS_DEFER_H__ */
102