From 93e47f88f486e5df1030066d0120b0db034ca6c8 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Mon, 15 Aug 2022 13:54:35 -0400 Subject: [PATCH 1/2] lib/commit: Directly use FICLONE for payload link The idea of payload linking is to reflink between objects where possible. Instead of relying on `glnx_regfile_copy_bytes` to hit the `FICLONE` path, just call `FICLONE` directly. At that point in the code, we've already established that the source and dest repos are on the same filesystem and that it supports `FICLONE`. Related: https://gitlab.gnome.org/GNOME/libglnx/-/merge_requests/41 Related: https://github.com/ostreedev/ostree/pull/2684#issuecomment-1204068437 --- src/libostree/ostree-repo-commit.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/libostree/ostree-repo-commit.c b/src/libostree/ostree-repo-commit.c index 35b16c71..6cfdc32b 100644 --- a/src/libostree/ostree-repo-commit.c +++ b/src/libostree/ostree-repo-commit.c @@ -881,11 +881,8 @@ _try_clone_from_payload_link (OstreeRepo *self, else { /* This undoes all of the previous writes; we want to generate reflinked data. */ - if (ftruncate (tmpf->fd, 0) < 0) - return glnx_throw_errno_prefix (error, "ftruncate"); - - if (glnx_regfile_copy_bytes (fdf, tmpf->fd, -1) < 0) - return glnx_throw_errno_prefix (error, "regfile copy"); + if (ioctl (tmpf->fd, FICLONE, fdf) < 0) + return glnx_throw_errno_prefix (error, "FICLONE"); return TRUE; } From 84670a007061196249cde89e31b36b5b37478e61 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Mon, 15 Aug 2022 17:50:11 -0400 Subject: [PATCH 2/2] tests/kolainst/staged-deploy: parse `rpm-ostree status --json` instead Don't parse `rpm-ostree status` output, it's not meant for that. Use `--json` output instead. While we're here, fix an obsolete reference to Ansible. Related: https://github.com/coreos/rpm-ostree/pull/3938 --- tests/kolainst/destructive/staged-deploy.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/kolainst/destructive/staged-deploy.sh b/tests/kolainst/destructive/staged-deploy.sh index af31078a..c923605f 100755 --- a/tests/kolainst/destructive/staged-deploy.sh +++ b/tests/kolainst/destructive/staged-deploy.sh @@ -100,8 +100,7 @@ EOF newcommit=$(ostree rev-parse staged-deploy) ostree admin upgrade --stage >out.txt test -f /run/ostree/staged-deployment - # Debating bouncing back out to Ansible for this - firstdeploycommit=$(rpm-ostree status |grep 'Commit:' |head -1|sed -e 's,^ *Commit: *,,') + firstdeploycommit=$(rpm-ostree status --json | jq -r .deployments[0].checksum) assert_streq "${firstdeploycommit}" "${newcommit}" # Cleanup rpm-ostree cleanup -rp