File 2003-btrfs-convert-rename-ext2_root-to-image_root.patch of Package btrfsprogs.356
From bfc0c515b29635856a620d305702a17fd9ebbf64 Mon Sep 17 00:00:00 2001
From: Jeff Mahoney <jeffm@suse.com>
Date: Wed, 14 Aug 2013 13:44:21 -0400
Subject: [PATCH 04/10] btrfs-convert: rename ext2_root to image_root
In preparation to extend to other file systems, rename ext2_root to
image_root.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
btrfs-convert.c | 39 ++++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 19 deletions(-)
Index: btrfs-progs-v3.16.2/btrfs-convert.c
===================================================================
--- btrfs-progs-v3.16.2.orig/btrfs-convert.c
+++ btrfs-progs-v3.16.2/btrfs-convert.c
@@ -43,7 +43,7 @@
#include <ext2fs/ext2_ext_attr.h>
#define INO_OFFSET (BTRFS_FIRST_FREE_OBJECTID - EXT2_ROOT_INO)
-#define EXT2_IMAGE_SUBVOL_OBJECTID BTRFS_FIRST_FREE_OBJECTID
+#define CONV_IMAGE_SUBVOL_OBJECTID BTRFS_FIRST_FREE_OBJECTID
/*
* Open Ext2fs in readonly mode, read block allocation bitmap and
@@ -1614,7 +1614,7 @@ static int init_btrfs(struct btrfs_root
BTRFS_FIRST_FREE_OBJECTID);
/* subvol for ext2 image file */
- ret = create_subvol(trans, root, EXT2_IMAGE_SUBVOL_OBJECTID);
+ ret = create_subvol(trans, root, CONV_IMAGE_SUBVOL_OBJECTID);
BUG_ON(ret);
/* subvol for data relocation */
ret = create_subvol(trans, root, BTRFS_DATA_RELOC_TREE_OBJECTID);
@@ -1895,7 +1895,7 @@ fail:
}
static int relocate_extents_range(struct btrfs_root *fs_root,
- struct btrfs_root *ext2_root,
+ struct btrfs_root *image_root,
u64 start_byte, u64 end_byte)
{
struct btrfs_fs_info *info = fs_root->fs_info;
@@ -1942,7 +1942,7 @@ static int relocate_extents_range(struct
}
btrfs_release_path(&path);
again:
- cur_root = (pass % 2 == 0) ? ext2_root : fs_root;
+ cur_root = (pass % 2 == 0) ? image_root : fs_root;
num_extents = 0;
trans = btrfs_start_transaction(cur_root, 1);
@@ -2050,7 +2050,7 @@ fail:
* relocate data in system chunk
*/
static int cleanup_sys_chunk(struct btrfs_root *fs_root,
- struct btrfs_root *ext2_root)
+ struct btrfs_root *image_root)
{
struct btrfs_block_group_cache *cache;
int i, ret = 0;
@@ -2064,7 +2064,7 @@ static int cleanup_sys_chunk(struct btrf
end_byte = cache->key.objectid + cache->key.offset;
if (cache->flags & BTRFS_BLOCK_GROUP_SYSTEM) {
- ret = relocate_extents_range(fs_root, ext2_root,
+ ret = relocate_extents_range(fs_root, image_root,
cache->key.objectid,
end_byte);
if (ret)
@@ -2076,7 +2076,7 @@ static int cleanup_sys_chunk(struct btrf
offset = btrfs_sb_offset(i);
offset &= ~((u64)BTRFS_STRIPE_LEN - 1);
- ret = relocate_extents_range(fs_root, ext2_root,
+ ret = relocate_extents_range(fs_root, image_root,
offset, offset + BTRFS_STRIPE_LEN);
if (ret)
goto fail;
@@ -2186,7 +2186,7 @@ static int do_convert(const char *devnam
u64 super_bytenr;
ext2_filsys ext2_fs;
struct btrfs_root *root;
- struct btrfs_root *ext2_root;
+ struct btrfs_root *image_root;
ret = open_ext2fs(devname, &ext2_fs);
if (ret) {
@@ -2260,12 +2260,13 @@ static int do_convert(const char *devnam
goto fail;
}
printf("creating ext2fs image file.\n");
- ext2_root = link_subvol(root, "ext2_saved", EXT2_IMAGE_SUBVOL_OBJECTID);
- if (!ext2_root) {
+ image_root = link_subvol(root, "ext2_saved",
+ CONV_IMAGE_SUBVOL_OBJECTID);
+ if (!image_root) {
fprintf(stderr, "unable to create subvol\n");
goto fail;
}
- ret = create_ext2_image(ext2_root, ext2_fs, "image");
+ ret = create_ext2_image(image_root, ext2_fs, "image");
if (ret) {
fprintf(stderr, "error during create_ext2_image %d\n", ret);
goto fail;
@@ -2282,7 +2283,7 @@ static int do_convert(const char *devnam
}
printf("cleaning up system chunk.\n");
- ret = cleanup_sys_chunk(root, ext2_root);
+ ret = cleanup_sys_chunk(root, image_root);
if (ret) {
fprintf(stderr, "error during cleanup_sys_chunk %d\n", ret);
goto fail;
@@ -2372,7 +2373,7 @@ static int do_rollback(const char *devna
int ret;
int i;
struct btrfs_root *root;
- struct btrfs_root *ext2_root;
+ struct btrfs_root *image_root;
struct btrfs_root *chunk_root;
struct btrfs_dir_item *dir;
struct btrfs_inode_item *inode;
@@ -2425,11 +2426,11 @@ static int do_rollback(const char *devna
btrfs_init_path(&path);
- key.objectid = EXT2_IMAGE_SUBVOL_OBJECTID;
+ key.objectid = CONV_IMAGE_SUBVOL_OBJECTID;
key.type = BTRFS_ROOT_ITEM_KEY;
key.offset = (u64)-1;
- ext2_root = btrfs_read_fs_root(root->fs_info, &key);
- if (!ext2_root || IS_ERR(ext2_root)) {
+ image_root = btrfs_read_fs_root(root->fs_info, &key);
+ if (!image_root || IS_ERR(image_root)) {
fprintf(stderr, "unable to open subvol %llu\n",
(unsigned long long)key.objectid);
goto fail;
@@ -2437,7 +2438,7 @@ static int do_rollback(const char *devna
name = "image";
root_dir = btrfs_root_dirid(&root->root_item);
- dir = btrfs_lookup_dir_item(NULL, ext2_root, &path,
+ dir = btrfs_lookup_dir_item(NULL, image_root, &path,
root_dir, name, strlen(name), 0);
if (!dir || IS_ERR(dir)) {
fprintf(stderr, "unable to find file %s\n", name);
@@ -2449,7 +2450,7 @@ static int do_rollback(const char *devna
objectid = key.objectid;
- ret = btrfs_lookup_inode(NULL, ext2_root, &path, &key, 0);
+ ret = btrfs_lookup_inode(NULL, image_root, &path, &key, 0);
if (ret) {
fprintf(stderr, "unable to find inode item\n");
goto fail;
@@ -2462,7 +2463,7 @@ static int do_rollback(const char *devna
key.objectid = objectid;
key.offset = 0;
btrfs_set_key_type(&key, BTRFS_EXTENT_DATA_KEY);
- ret = btrfs_search_slot(NULL, ext2_root, &key, &path, 0, 0);
+ ret = btrfs_search_slot(NULL, image_root, &key, &path, 0, 0);
if (ret != 0) {
fprintf(stderr, "unable to find first file extent\n");
btrfs_release_path(&path);