Commit ecf2363c authored by Andreas Gruenbacher's avatar Andreas Gruenbacher Committed by Philipp Reisner

drbd: _conn_send_cmd(): Return 0 upon success and an error code otherwise

Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent ce9879cb
...@@ -1926,7 +1926,7 @@ static inline int _drbd_send_cmd(struct drbd_conf *mdev, struct socket *sock, ...@@ -1926,7 +1926,7 @@ static inline int _drbd_send_cmd(struct drbd_conf *mdev, struct socket *sock,
enum drbd_packet cmd, struct p_header *h, size_t size, enum drbd_packet cmd, struct p_header *h, size_t size,
unsigned msg_flags) unsigned msg_flags)
{ {
return _conn_send_cmd(mdev->tconn, mdev->vnr, sock, cmd, h, size, msg_flags); return !_conn_send_cmd(mdev->tconn, mdev->vnr, sock, cmd, h, size, msg_flags);
} }
static inline int drbd_send_cmd(struct drbd_conf *mdev, int use_data_socket, static inline int drbd_send_cmd(struct drbd_conf *mdev, int use_data_socket,
......
...@@ -723,17 +723,14 @@ int _conn_send_cmd(struct drbd_tconn *tconn, int vnr, struct socket *sock, ...@@ -723,17 +723,14 @@ int _conn_send_cmd(struct drbd_tconn *tconn, int vnr, struct socket *sock,
enum drbd_packet cmd, struct p_header *h, size_t size, enum drbd_packet cmd, struct p_header *h, size_t size,
unsigned msg_flags) unsigned msg_flags)
{ {
int sent, ok; int err;
_prepare_header(tconn, vnr, h, cmd, size - sizeof(struct p_header)); _prepare_header(tconn, vnr, h, cmd, size - sizeof(struct p_header));
err = drbd_send_all(tconn, sock, h, size, msg_flags);
sent = drbd_send(tconn, sock, h, size, msg_flags); if (err && !signal_pending(current))
conn_warn(tconn, "short send %s size=%d\n",
ok = (sent == size); cmdname(cmd), (int)size);
if (!ok && !signal_pending(current)) return err;
conn_warn(tconn, "short sent %s size=%d sent=%d\n",
cmdname(cmd), (int)size, sent);
return ok;
} }
/* don't pass the socket. we may only look at it /* don't pass the socket. we may only look at it
...@@ -756,7 +753,7 @@ int conn_send_cmd(struct drbd_tconn *tconn, int vnr, int use_data_socket, ...@@ -756,7 +753,7 @@ int conn_send_cmd(struct drbd_tconn *tconn, int vnr, int use_data_socket,
/* drbd_disconnect() could have called drbd_free_sock() /* drbd_disconnect() could have called drbd_free_sock()
* while we were waiting in down()... */ * while we were waiting in down()... */
if (likely(sock != NULL)) if (likely(sock != NULL))
ok = _conn_send_cmd(tconn, vnr, sock, cmd, h, size, 0); ok = !_conn_send_cmd(tconn, vnr, sock, cmd, h, size, 0);
if (use_data_socket) if (use_data_socket)
mutex_unlock(&tconn->data.mutex); mutex_unlock(&tconn->data.mutex);
......
...@@ -711,7 +711,7 @@ static int drbd_send_fp(struct drbd_tconn *tconn, struct socket *sock, enum drbd ...@@ -711,7 +711,7 @@ static int drbd_send_fp(struct drbd_tconn *tconn, struct socket *sock, enum drbd
{ {
struct p_header *h = &tconn->data.sbuf.header; struct p_header *h = &tconn->data.sbuf.header;
return _conn_send_cmd(tconn, 0, sock, cmd, h, sizeof(*h), 0); return !_conn_send_cmd(tconn, 0, sock, cmd, h, sizeof(*h), 0);
} }
static enum drbd_packet drbd_recv_fp(struct drbd_tconn *tconn, struct socket *sock) static enum drbd_packet drbd_recv_fp(struct drbd_tconn *tconn, struct socket *sock)
...@@ -4150,7 +4150,7 @@ static int drbd_send_handshake(struct drbd_tconn *tconn) ...@@ -4150,7 +4150,7 @@ static int drbd_send_handshake(struct drbd_tconn *tconn)
memset(p, 0, sizeof(*p)); memset(p, 0, sizeof(*p));
p->protocol_min = cpu_to_be32(PRO_VERSION_MIN); p->protocol_min = cpu_to_be32(PRO_VERSION_MIN);
p->protocol_max = cpu_to_be32(PRO_VERSION_MAX); p->protocol_max = cpu_to_be32(PRO_VERSION_MAX);
ok = _conn_send_cmd(tconn, 0, tconn->data.socket, P_HAND_SHAKE, ok = !_conn_send_cmd(tconn, 0, tconn->data.socket, P_HAND_SHAKE,
&p->head, sizeof(*p), 0); &p->head, sizeof(*p), 0);
mutex_unlock(&tconn->data.mutex); mutex_unlock(&tconn->data.mutex);
return ok; return ok;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment