diff --git a/lib/libbe/be.c b/lib/libbe/be.c --- a/lib/libbe/be.c +++ b/lib/libbe/be.c @@ -1266,6 +1266,23 @@ return (0); } +static int +be_zfs_promote_cb(zfs_handle_t *zhp, void *data __unused) +{ + int err; + + if ((err = zfs_promote(zhp)) != 0) + return (err); + + return (zfs_iter_filesystems(zhp, be_zfs_promote_cb, NULL)); +} + +static int +be_zfs_promote(zfs_handle_t *zhp) +{ + return (be_zfs_promote_cb(zhp, NULL)); +} + int be_activate(libbe_handle_t *lbh, const char *bootenv, bool temporary) { @@ -1303,13 +1320,12 @@ break; } - err = zfs_promote(zhp); + err = be_zfs_promote(zhp); zfs_close(zhp); if (err) break; } - 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) }