]>
Commit | Line | Data |
---|---|---|
7acf15bf | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
a18e1f79 DW |
2 | /* |
3 | * Copyright (C) 2016 Oracle. All Rights Reserved. | |
a18e1f79 | 4 | * Author: Darrick J. Wong <darrick.wong@oracle.com> |
a18e1f79 DW |
5 | */ |
6 | #ifndef __XFS_DEFER_H__ | |
7 | #define __XFS_DEFER_H__ | |
8 | ||
4371b480 | 9 | struct xfs_btree_cur; |
a18e1f79 | 10 | struct xfs_defer_op_type; |
b1d41c43 | 11 | struct xfs_defer_capture; |
a18e1f79 | 12 | |
a18e1f79 DW |
13 | /* |
14 | * Header for deferred operation list. | |
a18e1f79 DW |
15 | */ |
16 | enum xfs_defer_ops_type { | |
aeb88300 | 17 | XFS_DEFER_OPS_TYPE_BMAP, |
23a15a6c | 18 | XFS_DEFER_OPS_TYPE_REFCOUNT, |
589b52d6 | 19 | XFS_DEFER_OPS_TYPE_RMAP, |
31a6b02a | 20 | XFS_DEFER_OPS_TYPE_FREE, |
d5c1b462 | 21 | XFS_DEFER_OPS_TYPE_AGFL_FREE, |
c6ad4bc1 | 22 | XFS_DEFER_OPS_TYPE_ATTR, |
a18e1f79 DW |
23 | XFS_DEFER_OPS_TYPE_MAX, |
24 | }; | |
25 | ||
c3514397 DW |
26 | /* |
27 | * Save a log intent item and a list of extents, so that we can replay | |
28 | * whatever action had to happen to the extent list and file the log done | |
29 | * item. | |
30 | */ | |
31 | struct xfs_defer_pending { | |
32 | struct list_head dfp_list; /* pending items */ | |
33 | struct list_head dfp_work; /* work items */ | |
18d0d657 | 34 | struct xfs_log_item *dfp_intent; /* log intent item */ |
95e01274 | 35 | struct xfs_log_item *dfp_done; /* log done item */ |
c3514397 DW |
36 | unsigned int dfp_count; /* # extent items */ |
37 | enum xfs_defer_ops_type dfp_type; | |
38 | }; | |
39 | ||
21375e5d | 40 | void xfs_defer_add(struct xfs_trans *tp, enum xfs_defer_ops_type type, |
a18e1f79 | 41 | struct list_head *h); |
ca7e896f | 42 | int xfs_defer_finish_noroll(struct xfs_trans **tp); |
ac0a2228 | 43 | int xfs_defer_finish(struct xfs_trans **tp); |
22913550 | 44 | void xfs_defer_cancel(struct xfs_trans *); |
76a3c33d | 45 | void xfs_defer_move(struct xfs_trans *dtp, struct xfs_trans *stp); |
a18e1f79 DW |
46 | |
47 | /* Description of a deferred type. */ | |
48 | struct xfs_defer_op_type { | |
18d0d657 CH |
49 | struct xfs_log_item *(*create_intent)(struct xfs_trans *tp, |
50 | struct list_head *items, unsigned int count, bool sort); | |
51 | void (*abort_intent)(struct xfs_log_item *intent); | |
95e01274 CH |
52 | struct xfs_log_item *(*create_done)(struct xfs_trans *tp, |
53 | struct xfs_log_item *intent, unsigned int count); | |
54 | int (*finish_item)(struct xfs_trans *tp, struct xfs_log_item *done, | |
4371b480 CH |
55 | struct list_head *item, struct xfs_btree_cur **state); |
56 | void (*finish_cleanup)(struct xfs_trans *tp, | |
57 | struct xfs_btree_cur *state, int error); | |
8d431a3b | 58 | void (*cancel_item)(struct list_head *item); |
c3514397 | 59 | unsigned int max_items; |
a18e1f79 DW |
60 | }; |
61 | ||
29ce8c42 DW |
62 | extern const struct xfs_defer_op_type xfs_bmap_update_defer_type; |
63 | extern const struct xfs_defer_op_type xfs_refcount_update_defer_type; | |
64 | extern const struct xfs_defer_op_type xfs_rmap_update_defer_type; | |
65 | extern const struct xfs_defer_op_type xfs_extent_free_defer_type; | |
66 | extern const struct xfs_defer_op_type xfs_agfl_free_defer_type; | |
6bcbc244 AH |
67 | extern const struct xfs_defer_op_type xfs_attr_defer_type; |
68 | ||
a18e1f79 | 69 | |
b445674e DW |
70 | /* |
71 | * Deferred operation item relogging limits. | |
72 | */ | |
73 | #define XFS_DEFER_OPS_NR_INODES 2 /* join up to two inodes */ | |
74 | #define XFS_DEFER_OPS_NR_BUFS 2 /* join up to two buffers */ | |
75 | ||
76 | /* Resources that must be held across a transaction roll. */ | |
77 | struct xfs_defer_resources { | |
78 | /* held buffers */ | |
79 | struct xfs_buf *dr_bp[XFS_DEFER_OPS_NR_BUFS]; | |
80 | ||
81 | /* inodes with no unlock flags */ | |
82 | struct xfs_inode *dr_ip[XFS_DEFER_OPS_NR_INODES]; | |
83 | ||
84 | /* number of held buffers */ | |
85 | unsigned short dr_bufs; | |
86 | ||
87 | /* bitmap of ordered buffers */ | |
88 | unsigned short dr_ordered; | |
89 | ||
90 | /* number of held inodes */ | |
91 | unsigned short dr_inos; | |
92 | }; | |
93 | ||
b1d41c43 DW |
94 | /* |
95 | * This structure enables a dfops user to detach the chain of deferred | |
96 | * operations from a transaction so that they can be continued later. | |
97 | */ | |
98 | struct xfs_defer_capture { | |
99 | /* List of other capture structures. */ | |
100 | struct list_head dfc_list; | |
101 | ||
102 | /* Deferred ops state saved from the transaction. */ | |
103 | struct list_head dfc_dfops; | |
104 | unsigned int dfc_tpflags; | |
75d8bf7e DW |
105 | |
106 | /* Block reservations for the data and rt devices. */ | |
107 | unsigned int dfc_blkres; | |
108 | unsigned int dfc_rtxres; | |
bb6667dc DW |
109 | |
110 | /* Log reservation saved from the transaction. */ | |
111 | unsigned int dfc_logres; | |
50edfee5 | 112 | |
7d6b86ac | 113 | struct xfs_defer_resources dfc_held; |
b1d41c43 DW |
114 | }; |
115 | ||
953cc24b DW |
116 | /* |
117 | * Functions to capture a chain of deferred operations and continue them later. | |
118 | * This doesn't normally happen except log recovery. | |
119 | */ | |
b1d41c43 | 120 | int xfs_defer_ops_capture_and_commit(struct xfs_trans *tp, |
7d6b86ac | 121 | struct list_head *capture_list); |
50edfee5 | 122 | void xfs_defer_ops_continue(struct xfs_defer_capture *d, struct xfs_trans *tp, |
7d6b86ac | 123 | struct xfs_defer_resources *dres); |
97165047 | 124 | void xfs_defer_ops_capture_abort(struct xfs_mount *mp, |
7d6b86ac DW |
125 | struct xfs_defer_capture *d); |
126 | void xfs_defer_resources_rele(struct xfs_defer_resources *dres); | |
953cc24b | 127 | |
1577541c DW |
128 | int __init xfs_defer_init_item_caches(void); |
129 | void xfs_defer_destroy_item_caches(void); | |
130 | ||
a18e1f79 | 131 | #endif /* __XFS_DEFER_H__ */ |