提交 1a7ba646 编写于 作者: P Philipp Reisner

drbd: Converted helper functions for drbd_send() to tconn

* drbd_update_congested()
* we_should_drop_the_connection()
Signed-off-by: NPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: NLars Ellenberg <lars.ellenberg@linbit.com>
上级 0625ac19
......@@ -1331,34 +1331,34 @@ int drbd_send_ov_request(struct drbd_conf *mdev, sector_t sector, int size)
* returns false if we should retry,
* true if we think connection is dead
*/
static int we_should_drop_the_connection(struct drbd_conf *mdev, struct socket *sock)
static int we_should_drop_the_connection(struct drbd_tconn *tconn, struct socket *sock)
{
int drop_it;
/* long elapsed = (long)(jiffies - mdev->last_received); */
drop_it = mdev->tconn->meta.socket == sock
|| !mdev->tconn->asender.task
|| get_t_state(&mdev->tconn->asender) != RUNNING
|| mdev->state.conn < C_CONNECTED;
drop_it = tconn->meta.socket == sock
|| !tconn->asender.task
|| get_t_state(&tconn->asender) != RUNNING
|| tconn->volume0->state.conn < C_CONNECTED;
if (drop_it)
return true;
drop_it = !--mdev->tconn->ko_count;
drop_it = !--tconn->ko_count;
if (!drop_it) {
dev_err(DEV, "[%s/%d] sock_sendmsg time expired, ko = %u\n",
current->comm, current->pid, mdev->tconn->ko_count);
request_ping(mdev->tconn);
conn_err(tconn, "[%s/%d] sock_sendmsg time expired, ko = %u\n",
current->comm, current->pid, tconn->ko_count);
request_ping(tconn);
}
return drop_it; /* && (mdev->state == R_PRIMARY) */;
}
static void drbd_update_congested(struct drbd_conf *mdev)
static void drbd_update_congested(struct drbd_tconn *tconn)
{
struct sock *sk = mdev->tconn->data.socket->sk;
struct sock *sk = tconn->data.socket->sk;
if (sk->sk_wmem_queued > sk->sk_sndbuf * 4 / 5)
set_bit(NET_CONGESTED, &mdev->tconn->flags);
set_bit(NET_CONGESTED, &tconn->flags);
}
/* The idea of sendpage seems to be to put some kind of reference
......@@ -1409,14 +1409,14 @@ static int _drbd_send_page(struct drbd_conf *mdev, struct page *page,
return _drbd_no_send_page(mdev, page, offset, size, msg_flags);
msg_flags |= MSG_NOSIGNAL;
drbd_update_congested(mdev);
drbd_update_congested(mdev->tconn);
set_fs(KERNEL_DS);
do {
sent = mdev->tconn->data.socket->ops->sendpage(mdev->tconn->data.socket, page,
offset, len,
msg_flags);
if (sent == -EAGAIN) {
if (we_should_drop_the_connection(mdev,
if (we_should_drop_the_connection(mdev->tconn,
mdev->tconn->data.socket))
break;
else
......@@ -1662,7 +1662,7 @@ int drbd_send(struct drbd_conf *mdev, struct socket *sock,
if (sock == mdev->tconn->data.socket) {
mdev->tconn->ko_count = mdev->tconn->net_conf->ko_count;
drbd_update_congested(mdev);
drbd_update_congested(mdev->tconn);
}
do {
/* STRANGE
......@@ -1676,7 +1676,7 @@ int drbd_send(struct drbd_conf *mdev, struct socket *sock,
*/
rv = kernel_sendmsg(sock, &msg, &iov, 1, size);
if (rv == -EAGAIN) {
if (we_should_drop_the_connection(mdev, sock))
if (we_should_drop_the_connection(mdev->tconn, sock))
break;
else
continue;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册