diff options
author | Chris Mason <chris.mason@fusionio.com> | 2013-10-16 10:36:55 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2013-10-16 10:42:53 -0400 |
commit | d1570a06184ed3748536a67693ef5cfd954d4032 (patch) | |
tree | 3fe610614ddc64a510006820a518297d14a9dec1 /disk-io.c | |
parent | 005d7d2efb0aaaae056584f3cbd25d3bfce73ea3 (diff) |
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.c | 31 |
1 files changed, 19 insertions, 12 deletions
@@ -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) |