btrfs: delayed_ref: Add new function to record reserved space into delayed ref
[linux-2.6-block.git] / fs / btrfs / qgroup.h
CommitLineData
fcebe456
JB
1/*
2 * Copyright (C) 2014 Facebook. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 * Boston, MA 021110-1307, USA.
17 */
18
19#ifndef __BTRFS_QGROUP__
20#define __BTRFS_QGROUP__
21
3368d001
QW
22#include "ulist.h"
23#include "delayed-ref.h"
24
3368d001
QW
25/*
26 * Record a dirty extent, and info qgroup to update quota on it
27 * TODO: Use kmem cache to alloc it.
28 */
29struct btrfs_qgroup_extent_record {
30 struct rb_node node;
31 u64 bytenr;
32 u64 num_bytes;
33 struct ulist *old_roots;
34};
35
fcebe456
JB
36int btrfs_quota_enable(struct btrfs_trans_handle *trans,
37 struct btrfs_fs_info *fs_info);
38int btrfs_quota_disable(struct btrfs_trans_handle *trans,
39 struct btrfs_fs_info *fs_info);
40int btrfs_qgroup_rescan(struct btrfs_fs_info *fs_info);
41void btrfs_qgroup_rescan_resume(struct btrfs_fs_info *fs_info);
42int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info);
43int btrfs_add_qgroup_relation(struct btrfs_trans_handle *trans,
44 struct btrfs_fs_info *fs_info, u64 src, u64 dst);
45int btrfs_del_qgroup_relation(struct btrfs_trans_handle *trans,
46 struct btrfs_fs_info *fs_info, u64 src, u64 dst);
47int btrfs_create_qgroup(struct btrfs_trans_handle *trans,
4087cf24 48 struct btrfs_fs_info *fs_info, u64 qgroupid);
fcebe456
JB
49int btrfs_remove_qgroup(struct btrfs_trans_handle *trans,
50 struct btrfs_fs_info *fs_info, u64 qgroupid);
51int btrfs_limit_qgroup(struct btrfs_trans_handle *trans,
52 struct btrfs_fs_info *fs_info, u64 qgroupid,
53 struct btrfs_qgroup_limit *limit);
54int btrfs_read_qgroup_config(struct btrfs_fs_info *fs_info);
55void btrfs_free_qgroup_config(struct btrfs_fs_info *fs_info);
56struct btrfs_delayed_extent_op;
3b7d00f9
QW
57int btrfs_qgroup_prepare_account_extents(struct btrfs_trans_handle *trans,
58 struct btrfs_fs_info *fs_info);
3368d001
QW
59struct btrfs_qgroup_extent_record
60*btrfs_qgroup_insert_dirty_extent(struct btrfs_delayed_ref_root *delayed_refs,
61 struct btrfs_qgroup_extent_record *record);
442244c9
QW
62int
63btrfs_qgroup_account_extent(struct btrfs_trans_handle *trans,
64 struct btrfs_fs_info *fs_info,
65 u64 bytenr, u64 num_bytes,
66 struct ulist *old_roots, struct ulist *new_roots);
550d7a2e
QW
67int btrfs_qgroup_account_extents(struct btrfs_trans_handle *trans,
68 struct btrfs_fs_info *fs_info);
fcebe456
JB
69int btrfs_run_qgroups(struct btrfs_trans_handle *trans,
70 struct btrfs_fs_info *fs_info);
71int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans,
72 struct btrfs_fs_info *fs_info, u64 srcid, u64 objectid,
73 struct btrfs_qgroup_inherit *inherit);
74int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes);
75void btrfs_qgroup_free(struct btrfs_root *root, u64 num_bytes);
76
77void assert_qgroups_uptodate(struct btrfs_trans_handle *trans);
78
79#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
80int btrfs_verify_qgroup_counts(struct btrfs_fs_info *fs_info, u64 qgroupid,
81 u64 rfer, u64 excl);
82#endif
83
52472553
QW
84/* New io_tree based accurate qgroup reserve API */
85int btrfs_qgroup_reserve_data(struct inode *inode, u64 start, u64 len);
f695fdce
QW
86int btrfs_qgroup_release_data(struct inode *inode, u64 start, u64 len);
87int btrfs_qgroup_free_data(struct inode *inode, u64 start, u64 len);
fcebe456 88#endif /* __BTRFS_QGROUP__ */