Commit Graph

187 Commits

Author SHA1 Message Date
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
Alex Young
9f4da5def0 Switch to use nbd_r2h_reply in read_reply()
Use a wrapper function to simplify the reply field reading.
2012-07-13 12:13:55 +01:00
Alex Young
40101e49f3 Silence a vfprintf valgrind error
Turns out that %lld causes valgrind to find an uninitialised variable
problem inside vfprintf.  Avoid it here by s/%lld/%d/.
2012-07-13 11:57:46 +01:00
Alex Young
2a50b64a43 Free the flexnbd switch mutex 2012-07-13 11:31:22 +01:00
Alex Young
00e912d0a6 Add a 'just in case' error case to acl checking 2012-07-13 10:16:44 +01:00
Alex Young
2f24d02a8f Remove unused variables
use_connect_from in control_mirror() and success in mode_serve() are no
longer used.
2012-07-13 09:34:18 +01:00
Alex Young
2e4e592c08 Enable writing after the 2G boundary
This patch fixes a bug in readwrite.c which truncated the 'from' field
in nbd requests.  It was casting them down from an off64_t to an int.
2012-07-12 18:01:10 +01:00
Alex Young
cef2dcaad2 Rename struct mirror_status to struct mirror 2012-07-12 14:54:48 +01:00
Alex Young
c6a084ce82 Add a --quiet command-line option
--quiet will suppress all log lines except FATAL.  Conceptually it's
exclusive with --verbose, but this isn't checked - last one wins.
2012-07-12 14:45:55 +01:00
Alex Young
10b46beeea Retry failed rebind attempts
When we receive a migration, if rebinding to the new listen address and
port fails for a reason which might be fixable, rather than killing the
server we retry once a second.  Also in this patch: non-overlapping log
messages and a fix for the client going away halfway through a sendfile
loop.
2012-07-12 14:14:46 +01:00
Alex Young
9002341e77 Fix the broken --rebind-port command-line option. 2012-07-12 10:45:19 +01:00
Alex Young
71b7708964 Minor tidy 2012-07-12 10:22:31 +01:00
Alex Young
eb90308b6e Handle a failed disconnect correctly
If the sender disconnects its socket before sending the disconnect
message, the destination should restart the migration process.  This
patch makes sure that happens.
2012-07-12 09:39:39 +01:00
Alex Young
f3cebcdcd5 Test a source crashing after an entrust.
This adds a test for destination behaviour, in that if a source crashes
after sending an entrust message but before the destination can reply,
the destination must allow the source to reconnect and retry the mirror.
2012-07-11 15:19:50 +01:00
Alex Young
84dd052465 Fix a test broken by stdout/stderr reshuffle 2012-07-11 10:12:10 +01:00
Alex Young
f3f017a87d Free all possibly held mutexes in error handlers
Now that we have 3 mutexes lying around, it's important that we check
and free these if necessary if error() is called in any thread that can
hold them.  To do this, we now have flexthread.c, which defines a
flexthread_mutex struct.  This is a wrapper around a pthread_mutex_t and
a pthread_t.  The idea is that in the error handler, the thread can
check whether it holds the mutex and can free it if and only if it does.
This is important because pthread fast mutexes can be freed by *any*
thread, not just the thread which holds them.

Note: it is only ever safe for a thread to check if it holds the mutex
itself.  It is *never* safe to check if another thread holds a mutex
without first locking that mutex, which makes the whole operation rather
pointless.
2012-07-11 09:43:16 +01:00
Alex Young
17fe6d3023 Test that a blocked entrust causes a retry 2012-07-03 18:00:31 +01:00
Alex Young
061512f3dc Test that a write reply with the wrong magic will force a retry 2012-07-03 17:01:39 +01:00
Alex Young
5c66d35677 Test that closing the socket immediately after sending write data causes an error 2012-07-03 15:33:00 +01:00
Alex Young
d16aebf36e Test that a disconnect after the write request but before the data is an error 2012-07-03 15:25:39 +01:00
Alex Young
a767d4bc8c Test the source handles a dest crash after write correctly 2012-07-03 14:52:27 +01:00
Alex Young
64ebbe7688 Refactor FakeSource from a module to a class 2012-07-03 14:39:05 +01:00
Alex Young
ded4914c84 Simplified FlexNBD::FakeDest 2012-07-03 14:23:20 +01:00
Alex Young
9e67f228f0 Rename a test class 2012-07-03 13:35:47 +01:00
Alex Young
2283b99834 Split acceptance tests into separate files 2012-07-03 13:33:52 +01:00
Alex Young
988b2ec014 Moved acceptance tests into tests/acceptance 2012-07-03 10:59:31 +01:00
Alex Young
c0c9c6f076 Moved unit tests into tests/unit 2012-07-03 10:53:08 +01:00
Alex Young
e817129c47 Changes to error severity in readwrite.c made a test fail, this patch fixes it 2012-07-02 18:10:02 +01:00
Alex Young
cc2e67d4bb Test that an invalid write gets an error response 2012-07-02 15:37:52 +01:00
Alex Young
ea4642a878 Check that a mirror write returning an error will cause a reconnect and retry 2012-07-02 15:04:45 +01:00
Alex Young
99f8c24b01 Tweak a timeout to prevent an intermittent test failure 2012-07-02 13:00:30 +01:00
Alex Young
9850f5d0a4 Test that timing out a write causes a disconnect and a reconnect 2012-06-28 14:45:53 +01:00
Alex Young
4de4cee3d0 Test for acl rejection 2012-06-28 13:29:22 +01:00
Alex Young
c9fdd5a60e Handle ECONNRESET during a read request 2012-06-28 11:46:02 +01:00
Alex Young
9b717d6391 Factor common code out of fake destinations 2012-06-28 11:34:36 +01:00
Alex Young
192471ee82 Factor common code out of the test fake sources
* * *
More fake source refacoring
2012-06-27 17:28:24 +01:00
Alex Young
137a764cc7 Add a test for a second client connecting during a mirror 2012-06-27 16:32:01 +01:00
Alex Young
cea9d97086 Missing file 2012-06-27 16:19:13 +01:00
Alex Young
04a10179a0 check_acl correctly sets log_level 2012-06-27 16:18:38 +01:00
Alex Young
ac3e6692a8 make sure that an invalid flexnbd signal fd can't break the serve accept loop 2012-06-27 16:17:51 +01:00
Alex Young
94b4fa887c Add mboxes 2012-06-27 15:45:33 +01:00
Alex Young
2078d17053 connect failure scenarios 2012-06-22 10:05:41 +01:00
Alex Young
80f298f6cd Make non-fatal errors return properly 2012-06-21 18:01:56 +01:00
Alex Young
f37a217cb9 Add listen mode 2012-06-21 18:01:50 +01:00
Alex Young
79ba1cf728 Make max_nbd_clients configurable per struct server 2012-06-21 17:22:34 +01:00
Alex Young
e21beb1866 Add the REQUEST_ENTRUST nbd request type 2012-06-21 17:12:06 +01:00
Alex Young
a3dc670939 Squash valgrind errors by making sure client threads get joined on termination 2012-06-21 17:11:12 +01:00
Alex Young
bafc3d3687 Make sure filename_incomplete gets freed 2012-06-21 15:58:32 +01:00
Alex Young
322eae137b Add a missed free() 2012-06-21 15:55:48 +01:00
Alex Young
43e95dc4db Make sure all the lines we read get freed (including the trailing blank) 2012-06-21 15:31:28 +01:00