.. | .. |
---|
1 | | -// SPDX-License-Identifier: GPL-2.0+ |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ |
---|
2 | 2 | /* |
---|
3 | 3 | * Copyright (C) 2016 Oracle. All Rights Reserved. |
---|
4 | 4 | * Author: Darrick J. Wong <darrick.wong@oracle.com> |
---|
.. | .. |
---|
6 | 6 | #ifndef __XFS_DEFER_H__ |
---|
7 | 7 | #define __XFS_DEFER_H__ |
---|
8 | 8 | |
---|
| 9 | +struct xfs_btree_cur; |
---|
9 | 10 | struct xfs_defer_op_type; |
---|
10 | | - |
---|
11 | | -/* |
---|
12 | | - * Save a log intent item and a list of extents, so that we can replay |
---|
13 | | - * whatever action had to happen to the extent list and file the log done |
---|
14 | | - * item. |
---|
15 | | - */ |
---|
16 | | -struct xfs_defer_pending { |
---|
17 | | - const struct xfs_defer_op_type *dfp_type; /* function pointers */ |
---|
18 | | - struct list_head dfp_list; /* pending items */ |
---|
19 | | - void *dfp_intent; /* log intent item */ |
---|
20 | | - void *dfp_done; /* log done item */ |
---|
21 | | - struct list_head dfp_work; /* work items */ |
---|
22 | | - unsigned int dfp_count; /* # extent items */ |
---|
23 | | -}; |
---|
| 11 | +struct xfs_defer_capture; |
---|
24 | 12 | |
---|
25 | 13 | /* |
---|
26 | 14 | * Header for deferred operation list. |
---|
.. | .. |
---|
34 | 22 | XFS_DEFER_OPS_TYPE_MAX, |
---|
35 | 23 | }; |
---|
36 | 24 | |
---|
| 25 | +/* |
---|
| 26 | + * Save a log intent item and a list of extents, so that we can replay |
---|
| 27 | + * whatever action had to happen to the extent list and file the log done |
---|
| 28 | + * item. |
---|
| 29 | + */ |
---|
| 30 | +struct xfs_defer_pending { |
---|
| 31 | + struct list_head dfp_list; /* pending items */ |
---|
| 32 | + struct list_head dfp_work; /* work items */ |
---|
| 33 | + struct xfs_log_item *dfp_intent; /* log intent item */ |
---|
| 34 | + struct xfs_log_item *dfp_done; /* log done item */ |
---|
| 35 | + unsigned int dfp_count; /* # extent items */ |
---|
| 36 | + enum xfs_defer_ops_type dfp_type; |
---|
| 37 | +}; |
---|
| 38 | + |
---|
37 | 39 | void xfs_defer_add(struct xfs_trans *tp, enum xfs_defer_ops_type type, |
---|
38 | 40 | struct list_head *h); |
---|
39 | 41 | int xfs_defer_finish_noroll(struct xfs_trans **tp); |
---|
.. | .. |
---|
43 | 45 | |
---|
44 | 46 | /* Description of a deferred type. */ |
---|
45 | 47 | struct xfs_defer_op_type { |
---|
46 | | - enum xfs_defer_ops_type type; |
---|
| 48 | + struct xfs_log_item *(*create_intent)(struct xfs_trans *tp, |
---|
| 49 | + struct list_head *items, unsigned int count, bool sort); |
---|
| 50 | + void (*abort_intent)(struct xfs_log_item *intent); |
---|
| 51 | + struct xfs_log_item *(*create_done)(struct xfs_trans *tp, |
---|
| 52 | + struct xfs_log_item *intent, unsigned int count); |
---|
| 53 | + int (*finish_item)(struct xfs_trans *tp, struct xfs_log_item *done, |
---|
| 54 | + struct list_head *item, struct xfs_btree_cur **state); |
---|
| 55 | + void (*finish_cleanup)(struct xfs_trans *tp, |
---|
| 56 | + struct xfs_btree_cur *state, int error); |
---|
| 57 | + void (*cancel_item)(struct list_head *item); |
---|
47 | 58 | unsigned int max_items; |
---|
48 | | - void (*abort_intent)(void *); |
---|
49 | | - void *(*create_done)(struct xfs_trans *, void *, unsigned int); |
---|
50 | | - int (*finish_item)(struct xfs_trans *, struct list_head *, void *, |
---|
51 | | - void **); |
---|
52 | | - void (*finish_cleanup)(struct xfs_trans *, void *, int); |
---|
53 | | - void (*cancel_item)(struct list_head *); |
---|
54 | | - int (*diff_items)(void *, struct list_head *, struct list_head *); |
---|
55 | | - void *(*create_intent)(struct xfs_trans *, uint); |
---|
56 | | - void (*log_item)(struct xfs_trans *, void *, struct list_head *); |
---|
57 | 59 | }; |
---|
58 | 60 | |
---|
59 | | -void xfs_defer_init_op_type(const struct xfs_defer_op_type *type); |
---|
| 61 | +extern const struct xfs_defer_op_type xfs_bmap_update_defer_type; |
---|
| 62 | +extern const struct xfs_defer_op_type xfs_refcount_update_defer_type; |
---|
| 63 | +extern const struct xfs_defer_op_type xfs_rmap_update_defer_type; |
---|
| 64 | +extern const struct xfs_defer_op_type xfs_extent_free_defer_type; |
---|
| 65 | +extern const struct xfs_defer_op_type xfs_agfl_free_defer_type; |
---|
| 66 | + |
---|
| 67 | +/* |
---|
| 68 | + * This structure enables a dfops user to detach the chain of deferred |
---|
| 69 | + * operations from a transaction so that they can be continued later. |
---|
| 70 | + */ |
---|
| 71 | +struct xfs_defer_capture { |
---|
| 72 | + /* List of other capture structures. */ |
---|
| 73 | + struct list_head dfc_list; |
---|
| 74 | + |
---|
| 75 | + /* Deferred ops state saved from the transaction. */ |
---|
| 76 | + struct list_head dfc_dfops; |
---|
| 77 | + unsigned int dfc_tpflags; |
---|
| 78 | + |
---|
| 79 | + /* Block reservations for the data and rt devices. */ |
---|
| 80 | + unsigned int dfc_blkres; |
---|
| 81 | + unsigned int dfc_rtxres; |
---|
| 82 | + |
---|
| 83 | + /* Log reservation saved from the transaction. */ |
---|
| 84 | + unsigned int dfc_logres; |
---|
| 85 | + |
---|
| 86 | + /* |
---|
| 87 | + * An inode reference that must be maintained to complete the deferred |
---|
| 88 | + * work. |
---|
| 89 | + */ |
---|
| 90 | + struct xfs_inode *dfc_capture_ip; |
---|
| 91 | +}; |
---|
| 92 | + |
---|
| 93 | +/* |
---|
| 94 | + * Functions to capture a chain of deferred operations and continue them later. |
---|
| 95 | + * This doesn't normally happen except log recovery. |
---|
| 96 | + */ |
---|
| 97 | +int xfs_defer_ops_capture_and_commit(struct xfs_trans *tp, |
---|
| 98 | + struct xfs_inode *capture_ip, struct list_head *capture_list); |
---|
| 99 | +void xfs_defer_ops_continue(struct xfs_defer_capture *d, struct xfs_trans *tp, |
---|
| 100 | + struct xfs_inode **captured_ipp); |
---|
| 101 | +void xfs_defer_ops_release(struct xfs_mount *mp, struct xfs_defer_capture *d); |
---|
60 | 102 | |
---|
61 | 103 | #endif /* __XFS_DEFER_H__ */ |
---|