From owner-svn-src-head@freebsd.org Mon Aug 13 03:42:16 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 10A271063F2B; Mon, 13 Aug 2018 03:42:16 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B6486872A8; Mon, 13 Aug 2018 03:42:15 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7DA352F3E6; Mon, 13 Aug 2018 03:42:15 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w7D3gFj3015505; Mon, 13 Aug 2018 03:42:15 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w7D3gFSh015502; Mon, 13 Aug 2018 03:42:15 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201808130342.w7D3gFSh015502@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 13 Aug 2018 03:42:14 +0000 (UTC) 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 X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in head: lib/libbe sbin/bectl X-SVN-Commit-Revision: 337697 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Aug 2018 03:42:16 -0000 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.