diff options
author | Yan Zheng <zheng.yan@oracle.com> | 2008-12-05 12:21:31 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-12-05 12:21:31 -0500 |
commit | 5ccd1715fa2eaad0b26037bb53706779c8c93b5f (patch) | |
tree | 3957b56e7b0d7d494c952829ff926df8c24377f6 /utils.c | |
parent | d79f499eae6671a04e80b5a3081fae8e2a311b54 (diff) |
superblock duplication
This patch updates btrfs-progs for superblock duplication.
Note: I didn't make this patch as complete as the one for
kernel since updating the converter requires changing the
code again. Thank you,
Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Diffstat (limited to 'utils.c')
-rw-r--r-- | utils.c | 26 |
1 files changed, 10 insertions, 16 deletions
@@ -194,18 +194,7 @@ int make_btrfs(int fd, const char *device, const char *label, /* create the items for the extent tree */ nritems = 0; - itemoff = __BTRFS_LEAF_DATA_SIZE(leafsize) - - sizeof(struct btrfs_extent_item); - btrfs_set_disk_key_objectid(&disk_key, 0); - btrfs_set_disk_key_offset(&disk_key, first_free); - btrfs_set_disk_key_type(&disk_key, BTRFS_EXTENT_ITEM_KEY); - btrfs_set_item_key(buf, &disk_key, nritems); - btrfs_set_item_offset(buf, btrfs_item_nr(buf, nritems), itemoff); - btrfs_set_item_size(buf, btrfs_item_nr(buf, nritems), - sizeof(struct btrfs_extent_item)); - extent_item = btrfs_item_ptr(buf, nritems, struct btrfs_extent_item); - btrfs_set_extent_refs(buf, extent_item, 1); - nritems++; + itemoff = __BTRFS_LEAF_DATA_SIZE(leafsize); for (i = 1; i < 7; i++) { BUG_ON(blocks[i] < first_free); BUG_ON(blocks[i] < blocks[i - 1]); @@ -517,17 +506,15 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans, kfree(buf); list_add(&device->dev_list, &root->fs_info->fs_devices->devices); device->fs_devices = root->fs_info->fs_devices; - ret = btrfs_bootstrap_super_map(&root->fs_info->mapping_tree, - root->fs_info->fs_devices); - BUG_ON(ret); return 0; } int btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret) { u64 block_count; + u64 bytenr; struct stat st; - int ret; + int i, ret; ret = fstat(fd, &st); if (ret < 0) { @@ -552,6 +539,13 @@ int btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret) exit(1); } + for (i = 0 ; i < BTRFS_SUPER_MIRROR_MAX; i++) { + bytenr = btrfs_sb_offset(i); + if (bytenr >= block_count) + break; + zero_blocks(fd, bytenr, BTRFS_SUPER_INFO_SIZE); + } + if (zero_end) { ret = zero_dev_end(fd, block_count); if (ret) { |