Commit 1a7ba646 authored by Philipp Reisner's avatar Philipp Reisner

drbd: Converted helper functions for drbd_send() to tconn

* drbd_update_congested()
* we_should_drop_the_connection()
Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent 0625ac19
...@@ -1331,34 +1331,34 @@ int drbd_send_ov_request(struct drbd_conf *mdev, sector_t sector, int size) ...@@ -1331,34 +1331,34 @@ int drbd_send_ov_request(struct drbd_conf *mdev, sector_t sector, int size)
* returns false if we should retry, * returns false if we should retry,
* true if we think connection is dead * 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; int drop_it;
/* long elapsed = (long)(jiffies - mdev->last_received); */ /* long elapsed = (long)(jiffies - mdev->last_received); */
drop_it = mdev->tconn->meta.socket == sock drop_it = tconn->meta.socket == sock
|| !mdev->tconn->asender.task || !tconn->asender.task
|| get_t_state(&mdev->tconn->asender) != RUNNING || get_t_state(&tconn->asender) != RUNNING
|| mdev->state.conn < C_CONNECTED; || tconn->volume0->state.conn < C_CONNECTED;
if (drop_it) if (drop_it)
return true; return true;
drop_it = !--mdev->tconn->ko_count; drop_it = !--tconn->ko_count;
if (!drop_it) { if (!drop_it) {
dev_err(DEV, "[%s/%d] sock_sendmsg time expired, ko = %u\n", conn_err(tconn, "[%s/%d] sock_sendmsg time expired, ko = %u\n",
current->comm, current->pid, mdev->tconn->ko_count); current->comm, current->pid, tconn->ko_count);
request_ping(mdev->tconn); request_ping(tconn);
} }
return drop_it; /* && (mdev->state == R_PRIMARY) */; 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) 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 /* 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, ...@@ -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); return _drbd_no_send_page(mdev, page, offset, size, msg_flags);
msg_flags |= MSG_NOSIGNAL; msg_flags |= MSG_NOSIGNAL;
drbd_update_congested(mdev); drbd_update_congested(mdev->tconn);
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
do { do {
sent = mdev->tconn->data.socket->ops->sendpage(mdev->tconn->data.socket, page, sent = mdev->tconn->data.socket->ops->sendpage(mdev->tconn->data.socket, page,
offset, len, offset, len,
msg_flags); msg_flags);
if (sent == -EAGAIN) { if (sent == -EAGAIN) {
if (we_should_drop_the_connection(mdev, if (we_should_drop_the_connection(mdev->tconn,
mdev->tconn->data.socket)) mdev->tconn->data.socket))
break; break;
else else
...@@ -1662,7 +1662,7 @@ int drbd_send(struct drbd_conf *mdev, struct socket *sock, ...@@ -1662,7 +1662,7 @@ int drbd_send(struct drbd_conf *mdev, struct socket *sock,
if (sock == mdev->tconn->data.socket) { if (sock == mdev->tconn->data.socket) {
mdev->tconn->ko_count = mdev->tconn->net_conf->ko_count; mdev->tconn->ko_count = mdev->tconn->net_conf->ko_count;
drbd_update_congested(mdev); drbd_update_congested(mdev->tconn);
} }
do { do {
/* STRANGE /* STRANGE
...@@ -1676,7 +1676,7 @@ int drbd_send(struct drbd_conf *mdev, struct socket *sock, ...@@ -1676,7 +1676,7 @@ int drbd_send(struct drbd_conf *mdev, struct socket *sock,
*/ */
rv = kernel_sendmsg(sock, &msg, &iov, 1, size); rv = kernel_sendmsg(sock, &msg, &iov, 1, size);
if (rv == -EAGAIN) { if (rv == -EAGAIN) {
if (we_should_drop_the_connection(mdev, sock)) if (we_should_drop_the_connection(mdev->tconn, sock))
break; break;
else else
continue; continue;
......
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