mirror of
https://github.com/FEX-Emu/linux.git
synced 2025-01-01 14:52:32 +00:00
drbd: Converted drbd_send_fp() from mdev to tconn
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
This commit is contained in:
parent
bedbd2a53a
commit
d38e787ecc
@ -1168,9 +1168,9 @@ extern int drbd_gen_and_send_sync_uuid(struct drbd_conf *mdev);
|
||||
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,
|
||||
@ -1870,6 +1870,13 @@ static inline void request_ping(struct drbd_tconn *tconn)
|
||||
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)
|
||||
{
|
||||
|
@ -651,51 +651,50 @@ void drbd_thread_current_set_cpu(struct drbd_conf *mdev, struct drbd_thread *thi
|
||||
}
|
||||
#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(tconn, vnr, h, cmd, size - sizeof(struct p_header));
|
||||
|
||||
prepare_header(mdev, 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;
|
||||
}
|
||||
|
||||
|
@ -698,16 +698,14 @@ out:
|
||||
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;
|
||||
@ -782,11 +780,11 @@ static int drbd_connect(struct drbd_conf *mdev)
|
||||
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user