libceph: drop msg->ack_stamp field
[linux-2.6-microblaze.git] / net / ceph / messenger.c
index af0f1fa..29b00b2 100644 (file)
@@ -613,6 +613,25 @@ static int con_close_socket(struct ceph_connection *con)
        return rc;
 }
 
+static void ceph_con_reset_protocol(struct ceph_connection *con)
+{
+       dout("%s con %p\n", __func__, con);
+
+       con_close_socket(con);
+       if (con->in_msg) {
+               WARN_ON(con->in_msg->con != con);
+               ceph_msg_put(con->in_msg);
+               con->in_msg = NULL;
+       }
+       if (con->out_msg) {
+               WARN_ON(con->out_msg->con != con);
+               ceph_msg_put(con->out_msg);
+               con->out_msg = NULL;
+       }
+
+       con->out_skip = 0;
+}
+
 /*
  * Reset a connection.  Discard all incoming and outgoing messages
  * and clear *_seq state.
@@ -632,31 +651,20 @@ static void ceph_msg_remove_list(struct list_head *head)
        }
 }
 
-static void reset_connection(struct ceph_connection *con)
+static void ceph_con_reset_session(struct ceph_connection *con)
 {
-       /* reset connection, out_queue, msg_ and connect_seq */
-       /* discard existing out_queue and msg_seq */
-       dout("reset_connection %p\n", con);
+       dout("%s con %p\n", __func__, con);
+
+       WARN_ON(con->in_msg);
+       WARN_ON(con->out_msg);
        ceph_msg_remove_list(&con->out_queue);
        ceph_msg_remove_list(&con->out_sent);
-
-       if (con->in_msg) {
-               BUG_ON(con->in_msg->con != con);
-               ceph_msg_put(con->in_msg);
-               con->in_msg = NULL;
-       }
-
-       con->connect_seq = 0;
        con->out_seq = 0;
-       if (con->out_msg) {
-               BUG_ON(con->out_msg->con != con);
-               ceph_msg_put(con->out_msg);
-               con->out_msg = NULL;
-       }
        con->in_seq = 0;
        con->in_seq_acked = 0;
 
-       con->out_skip = 0;
+       con->connect_seq = 0;
+       con->peer_global_seq = 0;
 }
 
 /*
@@ -673,10 +681,9 @@ void ceph_con_close(struct ceph_connection *con)
        con_flag_clear(con, CON_FLAG_WRITE_PENDING);
        con_flag_clear(con, CON_FLAG_BACKOFF);
 
-       reset_connection(con);
-       con->peer_global_seq = 0;
+       ceph_con_reset_protocol(con);
+       ceph_con_reset_session(con);
        cancel_con(con);
-       con_close_socket(con);
        mutex_unlock(&con->mutex);
 }
 EXPORT_SYMBOL(ceph_con_close);
@@ -2091,7 +2098,6 @@ static int process_connect(struct ceph_connection *con)
                       ceph_pr_addr(&con->peer_addr),
                       sup_feat, server_feat, server_feat & ~sup_feat);
                con->error_msg = "missing required protocol features";
-               reset_connection(con);
                return -1;
 
        case CEPH_MSGR_TAG_BADPROTOVER:
@@ -2102,7 +2108,6 @@ static int process_connect(struct ceph_connection *con)
                       le32_to_cpu(con->out_connect.protocol_version),
                       le32_to_cpu(con->in_reply.protocol_version));
                con->error_msg = "protocol version mismatch";
-               reset_connection(con);
                return -1;
 
        case CEPH_MSGR_TAG_BADAUTHORIZER:
@@ -2130,10 +2135,10 @@ static int process_connect(struct ceph_connection *con)
                 */
                dout("process_connect got RESET peer seq %u\n",
                     le32_to_cpu(con->in_reply.connect_seq));
-               pr_err("%s%lld %s connection reset\n",
-                      ENTITY_NAME(con->peer_name),
-                      ceph_pr_addr(&con->peer_addr));
-               reset_connection(con);
+               pr_info("%s%lld %s session reset\n",
+                       ENTITY_NAME(con->peer_name),
+                       ceph_pr_addr(&con->peer_addr));
+               ceph_con_reset_session(con);
                con_out_kvec_reset(con);
                ret = prepare_write_connect(con);
                if (ret < 0)
@@ -2142,7 +2147,6 @@ static int process_connect(struct ceph_connection *con)
 
                /* Tell ceph about it. */
                mutex_unlock(&con->mutex);
-               pr_info("reset on %s%lld\n", ENTITY_NAME(con->peer_name));
                if (con->ops->peer_reset)
                        con->ops->peer_reset(con);
                mutex_lock(&con->mutex);
@@ -2192,7 +2196,6 @@ static int process_connect(struct ceph_connection *con)
                               ceph_pr_addr(&con->peer_addr),
                               req_feat, server_feat, req_feat & ~server_feat);
                        con->error_msg = "missing required protocol features";
-                       reset_connection(con);
                        return -1;
                }
 
@@ -2276,7 +2279,6 @@ static void process_ack(struct ceph_connection *con)
                        break;
                dout("got ack for seq %llu type %d at %p\n", seq,
                     le16_to_cpu(m->hdr.type), m);
-               m->ack_stamp = jiffies;
                ceph_msg_remove(m);
        }
 
@@ -2528,12 +2530,13 @@ static void process_message(struct ceph_connection *con)
        con->in_seq++;
        mutex_unlock(&con->mutex);
 
-       dout("===== %p %llu from %s%lld %d=%s len %d+%d (%u %u %u) =====\n",
+       dout("===== %p %llu from %s%lld %d=%s len %d+%d+%d (%u %u %u) =====\n",
             msg, le64_to_cpu(msg->hdr.seq),
             ENTITY_NAME(msg->hdr.src),
             le16_to_cpu(msg->hdr.type),
             ceph_msg_type_name(le16_to_cpu(msg->hdr.type)),
             le32_to_cpu(msg->hdr.front_len),
+            le32_to_cpu(msg->hdr.middle_len),
             le32_to_cpu(msg->hdr.data_len),
             con->in_front_crc, con->in_middle_crc, con->in_data_crc);
        con->ops->dispatch(con, msg);
@@ -2811,6 +2814,9 @@ static int queue_con_delay(struct ceph_connection *con, unsigned long delay)
                return -ENOENT;
        }
 
+       if (delay >= HZ)
+               delay = round_jiffies_relative(delay);
+
        dout("%s %p %lu\n", __func__, con, delay);
        if (!queue_delayed_work(ceph_msgr_wq, &con->work, delay)) {
                dout("%s %p - already queued\n", __func__, con);
@@ -2870,7 +2876,7 @@ static bool con_backoff(struct ceph_connection *con)
        if (!con_flag_test_and_clear(con, CON_FLAG_BACKOFF))
                return false;
 
-       ret = queue_con_delay(con, round_jiffies_relative(con->delay));
+       ret = queue_con_delay(con, con->delay);
        if (ret) {
                dout("%s: con %p FAILED to back off %lu\n", __func__,
                        con, con->delay);
@@ -2985,7 +2991,7 @@ static void con_fault(struct ceph_connection *con)
               con->state != CON_STATE_NEGOTIATING &&
               con->state != CON_STATE_OPEN);
 
-       con_close_socket(con);
+       ceph_con_reset_protocol(con);
 
        if (con_flag_test(con, CON_FLAG_LOSSYTX)) {
                dout("fault on LOSSYTX channel, marking CLOSED\n");
@@ -2993,17 +2999,6 @@ static void con_fault(struct ceph_connection *con)
                return;
        }
 
-       if (con->in_msg) {
-               BUG_ON(con->in_msg->con != con);
-               ceph_msg_put(con->in_msg);
-               con->in_msg = NULL;
-       }
-       if (con->out_msg) {
-               BUG_ON(con->out_msg->con != con);
-               ceph_msg_put(con->out_msg);
-               con->out_msg = NULL;
-       }
-
        /* Requeue anything that hasn't been acked */
        list_splice_init(&con->out_sent, &con->out_queue);
 
@@ -3017,10 +3012,13 @@ static void con_fault(struct ceph_connection *con)
        } else {
                /* retry after a delay. */
                con->state = CON_STATE_PREOPEN;
-               if (con->delay == 0)
+               if (!con->delay) {
                        con->delay = BASE_DELAY_INTERVAL;
-               else if (con->delay < MAX_DELAY_INTERVAL)
+               } else if (con->delay < MAX_DELAY_INTERVAL) {
                        con->delay *= 2;
+                       if (con->delay > MAX_DELAY_INTERVAL)
+                               con->delay = MAX_DELAY_INTERVAL;
+               }
                con_flag_set(con, CON_FLAG_BACKOFF);
                queue_con(con);
        }