/* returns 1 if it was successful,
* returns 0 if there was no data socket.
* so wherever you are going to use the data.socket, e.g. do
- * if (!drbd_get_data_sock(mdev))
+ * if (!drbd_get_data_sock(mdev->tconn))
* return 0;
* CODE();
- * drbd_put_data_sock(mdev);
+ * drbd_get_data_sock(mdev->tconn);
*/
-static inline int drbd_get_data_sock(struct drbd_conf *mdev)
+static inline int drbd_get_data_sock(struct drbd_tconn *tconn)
{
- mutex_lock(&mdev->tconn->data.mutex);
+ mutex_lock(&tconn->data.mutex);
/* drbd_disconnect() could have called drbd_free_sock()
* while we were waiting in down()... */
- if (unlikely(mdev->tconn->data.socket == NULL)) {
- mutex_unlock(&mdev->tconn->data.mutex);
+ if (unlikely(tconn->data.socket == NULL)) {
+ mutex_unlock(&tconn->data.mutex);
return 0;
}
return 1;
}
-static inline void drbd_put_data_sock(struct drbd_conf *mdev)
+static inline void drbd_put_data_sock(struct drbd_tconn *tconn)
{
- mutex_unlock(&mdev->tconn->data.mutex);
+ mutex_unlock(&tconn->data.mutex);
}
/*
extern int _conn_send_cmd(struct drbd_tconn *tconn, int vnr, struct socket *sock,
enum drbd_packet cmd, struct p_header *h, size_t size,
unsigned msg_flags);
+extern int conn_send_cmd2(struct drbd_tconn *tconn, enum drbd_packet cmd,
+ char *data, size_t size);
#define USE_DATA_SOCKET 1
#define USE_META_SOCKET 0
extern int drbd_send_cmd(struct drbd_conf *mdev, int use_data_socket,
enum drbd_packet cmd, struct p_header *h, size_t size);
-extern int drbd_send_cmd2(struct drbd_conf *mdev, enum drbd_packet cmd,
- char *data, size_t size);
extern int drbd_send_sync_param(struct drbd_conf *mdev, struct syncer_conf *sc);
extern int drbd_send_b_ack(struct drbd_conf *mdev, u32 barrier_nr,
u32 set_size);
return ok;
}
-int drbd_send_cmd2(struct drbd_conf *mdev, enum drbd_packet cmd, char *data,
+int conn_send_cmd2(struct drbd_tconn *tconn, enum drbd_packet cmd, char *data,
size_t size)
{
- struct p_header h;
+ struct p_header80 h;
int ok;
- prepare_header(mdev, &h, cmd, size);
+ prepare_header80(&h, cmd, size);
- if (!drbd_get_data_sock(mdev))
+ if (!drbd_get_data_sock(tconn))
return 0;
ok = (sizeof(h) ==
- drbd_send(mdev->tconn, mdev->tconn->data.socket, &h, sizeof(h), 0));
+ drbd_send(tconn, tconn->data.socket, &h, sizeof(h), 0));
ok = ok && (size ==
- drbd_send(mdev->tconn, mdev->tconn->data.socket, data, size, 0));
+ drbd_send(tconn, tconn->data.socket, data, size, 0));
- drbd_put_data_sock(mdev);
+ drbd_put_data_sock(tconn);
return ok;
}
{
int err;
- if (!drbd_get_data_sock(mdev))
+ if (!drbd_get_data_sock(mdev->tconn))
return -1;
err = !_drbd_send_bitmap(mdev);
- drbd_put_data_sock(mdev);
+ drbd_put_data_sock(mdev->tconn);
return err;
}
void *dgb;
int dgs;
- if (!drbd_get_data_sock(mdev))
+ if (!drbd_get_data_sock(mdev->tconn))
return 0;
dgs = (mdev->tconn->agreed_pro_version >= 87 && mdev->tconn->integrity_w_tfm) ?
} */
}
- drbd_put_data_sock(mdev);
+ drbd_put_data_sock(mdev->tconn);
return ok;
}
* This one may be interrupted by DRBD_SIG and/or DRBD_SIGKILL
* in response to admin command or module unload.
*/
- if (!drbd_get_data_sock(mdev))
+ if (!drbd_get_data_sock(mdev->tconn))
return 0;
ok = sizeof(p) == drbd_send(mdev->tconn, mdev->tconn->data.socket, &p, sizeof(p), dgs ? MSG_MORE : 0);
if (ok)
ok = _drbd_send_zc_ee(mdev, peer_req);
- drbd_put_data_sock(mdev);
+ drbd_put_data_sock(mdev->tconn);
return ok;
}
get_random_bytes(my_challenge, CHALLENGE_LEN);
- rv = drbd_send_cmd2(mdev, P_AUTH_CHALLENGE, my_challenge, CHALLENGE_LEN);
+ rv = conn_send_cmd2(mdev->tconn, P_AUTH_CHALLENGE, my_challenge, CHALLENGE_LEN);
if (!rv)
goto fail;
goto fail;
}
- rv = drbd_send_cmd2(mdev, P_AUTH_RESPONSE, response, resp_size);
+ rv = conn_send_cmd2(mdev->tconn, P_AUTH_RESPONSE, response, resp_size);
if (!rv)
goto fail;
if (cancel)
return 1;
- if (!drbd_get_data_sock(mdev))
+ if (!drbd_get_data_sock(mdev->tconn))
return 0;
p->barrier = b->br_number;
/* inc_ap_pending was done where this was queued.
* or (on connection loss) in w_clear_epoch. */
ok = _drbd_send_cmd(mdev, mdev->tconn->data.socket, P_BARRIER,
&p->head, sizeof(*p), 0);
- drbd_put_data_sock(mdev);
+ drbd_put_data_sock(mdev->tconn);
return ok;
}