1
2
3
4
5
6#ifndef __XFS_DEFER_H__
7#define __XFS_DEFER_H__
8
9struct xfs_defer_op_type;
10
11
12
13
14
15
16struct xfs_defer_pending {
17 const struct xfs_defer_op_type *dfp_type;
18 struct list_head dfp_list;
19 void *dfp_intent;
20 void *dfp_done;
21 struct list_head dfp_work;
22 unsigned int dfp_count;
23};
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39enum xfs_defer_ops_type {
40 XFS_DEFER_OPS_TYPE_BMAP,
41 XFS_DEFER_OPS_TYPE_REFCOUNT,
42 XFS_DEFER_OPS_TYPE_RMAP,
43 XFS_DEFER_OPS_TYPE_FREE,
44 XFS_DEFER_OPS_TYPE_AGFL_FREE,
45 XFS_DEFER_OPS_TYPE_MAX,
46};
47
48#define XFS_DEFER_OPS_NR_INODES 2
49#define XFS_DEFER_OPS_NR_BUFS 2
50
51struct xfs_defer_ops {
52 bool dop_committed;
53 bool dop_low;
54 struct list_head dop_intake;
55 struct list_head dop_pending;
56
57
58 struct xfs_inode *dop_inodes[XFS_DEFER_OPS_NR_INODES];
59 struct xfs_buf *dop_bufs[XFS_DEFER_OPS_NR_BUFS];
60};
61
62void xfs_defer_add(struct xfs_defer_ops *dop, enum xfs_defer_ops_type type,
63 struct list_head *h);
64int xfs_defer_finish(struct xfs_trans **tp, struct xfs_defer_ops *dop);
65void xfs_defer_cancel(struct xfs_defer_ops *dop);
66void xfs_defer_init(struct xfs_defer_ops *dop, xfs_fsblock_t *fbp);
67bool xfs_defer_has_unfinished_work(struct xfs_defer_ops *dop);
68int xfs_defer_ijoin(struct xfs_defer_ops *dop, struct xfs_inode *ip);
69int xfs_defer_bjoin(struct xfs_defer_ops *dop, struct xfs_buf *bp);
70
71
72struct xfs_defer_op_type {
73 enum xfs_defer_ops_type type;
74 unsigned int max_items;
75 void (*abort_intent)(void *);
76 void *(*create_done)(struct xfs_trans *, void *, unsigned int);
77 int (*finish_item)(struct xfs_trans *, struct xfs_defer_ops *,
78 struct list_head *, void *, void **);
79 void (*finish_cleanup)(struct xfs_trans *, void *, int);
80 void (*cancel_item)(struct list_head *);
81 int (*diff_items)(void *, struct list_head *, struct list_head *);
82 void *(*create_intent)(struct xfs_trans *, uint);
83 void (*log_item)(struct xfs_trans *, void *, struct list_head *);
84};
85
86void xfs_defer_init_op_type(const struct xfs_defer_op_type *type);
87
88#endif
89