block/nbd: nbd reconnect
commitf7651539d80b3490207e94a494aa4b9b255edfdf
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Wed, 9 Oct 2019 08:41:57 +0000 (9 11:41 +0300)
committerEric Blake <eblake@redhat.com>
Tue, 22 Oct 2019 14:22:07 +0000 (22 09:22 -0500)
tree33b7dc6171ed95881744e7620d68c963d932238e
parent3d692649d1702f9cbd00eca8542384f85663b9c7
block/nbd: nbd reconnect

Implement reconnect. To achieve this:

1. add new modes:
   connecting-wait: means, that reconnecting is in progress, and there
     were small number of reconnect attempts, so all requests are
     waiting for the connection.
   connecting-nowait: reconnecting is in progress, there were a lot of
     attempts of reconnect, all requests will return errors.

   two old modes are used too:
   connected: normal state
   quit: exiting after fatal error or on close

Possible transitions are:

   * -> quit
   connecting-* -> connected
   connecting-wait -> connecting-nowait (transition is done after
                      reconnect-delay seconds in connecting-wait mode)
   connected -> connecting-wait

2. Implement reconnect in connection_co. So, in connecting-* mode,
    connection_co, tries to reconnect unlimited times.

3. Retry nbd queries on channel error, if we are in connecting-wait
    state.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20191009084158.15614-3-vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
block/nbd.c