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