aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h381
1 files changed, 366 insertions, 15 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index fa5c45b39075..4bab807227ad 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -91,6 +91,9 @@ struct btrfs_ordered_sum;
91/* for storing balance parameters in the root tree */ 91/* for storing balance parameters in the root tree */
92#define BTRFS_BALANCE_OBJECTID -4ULL 92#define BTRFS_BALANCE_OBJECTID -4ULL
93 93
94/* holds quota configuration and tracking */
95#define BTRFS_QUOTA_TREE_OBJECTID 8ULL
96
94/* orhpan objectid for tracking unlinked/truncated files */ 97/* orhpan objectid for tracking unlinked/truncated files */
95#define BTRFS_ORPHAN_OBJECTID -5ULL 98#define BTRFS_ORPHAN_OBJECTID -5ULL
96 99
@@ -709,6 +712,36 @@ struct btrfs_root_item {
709 struct btrfs_disk_key drop_progress; 712 struct btrfs_disk_key drop_progress;
710 u8 drop_level; 713 u8 drop_level;
711 u8 level; 714 u8 level;
715
716 /*
717 * The following fields appear after subvol_uuids+subvol_times
718 * were introduced.
719 */
720
721 /*
722 * This generation number is used to test if the new fields are valid
723 * and up to date while reading the root item. Everytime the root item
724 * is written out, the "generation" field is copied into this field. If
725 * anyone ever mounted the fs with an older kernel, we will have
726 * mismatching generation values here and thus must invalidate the
727 * new fields. See btrfs_update_root and btrfs_find_last_root for
728 * details.
729 * the offset of generation_v2 is also used as the start for the memset
730 * when invalidating the fields.
731 */
732 __le64 generation_v2;
733 u8 uuid[BTRFS_UUID_SIZE];
734 u8 parent_uuid[BTRFS_UUID_SIZE];
735 u8 received_uuid[BTRFS_UUID_SIZE];
736 __le64 ctransid; /* updated when an inode changes */
737 __le64 otransid; /* trans when created */
738 __le64 stransid; /* trans when sent. non-zero for received subvol */
739 __le64 rtransid; /* trans when received. non-zero for received subvol */
740 struct btrfs_timespec ctime;
741 struct btrfs_timespec otime;
742 struct btrfs_timespec stime;
743 struct btrfs_timespec rtime;
744 __le64 reserved[8]; /* for future */
712} __attribute__ ((__packed__)); 745} __attribute__ ((__packed__));
713 746
714/* 747/*
@@ -883,6 +916,72 @@ struct btrfs_block_group_item {
883 __le64 flags; 916 __le64 flags;
884} __attribute__ ((__packed__)); 917} __attribute__ ((__packed__));
885 918
919/*
920 * is subvolume quota turned on?
921 */
922#define BTRFS_QGROUP_STATUS_FLAG_ON (1ULL << 0)
923/*
924 * SCANNING is set during the initialization phase
925 */
926#define BTRFS_QGROUP_STATUS_FLAG_SCANNING (1ULL << 1)
927/*
928 * Some qgroup entries are known to be out of date,
929 * either because the configuration has changed in a way that
930 * makes a rescan necessary, or because the fs has been mounted
931 * with a non-qgroup-aware version.
932 * Turning qouta off and on again makes it inconsistent, too.
933 */
934#define BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT (1ULL << 2)
935
936#define BTRFS_QGROUP_STATUS_VERSION 1
937
938struct btrfs_qgroup_status_item {
939 __le64 version;
940 /*
941 * the generation is updated during every commit. As older
942 * versions of btrfs are not aware of qgroups, it will be
943 * possible to detect inconsistencies by checking the
944 * generation on mount time
945 */
946 __le64 generation;
947
948 /* flag definitions see above */
949 __le64 flags;
950
951 /*
952 * only used during scanning to record the progress
953 * of the scan. It contains a logical address
954 */
955 __le64 scan;
956} __attribute__ ((__packed__));
957
958struct btrfs_qgroup_info_item {
959 __le64 generation;
960 __le64 rfer;
961 __le64 rfer_cmpr;
962 __le64 excl;
963 __le64 excl_cmpr;
964} __attribute__ ((__packed__));
965
966/* flags definition for qgroup limits */
967#define BTRFS_QGROUP_LIMIT_MAX_RFER (1ULL << 0)
968#define BTRFS_QGROUP_LIMIT_MAX_EXCL (1ULL << 1)
969#define BTRFS_QGROUP_LIMIT_RSV_RFER (1ULL << 2)
970#define BTRFS_QGROUP_LIMIT_RSV_EXCL (1ULL << 3)
971#define BTRFS_QGROUP_LIMIT_RFER_CMPR (1ULL << 4)
972#define BTRFS_QGROUP_LIMIT_EXCL_CMPR (1ULL << 5)
973
974struct btrfs_qgroup_limit_item {
975 /*
976 * only updated when any of the other values change
977 */
978 __le64 flags;
979 __le64 max_rfer;
980 __le64 max_excl;
981 __le64 rsv_rfer;
982 __le64 rsv_excl;
983} __attribute__ ((__packed__));
984
886struct btrfs_space_info { 985struct btrfs_space_info {
887 u64 flags; 986 u64 flags;
888 987
@@ -1030,6 +1129,13 @@ struct btrfs_block_group_cache {
1030 struct list_head cluster_list; 1129 struct list_head cluster_list;
1031}; 1130};
1032 1131
1132/* delayed seq elem */
1133struct seq_list {
1134 struct list_head list;
1135 u64 seq;
1136};
1137
1138/* fs_info */
1033struct reloc_control; 1139struct reloc_control;
1034struct btrfs_device; 1140struct btrfs_device;
1035struct btrfs_fs_devices; 1141struct btrfs_fs_devices;
@@ -1044,6 +1150,7 @@ struct btrfs_fs_info {
1044 struct btrfs_root *dev_root; 1150 struct btrfs_root *dev_root;
1045 struct btrfs_root *fs_root; 1151 struct btrfs_root *fs_root;
1046 struct btrfs_root *csum_root; 1152 struct btrfs_root *csum_root;
1153 struct btrfs_root *quota_root;
1047 1154
1048 /* the log root tree is a directory of all the other log roots */ 1155 /* the log root tree is a directory of all the other log roots */
1049 struct btrfs_root *log_root_tree; 1156 struct btrfs_root *log_root_tree;
@@ -1144,6 +1251,8 @@ struct btrfs_fs_info {
1144 spinlock_t tree_mod_seq_lock; 1251 spinlock_t tree_mod_seq_lock;
1145 atomic_t tree_mod_seq; 1252 atomic_t tree_mod_seq;
1146 struct list_head tree_mod_seq_list; 1253 struct list_head tree_mod_seq_list;
1254 struct seq_list tree_mod_seq_elem;
1255 wait_queue_head_t tree_mod_seq_wait;
1147 1256
1148 /* this protects tree_mod_log */ 1257 /* this protects tree_mod_log */
1149 rwlock_t tree_mod_log_lock; 1258 rwlock_t tree_mod_log_lock;
@@ -1240,6 +1349,8 @@ struct btrfs_fs_info {
1240 */ 1349 */
1241 struct list_head space_info; 1350 struct list_head space_info;
1242 1351
1352 struct btrfs_space_info *data_sinfo;
1353
1243 struct reloc_control *reloc_ctl; 1354 struct reloc_control *reloc_ctl;
1244 1355
1245 spinlock_t delalloc_lock; 1356 spinlock_t delalloc_lock;
@@ -1296,6 +1407,29 @@ struct btrfs_fs_info {
1296#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY 1407#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
1297 u32 check_integrity_print_mask; 1408 u32 check_integrity_print_mask;
1298#endif 1409#endif
1410 /*
1411 * quota information
1412 */
1413 unsigned int quota_enabled:1;
1414
1415 /*
1416 * quota_enabled only changes state after a commit. This holds the
1417 * next state.
1418 */
1419 unsigned int pending_quota_state:1;
1420
1421 /* is qgroup tracking in a consistent state? */
1422 u64 qgroup_flags;
1423
1424 /* holds configuration and tracking. Protected by qgroup_lock */
1425 struct rb_root qgroup_tree;
1426 spinlock_t qgroup_lock;
1427
1428 /* list of dirty qgroups to be written at next commit */
1429 struct list_head dirty_qgroups;
1430
1431 /* used by btrfs_qgroup_record_ref for an efficient tree traversal */
1432 u64 qgroup_seq;
1299 1433
1300 /* filesystem state */ 1434 /* filesystem state */
1301 u64 fs_state; 1435 u64 fs_state;
@@ -1416,6 +1550,8 @@ struct btrfs_root {
1416 dev_t anon_dev; 1550 dev_t anon_dev;
1417 1551
1418 int force_cow; 1552 int force_cow;
1553
1554 spinlock_t root_times_lock;
1419}; 1555};
1420 1556
1421struct btrfs_ioctl_defrag_range_args { 1557struct btrfs_ioctl_defrag_range_args {
@@ -1525,6 +1661,30 @@ struct btrfs_ioctl_defrag_range_args {
1525#define BTRFS_DEV_ITEM_KEY 216 1661#define BTRFS_DEV_ITEM_KEY 216
1526#define BTRFS_CHUNK_ITEM_KEY 228 1662#define BTRFS_CHUNK_ITEM_KEY 228
1527 1663
1664/*
1665 * Records the overall state of the qgroups.
1666 * There's only one instance of this key present,
1667 * (0, BTRFS_QGROUP_STATUS_KEY, 0)
1668 */
1669#define BTRFS_QGROUP_STATUS_KEY 240
1670/*
1671 * Records the currently used space of the qgroup.
1672 * One key per qgroup, (0, BTRFS_QGROUP_INFO_KEY, qgroupid).
1673 */
1674#define BTRFS_QGROUP_INFO_KEY 242
1675/*
1676 * Contains the user configured limits for the qgroup.
1677 * One key per qgroup, (0, BTRFS_QGROUP_LIMIT_KEY, qgroupid).
1678 */
1679#define BTRFS_QGROUP_LIMIT_KEY 244
1680/*
1681 * Records the child-parent relationship of qgroups. For
1682 * each relation, 2 keys are present:
1683 * (childid, BTRFS_QGROUP_RELATION_KEY, parentid)
1684 * (parentid, BTRFS_QGROUP_RELATION_KEY, childid)
1685 */
1686#define BTRFS_QGROUP_RELATION_KEY 246
1687
1528#define BTRFS_BALANCE_ITEM_KEY 248 1688#define BTRFS_BALANCE_ITEM_KEY 248
1529 1689
1530/* 1690/*
@@ -1621,13 +1781,54 @@ static inline void btrfs_init_map_token (struct btrfs_map_token *token)
1621 offsetof(type, member), \ 1781 offsetof(type, member), \
1622 sizeof(((type *)0)->member))) 1782 sizeof(((type *)0)->member)))
1623 1783
1624#ifndef BTRFS_SETGET_FUNCS 1784#define DECLARE_BTRFS_SETGET_BITS(bits) \
1785u##bits btrfs_get_token_##bits(struct extent_buffer *eb, void *ptr, \
1786 unsigned long off, \
1787 struct btrfs_map_token *token); \
1788void btrfs_set_token_##bits(struct extent_buffer *eb, void *ptr, \
1789 unsigned long off, u##bits val, \
1790 struct btrfs_map_token *token); \
1791static inline u##bits btrfs_get_##bits(struct extent_buffer *eb, void *ptr, \
1792 unsigned long off) \
1793{ \
1794 return btrfs_get_token_##bits(eb, ptr, off, NULL); \
1795} \
1796static inline void btrfs_set_##bits(struct extent_buffer *eb, void *ptr, \
1797 unsigned long off, u##bits val) \
1798{ \
1799 btrfs_set_token_##bits(eb, ptr, off, val, NULL); \
1800}
1801
1802DECLARE_BTRFS_SETGET_BITS(8)
1803DECLARE_BTRFS_SETGET_BITS(16)
1804DECLARE_BTRFS_SETGET_BITS(32)
1805DECLARE_BTRFS_SETGET_BITS(64)
1806
1625#define BTRFS_SETGET_FUNCS(name, type, member, bits) \ 1807#define BTRFS_SETGET_FUNCS(name, type, member, bits) \
1626u##bits btrfs_##name(struct extent_buffer *eb, type *s); \ 1808static inline u##bits btrfs_##name(struct extent_buffer *eb, type *s) \
1627u##bits btrfs_token_##name(struct extent_buffer *eb, type *s, struct btrfs_map_token *token); \ 1809{ \
1628void btrfs_set_token_##name(struct extent_buffer *eb, type *s, u##bits val, struct btrfs_map_token *token);\ 1810 BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \
1629void btrfs_set_##name(struct extent_buffer *eb, type *s, u##bits val); 1811 return btrfs_get_##bits(eb, s, offsetof(type, member)); \
1630#endif 1812} \
1813static inline void btrfs_set_##name(struct extent_buffer *eb, type *s, \
1814 u##bits val) \
1815{ \
1816 BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \
1817 btrfs_set_##bits(eb, s, offsetof(type, member), val); \
1818} \
1819static inline u##bits btrfs_token_##name(struct extent_buffer *eb, type *s, \
1820 struct btrfs_map_token *token) \
1821{ \
1822 BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \
1823 return btrfs_get_token_##bits(eb, s, offsetof(type, member), token); \
1824} \
1825static inline void btrfs_set_token_##name(struct extent_buffer *eb, \
1826 type *s, u##bits val, \
1827 struct btrfs_map_token *token) \
1828{ \
1829 BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \
1830 btrfs_set_token_##bits(eb, s, offsetof(type, member), val, token); \
1831}
1631 1832
1632#define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \ 1833#define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \
1633static inline u##bits btrfs_##name(struct extent_buffer *eb) \ 1834static inline u##bits btrfs_##name(struct extent_buffer *eb) \
@@ -2189,6 +2390,16 @@ BTRFS_SETGET_STACK_FUNCS(root_used, struct btrfs_root_item, bytes_used, 64);
2189BTRFS_SETGET_STACK_FUNCS(root_limit, struct btrfs_root_item, byte_limit, 64); 2390BTRFS_SETGET_STACK_FUNCS(root_limit, struct btrfs_root_item, byte_limit, 64);
2190BTRFS_SETGET_STACK_FUNCS(root_last_snapshot, struct btrfs_root_item, 2391BTRFS_SETGET_STACK_FUNCS(root_last_snapshot, struct btrfs_root_item,
2191 last_snapshot, 64); 2392 last_snapshot, 64);
2393BTRFS_SETGET_STACK_FUNCS(root_generation_v2, struct btrfs_root_item,
2394 generation_v2, 64);
2395BTRFS_SETGET_STACK_FUNCS(root_ctransid, struct btrfs_root_item,
2396 ctransid, 64);
2397BTRFS_SETGET_STACK_FUNCS(root_otransid, struct btrfs_root_item,
2398 otransid, 64);
2399BTRFS_SETGET_STACK_FUNCS(root_stransid, struct btrfs_root_item,
2400 stransid, 64);
2401BTRFS_SETGET_STACK_FUNCS(root_rtransid, struct btrfs_root_item,
2402 rtransid, 64);
2192 2403
2193static inline bool btrfs_root_readonly(struct btrfs_root *root) 2404static inline bool btrfs_root_readonly(struct btrfs_root *root)
2194{ 2405{
@@ -2465,6 +2676,49 @@ static inline void btrfs_set_dev_stats_value(struct extent_buffer *eb,
2465 sizeof(val)); 2676 sizeof(val));
2466} 2677}
2467 2678
2679/* btrfs_qgroup_status_item */
2680BTRFS_SETGET_FUNCS(qgroup_status_generation, struct btrfs_qgroup_status_item,
2681 generation, 64);
2682BTRFS_SETGET_FUNCS(qgroup_status_version, struct btrfs_qgroup_status_item,
2683 version, 64);
2684BTRFS_SETGET_FUNCS(qgroup_status_flags, struct btrfs_qgroup_status_item,
2685 flags, 64);
2686BTRFS_SETGET_FUNCS(qgroup_status_scan, struct btrfs_qgroup_status_item,
2687 scan, 64);
2688
2689/* btrfs_qgroup_info_item */
2690BTRFS_SETGET_FUNCS(qgroup_info_generation, struct btrfs_qgroup_info_item,
2691 generation, 64);
2692BTRFS_SETGET_FUNCS(qgroup_info_rfer, struct btrfs_qgroup_info_item, rfer, 64);
2693BTRFS_SETGET_FUNCS(qgroup_info_rfer_cmpr, struct btrfs_qgroup_info_item,
2694 rfer_cmpr, 64);
2695BTRFS_SETGET_FUNCS(qgroup_info_excl, struct btrfs_qgroup_info_item, excl, 64);
2696BTRFS_SETGET_FUNCS(qgroup_info_excl_cmpr, struct btrfs_qgroup_info_item,
2697 excl_cmpr, 64);
2698
2699BTRFS_SETGET_STACK_FUNCS(stack_qgroup_info_generation,
2700 struct btrfs_qgroup_info_item, generation, 64);
2701BTRFS_SETGET_STACK_FUNCS(stack_qgroup_info_rfer, struct btrfs_qgroup_info_item,
2702 rfer, 64);
2703BTRFS_SETGET_STACK_FUNCS(stack_qgroup_info_rfer_cmpr,
2704 struct btrfs_qgroup_info_item, rfer_cmpr, 64);
2705BTRFS_SETGET_STACK_FUNCS(stack_qgroup_info_excl, struct btrfs_qgroup_info_item,
2706 excl, 64);
2707BTRFS_SETGET_STACK_FUNCS(stack_qgroup_info_excl_cmpr,
2708 struct btrfs_qgroup_info_item, excl_cmpr, 64);
2709
2710/* btrfs_qgroup_limit_item */
2711BTRFS_SETGET_FUNCS(qgroup_limit_flags, struct btrfs_qgroup_limit_item,
2712 flags, 64);
2713BTRFS_SETGET_FUNCS(qgroup_limit_max_rfer, struct btrfs_qgroup_limit_item,
2714 max_rfer, 64);
2715BTRFS_SETGET_FUNCS(qgroup_limit_max_excl, struct btrfs_qgroup_limit_item,
2716 max_excl, 64);
2717BTRFS_SETGET_FUNCS(qgroup_limit_rsv_rfer, struct btrfs_qgroup_limit_item,
2718 rsv_rfer, 64);
2719BTRFS_SETGET_FUNCS(qgroup_limit_rsv_excl, struct btrfs_qgroup_limit_item,
2720 rsv_excl, 64);
2721
2468static inline struct btrfs_fs_info *btrfs_sb(struct super_block *sb) 2722static inline struct btrfs_fs_info *btrfs_sb(struct super_block *sb)
2469{ 2723{
2470 return sb->s_fs_info; 2724 return sb->s_fs_info;
@@ -2607,7 +2861,6 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
2607 struct btrfs_root *root, u64 group_start); 2861 struct btrfs_root *root, u64 group_start);
2608u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags); 2862u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags);
2609u64 btrfs_get_alloc_profile(struct btrfs_root *root, int data); 2863u64 btrfs_get_alloc_profile(struct btrfs_root *root, int data);
2610void btrfs_set_inode_space_info(struct btrfs_root *root, struct inode *ionde);
2611void btrfs_clear_space_info_full(struct btrfs_fs_info *info); 2864void btrfs_clear_space_info_full(struct btrfs_fs_info *info);
2612int btrfs_check_data_free_space(struct inode *inode, u64 bytes); 2865int btrfs_check_data_free_space(struct inode *inode, u64 bytes);
2613void btrfs_free_reserved_data_space(struct inode *inode, u64 bytes); 2866void btrfs_free_reserved_data_space(struct inode *inode, u64 bytes);
@@ -2661,6 +2914,8 @@ int btrfs_force_chunk_alloc(struct btrfs_trans_handle *trans,
2661int btrfs_trim_fs(struct btrfs_root *root, struct fstrim_range *range); 2914int btrfs_trim_fs(struct btrfs_root *root, struct fstrim_range *range);
2662 2915
2663int btrfs_init_space_info(struct btrfs_fs_info *fs_info); 2916int btrfs_init_space_info(struct btrfs_fs_info *fs_info);
2917int btrfs_delayed_refs_qgroup_accounting(struct btrfs_trans_handle *trans,
2918 struct btrfs_fs_info *fs_info);
2664/* ctree.c */ 2919/* ctree.c */
2665int btrfs_bin_search(struct extent_buffer *eb, struct btrfs_key *key, 2920int btrfs_bin_search(struct extent_buffer *eb, struct btrfs_key *key,
2666 int level, int *slot); 2921 int level, int *slot);
@@ -2680,6 +2935,21 @@ int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key,
2680 struct btrfs_key *max_key, 2935 struct btrfs_key *max_key,
2681 struct btrfs_path *path, int cache_only, 2936 struct btrfs_path *path, int cache_only,
2682 u64 min_trans); 2937 u64 min_trans);
2938enum btrfs_compare_tree_result {
2939 BTRFS_COMPARE_TREE_NEW,
2940 BTRFS_COMPARE_TREE_DELETED,
2941 BTRFS_COMPARE_TREE_CHANGED,
2942};
2943typedef int (*btrfs_changed_cb_t)(struct btrfs_root *left_root,
2944 struct btrfs_root *right_root,
2945 struct btrfs_path *left_path,
2946 struct btrfs_path *right_path,
2947 struct btrfs_key *key,
2948 enum btrfs_compare_tree_result result,
2949 void *ctx);
2950int btrfs_compare_trees(struct btrfs_root *left_root,
2951 struct btrfs_root *right_root,
2952 btrfs_changed_cb_t cb, void *ctx);
2683int btrfs_cow_block(struct btrfs_trans_handle *trans, 2953int btrfs_cow_block(struct btrfs_trans_handle *trans,
2684 struct btrfs_root *root, struct extent_buffer *buf, 2954 struct btrfs_root *root, struct extent_buffer *buf,
2685 struct extent_buffer *parent, int parent_slot, 2955 struct extent_buffer *parent, int parent_slot,
@@ -2711,6 +2981,9 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root
2711 ins_len, int cow); 2981 ins_len, int cow);
2712int btrfs_search_old_slot(struct btrfs_root *root, struct btrfs_key *key, 2982int btrfs_search_old_slot(struct btrfs_root *root, struct btrfs_key *key,
2713 struct btrfs_path *p, u64 time_seq); 2983 struct btrfs_path *p, u64 time_seq);
2984int btrfs_search_slot_for_read(struct btrfs_root *root,
2985 struct btrfs_key *key, struct btrfs_path *p,
2986 int find_higher, int return_any);
2714int btrfs_realloc_node(struct btrfs_trans_handle *trans, 2987int btrfs_realloc_node(struct btrfs_trans_handle *trans,
2715 struct btrfs_root *root, struct extent_buffer *parent, 2988 struct btrfs_root *root, struct extent_buffer *parent,
2716 int start_slot, int cache_only, u64 *last_ret, 2989 int start_slot, int cache_only, u64 *last_ret,
@@ -2793,11 +3066,22 @@ static inline void free_fs_info(struct btrfs_fs_info *fs_info)
2793 kfree(fs_info->chunk_root); 3066 kfree(fs_info->chunk_root);
2794 kfree(fs_info->dev_root); 3067 kfree(fs_info->dev_root);
2795 kfree(fs_info->csum_root); 3068 kfree(fs_info->csum_root);
3069 kfree(fs_info->quota_root);
2796 kfree(fs_info->super_copy); 3070 kfree(fs_info->super_copy);
2797 kfree(fs_info->super_for_commit); 3071 kfree(fs_info->super_for_commit);
2798 kfree(fs_info); 3072 kfree(fs_info);
2799} 3073}
2800 3074
3075/* tree mod log functions from ctree.c */
3076u64 btrfs_get_tree_mod_seq(struct btrfs_fs_info *fs_info,
3077 struct seq_list *elem);
3078void btrfs_put_tree_mod_seq(struct btrfs_fs_info *fs_info,
3079 struct seq_list *elem);
3080static inline u64 btrfs_inc_tree_mod_seq(struct btrfs_fs_info *fs_info)
3081{
3082 return atomic_inc_return(&fs_info->tree_mod_seq);
3083}
3084
2801/* root-item.c */ 3085/* root-item.c */
2802int btrfs_find_root_ref(struct btrfs_root *tree_root, 3086int btrfs_find_root_ref(struct btrfs_root *tree_root,
2803 struct btrfs_path *path, 3087 struct btrfs_path *path,
@@ -2819,6 +3103,9 @@ int __must_check btrfs_update_root(struct btrfs_trans_handle *trans,
2819 struct btrfs_root *root, 3103 struct btrfs_root *root,
2820 struct btrfs_key *key, 3104 struct btrfs_key *key,
2821 struct btrfs_root_item *item); 3105 struct btrfs_root_item *item);
3106void btrfs_read_root_item(struct btrfs_root *root,
3107 struct extent_buffer *eb, int slot,
3108 struct btrfs_root_item *item);
2822int btrfs_find_last_root(struct btrfs_root *root, u64 objectid, struct 3109int btrfs_find_last_root(struct btrfs_root *root, u64 objectid, struct
2823 btrfs_root_item *item, struct btrfs_key *key); 3110 btrfs_root_item *item, struct btrfs_key *key);
2824int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid); 3111int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid);
@@ -2826,6 +3113,8 @@ int btrfs_find_orphan_roots(struct btrfs_root *tree_root);
2826void btrfs_set_root_node(struct btrfs_root_item *item, 3113void btrfs_set_root_node(struct btrfs_root_item *item,
2827 struct extent_buffer *node); 3114 struct extent_buffer *node);
2828void btrfs_check_and_init_root_item(struct btrfs_root_item *item); 3115void btrfs_check_and_init_root_item(struct btrfs_root_item *item);
3116void btrfs_update_root_times(struct btrfs_trans_handle *trans,
3117 struct btrfs_root *root);
2829 3118
2830/* dir-item.c */ 3119/* dir-item.c */
2831int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, 3120int btrfs_insert_dir_item(struct btrfs_trans_handle *trans,
@@ -3053,14 +3342,43 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
3053/* super.c */ 3342/* super.c */
3054int btrfs_parse_options(struct btrfs_root *root, char *options); 3343int btrfs_parse_options(struct btrfs_root *root, char *options);
3055int btrfs_sync_fs(struct super_block *sb, int wait); 3344int btrfs_sync_fs(struct super_block *sb, int wait);
3345
3346#ifdef CONFIG_PRINTK
3347__printf(2, 3)
3056void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...); 3348void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...);
3349#else
3350static inline __printf(2, 3)
3351void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...)
3352{
3353}
3354#endif
3355
3356__printf(5, 6)
3057void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, 3357void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
3058 unsigned int line, int errno, const char *fmt, ...); 3358 unsigned int line, int errno, const char *fmt, ...);
3059 3359
3360
3060void __btrfs_abort_transaction(struct btrfs_trans_handle *trans, 3361void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
3061 struct btrfs_root *root, const char *function, 3362 struct btrfs_root *root, const char *function,
3062 unsigned int line, int errno); 3363 unsigned int line, int errno);
3063 3364
3365#define btrfs_set_fs_incompat(__fs_info, opt) \
3366 __btrfs_set_fs_incompat((__fs_info), BTRFS_FEATURE_INCOMPAT_##opt)
3367
3368static inline void __btrfs_set_fs_incompat(struct btrfs_fs_info *fs_info,
3369 u64 flag)
3370{
3371 struct btrfs_super_block *disk_super;
3372 u64 features;
3373
3374 disk_super = fs_info->super_copy;
3375 features = btrfs_super_incompat_flags(disk_super);
3376 if (!(features & flag)) {
3377 features |= flag;
3378 btrfs_set_super_incompat_flags(disk_super, features);
3379 }
3380}
3381
3064#define btrfs_abort_transaction(trans, root, errno) \ 3382#define btrfs_abort_transaction(trans, root, errno) \
3065do { \ 3383do { \
3066 __btrfs_abort_transaction(trans, root, __func__, \ 3384 __btrfs_abort_transaction(trans, root, __func__, \
@@ -3080,6 +3398,7 @@ do { \
3080 (errno), fmt, ##args); \ 3398 (errno), fmt, ##args); \
3081} while (0) 3399} while (0)
3082 3400
3401__printf(5, 6)
3083void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function, 3402void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function,
3084 unsigned int line, int errno, const char *fmt, ...); 3403 unsigned int line, int errno, const char *fmt, ...);
3085 3404
@@ -3156,17 +3475,49 @@ void btrfs_reada_detach(void *handle);
3156int btree_readahead_hook(struct btrfs_root *root, struct extent_buffer *eb, 3475int btree_readahead_hook(struct btrfs_root *root, struct extent_buffer *eb,
3157 u64 start, int err); 3476 u64 start, int err);
3158 3477
3159/* delayed seq elem */ 3478/* qgroup.c */
3160struct seq_list { 3479struct qgroup_update {
3161 struct list_head list; 3480 struct list_head list;
3162 u64 seq; 3481 struct btrfs_delayed_ref_node *node;
3163 u32 flags; 3482 struct btrfs_delayed_extent_op *extent_op;
3164}; 3483};
3165 3484
3166void btrfs_get_tree_mod_seq(struct btrfs_fs_info *fs_info, 3485int btrfs_quota_enable(struct btrfs_trans_handle *trans,
3167 struct seq_list *elem); 3486 struct btrfs_fs_info *fs_info);
3168void btrfs_put_tree_mod_seq(struct btrfs_fs_info *fs_info, 3487int btrfs_quota_disable(struct btrfs_trans_handle *trans,
3169 struct seq_list *elem); 3488 struct btrfs_fs_info *fs_info);
3489int btrfs_quota_rescan(struct btrfs_fs_info *fs_info);
3490int btrfs_add_qgroup_relation(struct btrfs_trans_handle *trans,
3491 struct btrfs_fs_info *fs_info, u64 src, u64 dst);
3492int btrfs_del_qgroup_relation(struct btrfs_trans_handle *trans,
3493 struct btrfs_fs_info *fs_info, u64 src, u64 dst);
3494int btrfs_create_qgroup(struct btrfs_trans_handle *trans,
3495 struct btrfs_fs_info *fs_info, u64 qgroupid,
3496 char *name);
3497int btrfs_remove_qgroup(struct btrfs_trans_handle *trans,
3498 struct btrfs_fs_info *fs_info, u64 qgroupid);
3499int btrfs_limit_qgroup(struct btrfs_trans_handle *trans,
3500 struct btrfs_fs_info *fs_info, u64 qgroupid,
3501 struct btrfs_qgroup_limit *limit);
3502int btrfs_read_qgroup_config(struct btrfs_fs_info *fs_info);
3503void btrfs_free_qgroup_config(struct btrfs_fs_info *fs_info);
3504struct btrfs_delayed_extent_op;
3505int btrfs_qgroup_record_ref(struct btrfs_trans_handle *trans,
3506 struct btrfs_delayed_ref_node *node,
3507 struct btrfs_delayed_extent_op *extent_op);
3508int btrfs_qgroup_account_ref(struct btrfs_trans_handle *trans,
3509 struct btrfs_fs_info *fs_info,
3510 struct btrfs_delayed_ref_node *node,
3511 struct btrfs_delayed_extent_op *extent_op);
3512int btrfs_run_qgroups(struct btrfs_trans_handle *trans,
3513 struct btrfs_fs_info *fs_info);
3514int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans,
3515 struct btrfs_fs_info *fs_info, u64 srcid, u64 objectid,
3516 struct btrfs_qgroup_inherit *inherit);
3517int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes);
3518void btrfs_qgroup_free(struct btrfs_root *root, u64 num_bytes);
3519
3520void assert_qgroups_uptodate(struct btrfs_trans_handle *trans);
3170 3521
3171static inline int is_fstree(u64 rootid) 3522static inline int is_fstree(u64 rootid)
3172{ 3523{