mirror of
https://github.com/kdave/btrfs-progs
synced 2025-01-14 01:31:02 +00:00
Btrfs-progs: fix btrfs-convert rollback to check ROOT_BACKREF
Btrfs has changed to delete subvolume/snapshot asynchronously, which means that after umount itself, if we've already deleted 'ext2_saved', rollback can still be completed. So this adds a check for ROOT_BACKREF before checking ROOT_ITEM since ROOT_BACKREF is immediately not in the btree after ioctl(BTRFS_IOC_SNAP_DESTROY) returns. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [ updated error messages ] Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
30b72caa2e
commit
a1126f3673
@ -2596,6 +2596,23 @@ static int do_rollback(const char *devname)
|
||||
|
||||
btrfs_init_path(&path);
|
||||
|
||||
key.objectid = CONV_IMAGE_SUBVOL_OBJECTID;
|
||||
key.type = BTRFS_ROOT_BACKREF_KEY;
|
||||
key.offset = BTRFS_FS_TREE_OBJECTID;
|
||||
ret = btrfs_search_slot(NULL, root->fs_info->tree_root, &key, &path, 0,
|
||||
0);
|
||||
btrfs_release_path(&path);
|
||||
if (ret > 0) {
|
||||
fprintf(stderr,
|
||||
"ERROR: unable to convert ext2 image subvolume, is it deleted?\n");
|
||||
goto fail;
|
||||
} else if (ret < 0) {
|
||||
fprintf(stderr,
|
||||
"ERROR: unable to open ext2_subvol, id=%llu: %s\n",
|
||||
(unsigned long long)key.objectid, strerror(-ret));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
key.objectid = CONV_IMAGE_SUBVOL_OBJECTID;
|
||||
key.type = BTRFS_ROOT_ITEM_KEY;
|
||||
key.offset = (u64)-1;
|
||||
|
Loading…
Reference in New Issue
Block a user