libbe(3): Fix be_import to delete temp snapshot

Deleting the temp snapshot isn't immediately possible because it's the
origin of the newly imported boot environment. However, this is trivially
solved by opening the new boot environment and promoting it. The roles are
now reversed and the temp snapshot/dataset may be completely destroyed.

Remove the BUGS from libbe(3) and bectl(8).
This commit is contained in:
Kyle Evans 2018-08-13 03:42:14 +00:00
parent ce33c57d6c
commit 1b057aac2b
3 changed files with 21 additions and 17 deletions

View File

@ -720,11 +720,27 @@ be_import(libbe_handle_t *lbh, const char *bootenv, int fd)
err = zfs_clone(zfs, buf, props);
zfs_close(zfs);
nvlist_free(props);
/* XXX TODO: Figure out how to destroy the ghost... */
return (BE_ERR_SUCCESS);
if (err != 0)
return (set_error(lbh, BE_ERR_UNKNOWN));
/*
* Finally, we open up the dataset we just cloned the snapshot to so that
* we may promote it. This is necessary in order to clean up the ghost
* snapshot that doesn't need to be seen.
*/
if ((zfs = zfs_open(lbh->lzh, buf, ZFS_TYPE_DATASET)) == NULL)
return (set_error(lbh, BE_ERR_ZFSOPEN));
err = zfs_promote(zfs);
zfs_close(zfs);
if (err != 0)
return (set_error(lbh, BE_ERR_UNKNOWN));
/* Clean up the temporary snapshot */
return (be_destroy(lbh, nbuf, 0));
}
#if SOON

View File

@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd August 10, 2018
.Dd August 12, 2018
.Dt LIBBE 3
.Os
.Sh NAME
@ -455,9 +455,3 @@ were written as a 2017 Google Summer of Code project with Allan Jude serving
as a mentor.
Later work was done by
.An Kyle Evans Aq Mt kevans@FreeBSD.org .
.Sh BUGS
The
.Fn be_import
function does not destroy the temporary boot environment it creates for import,
because the snapshot created to do the import may not be deleted since it is the
origin of the new boot environment.

View File

@ -18,7 +18,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd August 10, 2018
.Dd August 12, 2018
.Dt BECTL 8
.Os
.Sh NAME
@ -271,9 +271,3 @@ Wrote the original
.Xr beadm 1
manual page that this one is derived from.
.El
.Sh BUGS
.Nm
import
does not destroy the temporary boot environment it creates for import, because
the snapshot created to do the import may not be deleted since it is the
origin of the new boot environment.