diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-04-26 16:46:15 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-04-26 16:46:15 -0400 |
commit | 9078a3e1e4e489dddc636c7bb8780349d4298743 (patch) | |
tree | 98597a438d60fc8722c7562b79cecaa303b4721d /fs/btrfs/ctree.h | |
parent | f2458e1d8c90958ed3631654cb7fd5ab01478505 (diff) |
Btrfs: start of block group code
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 66 |
1 files changed, 51 insertions, 15 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 26d0cdd46f49..419917279e65 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -239,6 +239,19 @@ struct btrfs_device_item { | |||
239 | __le64 device_id; | 239 | __le64 device_id; |
240 | } __attribute__ ((__packed__)); | 240 | } __attribute__ ((__packed__)); |
241 | 241 | ||
242 | /* tag for the radix tree of block groups in ram */ | ||
243 | #define BTRFS_BLOCK_GROUP_DIRTY 0 | ||
244 | #define BTRFS_BLOCK_GROUP_HINTS 8 | ||
245 | #define BTRFS_BLOCK_GROUP_SIZE (256 * 1024 * 1024) | ||
246 | struct btrfs_block_group_item { | ||
247 | __le64 used; | ||
248 | } __attribute__ ((__packed__)); | ||
249 | |||
250 | struct btrfs_block_group_cache { | ||
251 | struct btrfs_key key; | ||
252 | struct btrfs_block_group_item item; | ||
253 | }; | ||
254 | |||
242 | struct crypto_hash; | 255 | struct crypto_hash; |
243 | struct btrfs_fs_info { | 256 | struct btrfs_fs_info { |
244 | struct btrfs_root *extent_root; | 257 | struct btrfs_root *extent_root; |
@@ -249,6 +262,7 @@ struct btrfs_fs_info { | |||
249 | struct radix_tree_root pending_del_radix; | 262 | struct radix_tree_root pending_del_radix; |
250 | struct radix_tree_root pinned_radix; | 263 | struct radix_tree_root pinned_radix; |
251 | struct radix_tree_root dev_radix; | 264 | struct radix_tree_root dev_radix; |
265 | struct radix_tree_root block_group_radix; | ||
252 | 266 | ||
253 | u64 extent_tree_insert[BTRFS_MAX_LEVEL * 3]; | 267 | u64 extent_tree_insert[BTRFS_MAX_LEVEL * 3]; |
254 | int extent_tree_insert_nr; | 268 | int extent_tree_insert_nr; |
@@ -301,49 +315,67 @@ struct btrfs_root { | |||
301 | * info about object characteristics. There is one for every file and dir in | 315 | * info about object characteristics. There is one for every file and dir in |
302 | * the FS | 316 | * the FS |
303 | */ | 317 | */ |
304 | #define BTRFS_INODE_ITEM_KEY 1 | 318 | #define BTRFS_INODE_ITEM_KEY 1 |
319 | |||
320 | /* reserve 2-15 close to the inode for later flexibility */ | ||
305 | 321 | ||
306 | /* | 322 | /* |
307 | * dir items are the name -> inode pointers in a directory. There is one | 323 | * dir items are the name -> inode pointers in a directory. There is one |
308 | * for every name in a directory. | 324 | * for every name in a directory. |
309 | */ | 325 | */ |
310 | #define BTRFS_DIR_ITEM_KEY 2 | 326 | #define BTRFS_DIR_ITEM_KEY 16 |
311 | #define BTRFS_DIR_INDEX_KEY 3 | 327 | #define BTRFS_DIR_INDEX_KEY 17 |
312 | /* | 328 | /* |
313 | * inline data is file data that fits in the btree. | 329 | * extent data is for file data |
314 | */ | 330 | */ |
315 | #define BTRFS_INLINE_DATA_KEY 4 | 331 | #define BTRFS_EXTENT_DATA_KEY 18 |
316 | /* | ||
317 | * extent data is for data that can't fit in the btree. It points to | ||
318 | * a (hopefully) huge chunk of disk | ||
319 | */ | ||
320 | #define BTRFS_EXTENT_DATA_KEY 5 | ||
321 | /* | 332 | /* |
322 | * csum items have the checksums for data in the extents | 333 | * csum items have the checksums for data in the extents |
323 | */ | 334 | */ |
324 | #define BTRFS_CSUM_ITEM_KEY 6 | 335 | #define BTRFS_CSUM_ITEM_KEY 19 |
336 | |||
337 | /* reserve 20-31 for other file stuff */ | ||
325 | 338 | ||
326 | /* | 339 | /* |
327 | * root items point to tree roots. There are typically in the root | 340 | * root items point to tree roots. There are typically in the root |
328 | * tree used by the super block to find all the other trees | 341 | * tree used by the super block to find all the other trees |
329 | */ | 342 | */ |
330 | #define BTRFS_ROOT_ITEM_KEY 7 | 343 | #define BTRFS_ROOT_ITEM_KEY 32 |
331 | /* | 344 | /* |
332 | * extent items are in the extent map tree. These record which blocks | 345 | * extent items are in the extent map tree. These record which blocks |
333 | * are used, and how many references there are to each block | 346 | * are used, and how many references there are to each block |
334 | */ | 347 | */ |
335 | #define BTRFS_EXTENT_ITEM_KEY 8 | 348 | #define BTRFS_EXTENT_ITEM_KEY 33 |
349 | |||
350 | /* | ||
351 | * block groups give us hints into the extent allocation trees. Which | ||
352 | * blocks are free etc etc | ||
353 | */ | ||
354 | #define BTRFS_BLOCK_GROUP_ITEM_KEY 34 | ||
336 | 355 | ||
337 | /* | 356 | /* |
338 | * dev items list the devices that make up the FS | 357 | * dev items list the devices that make up the FS |
339 | */ | 358 | */ |
340 | #define BTRFS_DEV_ITEM_KEY 9 | 359 | #define BTRFS_DEV_ITEM_KEY 35 |
341 | 360 | ||
342 | /* | 361 | /* |
343 | * string items are for debugging. They just store a short string of | 362 | * string items are for debugging. They just store a short string of |
344 | * data in the FS | 363 | * data in the FS |
345 | */ | 364 | */ |
346 | #define BTRFS_STRING_ITEM_KEY 10 | 365 | #define BTRFS_STRING_ITEM_KEY 253 |
366 | |||
367 | |||
368 | static inline u64 btrfs_block_group_used(struct btrfs_block_group_item *bi) | ||
369 | { | ||
370 | return le64_to_cpu(bi->used); | ||
371 | } | ||
372 | |||
373 | static inline void btrfs_set_block_group_used(struct | ||
374 | btrfs_block_group_item *bi, | ||
375 | u64 val) | ||
376 | { | ||
377 | bi->used = cpu_to_le64(val); | ||
378 | } | ||
347 | 379 | ||
348 | static inline u64 btrfs_inode_generation(struct btrfs_inode_item *i) | 380 | static inline u64 btrfs_inode_generation(struct btrfs_inode_item *i) |
349 | { | 381 | { |
@@ -1037,6 +1069,10 @@ int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans, struct | |||
1037 | int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, | 1069 | int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, |
1038 | struct btrfs_root *root, | 1070 | struct btrfs_root *root, |
1039 | u64 blocknr, u64 num_blocks); | 1071 | u64 blocknr, u64 num_blocks); |
1072 | int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans, | ||
1073 | struct btrfs_root *root); | ||
1074 | int btrfs_free_block_groups(struct btrfs_fs_info *info); | ||
1075 | int btrfs_read_block_groups(struct btrfs_root *root); | ||
1040 | /* ctree.c */ | 1076 | /* ctree.c */ |
1041 | int btrfs_extend_item(struct btrfs_trans_handle *trans, struct btrfs_root | 1077 | int btrfs_extend_item(struct btrfs_trans_handle *trans, struct btrfs_root |
1042 | *root, struct btrfs_path *path, u32 data_size); | 1078 | *root, struct btrfs_path *path, u32 data_size); |