From f976337ad91e7232287bf3bc0e038987a11a8949 Mon Sep 17 00:00:00 2001 From: Andy Fiddaman Date: Thu, 14 Jan 2021 14:15:19 +0000 Subject: 13451 beadm needs to do more with temporary BE activation Reviewed by: C Fraire Reviewed by: Toomas Soome Reviewed by: Yuri Pankov Approved by: Gordon Ross --- usr/src/lib/libbe/common/be_create.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'usr/src/lib/libbe/common/be_create.c') diff --git a/usr/src/lib/libbe/common/be_create.c b/usr/src/lib/libbe/common/be_create.c index 4c69ac38f6..4158ddb677 100644 --- a/usr/src/lib/libbe/common/be_create.c +++ b/usr/src/lib/libbe/common/be_create.c @@ -24,7 +24,7 @@ * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2014, 2015 by Delphix. All rights reserved. * Copyright (c) 2016 Martin Matuska. All rights reserved. - * Copyright 2019 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2021 OmniOS Community Edition (OmniOSce) Association. */ /* @@ -50,6 +50,7 @@ #include #include +#include /* Library wide variables */ libzfs_handle_t *g_zfs = NULL; @@ -472,6 +473,28 @@ be_destroy(nvlist_t *be_attrs) } } + /* + * Detect if the BE to destroy is referenced in the pool's nextboot + * field, and unset it if so. + */ + if (getzoneid() == GLOBAL_ZONEID) { + char *nextboot = NULL; + + if (lzbe_get_boot_device(bt.obe_zpool, &nextboot) == 0 && + nextboot != NULL && strcmp(nextboot, bt.obe_root_ds) == 0) { + if (lzbe_set_boot_device(bt.obe_zpool, + lzbe_add, "") != 0) { + be_print_err(gettext("be_destroy: failed to " + "remove temporary activation for " + "dataset %s on pool %s\n"), + bt.obe_root_ds, bt.obe_zpool); + free(nextboot); + return (BE_ERR_UNKNOWN); + } + } + free(nextboot); + } + /* Get handle to BE's root dataset */ if ((zhp = zfs_open(g_zfs, bt.obe_root_ds, ZFS_TYPE_FILESYSTEM)) == NULL) { -- cgit v1.2.3