aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-04-15 15:41:47 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:01 -0400
commite17cade25ff8074101d653557a78df09c16ca276 (patch)
treec4bddc201bf77c9a460e726a5cdd5ca1add8c256 /fs/btrfs/extent-tree.c
parentb248a4152956cbae1b23f4c70ef5b51d6ea2ecfb (diff)
Btrfs: Add chunk uuids and update multi-device back references
Block headers now store the chunk tree uuid Chunk items records the device uuid for each stripes Device extent items record better back refs to the chunk tree Block groups record better back refs to the chunk tree The chunk tree format has also changed. The objectid of BTRFS_CHUNK_ITEM_KEY used to be the logical offset of the chunk. Now it is a chunk tree id, with the logical offset being stored in the offset field of the key. This allows a single chunk tree to record multiple logical address spaces, upping the number of bytes indexed by a chunk tree from 2^64 to 2^128. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index e49147e767df..71f045c63493 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -35,10 +35,6 @@ static int finish_current_insert(struct btrfs_trans_handle *trans, struct
35 btrfs_root *extent_root); 35 btrfs_root *extent_root);
36static int del_pending_extents(struct btrfs_trans_handle *trans, struct 36static int del_pending_extents(struct btrfs_trans_handle *trans, struct
37 btrfs_root *extent_root); 37 btrfs_root *extent_root);
38int btrfs_make_block_group(struct btrfs_trans_handle *trans,
39 struct btrfs_root *root, u64 bytes_used,
40 u64 type, u64 chunk_tree, u64 chunk_objectid,
41 u64 size);
42 38
43 39
44static int cache_block_group(struct btrfs_root *root, 40static int cache_block_group(struct btrfs_root *root,
@@ -980,7 +976,6 @@ int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,
980 ret = get_state_private(block_group_cache, start, &ptr); 976 ret = get_state_private(block_group_cache, start, &ptr);
981 if (ret) 977 if (ret)
982 break; 978 break;
983
984 cache = (struct btrfs_block_group_cache *)(unsigned long)ptr; 979 cache = (struct btrfs_block_group_cache *)(unsigned long)ptr;
985 err = write_one_cache_group(trans, root, 980 err = write_one_cache_group(trans, root,
986 path, cache); 981 path, cache);
@@ -1094,8 +1089,7 @@ printk("space info full %Lu\n", flags);
1094 BUG_ON(ret); 1089 BUG_ON(ret);
1095 1090
1096 ret = btrfs_make_block_group(trans, extent_root, 0, flags, 1091 ret = btrfs_make_block_group(trans, extent_root, 0, flags,
1097 extent_root->fs_info->chunk_root->root_key.objectid, 1092 BTRFS_FIRST_CHUNK_TREE_OBJECTID, start, num_bytes);
1098 start, num_bytes);
1099 BUG_ON(ret); 1093 BUG_ON(ret);
1100 1094
1101 return 0; 1095 return 0;
@@ -2782,7 +2776,7 @@ error:
2782 2776
2783int btrfs_make_block_group(struct btrfs_trans_handle *trans, 2777int btrfs_make_block_group(struct btrfs_trans_handle *trans,
2784 struct btrfs_root *root, u64 bytes_used, 2778 struct btrfs_root *root, u64 bytes_used,
2785 u64 type, u64 chunk_tree, u64 chunk_objectid, 2779 u64 type, u64 chunk_objectid, u64 chunk_offset,
2786 u64 size) 2780 u64 size)
2787{ 2781{
2788 int ret; 2782 int ret;
@@ -2796,14 +2790,14 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans,
2796 2790
2797 cache = kmalloc(sizeof(*cache), GFP_NOFS); 2791 cache = kmalloc(sizeof(*cache), GFP_NOFS);
2798 BUG_ON(!cache); 2792 BUG_ON(!cache);
2799 cache->key.objectid = chunk_objectid; 2793 cache->key.objectid = chunk_offset;
2800 cache->key.offset = size; 2794 cache->key.offset = size;
2801 cache->cached = 0; 2795 cache->cached = 0;
2802 cache->pinned = 0; 2796 cache->pinned = 0;
2797
2803 btrfs_set_key_type(&cache->key, BTRFS_BLOCK_GROUP_ITEM_KEY); 2798 btrfs_set_key_type(&cache->key, BTRFS_BLOCK_GROUP_ITEM_KEY);
2804 memset(&cache->item, 0, sizeof(cache->item)); 2799 memset(&cache->item, 0, sizeof(cache->item));
2805 btrfs_set_block_group_used(&cache->item, bytes_used); 2800 btrfs_set_block_group_used(&cache->item, bytes_used);
2806 btrfs_set_block_group_chunk_tree(&cache->item, chunk_tree);
2807 btrfs_set_block_group_chunk_objectid(&cache->item, chunk_objectid); 2801 btrfs_set_block_group_chunk_objectid(&cache->item, chunk_objectid);
2808 cache->flags = type; 2802 cache->flags = type;
2809 btrfs_set_block_group_flags(&cache->item, type); 2803 btrfs_set_block_group_flags(&cache->item, type);
@@ -2813,12 +2807,12 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans,
2813 BUG_ON(ret); 2807 BUG_ON(ret);
2814 2808
2815 bit = block_group_state_bits(type); 2809 bit = block_group_state_bits(type);
2816 set_extent_bits(block_group_cache, chunk_objectid, 2810 set_extent_bits(block_group_cache, chunk_offset,
2817 chunk_objectid + size - 1, 2811 chunk_offset + size - 1,
2818 bit | EXTENT_LOCKED, GFP_NOFS); 2812 bit | EXTENT_LOCKED, GFP_NOFS);
2819 set_state_private(block_group_cache, chunk_objectid,
2820 (unsigned long)cache);
2821 2813
2814 set_state_private(block_group_cache, chunk_offset,
2815 (unsigned long)cache);
2822 ret = btrfs_insert_item(trans, extent_root, &cache->key, &cache->item, 2816 ret = btrfs_insert_item(trans, extent_root, &cache->key, &cache->item,
2823 sizeof(cache->item)); 2817 sizeof(cache->item));
2824 BUG_ON(ret); 2818 BUG_ON(ret);