flexnbd: Disconnect clients at the start of a mirror last pass

Currently, we prevent clients from processing requests by taking
the server I/O lock. This leads to requests hanging for a long
time before being terminated when the migration completes, which
is not ideal. With this change, at the start of the final pass,
existing clients are closed and any new connections will be closed
immediately (so no NBD server handshake will be seen).

This is part of the work required to remove remove the server I/O
lock completely.
This commit is contained in:
nick
2013-09-10 16:03:26 +01:00
parent 0494295705
commit 487bef1f40
3 changed files with 92 additions and 30 deletions

View File

@@ -87,9 +87,12 @@ struct server {
int max_nbd_clients;
struct client_tbl_entry *nbd_client;
/* Should clients use the killswitch? */
/** Should clients use the killswitch? */
int use_killswitch;
/** If this isn't set, newly accepted clients will be closed immediately */
int allow_new_clients;
/* Marker for whether this server has control over the data in
* the file, or if we're waiting to receive it from an inbound
@@ -135,6 +138,15 @@ void server_prevent_mirror_start( struct server *serve );
void server_allow_mirror_start( struct server *serve );
int server_mirror_can_start( struct server *serve );
/* These three functions are used by mirror around the final pass, to close
* existing clients and prevent new ones from being around
*/
void server_forbid_new_clients( struct server *serve );
void server_close_clients( struct server *serve );
void server_join_clients( struct server *serve );
void server_allow_new_clients( struct server *serve );
void server_unlink( struct server * serve );
int do_serve( struct server *, struct self_pipe * );