Commit Graph

462 Commits

Author SHA1 Message Date
nick
1afea5c73d proxy: Respect the REQUEST_MASK 2013-06-19 11:18:22 +01:00
nick
62bdad2a6e ioutil: Add a bit more debug output to iobuf_read/write 2013-06-19 11:17:46 +01:00
nick
cd0a1f905f proxy: The minor optimisation bugs if needle is not advanced on iobuf_read() 2013-06-19 11:16:35 +01:00
nick
2156d06368 proxy: DRY up some code 2013-06-18 16:58:39 +01:00
nick
b14bba36ec proxy: Set proxy->upstream_fd before calling proxy_finish_connect_to_upstream
The only thing this affects is a log message
2013-06-18 15:58:38 +01:00
nick
f5c434f21c proxy: Initial move to event-loop proxy model.
Building with -DPREFETCH is currently broken, I'm sure, but otherwise
this version seems to be feature-complete compared to the previous one,
albeit wordier. Upcoming: cleanups
2013-06-18 15:37:39 +01:00
nick
662b9c2d07 readwrite: Expose a couple of points of functionality 2013-06-18 15:36:15 +01:00
nick
197c1131bf tests: Tell us which offset fails 2013-06-18 15:35:24 +01:00
nick
cecf2ebc77 proxy: log details of a request that fails upstream at the warn level 2013-06-07 12:12:12 +01:00
nick
f7e5353355 serve: Add a killswitch that causes the server to uncleanly exit on hang
We define a hang as 120 seconds for now; that should be OK (famous last words).
When I say unclean, I mean it; the control socket is left hanging around too.

This is a workaround for the fact that the client can hang the whole server by
sending a write request header specifying > 0 bytes, then uncleanly going away.
On the server side, we acquire the IO mutex, and then try to read > 0 bytes from
the socket; the data never arrives, and when the client reconnects, its requests
never get a response (since we're waiting on that mutex). Getting rid of that
mutex (which isn't actually needed, except for migration) would be better.
2013-06-06 14:16:20 +01:00
nick
f9fe421472 proxy: Some logging cleanups
New scheme:

Individual requests and extra information about stuff are debug
Lifecycle events are now info.
Problems doing anything are warn.
2013-06-06 12:24:28 +01:00
nick
1b6c10926f docs: Fix the documentation for the loglevel timestamps
We're actually using the system monotonic clock.
2013-06-06 12:23:14 +01:00
nick
24858fcde5 logging: Add a timestamp to the log messages we emit 2013-06-06 11:57:05 +01:00
nick
26c7f1b1c4 mirror: munmap() our range on cleanup 2013-05-30 11:09:24 +01:00
nick
055836c8cb mirror: Don't undo the MADV_SEQUENTIAL hinting over the course of a migration 2013-05-30 11:06:15 +01:00
nick
76cf2dc7b9 mirror: Only say we're unlinking the file if we actually are 2013-05-30 11:05:26 +01:00
nick
a5a7d45355 flexnbd: Add more madvise() hints, both for mirroring out and normal operation.
This is hopefully going to reduce flexnbd rss
2013-05-28 14:16:49 +01:00
Alex Young
e548cc53c8 Formatting fixup 2013-05-01 11:02:46 +01:00
nick
151b739e8d Automated merge with ssh://dev/flexnbd-c 2013-04-30 15:50:09 +01:00
nick
d9b3aab972 flexnbd: Pass MS_INVALIDATE to our msync calls
It's not necessary on Linux, but may be needed elsewhere
2013-04-30 11:04:17 +01:00
Alex Young
574d44f17f Add a trivial read buffer to flexnbd-proxy.
Since the vast majority (something like 94% on boot) are sequential small
reads, and since network latency is a major factor in determining how fast the
exposed device appears to the client, it makes sense for us to try to minimise
the number of network requests where we safely can.

This patch implements the simplest possible read cache in flexnbd-proxy.  When
it receives a read request, if it's a small request then flexnbd-proxy will
double the length of data requested.  On receiving the data from the upstream
server, flexnbd-proxy will return the first half to the downstream as normal,
and stash the second half in a buffer.  If the very next request is a read, and
the offset and length match those of what we have stored, that second request
will be satisfied from the buffer without going out over the network.

The cache is invalidated by any non-read request, or by a disconnection.
2013-04-29 14:50:42 +01:00
nick
33ee19dc5a flexnbd-proxy: Add UNIX socket support for the listen address 2013-04-15 16:52:54 +01:00
nick
4e70db8d7f readwrite.c: Set TCP_NODELAY on our NBD client sockets 2013-04-15 15:13:44 +01:00
nick
6984d3709e flexnbd: Don't bind() unless a bind address is specified 2013-04-09 11:47:32 +01:00
nick
2bb8434128 sockutil: Make sockaddr_address_string conform to its comment 2013-03-19 14:47:50 +00:00
nick
e994b80756 proxy: Switch to blocking I/O with signal handlers to exit.
It's safe to terminate the proxy at any point in its lifecycle, so
there's no point using signalfd() (and the associated select() +
non-blocking I/O gubbins) in it. We might want to use non-blocking
I/O in the future for other reasons, of course, at which point it
might become sensible to use signalfd() again. For now, this makes
us reliably responsive to TERM,INT and QUIT in a way that we weren't
previously.
2013-03-19 14:39:04 +00:00
nick
5257e93cb7 flexnbd: Split the proxy mode out into its own binary.
"flexnbd-proxy ..." should be identical in operation to "flexnbd proxy ..."
2013-03-19 13:13:37 +00:00
nick
21ac3cd0ed proxy: Deal with close() failures (and EINTR errnos) comprehensively 2013-03-15 12:07:16 +00:00
nick
f89352aa28 Add an explanatory comment in sock_try_connect() 2013-02-28 12:14:07 +00:00
nick
1d9f055dc7 Turn a couple of FIXME fatals in readwrite.c into warnings 2013-02-28 12:07:21 +00:00
nick
e659a78855 proxy: Fix the return value of a function to match the comment 2013-02-25 15:53:19 +00:00
nick
78299de299 Dummy commit to get past a merge commit 2013-02-21 13:57:33 +00:00
nick
6842864e74 Automated merge with file:///home/lupine/Development/bigv-repos/flexnbd-c-sockutil 2013-02-15 16:53:18 +00:00
nick
98d8fbeaf0 flexnbd: Add a proxy mode
This lets us proxy connections between NBD clients and servers, resiliently.
2013-02-15 16:52:16 +00:00
nick
9b67d30608 serve: Make some error conditions non-fatal, test them.
We don't want flexnbd serve to fall over and die if the client sends an invalid request.
2013-02-15 16:51:28 +00:00
nick
63f7e3e8d4 Fix some sockutil tests 2013-02-15 16:48:23 +00:00
nick
9826dc6c65 Automated merge with ssh://dev/flexnbd-c 2013-02-15 13:36:15 +00:00
nick
0324d3000d branch merge 2013-02-15 13:35:42 +00:00
nick
91085b87fc flexnbd: Add valgrind suppressions for a bug in glibc-2.11 2013-02-15 13:35:21 +00:00
nick
dfa7e1a21b serve: Don't die horribly in the event of EINTR being returned by select() 2013-02-14 16:38:45 +00:00
nick
8281809f42 flexnbd: Fix sock_try_bind so we don't retry on EADDRINUSE 2013-02-14 16:37:14 +00:00
nick
03bc12dd57 flexnbd read/write: Switch to a non-blocking connect() to allow us to time these out 2013-02-14 16:24:10 +00:00
nick
58c4a9530b Make acceptance tests verbose by default 2013-02-14 11:17:44 +00:00
nick
cb7eed28e7 sockutil: Add some tests for sockaddr_address_string 2013-02-13 15:07:30 +00:00
nick
ac560bd907 serve: Refactor some socket utility code into its own module.
We'll be using this in proxy mode later
2013-02-13 13:43:52 +00:00
nick
0fcbe04f80 flexnbd: Remove some obsolete 'rebind' options
They steal short options that I want for other things
2013-02-13 13:11:20 +00:00
nick
f63be84d80 flexnbd: Add some more information to nbdtypes.h 2013-02-08 17:05:22 +00:00
nick
8c04564645 flexnbd: Avoid a SIGSEGV when the allocation map fails to build.
In the event of a fiemap ioctl failing (when the file is on a tmpfs,
for instance), we would free() serve->allocation_map, but it would
remain not NULL, leading to segfaults in client.c when responding to
write requests.

Keeping the free() behaviour is more hassle than it's worth, as there
are synchronization problems with setting serve->allocation_map to
NULL, so we just omit the free() instead to avoid the segfault. This
is safe because we never consult the map until allocation_map_built is
set to true, and we never do that when the builder thread fails.
2013-02-08 16:17:16 +00:00
nick
ecfd108a53 Introduce socket_nbd_write_hello() and a macro to display errno results nicely 2013-02-08 15:53:27 +00:00
nick
56ce7d35c2 Add a debug message for cases where sendfile() fails 2013-02-06 14:41:49 +00:00