mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-28 09:02:19 +00:00
btrfs-progs: convert: move migrate_reserved_ranges
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
d44d9fb4f0
commit
0e4cabc479
@ -610,6 +610,50 @@ static int migrate_one_reserved_range(struct btrfs_trans_handle *trans,
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user