Commit Graph

640 Commits

Author SHA1 Message Date
nick
c2df38c9d3 mirror: Use libev to provide an event loop inside the mirror thread
We're doing this so we can implement bandwidth controls sanely.
2013-08-09 17:02:10 +01:00
nick
754949d43f bitset: Add a bitset_run_count_ex that lets you learn the value of the bits in the run 2013-08-09 16:49:38 +01:00
lupine
1a966ca0be bitset: Prove that bitset operations with len=0 don't underflow 2013-07-26 17:09:21 +01:00
nick
f590f8ed3c status: Add migration_speed ( bytes per second ) and migration_duration( seconds ) to the migration output 2013-07-26 11:50:01 +01:00
nick
bc9ce93648 bitset: squash one more bug 2013-07-25 10:58:50 +01:00
nick
a5870b8e9b Remove a stray debugging statement 2013-07-25 10:14:14 +01:00
nick
bed8959d47 bitset: Fix large runs 2013-07-24 17:42:08 +01:00
nick
5c59a412af flexnbd-proxy: ensure upstream cooldown is applied when read init from upstream fails 2013-07-24 16:01:38 +01:00
nick
253cee5a10 flexnbd: Acknowledge new return type of bitset_run_count 2013-07-24 15:08:29 +01:00
nick
7de22a385e flexnbd: clients should be MADV_RANDOM, rather than MADV_SEQUENTIAL 2013-07-24 14:18:23 +01:00
nick
14db3315ca non-debug builds get -O2 for impressive bitset speedups 2013-07-24 12:34:36 +01:00
nick
efe9eaef7c bitset: A more-efficient bit(set)_run_count 2013-07-24 12:03:24 +01:00
nick
f8fd4e0437 bitset: Actually enable an optimization in bit_set/clear_range
Previously, we were setting bits up to the first byte boundary,
memset()ing to the last byte boundary, then ignoring the memset()
and resetting every single bit up to the last one individually,
from where the first for-loop left off.

This should be *at least* nine times faster.
2013-07-24 11:19:52 +01:00
nick
9a37951aaa bitset: Use uint64_t everywhere to avoid possible integer overflows
Hasn't been a problem in practice, mind.
2013-07-24 10:34:22 +01:00
nick
d18423c153 tests: Fix a couple of compile warnings 2013-07-23 17:22:23 +01:00
nick
1b0fe24529 test: Add some tests for bitset_run_count 2013-07-23 17:13:40 +01:00
nick
5c5636b053 flexnbd mirror: If the final run would be longer than the file size, truncate to file size
This fixes migrations of images that are not exactly divisible by 4096
2013-07-23 11:00:51 +01:00
nick
afe76debf7 flexnbd status: Actually output pass statistics 2013-07-08 14:27:04 +01:00
nick
f4bfc70a4b flexnbd status: Add current pass clean/dirty byte statistics 2013-07-08 13:51:15 +01:00
nick
b29ef6d4de flexnbd status: Avoid a possible NULL dereference reading migration status
While the mirror mutex is taken, the mirroring can be abandoned and serve->mirror
set to NULL, so we need to lock around reading information from serve->mirror
2013-07-08 13:32:14 +01:00
nick
dee0bb27d6 flexnbd status: Add the size of the backing file, in bytes
This will be handy information if you're querying flexnbd for migration
stats, particularly.
2013-07-08 10:11:18 +01:00
nick
f556f298b1 flexnbd status: Add current migration pass to the status output if we're migrating 2013-07-08 09:58:31 +01:00
nick
55b452ebef Fix tests for new killswitch argument 2013-07-03 10:04:08 +01:00
nick
9f34752842 flexnbd: Make the killswitch runtime-selectable
We're not actually using it in production right now because it doesn't
shut its sockets down cleanly enough. This is a better option than
reverting the functionality or keeping production downgraded until
we sort out a handler that cleanly closes the sockets.
2013-07-03 09:56:35 +01:00
nick
81d41f567d proxy: Reduce the reconnect cooldown from 15 seconds to 3.
Exponential backoff would be better, but that's OK
2013-06-20 10:26:34 +01:00
nick
89fd18f6f0 proxy: Add a 30-second timeout for requests in-flight to upstream
It's a little more complicated than that, actually. For the various
states that involve reading from, or writing to, the upstream fd,
if the amount of time spent in that state is > 30 seconds, we reconnect
to the server and resend the request.

we also introduce a 15-second reconnect dampener to keep us from stressing
things unduly. This may need to be decreased, or turned into an exponential
backoff, at some point.
2013-06-19 16:36:19 +01:00
nick
3c56ba0af6 proxy: Fix a comment 2013-06-19 11:27:09 +01:00
nick
2a9884e9e9 proxy: Fix the prefetch code 2013-06-19 11:18:52 +01:00
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