1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#ifndef __BTRFS_QGROUP__
20#define __BTRFS_QGROUP__
21
22#include "ulist.h"
23#include "delayed-ref.h"
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57struct btrfs_qgroup_extent_record {
58 struct rb_node node;
59 u64 bytenr;
60 u64 num_bytes;
61 struct ulist *old_roots;
62};
63
64
65
66
67struct btrfs_qgroup {
68 u64 qgroupid;
69
70
71
72
73 u64 rfer;
74 u64 rfer_cmpr;
75 u64 excl;
76 u64 excl_cmpr;
77
78
79
80
81 u64 lim_flags;
82 u64 max_rfer;
83 u64 max_excl;
84 u64 rsv_rfer;
85 u64 rsv_excl;
86
87
88
89
90 u64 reserved;
91
92
93
94
95 struct list_head groups;
96 struct list_head members;
97 struct list_head dirty;
98 struct rb_node node;
99
100
101
102
103
104 u64 old_refcnt;
105 u64 new_refcnt;
106};
107
108
109
110
111#define QGROUP_RESERVE (1<<0)
112#define QGROUP_RELEASE (1<<1)
113#define QGROUP_FREE (1<<2)
114
115int btrfs_quota_enable(struct btrfs_trans_handle *trans,
116 struct btrfs_fs_info *fs_info);
117int btrfs_quota_disable(struct btrfs_trans_handle *trans,
118 struct btrfs_fs_info *fs_info);
119int btrfs_qgroup_rescan(struct btrfs_fs_info *fs_info);
120void btrfs_qgroup_rescan_resume(struct btrfs_fs_info *fs_info);
121int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info,
122 bool interruptible);
123int btrfs_add_qgroup_relation(struct btrfs_trans_handle *trans,
124 struct btrfs_fs_info *fs_info, u64 src, u64 dst);
125int btrfs_del_qgroup_relation(struct btrfs_trans_handle *trans,
126 struct btrfs_fs_info *fs_info, u64 src, u64 dst);
127int btrfs_create_qgroup(struct btrfs_trans_handle *trans,
128 struct btrfs_fs_info *fs_info, u64 qgroupid);
129int btrfs_remove_qgroup(struct btrfs_trans_handle *trans,
130 struct btrfs_fs_info *fs_info, u64 qgroupid);
131int btrfs_limit_qgroup(struct btrfs_trans_handle *trans,
132 struct btrfs_fs_info *fs_info, u64 qgroupid,
133 struct btrfs_qgroup_limit *limit);
134int btrfs_read_qgroup_config(struct btrfs_fs_info *fs_info);
135void btrfs_free_qgroup_config(struct btrfs_fs_info *fs_info);
136struct btrfs_delayed_extent_op;
137
138
139
140
141
142
143
144
145
146
147
148
149int btrfs_qgroup_trace_extent_nolock(
150 struct btrfs_fs_info *fs_info,
151 struct btrfs_delayed_ref_root *delayed_refs,
152 struct btrfs_qgroup_extent_record *record);
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175int btrfs_qgroup_trace_extent_post(struct btrfs_fs_info *fs_info,
176 struct btrfs_qgroup_extent_record *qrecord);
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191int btrfs_qgroup_trace_extent(struct btrfs_trans_handle *trans,
192 struct btrfs_fs_info *fs_info, u64 bytenr, u64 num_bytes,
193 gfp_t gfp_flag);
194
195
196
197
198
199
200
201int btrfs_qgroup_trace_leaf_items(struct btrfs_trans_handle *trans,
202 struct btrfs_fs_info *fs_info,
203 struct extent_buffer *eb);
204
205
206
207
208
209
210
211
212
213
214int btrfs_qgroup_trace_subtree(struct btrfs_trans_handle *trans,
215 struct btrfs_root *root,
216 struct extent_buffer *root_eb,
217 u64 root_gen, int root_level);
218int
219btrfs_qgroup_account_extent(struct btrfs_trans_handle *trans,
220 struct btrfs_fs_info *fs_info,
221 u64 bytenr, u64 num_bytes,
222 struct ulist *old_roots, struct ulist *new_roots);
223int btrfs_qgroup_account_extents(struct btrfs_trans_handle *trans,
224 struct btrfs_fs_info *fs_info);
225int btrfs_run_qgroups(struct btrfs_trans_handle *trans,
226 struct btrfs_fs_info *fs_info);
227int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans,
228 struct btrfs_fs_info *fs_info, u64 srcid, u64 objectid,
229 struct btrfs_qgroup_inherit *inherit);
230void btrfs_qgroup_free_refroot(struct btrfs_fs_info *fs_info,
231 u64 ref_root, u64 num_bytes);
232static inline void btrfs_qgroup_free_delayed_ref(struct btrfs_fs_info *fs_info,
233 u64 ref_root, u64 num_bytes)
234{
235 trace_btrfs_qgroup_free_delayed_ref(fs_info, ref_root, num_bytes);
236 btrfs_qgroup_free_refroot(fs_info, ref_root, num_bytes);
237}
238
239#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
240int btrfs_verify_qgroup_counts(struct btrfs_fs_info *fs_info, u64 qgroupid,
241 u64 rfer, u64 excl);
242#endif
243
244
245int btrfs_qgroup_reserve_data(struct inode *inode,
246 struct extent_changeset **reserved, u64 start, u64 len);
247int btrfs_qgroup_release_data(struct inode *inode, u64 start, u64 len);
248int btrfs_qgroup_free_data(struct inode *inode,
249 struct extent_changeset *reserved, u64 start, u64 len);
250
251int btrfs_qgroup_reserve_meta(struct btrfs_root *root, int num_bytes,
252 bool enforce);
253void btrfs_qgroup_free_meta_all(struct btrfs_root *root);
254void btrfs_qgroup_free_meta(struct btrfs_root *root, int num_bytes);
255void btrfs_qgroup_check_reserved_leak(struct inode *inode);
256#endif
257