]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - libxfs/xfs_defer.h
8908a2716774a9c01cd702f216b3cf92962c2030
[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 enum xfs_defer_ops_type {
30 XFS_DEFER_OPS_TYPE_BMAP,
31 XFS_DEFER_OPS_TYPE_REFCOUNT,
32 XFS_DEFER_OPS_TYPE_RMAP,
33 XFS_DEFER_OPS_TYPE_FREE,
34 XFS_DEFER_OPS_TYPE_AGFL_FREE,
35 XFS_DEFER_OPS_TYPE_MAX,
36 };
37
38 void xfs_defer_add(struct xfs_defer_ops *dop, 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_init(struct xfs_trans *tp, struct xfs_defer_ops *dop);
44 bool xfs_defer_has_unfinished_work(struct xfs_defer_ops *dop);
45 int xfs_defer_ijoin(struct xfs_defer_ops *dop, struct xfs_inode *ip);
46 int xfs_defer_bjoin(struct xfs_defer_ops *dop, struct xfs_buf *bp);
47 void xfs_defer_move(struct xfs_trans *dtp, struct xfs_trans *stp);
48
49 /* Description of a deferred type. */
50 struct xfs_defer_op_type {
51 enum xfs_defer_ops_type type;
52 unsigned int max_items;
53 void (*abort_intent)(void *);
54 void *(*create_done)(struct xfs_trans *, void *, unsigned int);
55 int (*finish_item)(struct xfs_trans *, struct xfs_defer_ops *,
56 struct list_head *, void *, void **);
57 void (*finish_cleanup)(struct xfs_trans *, void *, int);
58 void (*cancel_item)(struct list_head *);
59 int (*diff_items)(void *, struct list_head *, struct list_head *);
60 void *(*create_intent)(struct xfs_trans *, uint);
61 void (*log_item)(struct xfs_trans *, void *, struct list_head *);
62 };
63
64 void xfs_defer_init_op_type(const struct xfs_defer_op_type *type);
65
66 #endif /* __XFS_DEFER_H__ */