Skip to content
Snippets Groups Projects
Commit 3a4d0f46 authored by Colin Walters's avatar Colin Walters
Browse files

fdio: Expose glnx_regfile_copy_bytes(), rewrite: GNU style, POSIX errno

NOTE: This changes the error handling API of `glnx_loop_write()` to be
"old school POSIX" instead of "systemd".

In ostree in a few places we use `g_output_stream_splice()`.  I
thought this would use `splice()`, but actually it doesn't today.

They also, if a cancellable is provided, end up dropping into `poll()` for every
read and write. (In addition to copying data to/from userspace).

My opinion on this is - for *local files* that's dumb. In the big picture, you
really only need cancellation when copying gigabytes. Down the line, we could
perhaps add a `glnx_copy_bytes_cancellable()` that only did that check e.g.
every gigabyte of copied data. And when we do that we should use
`g_cancellable_set_error_if_cancelled()` rather than a `poll()` with the regular
file FD, since regular files are *always* readable and writable.

For my use case with rpm-ostree though, we don't have gigabyte sized files, and
seeing all of the `poll()` calls in strace is annoying. So let's have the
non-cancellable file copying API that's modern and uses both reflink and
`sendfile()` if available, in that order.

My plan at some point once this is tested more is to migrate this code
into GLib.

Note that in order to keep our APIs consistent, I switched the systemd-imported
code to "old school POSIX" error conventions. Otherwise we'd have *3* (POSIX,
systemd, and GError) and particularly given the first two are easily confused,
it'd be a recipe for bugs.
parent dc1956b2
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment