extern int drbd_send_sizes(struct drbd_conf *mdev, int trigger_reply, enum dds_flags flags);
extern int _drbd_send_state(struct drbd_conf *mdev);
extern int drbd_send_state(struct drbd_conf *mdev);
-extern int _drbd_send_cmd(struct drbd_conf *mdev, struct socket *sock,
- enum drbd_packet cmd, struct p_header *h,
- size_t size, unsigned msg_flags);
+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);
#define USE_DATA_SOCKET 1
#define USE_META_SOCKET 0
extern int drbd_send_cmd(struct drbd_conf *mdev, int use_data_socket,
wake_asender(tconn);
}
+static inline int _drbd_send_cmd(struct drbd_conf *mdev, struct socket *sock,
+ enum drbd_packet cmd, struct p_header *h, size_t size,
+ unsigned msg_flags)
+{
+ return _conn_send_cmd(mdev->tconn, mdev->vnr, sock, cmd, h, size, msg_flags);
+}
+
static inline int drbd_send_short_cmd(struct drbd_conf *mdev,
enum drbd_packet cmd)
{
}
#endif
-static void prepare_header80(struct drbd_conf *mdev, struct p_header80 *h,
- enum drbd_packet cmd, int size)
+static void prepare_header80(struct p_header80 *h, enum drbd_packet cmd, int size)
{
h->magic = cpu_to_be32(DRBD_MAGIC);
h->command = cpu_to_be16(cmd);
h->length = cpu_to_be16(size);
}
-static void prepare_header95(struct drbd_conf *mdev, struct p_header95 *h,
- enum drbd_packet cmd, int size)
+static void prepare_header95(struct p_header95 *h, enum drbd_packet cmd, int size)
{
h->magic = cpu_to_be16(DRBD_MAGIC_BIG);
h->command = cpu_to_be16(cmd);
h->length = cpu_to_be32(size);
}
+static void _prepare_header(struct drbd_tconn *tconn, int vnr, struct p_header *h,
+ enum drbd_packet cmd, int size)
+{
+ if (tconn->agreed_pro_version >= 100 || size > DRBD_MAX_SIZE_H80_PACKET)
+ prepare_header95(&h->h95, cmd, size);
+ else
+ prepare_header80(&h->h80, cmd, size);
+}
+
static void prepare_header(struct drbd_conf *mdev, struct p_header *h,
enum drbd_packet cmd, int size)
{
- if (mdev->tconn->agreed_pro_version >= 100 || size > DRBD_MAX_SIZE_H80_PACKET)
- prepare_header95(mdev, &h->h95, cmd, size);
- else
- prepare_header80(mdev, &h->h80, cmd, size);
+ _prepare_header(mdev->tconn, mdev->vnr, h, cmd, size);
}
/* the appropriate socket mutex must be held already */
-int _drbd_send_cmd(struct drbd_conf *mdev, struct socket *sock,
+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)
{
int sent, ok;
- if (!expect(h))
- return false;
- if (!expect(size))
- return false;
-
- prepare_header(mdev, h, cmd, size - sizeof(struct p_header));
+ _prepare_header(tconn, vnr, h, cmd, size - sizeof(struct p_header));
- sent = drbd_send(mdev->tconn, sock, h, size, msg_flags);
+ sent = drbd_send(tconn, sock, h, size, msg_flags);
ok = (sent == size);
if (!ok && !signal_pending(current))
- dev_warn(DEV, "short sent %s size=%d sent=%d\n",
- cmdname(cmd), (int)size, sent);
+ conn_warn(tconn, "short sent %s size=%d sent=%d\n",
+ cmdname(cmd), (int)size, sent);
return ok;
}
return s_estab;
}
-static int drbd_send_fp(struct drbd_conf *mdev, struct socket *sock,
- enum drbd_packet cmd)
+static int drbd_send_fp(struct drbd_tconn *tconn, struct socket *sock, enum drbd_packet cmd)
{
- struct p_header *h = &mdev->tconn->data.sbuf.header;
+ struct p_header *h = &tconn->data.sbuf.header;
- return _drbd_send_cmd(mdev, 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_conf *mdev,
- struct socket *sock)
+static enum drbd_packet drbd_recv_fp(struct drbd_conf *mdev, struct socket *sock)
{
struct p_header80 *h = &mdev->tconn->data.rbuf.header.h80;
int rr;
if (s) {
if (!sock) {
- drbd_send_fp(mdev, s, P_HAND_SHAKE_S);
+ drbd_send_fp(mdev->tconn, s, P_HAND_SHAKE_S);
sock = s;
s = NULL;
} else if (!msock) {
- drbd_send_fp(mdev, s, P_HAND_SHAKE_M);
+ drbd_send_fp(mdev->tconn, s, P_HAND_SHAKE_M);
msock = s;
s = NULL;
} else {