Commit Graph

386 Commits

Author SHA1 Message Date
Alex Young
8b43321ef2 Fix for deadlocks when writing while migrating 2012-09-13 12:21:43 +01:00
nick
13328910c8 Add a test case that tickles a deadlock bug when migrating active source discs 2012-09-12 17:13:33 +01:00
Alex Young
50001cd6e7 Merge 2012-09-12 15:43:15 +01:00
Alex Young
ccf5baa956 Add a -dbg package to the debian build 2012-09-12 15:42:58 +01:00
nick
ee652a2965 Fix some races in the acceptance tests 2012-09-11 16:21:35 +01:00
nick
e724d83bec Ensure fiemap ioctl calls are synchronous. 2012-09-11 15:37:13 +01:00
Alex Young
239136064a Add default empty LDFLAGS 2012-08-24 09:32:33 +01:00
Alex Young
c3c621f750 Don't free a client which hasn't finished yet. 2012-08-23 17:51:19 +01:00
Alex Young
c5dfe16f35 Don't close the same file descriptor more than once. 2012-08-23 16:01:37 +01:00
Alex Young
b1a4db2727 Further merge fail fix
The reversal of the control protocol lines for the mirror command wasn't
complete.
2012-07-24 14:19:53 +01:00
nick
2c0f86c018 Fix a merge fail 2012-07-24 09:21:40 +01:00
Alex Young
53eca40fad Fix tests broken by entrust removal
Missed check_readwrite and check_flexnbd
2012-07-23 15:45:39 +01:00
Alex Young
33f95e1986 Add the --unlink option to mirror
This deletes the local file before tearing down the mirror connection,
allowing us to avoid an ambiguous recovery situation.
2012-07-23 13:39:27 +01:00
Alex Young
fd935ce4c9 Simplify the migration handover protocol
The three-way hand-off has a problem: there's no way to arrange for the
state of the migration to be unambiguous in case of failure.  If the
final "disconnect" message is lost (as in, the destination never
receives it whether it is sent by the sender or not), the destination
has no option but to quit with an error status and let a human sort it
out.  However, at that point we can either arrange to have a .INCOMPLETE
file still on disc or not - and it doesn't matter which we choose, we
can still end up with dataloss by picking a specific calamity to have
befallen the sender.

Given this, it makes sense to fall back to a simpler protocol: just send
all the data, then send a "disconnect" message.  This has the same
downside that we need a human to sort out specific failure cases, but
combined with --unlink before sending "disconnect" (see next patch) it
will always be possible for a human to disambiguate, whether the
destination quit with an error status or not.
2012-07-23 10:22:25 +01:00
Alex Young
f6f4266fd6 Update the README for new listen behaviour
Get rid of references to rebind addresses and update the usage examples.
2012-07-23 10:10:47 +01:00
Alex Young
4790912750 Remove listen mode
Changing behaviour so that instead of rebinding after a successful
migration and continuing as an ordinary server, we simply quit with a
0 exit code and let our caller restart us as a server if they want to.
This means that everything in listen.c, listen.h, and anything making
reference to a rebind address is unneeded.
2012-07-23 09:48:50 +01:00
Alex Young
77f4ac29c6 Include strerror(errno) in stat debug output 2012-07-20 09:51:53 +01:00
Alex Young
b0f1a027c6 Add .INCOMPLETE file marker to flexnbd listen
We drop a marker onto the filesystem to say when we know the image we're
serving is not yet ready.
2012-07-19 17:34:20 +01:00
Alex Young
76bbdb4889 Force gzipping the man page 2012-07-19 17:22:25 +01:00
Alex Young
314c0c2a2a Added the flexnbd break command to stop mirroring 2012-07-17 16:30:49 +01:00
Alex Young
1caa3d4e27 Make an EADDRINUSE on server bind fatal.
This is important because if we try to rebind after a migration and
someone else is in the way, any clients trying to reconnect to us will
instead be connecting to the squatter.
2012-07-16 12:34:39 +01:00
Alex Young
2e20e7197a Add the pid to the status output
This will be needed if we daemonise flexnbd.
2012-07-16 11:50:59 +01:00
Alex Young
8814894874 Test setting an ACL 2012-07-16 11:38:01 +01:00
Alex Young
66ff06fe0e Block a second mirror attempt
If a second mirror command is run while the first is still going,
flexnbd needs to prevent the second because we only have one dirty map.
Also, the shutdown becomes Complicated if we allow more than one mirror
at a time.
2012-07-16 11:21:56 +01:00
Alex Young
db30ea0c48 Better error handling for remotes 2012-07-16 11:04:45 +01:00
Alex Young
9a81af5f8f Added tag 0.0.2 for changeset 99b403167181 2012-07-16 10:49:03 +01:00
Alex Young
484a29b3f6 Add README.txt to the deb task code files 0.0.2 2012-07-16 10:29:06 +01:00
Alex Young
d0b39cce08 Flush bad write data from the client socket.
If the client makes a write that's out of range, by the time we get to
validate the message at the server end the client has already stuffed
the socket with data we can't use, so we have to flush it.

This patch also fixes a potential problem in the acceptance tests where
the error field was being returned as an array rather than a value.
2012-07-15 23:19:12 +01:00
Alex Young
f5850e5aaf Switch from expecting a reconnection to *not* doing do
If we're aborting mirror operations early, a couple of specs need to
change sense.
2012-07-15 22:07:00 +01:00
Alex Young
10625e402b Move the mirror commit state mbox to struct control
The mirror_super signals the commit state to the control thread via an
mbox, and this mbox is moved to control.  It was owned by mirror_super,
but the problem with that is that mirror_super can free the mbox before
the control client has been scheduled to receive the message.  If it's
owned by the control object, that can't happen.
2012-07-15 21:57:36 +01:00
Alex Young
b20fbc6a66 Don't retry a mirror which failed on the first attempt
If the mirror attempt failed and we were able to report an error to the
user, it makes no sense to attempt a retry.  We don't have a way to
abort a mirror attempt yet, so if the user got a setting wrong and it's
failing for that reason, the only recourse they'd have would be to
restart the server.
2012-07-15 20:07:17 +01:00
Alex Young
a10adf007c Switch the mirror commit_signal to an mbox
At the moment, a first-pass failed migration will retry. This is wrong,
it should abort.  However, to make that happen the mirror supervisor
needs to know the commit state of the mirror thread.  With a self_pipe
mirror commit signal that information wasn't there.
2012-07-15 19:46:35 +01:00
Alex Young
5794913fdf Delete the MS_FINALISE mirror state
It's not being used for anything.
2012-07-15 18:40:50 +01:00
Alex Young
e77234c6b1 Close the mirror client socket on rejection
If the mirror attempt connects ok, but is rejected (say, for reporting
the wrong size), the client socket needs to be closed.  The destination
end can't close its socket and accept another connection attempt unless
it does.
2012-07-15 18:30:20 +01:00
Alex Young
e0a61e91e6 Simplify acceptance test launching
Get rid of checking for --verbose, since it's always there now
2012-07-15 17:14:22 +01:00
Alex Young
f7379e3278 Tweak help output for the --bind option
Each option's parameter should be unique - they're instances, not
classes
2012-07-14 21:43:27 +01:00
Alex Young
a1ea2ba4c5 Add a rake task to build the man page
Also tweak the debian .install to put it in the right place.
2012-07-14 18:47:25 +01:00
Alex Young
54a1409dce Added a README.txt and a man page
Spoiler: they're the same thing. Added a `rake man` task to build the
man page.  Depends on asciidoc.
2012-07-14 18:36:02 +01:00
Alex Young
f9baa95b0f Raise the log level of a write-request-out-of-range
Without this, the error you get is a "Bad magic", when the next read
loop tries to read write data as a request.  This should be flushed from
the socket (although *when* is an open question), but upping the log
level at least gives us a more informative output.
2012-07-14 17:27:13 +01:00
Alex Young
69ad6d6b7a Only copy constants from C to Ruby once
This avoids unnecessary duplicate constant warnings for C constants that
are defined in two legs of an #ifdef.
2012-07-14 17:25:26 +01:00
Alex Young
b734a468c1 Make the --verbose flag universal
Previously, the --verbose flag was only present in debug builds. Now
it's present whether you define DEBUG or not.  What changes is the
amount of information printed to stderr: DEBUG sets the --verbose log
level to 0 (debug), while DEBUG unset sets it to 1 (info).  This makes
driving the binary slightly simpler as you don't have to detect whether
it's a debug build by scanning for "--verbose" in the help output.
2012-07-14 12:27:16 +01:00
Alex Young
768b30c4eb Clobber a dangling fprintf 2012-07-14 12:11:25 +01:00
Alex Young
1ce1003d3d Error when reading sent data fails
If the client cuts off part-way through the write, it should cause an
error, not a fatal.  Previously this happened if the open file had a
fiemap, but not if there was no allocation map.  This patch fixes that,
along with an associated valgrind error.
2012-07-14 12:10:12 +01:00
Alex Young
c6e6952def Open files with O_DIRECT dependent on a compile-time DIRECT_IO #define.
O_DIRECT causes problems on (at least) a wheezy VM, and there are mixed
reports about its performance impact.  This patch makes it a
compile-time choice which should remain until it's been benchmarked.
2012-07-14 10:07:58 +01:00
Alex Young
03c06a689d Append the CFLAGS environment variable to the build flags.
This is going to be used for the DIRECT_IO flag.
2012-07-14 10:05:35 +01:00
Alex Young
e4d2b9a667 Make test sockets less dependent on enviroment
It seems that ruby in a default wheezy VM can't handle a source address
of nil.
2012-07-14 10:04:55 +01:00
Alex Young
2ea5a2e38a Unlink the control socket on clean shutdown
Previously, the behaviour was to unlink any control socket sat where we
wanted to open ours.  This would make us lose control of running servers
if we happened to collide accidentally.  With this patch, the new
process will abort() if there is a control socket squatting on the
path we want, and unlink it when it closes.

This means that an unclean shutdown will leave a dangling, unattached
control socket which will block a restart, but that's a better option
than intentionally cutting off running servers.
2012-07-13 14:09:52 +01:00
Alex Young
a838714571 Tweak the fuzz script to work with the new test layout 2012-07-13 13:13:04 +01:00
Alex Young
fd8ee5b8c3 Tweak the parse_acl declaration
Array lengths don't make sense in function declarations.
2012-07-13 12:37:21 +01:00
Alex Young
15109c72d1 Add a newline to log messages at macro expansion
This simplifies building the log output because it means we don't have
to malloc a buffer to append a newline, and we keep the atomic write
property we're after.  It also takes advantage of the C constant string
concatenation which we already require to work to prepend the thread and
pid data.
2012-07-13 12:18:19 +01:00