diff options
author | Liu Bo <bo.li.liu@oracle.com> | 2015-10-18 13:44:41 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2015-11-02 09:35:06 +0100 |
commit | a1126f3673f60814609491d16c863a3a91ec078f (patch) | |
tree | a9286c2756733feb0c5ee73ab42ba4a369b74541 /btrfs-convert.c | |
parent | 30b72caa2e640bcfa15535f3d28385149c63939f (diff) | |
download | btrfs-progs-a1126f3673f60814609491d16c863a3a91ec078f.tar.gz |
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>
Diffstat (limited to 'btrfs-convert.c')
-rw-r--r-- | btrfs-convert.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/btrfs-convert.c b/btrfs-convert.c index 39eaa37..5b9171e 100644 --- a/btrfs-convert.c +++ b/btrfs-convert.c @@ -2597,6 +2597,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; image_root = btrfs_read_fs_root(root->fs_info, &key); |