mirror of
https://github.com/kdave/btrfs-progs
synced 2025-01-30 01:12:45 +00:00
btrfs-progs: convert: Introduce function to read out btrfs reserved range
Introduce a new function, read_reserved_ranges(), to allow later rollback to use these data to do rollback. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
This commit is contained in:
parent
5613d32e75
commit
b82b12265b
@ -1513,6 +1513,36 @@ fail:
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read out data of convert image which is in btrfs reserved ranges so we can
|
||||
* use them to overwrite the ranges during rollback.
|
||||
*/
|
||||
static int read_reserved_ranges(struct btrfs_root *root, u64 ino,
|
||||
u64 total_bytes, char *reserved_ranges[])
|
||||
{
|
||||
int i;
|
||||
int ret = 0;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(btrfs_reserved_ranges); i++) {
|
||||
struct simple_range *range = &btrfs_reserved_ranges[i];
|
||||
|
||||
if (range->start + range->len >= total_bytes)
|
||||
break;
|
||||
ret = btrfs_read_file(root, ino, range->start, range->len,
|
||||
reserved_ranges[i]);
|
||||
if (ret < range->len) {
|
||||
error(
|
||||
"failed to read data of convert image, offset=%llu len=%llu ret=%d",
|
||||
range->start, range->len, ret);
|
||||
if (ret >= 0)
|
||||
ret = -EIO;
|
||||
break;
|
||||
}
|
||||
ret = 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int do_rollback(const char *devname)
|
||||
{
|
||||
int fd = -1;
|
||||
|
Loading…
Reference in New Issue
Block a user