Page MenuHomeFreeBSD

D40972.diff
No OneTemporary

D40972.diff

diff --git a/lib/libbe/be.c b/lib/libbe/be.c
--- a/lib/libbe/be.c
+++ b/lib/libbe/be.c
@@ -1266,12 +1266,38 @@
return (0);
}
+static int
+be_zfs_promote_cb(zfs_handle_t *zhp, void *data)
+{
+ char origin[BE_MAXPATHLEN];
+ bool *found_origin = (bool *)data;
+ int err;
+
+ if (zfs_prop_get(zhp, ZFS_PROP_ORIGIN, origin, sizeof(origin),
+ NULL, NULL, 0, true) == 0) {
+ *found_origin = true;
+ err = zfs_promote(zhp);
+ if (err)
+ return (err);
+ }
+
+ return (zfs_iter_filesystems(zhp, be_zfs_promote_cb, data));
+}
+
+static int
+be_zfs_promote(zfs_handle_t *zhp, bool *found_origin)
+{
+ *found_origin = false;
+ return (be_zfs_promote_cb(zhp, (void *)found_origin));
+}
+
int
be_activate(libbe_handle_t *lbh, const char *bootenv, bool temporary)
{
- char be_path[BE_MAXPATHLEN], origin[BE_MAXPATHLEN];
+ char be_path[BE_MAXPATHLEN];
zfs_handle_t *zhp;
int err;
+ bool found_origin;
be_root_concat(lbh, bootenv, be_path);
@@ -1297,19 +1323,15 @@
if (zhp == NULL)
return (-1);
- if (zfs_prop_get(zhp, ZFS_PROP_ORIGIN, origin, sizeof(origin),
- NULL, NULL, 0, 1) != 0) {
- zfs_close(zhp);
- break;
- }
+ err = be_zfs_promote(zhp, &found_origin);
- err = zfs_promote(zhp);
zfs_close(zhp);
- if (err)
+ if (!found_origin)
break;
+ if (err)
+ return (err);
}
-
if (err)
return (-1);
}
diff --git a/sbin/bectl/tests/bectl_test.sh b/sbin/bectl/tests/bectl_test.sh
--- a/sbin/bectl/tests/bectl_test.sh
+++ b/sbin/bectl/tests/bectl_test.sh
@@ -528,7 +528,6 @@
atf_test_case bectl_promotion cleanup
bectl_promotion_head()
{
-
atf_set "descr" "Check bectl promotion upon activation"
atf_set "require.user" root
}
@@ -550,7 +549,7 @@
mount=${cwd}/mnt
root=${mount}/root
- bectl_create_setup ${zpool} ${disk} ${mount}
+ bectl_create_deep_setup ${zpool} ${disk} ${mount}
atf_check mkdir -p ${root}
# Sleeps interspersed to workaround some naming quirks; notably,
@@ -560,23 +559,22 @@
# with the same name, and the promotion will fail.
atf_check bectl -r ${zpool}/ROOT rename default A
sleep 1
- atf_check bectl -r ${zpool}/ROOT create -e A B
+ atf_check bectl -r ${zpool}/ROOT create -r -e A B
sleep 1
- atf_check bectl -r ${zpool}/ROOT create -e B C
+ atf_check bectl -r ${zpool}/ROOT create -r -e B C
# C should be a clone of B to start with
- atf_check -o not-inline:"-" zfs list -H -o origin ${zpool}/ROOT/C
+ atf_check -o not-inline:"-" zfs list -Hr -o origin ${zpool}/ROOT/C
# Activating it should then promote it all the way out of clone-hood.
# This entails two promotes internally, as the first would promote it to
# a snapshot of A before finally promoting it the second time out of
# clone status.
atf_check -o not-empty bectl -r ${zpool}/ROOT activate C
- atf_check -o inline:"-\n" zfs list -H -o origin ${zpool}/ROOT/C
+ atf_check -o inline:"-\n-\n" zfs list -Hr -o origin ${zpool}/ROOT/C
}
bectl_promotion_cleanup()
{
-
bectl_cleanup $(get_zpool_name)
}

File Metadata

Mime Type
text/plain
Expires
Tue, Jan 27, 9:43 PM (18 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28060513
Default Alt Text
D40972.diff (2 KB)

Event Timeline