Commit Graph

48 Commits

Author SHA1 Message Date
Colin Walters 2a9689b76a Update libglnx, port various bits to new API
Using the error prefixing in the delta processing allows us to
do new code style.  Also strip trailing whitespace.

Use error prefixing in a few other random places.  I didn't
hunt for all of them, just testing out the new API.

Use `glnx_fchmod()`.  Also note I dropped one `fchmod (tmpf, 0600)`
which is no longer necessary.

Update submodule: libglnx

Closes: #1011
Approved by: jlebon
2017-07-18 19:18:38 +00:00
Colin Walters d57410a7e6 lib: Add a helper to convert struct stat → GFileInfo
It's more natural for a few calling places. Prep for patches to go the other
way, which in turn are prep for adding a commit filter v2 that takes `struct
stat`.

`ot_gfile_type_for_mode()` was only used in this function, so inline it here.

Closes: #974
Approved by: jlebon
2017-06-29 18:17:28 +00:00
Colin Walters 5776d5dcc0 Port to GLnxTmpfile
There's lots of mechanically replacing `OtTmpFile` with `GLnxTmpfile`;
the biggest changes are in the commit path.  Symlink commits are now
very clearly separated from regular files.  Symlinks are `OtCleanupUnlinkat`,
and regular files are `GLnxTmpfile`.

The commit codepath separates those as `_ostree_repo_commit_path_final()` and
`_ostree_repo_commit_tmpf_final()`. A nice aspect of all of this is that they
both *consume* the temporary on success. This avoids an extra spurious
`unlink()` call.

One of the biggest bits of code motion is in `commit_loose_regfile_object()`,
which no longer needs to care about symlinks. For the most parth though it's
just removing conditionals.

Update submodule: libglnx

Closes: #958
Approved by: jlebon
2017-06-27 22:02:14 +00:00
Colin Walters af3a96755b lib: Use OtTmpFile for static delta processing
The `OstreeRepoContentBareCommit` struct was basically an `OtTmpFile`, so let's
make it one. I moved the "convert to `GOutputStream`" logic into the callers,
since that bit can't fail; it makes the implementation much simpler since we can
just return the result of `ot_open_tmpfile_linkable_at()`.

Prep for `GLnxTmpfile` porting.

Closes: #957
Approved by: jlebon
2017-06-26 17:17:32 +00:00
Colin Walters 612c8a5fa8 lib/repo: More cleanup of load_file() internals
This is followon work from previous cleanups.  Basically
`stat_bare_content_object()` was the `fstatat()` logic
and `ostree_repo_read_bare_fd()` was the `openat()` implementation;
they duplicated some bits to find the object in staging, recurse
into parent etc.

Further, I wanted an internal-only version of this API which didn't allocate
`GFileInfo`/`GInputStream` but used a plain `fd` and `struct stat` to avoid
mallocs.

The end version here I think looks a lot nicer, since we deduplicate the various
`open()` calls in the different cases for example.

Closes: #952
Approved by: jlebon
2017-06-23 18:29:51 +00:00
Alexander Larsson 07dc33ca4a static delta apply: Work on bare-user-only repos
Flatpak make check is failing when applying a static delta
to a bare-user-only repo due to an assert. The fix is to add
bare-user-only to the assert check.

Closes: #940
Approved by: giuseppe
2017-06-19 09:09:17 +00:00
Colin Walters 88a1fc92a9 tree-wide: Add+run spatch to use glnx_throw()
I had to run a sed job to add whitespace after, but otherwise this was easy.

Closes: #890
Approved by: jlebon
2017-05-26 19:27:11 +00:00
Colin Walters 4c8fc92aa0 lib: Always checksum content in deltas
This is a follow up to conversation on list - in practice, if we're
backing away from summary signing, then it makes sense to remove the
special casing for checksums in deltas around summary signatures.

This is also related to the recent change to enable GPG checking for
commits in deltas - now we have a more coherent story between the
previous pull path and deltas.

I didn't do any performance checking, and while it's slightly annoying
that we're now doing sha256 on the delta content twice (once for the
part and once per object)...sha256 is pretty fast, I think most users
are I/O bound anyways, and it'd drop even farther if we started using
openssl.

Closes: #612
Approved by: jlebon
2016-12-06 15:59:35 +00:00
Colin Walters ab0400b722 [ASAN] deltas: Fix minor memory leak
We were leaking the checksum, ensure we free it in both normal and
error paths.

Closes: #598
Approved by: jlebon
2016-11-30 18:51:26 +00:00
Jasper St. Pierre fbce608177 ostree-repo-static-delta-processing: Don't close(-1)
Ultimately harmless, but causes somewhat scary strace messages.

Closes: #591
Approved by: cgwalters
2016-11-22 02:32:33 +00:00
Colin Walters b77edf24a3 tree-wide: Remove unused variables detected by CLang
CLang finds these, whereas GCC treats having
`__attribute__((cleanup))` as a use.

This obsoletes https://github.com/ostreedev/ostree/pull/411

Closes: #548
Approved by: jlebon
2016-10-27 17:02:01 +00:00
Dan Nicholson 512090785e deltas: Allow processing of empty delta parts
If a static delta is generated between 2 commits with the same content,
then the delta will contain 1 part with no checksums. While useless,
this is a valid delta that shouldn't raise an assertion. If the delta
part has no checksums, then there are no objects to recreate and the
processing can be skipped.

Closes: #420
Approved by: cgwalters
2016-07-31 00:01:52 +00:00
Jonathan Lebon 1db0c8dcd6 static-delta: remove unused struct
Closes: #418
Approved by: cgwalters
2016-07-29 16:38:19 +00:00
Colin Walters 6ffcb24d22 deltas: Handle untrusted checksums faster and more robustly
When reworking the ostree core [to use O_TMPFILE](https://github.com/ostreedev/ostree/pull/369),
I hit an issue in the way the untrusted delta codepath ends up trying
to re-open the file to checksum it.  That's not possible with
`O_TMPFILE` since the fd (which we opened `O_WRONLY`) is the only
accessible reference to the content.

Fix this by changing the delta processing code to update a checksum as
we're doing writes, which is also faster, and ends up simplifying the
code as well.

What would be an even larger simplification here is if we e.g. used a
separate thread calling `write_object()` or something like that; the
main issue I see there is somehow bridging the fact that function
wants a `GInputStream*` but the delta code is generating stream of
writes.

Closes: #392
Approved by: jlebon
2016-07-29 16:03:28 +00:00
Mathnerd314 4cb77c51db core: Use OSTREE_SHA256_STRING_LEN instead of 64
Closes: #359
Approved by: cgwalters
2016-06-22 16:10:01 +00:00
Alexander Larsson b4b26907c8 static-delta: Initialize read_source_fd to -1
If not, we'll get ESPIPE when seeking on fd 0.

Closes: #260
Approved by: cgwalters
2016-04-15 11:56:06 +00:00
Colin Walters d456fe5adb libglnx porting: Use glnx_set_error_from_errno
⚠️ There is a notable spiked pit trap here around
`posix_fallocate()` and `errno`.  This has bit other projects,
see e.g.
7bb87460e6

Otherwise the port was straightforward.
2016-03-23 10:26:01 -04:00
Colin Walters 0481389afd lib: Expand `ostree static-delta show` to show part stats
Now we display stats on the individual parts, such as the blob size
and the number of each type of opcode.  Most interesting to me is
things like how many bsdiff opcodes there are vs new objects, etc.
2016-02-08 14:46:13 +01:00
Colin Walters 56fc249d08 lib: Create an internal static delta parsing/opening function
We had code to deal with opening/checksumming/decompressing static
deltas in a few places.  I'd like to teach `ostree static-delta show`
how to display more information, and this will allow it to just use
`_ostree_static_delta_part_open()` too.
2016-02-08 14:46:13 +01:00
Alexander Larsson 78f14555c8 deltas: Verify checksums in apply-offline unless skip_validate is TRUE 2015-11-10 08:56:14 +01:00
Alexander Larsson 7a4fb1b2f1 Add _ostree_repo_open|commit_untrusted_content_bare
Also renames OstreeRepoTrustedContentBareCommit to
OstreeRepoContentBareCommit so that it can be used by both.

This will be needed when we introduce checksum verification of objects
in static deltas.
2015-11-10 08:56:14 +01:00
John Hiesey f2b4a9e107 static-delta: Don't run bspatch when output object already exists
There is already a check that the destination object does not
exist in all other cases when processing an incoming static delta.
However, the bspatch case would still try to run and fail. Add
an analogous check to that case as well.

https://bugzilla.gnome.org/show_bug.cgi?id=756260
2015-10-10 10:31:10 -04:00
Alexander Larsson fd6c572c42 _ostree_static_delta_part_validate: Take a stream instead of a file as arg
This is only called in one place, and we have already opened the file there,
no need to open it twice.
2015-09-13 22:25:21 -04:00
Matthew Barnes c2c322efa9 Use g_autoptr(GVariant) instead of gs_unref_variant 2015-05-06 22:07:10 -04:00
Matthew Barnes e6556dd223 Use g_autoptr(GBytes) instead of gs_unref_bytes 2015-05-06 22:07:10 -04:00
Matthew Barnes 4ee1acd981 Use g_autoptr() for GIO object types
GLib 2.44 supplies all the necessary autocleanup macros for GIO types,
and libglnx backports the relevant macros for ostree.
2015-05-06 21:51:19 -04:00
Matthew Barnes 7a62d64968 Use g_autofree instead of gs_free 2015-05-06 21:50:17 -04:00
Giuseppe Scrivano cf30f8717a g_output_stream_splice: check correctly the error code
While at it, change the style of other two occurrences.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-04-24 18:26:22 +02:00
Colin Walters 67cec3a4de deltas: Use mmap() instead of copying input file
It's more efficient.
2015-03-03 18:39:45 -05:00
Giuseppe Scrivano 3f3bb8e37d Add bsdiff support to deltas
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-03-03 12:16:17 -05:00
Matthew Barnes b05d670031 libotutil: Remove ot_variant_new_from_bytes()
Not needed anymore - use g_variant_new_from_bytes().
2015-03-02 15:12:06 -05:00
Giuseppe Scrivano 22af1d9633 ostree-repo-static-delta-processing: initialize "modev"
Can be gs_unref_variant'ed on an early error.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-02-23 16:41:42 -05:00
Colin Walters 9aa7e30b38 deltas: Implement rollsums
This does an rsync-style prepared delta basically.  On my test data,
it shaves ~6MB of uncompressed data.  Not a huge amount, but I expect
this to be more useful for things like binaries which embed data, etc.
2015-02-16 10:10:35 -05:00
Colin Walters 345754a564 deltas: Initial code to copy content from existing objects
This is preparatory work for implementing rollsum support.
2015-02-16 10:10:35 -05:00
Colin Walters 7900c82a36 deltas: Flesh out the open/write/close opcodes
Refactor open-splice-and-close to call open/close.  We can't just call
write as that would require duplicating the object size parameter.
2015-02-16 10:10:35 -05:00
Colin Walters 96181da26a deltas: Use the new internal streaming APIs
This is significantly more efficient.
2015-02-16 10:10:35 -05:00
Colin Walters 7aea18cf0d deltas: Stub out a few more opcodes 2015-02-16 10:10:35 -05:00
Colin Walters d749932f6b deltas: Rework format to allow streaming
There's still some silliness here, but there is now only one opcode
open-splice-and-close, that writes a single chunk from the payload.
This is really all we need for metadata, and small content objects are
also fine with this.

We get some deduplication between content objects by creating a
dictionary for (uid,gid,mode) tuples and xattrs.

This still keeps the operation/payload code in, so we could do
rollsums in a future update easily.
2015-02-16 10:10:35 -05:00
Colin Walters 513d47a90c deltas: Add _V0 to part #define
To make more explicitly clear that this is the version that matches
the version in the metadata.
2015-02-16 10:10:35 -05:00
Colin Walters 3c2a36eab0 deltas: Remove support for gzipped delta parts
XZ is really, really good.
2015-02-16 10:10:35 -05:00
Colin Walters 8195fd18e2 deltas: Use trusted writes
We have a chain of checksums from the root up until here.  While doing
checksums of the objects individually would be a good redundancy check
for test cases and the like, when doing a pull there's no good reason
to burn cycles on SHA256.
2015-01-20 23:28:26 -05:00
Colin Walters 6d1de23f87 deltas: Drop async content writes
This caused deadlocks and/or EMFILE due to the interaction between
threads and fds.  What we really want here is a better pull-based
model for parsing content objects.

Another idea would be to change static deltas so that content objects
have a special opcode that includes their metadata first, and then do
rollsums etc. only over actual content.
2015-01-20 23:21:26 -05:00
Colin Walters d49fc876bb deltas: Unlink temporary metadata files before processing
Leaking them is bad.
2015-01-20 23:16:30 -05:00
Giuseppe Scrivano 4991e9ab6a static-delta: limit the number of writes in process to 1
This will avoid too many open files at the same time that could cause
an EMFILE error.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
(cherry picked from commit bc092b06f0e34e93f7d6102957bf55fd7ffd1b9e)
2015-01-20 09:51:02 -05:00
Colin Walters 2f9567ad56 deltas: Use *at() for writes
Yet another GFile* user goes away in a performance sensitive path.
2015-01-14 22:29:45 -05:00
Colin Walters 92c338de74 deltas: (trivial) delete some debugging prints
They create too much noise.
2015-01-14 11:38:10 -05:00
Colin Walters ca678224be Static deltas support
https://bugzilla.gnome.org/show_bug.cgi?id=721799
2014-12-18 12:48:47 +01:00
Colin Walters 2d6374822b Initial basic static delta code drop
This has a very basic level of functionality (deltas can be generated,
and applied offline).  There is only some stubbed out pull code to
fetch them via HTTP.

But, better to commit this now and improve it from a known starting
point, rather than have it languish in a branch.
2014-02-04 10:31:44 -05:00