mirror of https://gitee.com/openkylin/linux.git
drbd: Converted drbd_(get|put)_data_sock() and drbd_send_cmd2() 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
65d11ed6f2
commit
611208706f
|
@ -1109,26 +1109,26 @@ static inline unsigned int mdev_to_minor(struct drbd_conf *mdev)
|
|||
/* 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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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,
|
||||
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);
|
||||
|
|
|
@ -727,23 +727,23 @@ int drbd_send_cmd(struct drbd_conf *mdev, int use_data_socket,
|
|||
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;
|
||||
}
|
||||
|
@ -1188,10 +1188,10 @@ int drbd_send_bitmap(struct drbd_conf *mdev)
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1505,7 +1505,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
|
|||
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) ?
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
* 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);
|
||||
|
@ -1607,7 +1607,7 @@ int drbd_send_block(struct drbd_conf *mdev, enum drbd_packet cmd,
|
|||
if (ok)
|
||||
ok = _drbd_send_zc_ee(mdev, peer_req);
|
||||
|
||||
drbd_put_data_sock(mdev);
|
||||
drbd_put_data_sock(mdev->tconn);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
|
|
@ -4093,7 +4093,7 @@ static int drbd_do_auth(struct drbd_conf *mdev)
|
|||
|
||||
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;
|
||||
|
||||
|
@ -4148,7 +4148,7 @@ static int drbd_do_auth(struct drbd_conf *mdev)
|
|||
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;
|
||||
|
||||
|
|
|
@ -1197,7 +1197,7 @@ int w_send_barrier(struct drbd_conf *mdev, struct drbd_work *w, int cancel)
|
|||
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.
|
||||
|
@ -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. */
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue