Commit 61120870 authored by Philipp Reisner's avatar Philipp Reisner

drbd: Converted drbd_(get|put)_data_sock() and drbd_send_cmd2() to tconn

Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent 65d11ed6
...@@ -1109,26 +1109,26 @@ static inline unsigned int mdev_to_minor(struct drbd_conf *mdev) ...@@ -1109,26 +1109,26 @@ static inline unsigned int mdev_to_minor(struct drbd_conf *mdev)
/* returns 1 if it was successful, /* returns 1 if it was successful,
* returns 0 if there was no data socket. * returns 0 if there was no data socket.
* so wherever you are going to use the data.socket, e.g. do * 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; * return 0;
* CODE(); * 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() /* drbd_disconnect() could have called drbd_free_sock()
* while we were waiting in down()... */ * while we were waiting in down()... */
if (unlikely(mdev->tconn->data.socket == NULL)) { if (unlikely(tconn->data.socket == NULL)) {
mutex_unlock(&mdev->tconn->data.mutex); mutex_unlock(&tconn->data.mutex);
return 0; return 0;
} }
return 1; 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);
} }
/* /*
...@@ -1171,12 +1171,12 @@ extern int drbd_send_state(struct drbd_conf *mdev); ...@@ -1171,12 +1171,12 @@ extern int drbd_send_state(struct drbd_conf *mdev);
extern int _conn_send_cmd(struct drbd_tconn *tconn, int vnr, struct socket *sock, 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, enum drbd_packet cmd, struct p_header *h, size_t size,
unsigned msg_flags); 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_DATA_SOCKET 1
#define USE_META_SOCKET 0 #define USE_META_SOCKET 0
extern int drbd_send_cmd(struct drbd_conf *mdev, int use_data_socket, extern int drbd_send_cmd(struct drbd_conf *mdev, int use_data_socket,
enum drbd_packet cmd, struct p_header *h, size_t size); 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_sync_param(struct drbd_conf *mdev, struct syncer_conf *sc);
extern int drbd_send_b_ack(struct drbd_conf *mdev, u32 barrier_nr, extern int drbd_send_b_ack(struct drbd_conf *mdev, u32 barrier_nr,
u32 set_size); u32 set_size);
......
...@@ -727,23 +727,23 @@ int drbd_send_cmd(struct drbd_conf *mdev, int use_data_socket, ...@@ -727,23 +727,23 @@ int drbd_send_cmd(struct drbd_conf *mdev, int use_data_socket,
return ok; 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) size_t size)
{ {
struct p_header h; struct p_header80 h;
int ok; 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; return 0;
ok = (sizeof(h) == 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 == 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; return ok;
} }
...@@ -1188,10 +1188,10 @@ int drbd_send_bitmap(struct drbd_conf *mdev) ...@@ -1188,10 +1188,10 @@ int drbd_send_bitmap(struct drbd_conf *mdev)
{ {
int err; int err;
if (!drbd_get_data_sock(mdev)) if (!drbd_get_data_sock(mdev->tconn))
return -1; return -1;
err = !_drbd_send_bitmap(mdev); err = !_drbd_send_bitmap(mdev);
drbd_put_data_sock(mdev); drbd_put_data_sock(mdev->tconn);
return err; return err;
} }
...@@ -1505,7 +1505,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req) ...@@ -1505,7 +1505,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
void *dgb; void *dgb;
int dgs; int dgs;
if (!drbd_get_data_sock(mdev)) if (!drbd_get_data_sock(mdev->tconn))
return 0; return 0;
dgs = (mdev->tconn->agreed_pro_version >= 87 && mdev->tconn->integrity_w_tfm) ? dgs = (mdev->tconn->agreed_pro_version >= 87 && mdev->tconn->integrity_w_tfm) ?
...@@ -1564,7 +1564,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req) ...@@ -1564,7 +1564,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
} */ } */
} }
drbd_put_data_sock(mdev); drbd_put_data_sock(mdev->tconn);
return ok; return ok;
} }
...@@ -1595,7 +1595,7 @@ int drbd_send_block(struct drbd_conf *mdev, enum drbd_packet cmd, ...@@ -1595,7 +1595,7 @@ int drbd_send_block(struct drbd_conf *mdev, enum drbd_packet cmd,
* This one may be interrupted by DRBD_SIG and/or DRBD_SIGKILL * This one may be interrupted by DRBD_SIG and/or DRBD_SIGKILL
* in response to admin command or module unload. * in response to admin command or module unload.
*/ */
if (!drbd_get_data_sock(mdev)) if (!drbd_get_data_sock(mdev->tconn))
return 0; return 0;
ok = sizeof(p) == drbd_send(mdev->tconn, mdev->tconn->data.socket, &p, sizeof(p), dgs ? MSG_MORE : 0); ok = sizeof(p) == drbd_send(mdev->tconn, mdev->tconn->data.socket, &p, sizeof(p), dgs ? MSG_MORE : 0);
...@@ -1607,7 +1607,7 @@ int drbd_send_block(struct drbd_conf *mdev, enum drbd_packet cmd, ...@@ -1607,7 +1607,7 @@ int drbd_send_block(struct drbd_conf *mdev, enum drbd_packet cmd,
if (ok) if (ok)
ok = _drbd_send_zc_ee(mdev, peer_req); ok = _drbd_send_zc_ee(mdev, peer_req);
drbd_put_data_sock(mdev); drbd_put_data_sock(mdev->tconn);
return ok; return ok;
} }
......
...@@ -4093,7 +4093,7 @@ static int drbd_do_auth(struct drbd_conf *mdev) ...@@ -4093,7 +4093,7 @@ static int drbd_do_auth(struct drbd_conf *mdev)
get_random_bytes(my_challenge, CHALLENGE_LEN); 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) if (!rv)
goto fail; goto fail;
...@@ -4148,7 +4148,7 @@ static int drbd_do_auth(struct drbd_conf *mdev) ...@@ -4148,7 +4148,7 @@ static int drbd_do_auth(struct drbd_conf *mdev)
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) if (!rv)
goto fail; goto fail;
......
...@@ -1197,7 +1197,7 @@ int w_send_barrier(struct drbd_conf *mdev, struct drbd_work *w, int cancel) ...@@ -1197,7 +1197,7 @@ int w_send_barrier(struct drbd_conf *mdev, struct drbd_work *w, int cancel)
if (cancel) if (cancel)
return 1; return 1;
if (!drbd_get_data_sock(mdev)) if (!drbd_get_data_sock(mdev->tconn))
return 0; return 0;
p->barrier = b->br_number; p->barrier = b->br_number;
/* inc_ap_pending was done where this was queued. /* inc_ap_pending was done where this was queued.
...@@ -1205,7 +1205,7 @@ int w_send_barrier(struct drbd_conf *mdev, struct drbd_work *w, int cancel) ...@@ -1205,7 +1205,7 @@ int w_send_barrier(struct drbd_conf *mdev, struct drbd_work *w, int cancel)
* or (on connection loss) in w_clear_epoch. */ * or (on connection loss) in w_clear_epoch. */
ok = _drbd_send_cmd(mdev, mdev->tconn->data.socket, P_BARRIER, ok = _drbd_send_cmd(mdev, mdev->tconn->data.socket, P_BARRIER,
&p->head, sizeof(*p), 0); &p->head, sizeof(*p), 0);
drbd_put_data_sock(mdev); drbd_put_data_sock(mdev->tconn);
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