aboutsummaryrefslogtreecommitdiffstats
path: root/disk-io.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@fusionio.com>2013-10-16 10:36:55 -0400
committerChris Mason <chris.mason@fusionio.com>2013-10-16 10:42:53 -0400
commitd1570a06184ed3748536a67693ef5cfd954d4032 (patch)
tree3fe610614ddc64a510006820a518297d14a9dec1 /disk-io.c
parent005d7d2efb0aaaae056584f3cbd25d3bfce73ea3 (diff)
downloadbtrfs-progs-d1570a06184ed3748536a67693ef5cfd954d4032.tar.gz
btrfs-progs-d1570a06184ed3748536a67693ef5cfd954d4032.tar.xz
btrfs-progs-d1570a06184ed3748536a67693ef5cfd954d4032.zip
mkfs: fix mkfs -r to properly allocate space
mkfs -r wasn't creating chunks properly, making it very difficult to allocate space for anything except tiny filesystems. This changes it around to use more of the generic infrastructure, and to do actual logical->physical block number translation. It also allocates space to the files in smaller extents (max 1MB), which keeps the allocator from trying to allocate an extent bigger than a single chunk. It doesn't quite support multi-device mkfs -r yet, but is much closer. Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'disk-io.c')
-rw-r--r--disk-io.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/disk-io.c b/disk-io.c
index b06eb03..ca76c42 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -312,9 +312,9 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
return NULL;
}
-static int write_tree_block(struct btrfs_trans_handle *trans,
- struct btrfs_root *root,
- struct extent_buffer *eb)
+int write_and_map_eb(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root,
+ struct extent_buffer *eb)
{
int ret;
int dev_nr;
@@ -322,15 +322,6 @@ static int write_tree_block(struct btrfs_trans_handle *trans,
u64 *raid_map = NULL;
struct btrfs_multi_bio *multi = NULL;
- if (check_tree_block(root, eb))
- BUG();
-
- if (!btrfs_buffer_uptodate(eb, trans->transid))
- BUG();
-
- btrfs_set_header_flag(eb, BTRFS_HEADER_FLAG_WRITTEN);
- csum_tree_block(root, eb, 0);
-
dev_nr = 0;
length = eb->len;
ret = btrfs_map_block(&root->fs_info->mapping_tree, WRITE,
@@ -353,6 +344,22 @@ static int write_tree_block(struct btrfs_trans_handle *trans,
return 0;
}
+int write_tree_block(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root,
+ struct extent_buffer *eb)
+{
+ if (check_tree_block(root, eb))
+ BUG();
+
+ if (!btrfs_buffer_uptodate(eb, trans->transid))
+ BUG();
+
+ btrfs_set_header_flag(eb, BTRFS_HEADER_FLAG_WRITTEN);
+ csum_tree_block(root, eb, 0);
+
+ return write_and_map_eb(trans, root, eb);
+}
+
int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
u32 stripesize, struct btrfs_root *root,
struct btrfs_fs_info *fs_info, u64 objectid)