summaryrefslogtreecommitdiff
path: root/ctree.h
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-04-26 16:46:06 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-04-26 16:46:06 -0400
commit5856b7e1241b07a5d461ff1592562c8520c42d93 (patch)
tree2dfd928a18b73491a7a1aa698cbca84994511ec6 /ctree.h
parentc2d777735cb24b283d7dc19ba124652f0d965318 (diff)
start of block group code
Diffstat (limited to 'ctree.h')
-rw-r--r--ctree.h70
1 files changed, 55 insertions, 15 deletions
diff --git a/ctree.h b/ctree.h
index 7dedae80..efd044a2 100644
--- a/ctree.h
+++ b/ctree.h
@@ -237,6 +237,19 @@ struct btrfs_device_item {
__le64 device_id;
} __attribute__ ((__packed__));
+/* tag for the radix tree of block groups in ram */
+#define BTRFS_BLOCK_GROUP_DIRTY 0
+#define BTRFS_BLOCK_GROUP_HINTS 8
+#define BTRFS_BLOCK_GROUP_SIZE (256 * 1024 * 1024)
+struct btrfs_block_group_item {
+ __le64 used;
+} __attribute__ ((__packed__));
+
+struct btrfs_block_group_cache {
+ struct btrfs_key key;
+ struct btrfs_block_group_item item;
+};
+
struct btrfs_fs_info {
struct btrfs_root *fs_root;
struct btrfs_root *extent_root;
@@ -247,6 +260,7 @@ struct btrfs_fs_info {
struct radix_tree_root cache_radix;
struct radix_tree_root pinned_radix;
struct radix_tree_root dev_radix;
+ struct radix_tree_root block_group_radix;
struct list_head trans;
struct list_head cache;
u64 last_inode_alloc;
@@ -285,49 +299,67 @@ struct btrfs_root {
* info about object characteristics. There is one for every file and dir in
* the FS
*/
-#define BTRFS_INODE_ITEM_KEY 1
+#define BTRFS_INODE_ITEM_KEY 1
+
+/* reserve 2-15 close to the inode for later flexibility */
/*
* dir items are the name -> inode pointers in a directory. There is one
* for every name in a directory.
*/
-#define BTRFS_DIR_ITEM_KEY 2
-#define BTRFS_DIR_INDEX_KEY 3
+#define BTRFS_DIR_ITEM_KEY 16
+#define BTRFS_DIR_INDEX_KEY 17
/*
- * inline data is file data that fits in the btree.
+ * extent data is for file data
*/
-#define BTRFS_INLINE_DATA_KEY 4
-/*
- * extent data is for data that can't fit in the btree. It points to
- * a (hopefully) huge chunk of disk
- */
-#define BTRFS_EXTENT_DATA_KEY 5
+#define BTRFS_EXTENT_DATA_KEY 18
/*
* csum items have the checksums for data in the extents
*/
-#define BTRFS_CSUM_ITEM_KEY 6
+#define BTRFS_CSUM_ITEM_KEY 19
+
+/* reserve 20-31 for other file stuff */
/*
* root items point to tree roots. There are typically in the root
* tree used by the super block to find all the other trees
*/
-#define BTRFS_ROOT_ITEM_KEY 7
+#define BTRFS_ROOT_ITEM_KEY 32
/*
* extent items are in the extent map tree. These record which blocks
* are used, and how many references there are to each block
*/
-#define BTRFS_EXTENT_ITEM_KEY 8
+#define BTRFS_EXTENT_ITEM_KEY 33
+
+/*
+ * block groups give us hints into the extent allocation trees. Which
+ * blocks are free etc etc
+ */
+#define BTRFS_BLOCK_GROUP_ITEM_KEY 34
/*
* dev items list the devices that make up the FS
*/
-#define BTRFS_DEV_ITEM_KEY 9
+#define BTRFS_DEV_ITEM_KEY 35
/*
* string items are for debugging. They just store a short string of
* data in the FS
*/
-#define BTRFS_STRING_ITEM_KEY 10
+#define BTRFS_STRING_ITEM_KEY 253
+
+
+static inline u64 btrfs_block_group_used(struct btrfs_block_group_item *bi)
+{
+ return le64_to_cpu(bi->used);
+}
+
+static inline void btrfs_set_block_group_used(struct
+ btrfs_block_group_item *bi,
+ u64 val)
+{
+ bi->used = cpu_to_le64(val);
+}
static inline u64 btrfs_inode_generation(struct btrfs_inode_item *i)
{
@@ -1019,4 +1051,12 @@ int btrfs_insert_inode(struct btrfs_trans_handle *trans, struct btrfs_root
*inode_item);
int btrfs_lookup_inode(struct btrfs_trans_handle *trans, struct btrfs_root
*root, struct btrfs_path *path, u64 objectid, int mod);
+int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root);
+int btrfs_free_block_groups(struct btrfs_fs_info *info);
+int btrfs_read_block_groups(struct btrfs_root *root);
+int btrfs_insert_block_group(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root,
+ struct btrfs_key *key,
+ struct btrfs_block_group_item *bi);
#endif