summaryrefslogtreecommitdiff
path: root/mkfs.c
diff options
context:
space:
mode:
authorZheng Yan <zheng.yan@oracle.com>2008-09-23 12:29:10 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2008-09-23 12:29:10 -0400
commit428b7fa6302c97f5a79f4864a448f481b08a0dfe (patch)
tree59cdff5184e68da4bb3bd59c1737beea2b6c677d /mkfs.c
parentcea88ec1d7c61684b39a383996606b6e2f83bc21 (diff)
Full back reference support
This patch makes the back reference system to explicit record the location of parent node for all types of extents. The location of parent node is placed into the offset field of backref key. Every time a tree block is balanced, the back references for the affected lower level extents are updated.
Diffstat (limited to 'mkfs.c')
-rw-r--r--mkfs.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/mkfs.c b/mkfs.c
index 8d7071e7..6a100640 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -69,8 +69,8 @@ static u64 parse_size(char *s)
return atol(s) * mult;
}
-static int make_root_dir(int fd, const char *device_name) {
- struct btrfs_root *root;
+static int make_root_dir(struct btrfs_root *root)
+{
struct btrfs_trans_handle *trans;
struct btrfs_key location;
u64 bytes_used;
@@ -78,12 +78,6 @@ static int make_root_dir(int fd, const char *device_name) {
u64 chunk_size = 0;
int ret;
- root = open_ctree_fd(fd, device_name, 0, O_RDWR);
-
- if (!root) {
- fprintf(stderr, "ctree init failed\n");
- return -1;
- }
trans = btrfs_start_transaction(root, 1);
bytes_used = btrfs_super_bytes_used(&root->fs_info->super_copy);
@@ -119,7 +113,6 @@ static int make_root_dir(int fd, const char *device_name) {
chunk_start, chunk_size);
BUG_ON(ret);
- // ret = btrfs_make_block_group(trans, root, 0, 1);
ret = btrfs_make_root_dir(trans, root->fs_info->tree_root,
BTRFS_ROOT_TREE_DIR_OBJECTID);
if (ret)
@@ -143,7 +136,6 @@ static int make_root_dir(int fd, const char *device_name) {
goto err;
btrfs_commit_transaction(trans, root);
- ret = close_ctree(root);
err:
return ret;
}
@@ -405,13 +397,15 @@ int main(int ac, char **av)
fprintf(stderr, "error during mkfs %d\n", ret);
exit(1);
}
- ret = make_root_dir(fd, file);
+ root = open_ctree(file, 0, O_RDWR);
+ root->fs_info->alloc_start = alloc_start;
+
+ ret = make_root_dir(root);
if (ret) {
fprintf(stderr, "failed to setup the root directory\n");
exit(1);
}
- root = open_ctree(file, 0, O_RDWR);
- root->fs_info->alloc_start = alloc_start;
+
trans = btrfs_start_transaction(root, 1);
if (ac == 0)
@@ -463,6 +457,7 @@ int main(int ac, char **av)
raid_groups:
ret = create_raid_groups(trans, root, data_profile,
metadata_profile);
+ BUG_ON(ret);
printf("fs created label %s on %s\n\tnodesize %u leafsize %u "
"sectorsize %u size %s\n",