summaryrefslogtreecommitdiff
path: root/btrfs-convert.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-08-23 17:43:21 +0200
committerDavid Sterba <dsterba@suse.com>2016-08-24 14:37:36 +0200
commit0e4cabc479455a2047ee8a76ca7e23b5be995013 (patch)
treeeded56c2d63fa6c20f9e81df405bcbb0d3c08f6b /btrfs-convert.c
parentd44d9fb4f0669b1dfa0cb5fd72801c17b9e69ad7 (diff)
btrfs-progs: convert: move migrate_reserved_ranges
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'btrfs-convert.c')
-rw-r--r--btrfs-convert.c88
1 files changed, 44 insertions, 44 deletions
diff --git a/btrfs-convert.c b/btrfs-convert.c
index 2d933cd4..1c6d02c0 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -611,6 +611,50 @@ static int migrate_one_reserved_range(struct btrfs_trans_handle *trans,
}
/*
+ * Relocate the used ext2 data in reserved ranges
+ * [0,1M)
+ * [btrfs_sb_offset(1), +BTRFS_STRIPE_LEN)
+ * [btrfs_sb_offset(2), +BTRFS_STRIPE_LEN)
+ */
+static int migrate_reserved_ranges(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root,
+ struct cache_tree *used,
+ struct btrfs_inode_item *inode, int fd,
+ u64 ino, u64 total_bytes, int datacsum)
+{
+ u64 cur_off;
+ u64 cur_len;
+ int ret = 0;
+
+ /* 0 ~ 1M */
+ cur_off = 0;
+ cur_len = 1024 * 1024;
+ ret = migrate_one_reserved_range(trans, root, used, inode, fd, ino,
+ cur_off, cur_len, datacsum);
+ if (ret < 0)
+ return ret;
+
+ /* second sb(fisrt sb is included in 0~1M) */
+ cur_off = btrfs_sb_offset(1);
+ cur_len = min(total_bytes, cur_off + BTRFS_STRIPE_LEN) - cur_off;
+ if (cur_off > total_bytes)
+ return ret;
+ ret = migrate_one_reserved_range(trans, root, used, inode, fd, ino,
+ cur_off, cur_len, datacsum);
+ if (ret < 0)
+ return ret;
+
+ /* Last sb */
+ cur_off = btrfs_sb_offset(2);
+ cur_len = min(total_bytes, cur_off + BTRFS_STRIPE_LEN) - cur_off;
+ if (cur_off > total_bytes)
+ return ret;
+ ret = migrate_one_reserved_range(trans, root, used, inode, fd, ino,
+ cur_off, cur_len, datacsum);
+ return ret;
+}
+
+/*
* Open Ext2fs in readonly mode, read block allocation bitmap and
* inode bitmap into memory.
*/
@@ -1459,50 +1503,6 @@ static int ext2_copy_inodes(struct btrfs_convert_context *cctx,
return ret;
}
-/*
- * Relocate the used ext2 data in reserved ranges
- * [0,1M)
- * [btrfs_sb_offset(1), +BTRFS_STRIPE_LEN)
- * [btrfs_sb_offset(2), +BTRFS_STRIPE_LEN)
- */
-static int migrate_reserved_ranges(struct btrfs_trans_handle *trans,
- struct btrfs_root *root,
- struct cache_tree *used,
- struct btrfs_inode_item *inode, int fd,
- u64 ino, u64 total_bytes, int datacsum)
-{
- u64 cur_off;
- u64 cur_len;
- int ret = 0;
-
- /* 0 ~ 1M */
- cur_off = 0;
- cur_len = 1024 * 1024;
- ret = migrate_one_reserved_range(trans, root, used, inode, fd, ino,
- cur_off, cur_len, datacsum);
- if (ret < 0)
- return ret;
-
- /* second sb(fisrt sb is included in 0~1M) */
- cur_off = btrfs_sb_offset(1);
- cur_len = min(total_bytes, cur_off + BTRFS_STRIPE_LEN) - cur_off;
- if (cur_off > total_bytes)
- return ret;
- ret = migrate_one_reserved_range(trans, root, used, inode, fd, ino,
- cur_off, cur_len, datacsum);
- if (ret < 0)
- return ret;
-
- /* Last sb */
- cur_off = btrfs_sb_offset(2);
- cur_len = min(total_bytes, cur_off + BTRFS_STRIPE_LEN) - cur_off;
- if (cur_off > total_bytes)
- return ret;
- ret = migrate_one_reserved_range(trans, root, used, inode, fd, ino,
- cur_off, cur_len, datacsum);
- return ret;
-}
-
static int wipe_reserved_ranges(struct cache_tree *tree, u64 min_stripe_size,
int ensure_size);