btrfs-progs: convert: move create_subvol
authorDavid Sterba <dsterba@suse.com>
Tue, 23 Aug 2016 15:48:44 +0000 (17:48 +0200)
committerDavid Sterba <dsterba@suse.com>
Wed, 24 Aug 2016 12:37:36 +0000 (14:37 +0200)
Signed-off-by: David Sterba <dsterba@suse.com>
btrfs-convert.c

index 46fd534..151957f 100644 (file)
@@ -1152,6 +1152,41 @@ fail:
        return new_root;
 }
 
+static int create_subvol(struct btrfs_trans_handle *trans,
+                        struct btrfs_root *root, u64 root_objectid)
+{
+       struct extent_buffer *tmp;
+       struct btrfs_root *new_root;
+       struct btrfs_key key;
+       struct btrfs_root_item root_item;
+       int ret;
+
+       ret = btrfs_copy_root(trans, root, root->node, &tmp,
+                             root_objectid);
+       BUG_ON(ret);
+
+       memcpy(&root_item, &root->root_item, sizeof(root_item));
+       btrfs_set_root_bytenr(&root_item, tmp->start);
+       btrfs_set_root_level(&root_item, btrfs_header_level(tmp));
+       btrfs_set_root_generation(&root_item, trans->transid);
+       free_extent_buffer(tmp);
+
+       key.objectid = root_objectid;
+       key.type = BTRFS_ROOT_ITEM_KEY;
+       key.offset = trans->transid;
+       ret = btrfs_insert_root(trans, root->fs_info->tree_root,
+                               &key, &root_item);
+
+       key.offset = (u64)-1;
+       new_root = btrfs_read_fs_root(root->fs_info, &key);
+       BUG_ON(!new_root || IS_ERR(new_root));
+
+       ret = btrfs_make_root_dir(trans, new_root, BTRFS_FIRST_FREE_OBJECTID);
+       BUG_ON(ret);
+
+       return 0;
+}
+
 /*
  * Open Ext2fs in readonly mode, read block allocation bitmap and
  * inode bitmap into memory.
@@ -2001,41 +2036,6 @@ static int ext2_copy_inodes(struct btrfs_convert_context *cctx,
        return ret;
 }
 
-static int create_subvol(struct btrfs_trans_handle *trans,
-                        struct btrfs_root *root, u64 root_objectid)
-{
-       struct extent_buffer *tmp;
-       struct btrfs_root *new_root;
-       struct btrfs_key key;
-       struct btrfs_root_item root_item;
-       int ret;
-
-       ret = btrfs_copy_root(trans, root, root->node, &tmp,
-                             root_objectid);
-       BUG_ON(ret);
-
-       memcpy(&root_item, &root->root_item, sizeof(root_item));
-       btrfs_set_root_bytenr(&root_item, tmp->start);
-       btrfs_set_root_level(&root_item, btrfs_header_level(tmp));
-       btrfs_set_root_generation(&root_item, trans->transid);
-       free_extent_buffer(tmp);
-
-       key.objectid = root_objectid;
-       key.type = BTRFS_ROOT_ITEM_KEY;
-       key.offset = trans->transid;
-       ret = btrfs_insert_root(trans, root->fs_info->tree_root,
-                               &key, &root_item);
-
-       key.offset = (u64)-1;
-       new_root = btrfs_read_fs_root(root->fs_info, &key);
-       BUG_ON(!new_root || IS_ERR(new_root));
-
-       ret = btrfs_make_root_dir(trans, new_root, BTRFS_FIRST_FREE_OBJECTID);
-       BUG_ON(ret);
-
-       return 0;
-}
-
 /*
  * New make_btrfs() has handle system and meta chunks quite well.
  * So only need to add remaining data chunks.