aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/mkfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/mkfs.c')
-rw-r--r--fs/btrfs/mkfs.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/fs/btrfs/mkfs.c b/fs/btrfs/mkfs.c
index 317d20ce759d..9aa900811c33 100644
--- a/fs/btrfs/mkfs.c
+++ b/fs/btrfs/mkfs.c
@@ -50,9 +50,10 @@ int mkfs(int fd, u64 num_blocks, u32 blocksize)
50 itemoff = __BTRFS_LEAF_DATA_SIZE(blocksize) - sizeof(root_item); 50 itemoff = __BTRFS_LEAF_DATA_SIZE(blocksize) - sizeof(root_item);
51 btrfs_set_item_offset(&item, itemoff); 51 btrfs_set_item_offset(&item, itemoff);
52 btrfs_set_item_size(&item, sizeof(root_item)); 52 btrfs_set_item_size(&item, sizeof(root_item));
53 btrfs_set_key_objectid(&item.key, BTRFS_EXTENT_TREE_OBJECTID); 53 btrfs_set_disk_key_objectid(&item.key, BTRFS_EXTENT_TREE_OBJECTID);
54 btrfs_set_key_offset(&item.key, 0); 54 btrfs_set_disk_key_offset(&item.key, 0);
55 btrfs_set_key_flags(&item.key, 0); 55 btrfs_set_disk_key_flags(&item.key, 0);
56 btrfs_set_disk_key_type(&item.key, BTRFS_ROOT_ITEM_KEY);
56 memcpy(empty_leaf->items, &item, sizeof(item)); 57 memcpy(empty_leaf->items, &item, sizeof(item));
57 memcpy(btrfs_leaf_data(empty_leaf) + itemoff, 58 memcpy(btrfs_leaf_data(empty_leaf) + itemoff,
58 &root_item, sizeof(root_item)); 59 &root_item, sizeof(root_item));
@@ -60,7 +61,7 @@ int mkfs(int fd, u64 num_blocks, u32 blocksize)
60 btrfs_set_root_blocknr(&root_item, start_block + 3); 61 btrfs_set_root_blocknr(&root_item, start_block + 3);
61 itemoff = itemoff - sizeof(root_item); 62 itemoff = itemoff - sizeof(root_item);
62 btrfs_set_item_offset(&item, itemoff); 63 btrfs_set_item_offset(&item, itemoff);
63 btrfs_set_key_objectid(&item.key, BTRFS_FS_TREE_OBJECTID); 64 btrfs_set_disk_key_objectid(&item.key, BTRFS_FS_TREE_OBJECTID);
64 memcpy(empty_leaf->items + 1, &item, sizeof(item)); 65 memcpy(empty_leaf->items + 1, &item, sizeof(item));
65 memcpy(btrfs_leaf_data(empty_leaf) + itemoff, 66 memcpy(btrfs_leaf_data(empty_leaf) + itemoff,
66 &root_item, sizeof(root_item)); 67 &root_item, sizeof(root_item));
@@ -73,9 +74,10 @@ int mkfs(int fd, u64 num_blocks, u32 blocksize)
73 btrfs_set_header_nritems(&empty_leaf->header, 4); 74 btrfs_set_header_nritems(&empty_leaf->header, 4);
74 75
75 /* item1, reserve blocks 0-16 */ 76 /* item1, reserve blocks 0-16 */
76 btrfs_set_key_objectid(&item.key, 0); 77 btrfs_set_disk_key_objectid(&item.key, 0);
77 btrfs_set_key_offset(&item.key, start_block + 1); 78 btrfs_set_disk_key_offset(&item.key, start_block + 1);
78 btrfs_set_key_flags(&item.key, 0); 79 btrfs_set_disk_key_flags(&item.key, 0);
80 btrfs_set_disk_key_type(&item.key, BTRFS_EXTENT_ITEM_KEY);
79 itemoff = __BTRFS_LEAF_DATA_SIZE(blocksize) - 81 itemoff = __BTRFS_LEAF_DATA_SIZE(blocksize) -
80 sizeof(struct btrfs_extent_item); 82 sizeof(struct btrfs_extent_item);
81 btrfs_set_item_offset(&item, itemoff); 83 btrfs_set_item_offset(&item, itemoff);
@@ -87,8 +89,8 @@ int mkfs(int fd, u64 num_blocks, u32 blocksize)
87 &extent_item, btrfs_item_size(&item)); 89 &extent_item, btrfs_item_size(&item));
88 90
89 /* item2, give block 17 to the root */ 91 /* item2, give block 17 to the root */
90 btrfs_set_key_objectid(&item.key, start_block + 1); 92 btrfs_set_disk_key_objectid(&item.key, start_block + 1);
91 btrfs_set_key_offset(&item.key, 1); 93 btrfs_set_disk_key_offset(&item.key, 1);
92 itemoff = itemoff - sizeof(struct btrfs_extent_item); 94 itemoff = itemoff - sizeof(struct btrfs_extent_item);
93 btrfs_set_item_offset(&item, itemoff); 95 btrfs_set_item_offset(&item, itemoff);
94 btrfs_set_extent_owner(&extent_item, BTRFS_ROOT_TREE_OBJECTID); 96 btrfs_set_extent_owner(&extent_item, BTRFS_ROOT_TREE_OBJECTID);
@@ -97,8 +99,8 @@ int mkfs(int fd, u64 num_blocks, u32 blocksize)
97 &extent_item, btrfs_item_size(&item)); 99 &extent_item, btrfs_item_size(&item));
98 100
99 /* item3, give block 18 to the extent root */ 101 /* item3, give block 18 to the extent root */
100 btrfs_set_key_objectid(&item.key, start_block + 2); 102 btrfs_set_disk_key_objectid(&item.key, start_block + 2);
101 btrfs_set_key_offset(&item.key, 1); 103 btrfs_set_disk_key_offset(&item.key, 1);
102 itemoff = itemoff - sizeof(struct btrfs_extent_item); 104 itemoff = itemoff - sizeof(struct btrfs_extent_item);
103 btrfs_set_item_offset(&item, itemoff); 105 btrfs_set_item_offset(&item, itemoff);
104 btrfs_set_extent_owner(&extent_item, BTRFS_EXTENT_TREE_OBJECTID); 106 btrfs_set_extent_owner(&extent_item, BTRFS_EXTENT_TREE_OBJECTID);
@@ -107,8 +109,8 @@ int mkfs(int fd, u64 num_blocks, u32 blocksize)
107 &extent_item, btrfs_item_size(&item)); 109 &extent_item, btrfs_item_size(&item));
108 110
109 /* item4, give block 19 to the FS root */ 111 /* item4, give block 19 to the FS root */
110 btrfs_set_key_objectid(&item.key, start_block + 3); 112 btrfs_set_disk_key_objectid(&item.key, start_block + 3);
111 btrfs_set_key_offset(&item.key, 1); 113 btrfs_set_disk_key_offset(&item.key, 1);
112 itemoff = itemoff - sizeof(struct btrfs_extent_item); 114 itemoff = itemoff - sizeof(struct btrfs_extent_item);
113 btrfs_set_item_offset(&item, itemoff); 115 btrfs_set_item_offset(&item, itemoff);
114 btrfs_set_extent_owner(&extent_item, BTRFS_FS_TREE_OBJECTID); 116 btrfs_set_extent_owner(&extent_item, BTRFS_FS_TREE_OBJECTID);