Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Aug 2018 03:42:14 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r337697 - in head: lib/libbe sbin/bectl
Message-ID:  <201808130342.w7D3gFSh015502@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Mon Aug 13 03:42:14 2018
New Revision: 337697
URL: https://svnweb.freebsd.org/changeset/base/337697

Log:
  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).

Modified:
  head/lib/libbe/be.c
  head/lib/libbe/libbe.3
  head/sbin/bectl/bectl.8

Modified: head/lib/libbe/be.c
==============================================================================
--- head/lib/libbe/be.c	Mon Aug 13 03:38:32 2018	(r337696)
+++ head/lib/libbe/be.c	Mon Aug 13 03:42:14 2018	(r337697)
@@ -720,11 +720,27 @@ be_import(libbe_handle_t *lbh, const char *bootenv, in
 
 	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

Modified: head/lib/libbe/libbe.3
==============================================================================
--- head/lib/libbe/libbe.3	Mon Aug 13 03:38:32 2018	(r337696)
+++ head/lib/libbe/libbe.3	Mon Aug 13 03:42:14 2018	(r337697)
@@ -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 w
 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.

Modified: head/sbin/bectl/bectl.8
==============================================================================
--- head/sbin/bectl/bectl.8	Mon Aug 13 03:38:32 2018	(r337696)
+++ head/sbin/bectl/bectl.8	Mon Aug 13 03:42:14 2018	(r337697)
@@ -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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808130342.w7D3gFSh015502>