From nobody Mon Jul 17 19:08:53 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4R4WpF46XKz4n2Qt; Mon, 17 Jul 2023 19:08:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4R4WpF3cWgz3r1G; Mon, 17 Jul 2023 19:08:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689620933; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=D4P3i5F8eIjmWmJHphUpnx/p1Obqhkq4/eJKEe4WRk4=; b=Ipf5WNhpgacUkqWjQtvKD5v5Q7Qsw1IRd3rkYNfDE6Vgbe+vJXY3ZIrDJJ4S4e6DL/0rrZ 8bUzIH0GsXh8lLvgzcBnmo+WdbJQbf+c5VvhCNBTIeUGF1GWSMz6t+VSvwGiXgNhhv+eX/ PN00Q/cOv3TstOW2qfw6GW9xRZnpOBZV0va69SsNxFWUJIeMCe8KbTtEQcufjQpuUS7u8i JR6i0QF+HMD14VKy/ITF1XgXNmxdM0Zb8QP7XC93cbR0Jgj7mBs5bXKniCISgodPo3Lfja /WfSkTaUh70hIkEsmAov7PxramFOpd5Za8lmveW4cCnhWq8WPlf5HzKAKcwf+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689620933; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=D4P3i5F8eIjmWmJHphUpnx/p1Obqhkq4/eJKEe4WRk4=; b=gfoY4FFLIuWC3/pEfltgrWIgaxpPN5c5XzZ623jri3bhNjC+pDftPD+rPxY0e1GQIcGXdt BoYklnyN9HRezVCuLc33AutRpM5Vb400S8Rz7zxIAaarwF9hNThVE2pk0FRvIvpWcSh12y bItDkY/BP03SK4QXeBx0uurPOjosW0J5sTz8chFR2kEXbVKrzxIhAKLKxtoLlKfvIg6xGY EjtxXcJXMpnAh4Ctfp7KDZLUsBrecOQgdFQrAuX2fwMEsBXesf7R+mK/yaGGcGc/mTU+1G GB82qIDkM6r5On23BzOft97qAsnpeQ9yMUGFcsxcqncSa9gXUZ2XAVtZvgct6g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1689620933; a=rsa-sha256; cv=none; b=t8Oa794HlVOumCi/r6Vod2J0ShVKoedq+zA6V8MnRvuhcSK5v+ui/K25/MVitLsr4LGeaK 8IiJbGOmkB32LZcEQhivy/bcVix/CvlSbuMEedhoXB9gPZP5faP8tPrGQEZRJ/UQMzQoZF BFT0XjkG+W5Sy8ir3EqcNyP6xDcJxnZd25BzAleTOSze2GBjeLVO4/C4ij9DqG1uru2fgx 5W0jreCbMO9Sdntf9x4DO/HTuZWhzOi2L+1UxjmCgUBCsE5w14JQalfQNE5136f4+qqFhP K4jMz3xHuOLECzW9JicR1ziSGqSBJEoyByWaopaFbowFqRRBOxN1QHyeBMFXvQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4R4WpF2hmFzZxX; Mon, 17 Jul 2023 19:08:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 36HJ8rpx014213; Mon, 17 Jul 2023 19:08:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36HJ8rdL014212; Mon, 17 Jul 2023 19:08:53 GMT (envelope-from git) Date: Mon, 17 Jul 2023 19:08:53 GMT Message-Id: <202307171908.36HJ8rdL014212@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 4b426cf3a46a - main - libbe: recursively promote deep BE datasets List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4b426cf3a46a429474e2a138d3360acc23411563 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=4b426cf3a46a429474e2a138d3360acc23411563 commit 4b426cf3a46a429474e2a138d3360acc23411563 Author: R. Christian McDonald AuthorDate: 2023-07-17 19:06:28 +0000 Commit: Kyle Evans CommitDate: 2023-07-17 19:08:32 +0000 libbe: recursively promote deep BE datasets beadm will recursively promote deep BE datasets. In order to match the beadm behavior, we need to recursively iterate over child filesystems and promote them along the way. This patch further refines the work from D40903, completing the fix for promotion. Reviewed by: kevans, rew Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D40972 --- lib/libbe/be.c | 40 +++++++++++++++++++++++++++++++--------- sbin/bectl/tests/bectl_test.sh | 12 +++++------- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/lib/libbe/be.c b/lib/libbe/be.c index 31836c623c4a..e607ab12215b 100644 --- a/lib/libbe/be.c +++ b/lib/libbe/be.c @@ -1266,12 +1266,38 @@ be_deactivate(libbe_handle_t *lbh, const char *ds, bool temporary) 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 @@ be_activate(libbe_handle_t *lbh, const char *bootenv, bool temporary) 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 index 7ca7af8a1abf..75884029d93e 100755 --- a/sbin/bectl/tests/bectl_test.sh +++ b/sbin/bectl/tests/bectl_test.sh @@ -528,7 +528,6 @@ bectl_jail_cleanup() 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 @@ bectl_promotion_body() 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 @@ bectl_promotion_body() # 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) }