|
@@ -96,6 +96,9 @@ struct btrfs_ordered_sum;
|
|
|
/* for storing items that use the BTRFS_UUID_KEY* types */
|
|
|
#define BTRFS_UUID_TREE_OBJECTID 9ULL
|
|
|
|
|
|
+/* tracks free space in block groups. */
|
|
|
+#define BTRFS_FREE_SPACE_TREE_OBJECTID 10ULL
|
|
|
+
|
|
|
/* for storing balance parameters in the root tree */
|
|
|
#define BTRFS_BALANCE_OBJECTID -4ULL
|
|
|
|
|
@@ -500,6 +503,8 @@ struct btrfs_super_block {
|
|
|
* Compat flags that we support. If any incompat flags are set other than the
|
|
|
* ones specified below then we will fail to mount
|
|
|
*/
|
|
|
+#define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE (1ULL << 0)
|
|
|
+
|
|
|
#define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0)
|
|
|
#define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1)
|
|
|
#define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS (1ULL << 2)
|
|
@@ -1061,6 +1066,13 @@ struct btrfs_block_group_item {
|
|
|
__le64 flags;
|
|
|
} __attribute__ ((__packed__));
|
|
|
|
|
|
+struct btrfs_free_space_info {
|
|
|
+ __le32 extent_count;
|
|
|
+ __le32 flags;
|
|
|
+} __attribute__ ((__packed__));
|
|
|
+
|
|
|
+#define BTRFS_FREE_SPACE_USING_BITMAPS (1ULL << 0)
|
|
|
+
|
|
|
#define BTRFS_QGROUP_LEVEL_SHIFT 48
|
|
|
static inline u64 btrfs_qgroup_level(u64 qgroupid)
|
|
|
{
|
|
@@ -2058,6 +2070,27 @@ struct btrfs_ioctl_defrag_range_args {
|
|
|
*/
|
|
|
#define BTRFS_BLOCK_GROUP_ITEM_KEY 192
|
|
|
|
|
|
+/*
|
|
|
+ * Every block group is represented in the free space tree by a free space info
|
|
|
+ * item, which stores some accounting information. It is keyed on
|
|
|
+ * (block_group_start, FREE_SPACE_INFO, block_group_length).
|
|
|
+ */
|
|
|
+#define BTRFS_FREE_SPACE_INFO_KEY 198
|
|
|
+
|
|
|
+/*
|
|
|
+ * A free space extent tracks an extent of space that is free in a block group.
|
|
|
+ * It is keyed on (start, FREE_SPACE_EXTENT, length).
|
|
|
+ */
|
|
|
+#define BTRFS_FREE_SPACE_EXTENT_KEY 199
|
|
|
+
|
|
|
+/*
|
|
|
+ * When a block group becomes very fragmented, we convert it to use bitmaps
|
|
|
+ * instead of extents. A free space bitmap is keyed on
|
|
|
+ * (start, FREE_SPACE_BITMAP, length); the corresponding item is a bitmap with
|
|
|
+ * (length / sectorsize) bits.
|
|
|
+ */
|
|
|
+#define BTRFS_FREE_SPACE_BITMAP_KEY 200
|
|
|
+
|
|
|
#define BTRFS_DEV_EXTENT_KEY 204
|
|
|
#define BTRFS_DEV_ITEM_KEY 216
|
|
|
#define BTRFS_CHUNK_ITEM_KEY 228
|
|
@@ -2458,6 +2491,11 @@ BTRFS_SETGET_FUNCS(disk_block_group_flags,
|
|
|
BTRFS_SETGET_STACK_FUNCS(block_group_flags,
|
|
|
struct btrfs_block_group_item, flags, 64);
|
|
|
|
|
|
+/* struct btrfs_free_space_info */
|
|
|
+BTRFS_SETGET_FUNCS(free_space_extent_count, struct btrfs_free_space_info,
|
|
|
+ extent_count, 32);
|
|
|
+BTRFS_SETGET_FUNCS(free_space_flags, struct btrfs_free_space_info, flags, 32);
|
|
|
+
|
|
|
/* struct btrfs_inode_ref */
|
|
|
BTRFS_SETGET_FUNCS(inode_ref_name_len, struct btrfs_inode_ref, name_len, 16);
|
|
|
BTRFS_SETGET_FUNCS(inode_ref_index, struct btrfs_inode_ref, index, 64);
|