]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - libxfs/xfs_defer.h
xfs: move extent busy tree initialization to xfs_initialize_perag
[thirdparty/xfsprogs-dev.git] / libxfs / xfs_defer.h
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_ops;
11
12 /*
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
15 * item.
16 */
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 */
24 };
25
26 /*
27 * Header for deferred operation list.
28 *
29 * dop_low is used by the allocator to activate the lowspace algorithm -
30 * when free space is running low the extent allocator may choose to
31 * allocate an extent from an AG without leaving sufficient space for
32 * a btree split when inserting the new extent. In this case the allocator
33 * will enable the lowspace algorithm which is supposed to allow further
34 * allocations (such as btree splits and newroots) to allocate from
35 * sequential AGs. In order to avoid locking AGs out of order the lowspace
36 * algorithm will start searching for free space from AG 0. If the correct
37 * transaction reservations have been made then this algorithm will eventually
38 * find all the space it needs.
39 */
40 enum xfs_defer_ops_type {
41 XFS_DEFER_OPS_TYPE_BMAP,
42 XFS_DEFER_OPS_TYPE_REFCOUNT,
43 XFS_DEFER_OPS_TYPE_RMAP,
44 XFS_DEFER_OPS_TYPE_FREE,
45 XFS_DEFER_OPS_TYPE_AGFL_FREE,
46 XFS_DEFER_OPS_TYPE_MAX,
47 };
48
49 void xfs_defer_add(struct xfs_defer_ops *dop, enum xfs_defer_ops_type type,
50 struct list_head *h);
51 int xfs_defer_finish_noroll(struct xfs_trans **tp);
52 int xfs_defer_finish(struct xfs_trans **tp);
53 void __xfs_defer_cancel(struct xfs_defer_ops *dop);
54 void xfs_defer_init(struct xfs_trans *tp, struct xfs_defer_ops *dop);
55 bool xfs_defer_has_unfinished_work(struct xfs_defer_ops *dop);
56 int xfs_defer_ijoin(struct xfs_defer_ops *dop, struct xfs_inode *ip);
57 int xfs_defer_bjoin(struct xfs_defer_ops *dop, struct xfs_buf *bp);
58 void xfs_defer_move(struct xfs_defer_ops *dst, struct xfs_defer_ops *src);
59
60 /* Description of a deferred type. */
61 struct xfs_defer_op_type {
62 enum xfs_defer_ops_type type;
63 unsigned int max_items;
64 void (*abort_intent)(void *);
65 void *(*create_done)(struct xfs_trans *, void *, unsigned int);
66 int (*finish_item)(struct xfs_trans *, struct xfs_defer_ops *,
67 struct list_head *, void *, void **);
68 void (*finish_cleanup)(struct xfs_trans *, void *, int);
69 void (*cancel_item)(struct list_head *);
70 int (*diff_items)(void *, struct list_head *, struct list_head *);
71 void *(*create_intent)(struct xfs_trans *, uint);
72 void (*log_item)(struct xfs_trans *, void *, struct list_head *);
73 };
74
75 void xfs_defer_init_op_type(const struct xfs_defer_op_type *type);
76
77 #endif /* __XFS_DEFER_H__ */