Btrfs: fix extent owner/type setting on extent tree blocks
authorChris Mason <chris.mason@oracle.com>
Mon, 23 Apr 2007 21:01:05 +0000 (17:01 -0400)
committerDavid Woodhouse <dwmw2@hera.kernel.org>
Mon, 23 Apr 2007 21:01:05 +0000 (17:01 -0400)
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/extent-tree.c

index 49f7cd6e067c801b091377532674e372cea4f772..aac3eccffb8ea933080a884f7afead725272d202 100644 (file)
@@ -167,6 +167,8 @@ static int finish_current_insert(struct btrfs_trans_handle *trans, struct
        ins.offset = 1;
        ins.flags = 0;
        btrfs_set_key_type(&ins, BTRFS_EXTENT_ITEM_KEY);
+       btrfs_set_extent_type(&extent_item, BTRFS_EXTENT_TREE);
+       btrfs_set_extent_owner(&extent_item, extent_root->root_key.objectid);
 
        for (i = 0; i < extent_root->fs_info->current_insert.flags; i++) {
                ins.objectid = extent_root->fs_info->current_insert.objectid +
@@ -356,7 +358,7 @@ static int find_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
        btrfs_set_key_type(ins, BTRFS_EXTENT_ITEM_KEY);
 
        level = btrfs_header_level(btrfs_buffer_header(root->node));
-       total_needed += (level + 1) * 3;
+       total_needed += (level + 2) * 3;
        if (root->fs_info->last_insert.objectid == 0 && search_end == (u64)-1) {
                struct btrfs_disk_key *last_key;
                btrfs_init_path(path);