drbd: Converted helper functions for drbd_send() to tconn
authorPhilipp Reisner <philipp.reisner@linbit.com>
Mon, 7 Feb 2011 13:56:02 +0000 (14:56 +0100)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Wed, 28 Sep 2011 08:26:59 +0000 (10:26 +0200)
* drbd_update_congested()
* we_should_drop_the_connection()

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
drivers/block/drbd/drbd_main.c

index 899bbb1c9865de79f1f555fdb608d565b8d61990..be4cb1ac2e9651b84ec181e9e63361c708b26578 100644 (file)
@@ -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;