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....@oracle.com> --- btrfs-convert.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/btrfs-convert.c b/btrfs-convert.c index 802930c..f8a6c16 100644 --- a/btrfs-convert.c +++ b/btrfs-convert.c @@ -2591,6 +2591,22 @@ 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, "unable to open subvol %llu\n", + (unsigned long long)key.objectid); + goto fail; + } else if (ret < 0) { + fprintf(stderr, "unable to open subvol %llu ret %d\n", + (unsigned long long)key.objectid, 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); -- 1.8.2.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html