summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-08-23 17:40:08 +0200
committerDavid Sterba <dsterba@suse.com>2016-08-24 14:37:36 +0200
commit09dac6063832dcd83572bc0f52e4a826a5f6653b (patch)
treed57f69fdb17f519e566e4692ddf7bb5d956e7045
parent70b5221bfb6705bcce59d19d653fd06b240809eb (diff)
btrfs-progs: convert: move init_blk_iterate_data
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--btrfs-convert.c86
1 files changed, 43 insertions, 43 deletions
diff --git a/btrfs-convert.c b/btrfs-convert.c
index a9af9a04..4343c4b5 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -218,6 +218,49 @@ static int csum_disk_extent(struct btrfs_trans_handle *trans,
return ret;
}
+struct blk_iterate_data {
+ struct btrfs_trans_handle *trans;
+ struct btrfs_root *root;
+ struct btrfs_root *convert_root;
+ struct btrfs_inode_item *inode;
+ u64 convert_ino;
+ u64 objectid;
+ u64 first_block;
+ u64 disk_block;
+ u64 num_blocks;
+ u64 boundary;
+ int checksum;
+ int errcode;
+};
+
+static void init_blk_iterate_data(struct blk_iterate_data *data,
+ struct btrfs_trans_handle *trans,
+ struct btrfs_root *root,
+ struct btrfs_inode_item *inode,
+ u64 objectid, int checksum)
+{
+ struct btrfs_key key;
+
+ data->trans = trans;
+ data->root = root;
+ data->inode = inode;
+ data->objectid = objectid;
+ data->first_block = 0;
+ data->disk_block = 0;
+ data->num_blocks = 0;
+ data->boundary = (u64)-1;
+ data->checksum = checksum;
+ data->errcode = 0;
+
+ key.objectid = CONV_IMAGE_SUBVOL_OBJECTID;
+ key.type = BTRFS_ROOT_ITEM_KEY;
+ key.offset = (u64)-1;
+ data->convert_root = btrfs_read_fs_root(root->fs_info, &key);
+ /* Impossible as we just opened it before */
+ BUG_ON(!data->convert_root || IS_ERR(data->convert_root));
+ data->convert_ino = BTRFS_FIRST_FREE_OBJECTID + 1;
+}
+
/*
* Open Ext2fs in readonly mode, read block allocation bitmap and
* inode bitmap into memory.
@@ -459,49 +502,6 @@ error:
return -1;
}
-struct blk_iterate_data {
- struct btrfs_trans_handle *trans;
- struct btrfs_root *root;
- struct btrfs_root *convert_root;
- struct btrfs_inode_item *inode;
- u64 convert_ino;
- u64 objectid;
- u64 first_block;
- u64 disk_block;
- u64 num_blocks;
- u64 boundary;
- int checksum;
- int errcode;
-};
-
-static void init_blk_iterate_data(struct blk_iterate_data *data,
- struct btrfs_trans_handle *trans,
- struct btrfs_root *root,
- struct btrfs_inode_item *inode,
- u64 objectid, int checksum)
-{
- struct btrfs_key key;
-
- data->trans = trans;
- data->root = root;
- data->inode = inode;
- data->objectid = objectid;
- data->first_block = 0;
- data->disk_block = 0;
- data->num_blocks = 0;
- data->boundary = (u64)-1;
- data->checksum = checksum;
- data->errcode = 0;
-
- key.objectid = CONV_IMAGE_SUBVOL_OBJECTID;
- key.type = BTRFS_ROOT_ITEM_KEY;
- key.offset = (u64)-1;
- data->convert_root = btrfs_read_fs_root(root->fs_info, &key);
- /* Impossible as we just opened it before */
- BUG_ON(!data->convert_root || IS_ERR(data->convert_root));
- data->convert_ino = BTRFS_FIRST_FREE_OBJECTID + 1;
-}
-
/*
* Record a file extent in original filesystem into btrfs one.
* The special point is, old disk_block can point to a reserved range.