[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Xen-devel] [PATCH 11/17] tools: block-remus: clean unused functions
On Oct 13, 2014 10:15 PM, "Wen Congyang" <wency@xxxxxxxxxxxxxx> wrote:
>
> Signed-off-by: Wen Congyang <wency@xxxxxxxxxxxxxx>
> ---
> Âtools/blktap2/drivers/block-remus.c | 142 ------------------------------------
> Â1 file changed, 142 deletions(-)
>
> diff --git a/tools/blktap2/drivers/block-remus.c b/tools/blktap2/drivers/block-remus.c
> index 9be47f6..e5ad782 100644
> --- a/tools/blktap2/drivers/block-remus.c
> +++ b/tools/blktap2/drivers/block-remus.c
> @@ -186,7 +186,6 @@ typedef struct tdremus_wire {
>
> Â#define TDREMUS_READ "rreq"
> Â#define TDREMUS_WRITE "wreq"
> -#define TDREMUS_SUBMIT "sreq"
> Â#define TDREMUS_COMMIT "creq"
> Â#define TDREMUS_DONE "done"
> Â#define TDREMUS_FAIL "fail"
> @@ -750,42 +749,6 @@ static void close_server_fd(struct tdremus_state *s)
>
> Â/* primary functions */
> Âstatic void remus_client_event(event_id_t, char mode, void *private);
> -static void remus_connect_event(event_id_t id, char mode, void *private);
> -static void remus_retry_connect_event(event_id_t id, char mode, void *private);
> -
> -static int primary_do_connect(struct tdremus_state *state)
> -{
> -Â Â Â Âevent_id_t id;
> -Â Â Â Âint fd;
> -Â Â Â Âint rc;
> -Â Â Â Âint flags;
> -
> -Â Â Â ÂRPRINTF("client connecting to %s:%d...\n", inet_ntoa(state->sa.sin_addr), ntohs(state->sa.sin_port));
> -
> -Â Â Â Âif ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
> -Â Â Â Â Â Â Â ÂRPRINTF("could not create client socket: %d\n", errno);
> -Â Â Â Â Â Â Â Âreturn -1;
> -Â Â Â Â}
> -
> -Â Â Â Â/* make socket nonblocking */
> -Â Â Â Âif ((flags = fcntl(fd, F_GETFL, 0)) == -1)
> -Â Â Â Â Â Â Â Âflags = 0;
> -Â Â Â Âif (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1)
> -Â Â Â Â Â Â Â Âreturn -1;
> -
> -Â Â Â Â/* once we have created the socket and populated the address, we can now start
> -Â Â Â Â * our non-blocking connect. rather than duplicating code we trigger a timeout
> -Â Â Â Â * on the socket fd, which calls out nonblocking connect code
> -Â Â Â Â */
> -Â Â Â Âif((id = tapdisk_server_register_event(SCHEDULER_POLL_TIMEOUT, fd, 0, remus_retry_connect_event, state)) < 0) {
> -Â Â Â Â Â Â Â ÂRPRINTF("error registering timeout client connection event handler: %s\n", strerror(id));
> -Â Â Â Â Â Â Â Â/* TODO: we leak a fd here */
> -Â Â Â Â Â Â Â Âreturn -1;
> -Â Â Â Â}
> -Â Â Â Âstate->stream_fd.fd = fd;
> -Â Â Â Âstate->stream_fd.id = id;
> -Â Â Â Âreturn 0;
> -}
>
> Âstatic int primary_blocking_connect(struct tdremus_state *state)
> Â{
> @@ -939,100 +902,6 @@ static int primary_start(td_driver_t *driver)
> Â Â Â Â return 0;
> Â}
>
> -/* timeout callback */
> -static void remus_retry_connect_event(event_id_t id, char mode, void *private)
> -{
> -Â Â Â Âstruct tdremus_state *s = (struct tdremus_state *)private;
> -
> -Â Â Â Â/* do a non-blocking connect */
> -Â Â Â Âif (connect(s->stream_fd.fd, (struct sockaddr *)&s->sa, sizeof(s->sa))
> -Â Â Â Â Â Â&& errno != EINPROGRESS)
> -Â Â Â Â{
> -Â Â Â Â Â Â Â Âif(errno == ECONNREFUSED || errno == ENETUNREACH || errno == EAGAIN || errno == ECONNABORTED)
> -Â Â Â Â Â Â Â Â{
> -Â Â Â Â Â Â Â Â Â Â Â Â/* try again in a second */
> -Â Â Â Â Â Â Â Â Â Â Â Âtapdisk_server_unregister_event(s->stream_fd.id);
> -Â Â Â Â Â Â Â Â Â Â Â Âif((id = tapdisk_server_register_event(SCHEDULER_POLL_TIMEOUT, s->stream_fd.fd, REMUS_CONNRETRY_TIMEOUT, remus_retry_connect_event, s)) < 0) {
> -Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂRPRINTF("error registering timeout client connection event handler: %s\n", strerror(id));
> -Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âreturn;
> -Â Â Â Â Â Â Â Â Â Â Â Â}
> -Â Â Â Â Â Â Â Â Â Â Â Âs->stream_fd.id = id;
> -Â Â Â Â Â Â Â Â}
> -Â Â Â Â Â Â Â Âelse
> -Â Â Â Â Â Â Â Â{
> -Â Â Â Â Â Â Â Â Â Â Â Â/* not recoverable */
> -Â Â Â Â Â Â Â Â Â Â Â ÂRPRINTF("error connection to server %s\n", strerror(errno));
> -Â Â Â Â Â Â Â Â Â Â Â Âreturn;
> -Â Â Â Â Â Â Â Â}
> -Â Â Â Â}
> -Â Â Â Âelse
> -Â Â Â Â{
> -Â Â Â Â Â Â Â Â/* the connect returned EINPROGRESS (nonblocking connect) we must wait for the fd to be writeable to determine if the connect worked */
> -
> -Â Â Â Â Â Â Â Âtapdisk_server_unregister_event(s->stream_fd.id);
> -Â Â Â Â Â Â Â Âif((id = tapdisk_server_register_event(SCHEDULER_POLL_WRITE_FD, s->stream_fd.fd, 0, remus_connect_event, s)) < 0) {
> -Â Â Â Â Â Â Â Â Â Â Â ÂRPRINTF("error registering client connection event handler: %s\n", strerror(id));
> -Â Â Â Â Â Â Â Â Â Â Â Âreturn;
> -Â Â Â Â Â Â Â Â}
> -Â Â Â Â Â Â Â Âs->stream_fd.id = id;
> -Â Â Â Â}
> -}
> -
> -/* callback when nonblocking connect() is finished */
> -/* called only by primary in unprotected state */
> -static void remus_connect_event(event_id_t id, char mode, void *private)
> -{
> -Â Â Â Âint socket_errno;
> -Â Â Â Âsocklen_t socket_errno_size;
> -Â Â Â Âstruct tdremus_state *s = (struct tdremus_state *)private;
> -
> -Â Â Â Â/* check to se if the connect succeeded */
> -Â Â Â Âsocket_errno_size = sizeof(socket_errno);
> -Â Â Â Âif (getsockopt(s->stream_fd.fd, SOL_SOCKET, SO_ERROR, &socket_errno, &socket_errno_size)) {
> -Â Â Â Â Â Â Â ÂRPRINTF("error getting socket errno\n");
> -Â Â Â Â Â Â Â Âreturn;
> -Â Â Â Â}
> -
> -Â Â Â ÂRPRINTF("socket connect returned %d\n", socket_errno);
> -
> -Â Â Â Âif(socket_errno)
> -Â Â Â Â{
> -Â Â Â Â Â Â Â Â/* the connect did not succeed */
> -
> -Â Â Â Â Â Â Â Âif(socket_errno == ECONNREFUSED || socket_errno == ENETUNREACH || socket_errno == ETIMEDOUT
> -Â Â Â Â Â Â Â Â Â || socket_errno == ECONNABORTED || socket_errno == EAGAIN)
> -Â Â Â Â Â Â Â Â{
> -Â Â Â Â Â Â Â Â Â Â Â Â/* we can probably assume that the backup is down. just try again later */
> -Â Â Â Â Â Â Â Â Â Â Â Âtapdisk_server_unregister_event(s->stream_fd.id);
> -Â Â Â Â Â Â Â Â Â Â Â Âif((id = tapdisk_server_register_event(SCHEDULER_POLL_TIMEOUT, s->stream_fd.fd, REMUS_CONNRETRY_TIMEOUT, remus_retry_connect_event, s)) < 0) {
> -Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂRPRINTF("error registering timeout client connection event handler: %s\n", strerror(id));
> -Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âreturn;
> -Â Â Â Â Â Â Â Â Â Â Â Â}
> -Â Â Â Â Â Â Â Â Â Â Â Âs->stream_fd.id = id;
> -Â Â Â Â Â Â Â Â}
> -Â Â Â Â Â Â Â Âelse
> -Â Â Â Â Â Â Â Â{
> -Â Â Â Â Â Â Â Â Â Â Â ÂRPRINTF("socket connect returned %d, giving up\n", socket_errno);
> -Â Â Â Â Â Â Â Â}
> -Â Â Â Â}
> -Â Â Â Âelse
> -Â Â Â Â{
> -Â Â Â Â Â Â Â Â/* the connect succeeded */
> -
> -Â Â Â Â Â Â Â Â/* unregister this function and register a new event handler */
> -Â Â Â Â Â Â Â Âtapdisk_server_unregister_event(s->stream_fd.id);
> -Â Â Â Â Â Â Â Âif((id = tapdisk_server_register_event(SCHEDULER_POLL_READ_FD, s->stream_fd.fd, 0, remus_client_event, s)) < 0) {
> -Â Â Â Â Â Â Â Â Â Â Â ÂRPRINTF("error registering client event handler: %s\n", strerror(id));
> -Â Â Â Â Â Â Â Â Â Â Â Âreturn;
> -Â Â Â Â Â Â Â Â}
> -Â Â Â Â Â Â Â Âs->stream_fd.id = id;
> -
> -Â Â Â Â Â Â Â Â/* switch from unprotected to protected client */
> -Â Â Â Â Â Â Â Âswitch_mode(s->tdremus_driver, mode_primary);
> -Â Â Â Â}
> -}
> -
> -
> Â/* we install this event handler on the primary once we have connected to the backup */
> Â/* wait for "done" message to commit checkpoint */
> Âstatic void remus_client_event(event_id_t id, char mode, void *private)
> @@ -1247,15 +1116,6 @@ static int server_do_wreq(td_driver_t *driver)
> Â Â Â Â return -1;
> Â}
>
> -static int server_do_sreq(td_driver_t *driver)
> -{
> -Â Â Â Â/*
> -Â Â Â Â ÂRPRINTF("submit request received\n");
> -Â */
> -
> -Â Â Â Âreturn 0;
> -}
> -
> Â/* at this point, the server can start applying the most recent
> Â * ramdisk. */
> Âstatic int server_do_creq(td_driver_t *driver)
> @@ -1296,8 +1156,6 @@ static void remus_server_event(event_id_t id, char mode, void *private)
>
> Â Â Â Â if (!strcmp(req, TDREMUS_WRITE))
> Â Â Â Â Â Â Â Â server_do_wreq(driver);
> -Â Â Â Âelse if (!strcmp(req, TDREMUS_SUBMIT))
> -Â Â Â Â Â Â Â Âserver_do_sreq(driver);
> Â Â Â Â else if (!strcmp(req, TDREMUS_COMMIT))
> Â Â Â Â Â Â Â Â server_do_creq(driver);
> Â Â Â Â else
> --
> 1.9.3
>
>
>
Acked-by: Shriram Rajagopalan <rshriram@xxxxxxxxx>
_______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxx
> http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|