Commit Graph

59 Commits

Author SHA1 Message Date
Colin Walters 24ac4ff190 deltas: Only keep one file open at a time during compilation
Otherwise it's possible for us to exhaust available file descriptors
or (on 32 bit) run up against mmap limits.

In the rollsum case, we didn't need to hold open the "from" object
at all.  And in the bsdiff case, we weren't even looking at either of
the files until we started processing.

Also, while we have the patient open, switch to using O_TMPFILE
if available.

Closes: #567
Approved by: giuseppe
2016-11-07 11:17:59 +00:00
Colin Walters 7f2960db43 Define an initializer for GVariant{Builder,Dict}
So we build warning-free on GLib (< 2.50, >= 2.50).  This
is a band aid until we hard-require >= 2.50.

Closes: #547
Approved by: jlebon
2016-10-27 18:49:15 +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
Colin Walters 23b4b58d57 delta: Unreference files we've processed
This should help avoid address space exhaustion on 32 bit systems,
and in general is obviously going to improve efficiency.

Closes: #498
Approved by: alexlarsson
2016-09-08 15:21:41 +00:00
Colin Walters 8dbb104cdc delta: Add missing `goto out` for failure to mmap()
This was hit in practice when generating a delta for a flatpak app on ARM
it looks like.

Closes: #497
Approved by: alexlarsson
2016-09-08 14:34:04 +00:00
Dan Nicholson c3c07a2d49 deltas: Use F_DUPFD_CLOEXEC properly
You need to supply an argument to F_DUPFD_CLOEXEC or fcntl will return
EINVAL. Use 3 as the minimum fd number as is standard.

Closes: #454

Closes: #448
Approved by: cgwalters
2016-08-10 10:54:46 +00:00
Dan Nicholson 1e5ff71c49 deltas: Handle cleanup of fd array properly
If there's an early error, part_temp_fds will be NULL and dereferencing
the len member will segfault.

Closes: #454

Closes: #448
Approved by: cgwalters
2016-08-10 10:54:46 +00:00
Colin Walters cfd402e5f7 lib: Fix a compiler warning introduced from earlier patch
I think we'd end up closing stdin...yuck.  Need to investigate
having this be fatal, but CentOS 7 `gcc-4.8.5` doesn't understand
`-Werror=int-conversion`.

Closes: #430
Approved by: giuseppe
2016-08-05 07:38:09 +00:00
Colin Walters f66906c401 deltas: Port compilation to libglnx/fd-relative
This was the last use of libgsystem tmpfile APIs.  The change here is
a bit uglier than it needs to be because we support creating the delta
in place as well as in the repo, so we needed to abstract over
locations.

Closes: #424
Approved by: giuseppe
2016-08-03 08:10:27 +00:00
Colin Walters 6e57987c7c libglnx porting: Port away from gs_file_ensure_directory()
The init-fs code in particular gets (IMO) a lot cleaner being fd
relative.

Closes: #312
Approved by: giuseppe
2016-05-30 11:33:28 +00:00
Krzesimir Nowak cb45456708 libostree: Fix bracket-missing warnings
Apparently I got the bracketing wrong in
862e6ecdcc58f025696b1394adfc0fcf7322df23:

src/libostree/ostree-repo.c: In function 'ostree_repo_delete_object':
src/libostree/ostree-repo.c:3538:11: warning: missing braces around
initializer [-Wmissing-braces]
           g_auto(GVariantBuilder) builder = {0,};

Closes: #298
Approved by: cgwalters
2016-05-13 12:22:59 +00:00
Krzesimir Nowak 862e6ecdcc libostree: Variant-related leak plugs and fixes
This tries to avoid leaking GVariantBuilders and GVariants in some
situations. The leaks were usually happening when some error occurred
or because of unclear variant ownership situation.

The former is mostly about making sure that g_variant_builder_clear is
called on builders that didn't finish their variant building process.

The latter is surely more work - sometimes the result of
g_variant_builder_end() should not be passed directly to a function,
but rather stored in a g_autoptr(GVariant), sunk and then passed to a
function. IMO, with an advent of g_autoptr, GVariants should be always
sunk instead of relying on some receiver function sinking it. This
would make an easy-to-follow policy of always sinking your
variants. Functions could then assume that the passed variant is
already sunk. These leaks are still happenning in commands, but they
are less harmful, since that code will not be used by some daemon as a
library routine.

Closes: #291
Approved by: cgwalters
2016-05-12 11:17:09 +00:00
Krzesimir Nowak 925faca108 lib: Fix a typo
Closes: #267
Approved by: cgwalters
2016-04-19 12:16:16 +00:00
Alexander Larsson a08b7765b7 static-delta: Put temp files in /var/tmp
We may not have write permissions in the current directory.

Closes: #259
Approved by: cgwalters
2016-04-14 20:49:32 +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 c58ad36840 libglnx porting: gs_transfer_out_value -> g_steal_pointer
It's a bit more verbose but...eh.
2016-03-18 12:08:19 -04:00
Colin Walters ac4c298061 libglnx porting: gs_fd_close -> glnx_fd_close
I'd like to eventually kill libgsystem.
2016-03-18 12:08:19 -04:00
Colin Walters 04d77da005 deltas: Use endianness marker when parsing
Extend the `static-delta show` and `pull` commands to use the
endianness information (if available).
2016-02-26 08:19:01 -05:00
Colin Walters 277220aaa6 deltas: Include an endianness marker
We screwed up and had delta integers use host endianness.  Start
digging out by at least annotating the endianness.

https://bugzilla.gnome.org/show_bug.cgi?id=762515
2016-02-26 08:19:01 -05:00
Colin Walters fa9e547e09 lib: Add a #define OSTREE_SHA256_DIGEST_LEN 32
And use it internally.  This way it's a bit less magical.
2016-01-28 15:24:16 -05:00
Alexander Larsson 1c056eb282 deltas: Support including detached metadata in static deltas
This is very useful for the inline-parts case, as you can then include
detached signatures in a single file representing the commit.

It is not as important for the generic pull case, as the detached
metadata is only a single small file. Additionally the detached
metadata is not content referenced and may change after the static
delta file was created, so we need to pull the latest version anyway.
2015-11-10 08:56:16 +01:00
Alexander Larsson dac57b6410 deltas: Support passing filename to delta generator 2015-11-10 08:56:15 +01:00
Alexander Larsson b22b859dc5 deltas: Make min-fallback-size 0 actually disable fallbacks
This is what the docs specify.
2015-11-10 08:56:14 +01:00
Alexander Larsson 11a79220e2 static deltas: Add support for inline-parts
In this mode the parts are stored in the metadata of the main delta
superblock file.  This can be useful if you want a single-file delta
for easy transport, or for http in the case the delta is very small.
2015-11-10 08:56:12 +01:00
Alexander Larsson 30768a979f generate-static-delta: Support min-fallback-size 0 to disable fallbacks 2015-11-10 08:56:12 +01:00
John Hiesey 60e5529ba0 static-delta: Set error on bsdiff failure
bsdiff can fail when generating static deltas, particularly if
not enough memory is available. Set error properly when this happens.

https://bugzilla.gnome.org/show_bug.cgi?id=756260
2015-10-10 10:38:01 -04:00
John Hiesey 153f092d51 static-delta: assert on non-regular files
Now that the computed similar objects are all regular files,
get_unpacked_unlinked_content should never be called on any other
object type. Assert that this is true instead of silently succeeding.
2015-08-26 16:25:28 -04:00
Giuseppe Scrivano b7063ed1ae static-delta: add max-bsdiff-size option
It allows to specify the maximum size for input files to attempt
bsdiff compression for.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-07-28 13:02:27 +02:00
Giuseppe Scrivano cac92f62c4 static-delta: do not fail compilation with big files
Just skip the bsdiff compression instead of failing the operation.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-07-28 12:28:25 +02:00
John Hiesey 06fc597762 Fix tests on 32 bit systems
Use guint64 when the 't' format is used for GVariant
2015-06-04 17:58:12 -04:00
Matthew Barnes cca69b3f55 Use g_autoptr(GVariantBuilder) instead of gs_unref_variant_builder 2015-05-06 22:07:11 -04:00
Matthew Barnes c2c322efa9 Use g_autoptr(GVariant) instead of gs_unref_variant 2015-05-06 22:07:10 -04:00
Matthew Barnes bb231fdf74 Use g_autoptr(GPtrArray) instead of gs_unref_ptrarray 2015-05-06 22:07:10 -04:00
Matthew Barnes 196d983af9 Use g_autoptr(GHashTable) instead of gs_unref_hashtable 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 3f044267b5 Use g_autoptr(GChecksum) instead of gs_free_checksum 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
Giuseppe Scrivano 150048f9b8 src: drop some dead assignments
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-03-06 18:45:37 +01:00
Colin Walters 3e3eb01335 deltas: Gather statistics on total number rollsum'd and bsdiff'd
Useful for debugging at least.  Though in the future it'd be nice to
store this inside the delta metadata maybe?
2015-03-03 18:32:24 -05:00
Giuseppe Scrivano 948327fb67 ostree_repo_static_delta_generate: add new param "verbose"
it will be used by the next patch that adds "--generate-static-delta"
to the commit command.

As part of the patch, update the list of supported "params" in the
documentation.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-03-03 12:16:17 -05:00
Colin Walters 392929d9bc static-delta: Add --disable-bsdiff option
A builder may not want to pay the CPU penalty.  Also it's useful for
evaluating performance.
2015-03-03 12:16:17 -05:00
Giuseppe Scrivano 439e1c1b97 static-delta: increase threshold for rollsum to 50%
It favours bsdiff usage for files that are not very rollsum friendly.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-03-03 12:16:17 -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
Colin Walters c54df89771 deltas: Search for similar objects (possibly renamed across directories)
The previous diff algorithm was file tree based, and only looked
at modified files that lived at the same path.

However, components like the Linux kernel have versioned
subdirectories, e.g. /usr/lib/modules/$kver/.../ext4.ko.  We want to
be able to detect these "modified renames" so that we can compute
diffs (rollsum, bsdiff).
2015-02-16 10:10:35 -05:00
Colin Walters 08476ce254 deltas: Prune deltas when the corresponding "to" commit vanishes
We want prune to actually give you back disk space when using deltas.
2015-02-16 10:10:35 -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 8fb29c9e5d deltas: Print total size of rollsums we would use 2015-02-16 10:10:35 -05:00
Colin Walters 3df8be0d92 deltas: Compute rollsum targets 2015-02-16 10:10:35 -05:00