Merge branches 'pm-cpufreq', 'pm-cpuidle' and 'acpi-cppc'
[deliverable/linux.git] / net / ceph / messenger.c
index 9cfedf565f5b236b5ede7974466cf62af6ad995c..1831f63536225bbe120dbc5215b26d2d6518f3fb 100644 (file)
@@ -235,18 +235,12 @@ static struct workqueue_struct *ceph_msgr_wq;
 static int ceph_msgr_slab_init(void)
 {
        BUG_ON(ceph_msg_cache);
-       ceph_msg_cache = kmem_cache_create("ceph_msg",
-                                       sizeof (struct ceph_msg),
-                                       __alignof__(struct ceph_msg), 0, NULL);
-
+       ceph_msg_cache = KMEM_CACHE(ceph_msg, 0);
        if (!ceph_msg_cache)
                return -ENOMEM;
 
        BUG_ON(ceph_msg_data_cache);
-       ceph_msg_data_cache = kmem_cache_create("ceph_msg_data",
-                                       sizeof (struct ceph_msg_data),
-                                       __alignof__(struct ceph_msg_data),
-                                       0, NULL);
+       ceph_msg_data_cache = KMEM_CACHE(ceph_msg_data, 0);
        if (ceph_msg_data_cache)
                return 0;
 
@@ -1197,6 +1191,13 @@ static bool ceph_msg_data_advance(struct ceph_msg_data_cursor *cursor,
        return new_piece;
 }
 
+static size_t sizeof_footer(struct ceph_connection *con)
+{
+       return (con->peer_features & CEPH_FEATURE_MSG_AUTH) ?
+           sizeof(struct ceph_msg_footer) :
+           sizeof(struct ceph_msg_footer_old);
+}
+
 static void prepare_message_data(struct ceph_msg *msg, u32 data_len)
 {
        BUG_ON(!msg);
@@ -1214,25 +1215,19 @@ static void prepare_message_data(struct ceph_msg *msg, u32 data_len)
 static void prepare_write_message_footer(struct ceph_connection *con)
 {
        struct ceph_msg *m = con->out_msg;
-       int v = con->out_kvec_left;
 
        m->footer.flags |= CEPH_MSG_FOOTER_COMPLETE;
 
        dout("prepare_write_message_footer %p\n", con);
-       con->out_kvec[v].iov_base = &m->footer;
+       con_out_kvec_add(con, sizeof_footer(con), &m->footer);
        if (con->peer_features & CEPH_FEATURE_MSG_AUTH) {
                if (con->ops->sign_message)
                        con->ops->sign_message(m);
                else
                        m->footer.sig = 0;
-               con->out_kvec[v].iov_len = sizeof(m->footer);
-               con->out_kvec_bytes += sizeof(m->footer);
        } else {
                m->old_footer.flags = m->footer.flags;
-               con->out_kvec[v].iov_len = sizeof(m->old_footer);
-               con->out_kvec_bytes += sizeof(m->old_footer);
        }
-       con->out_kvec_left++;
        con->out_more = m->more_to_follow;
        con->out_msg_done = true;
 }
@@ -2335,9 +2330,9 @@ static int read_partial_message(struct ceph_connection *con)
                        ceph_pr_addr(&con->peer_addr.in_addr),
                        seq, con->in_seq + 1);
                con->in_base_pos = -front_len - middle_len - data_len -
-                       sizeof(m->footer);
+                       sizeof_footer(con);
                con->in_tag = CEPH_MSGR_TAG_READY;
-               return 0;
+               return 1;
        } else if ((s64)seq - (s64)con->in_seq > 1) {
                pr_err("read_partial_message bad seq %lld expected %lld\n",
                       seq, con->in_seq + 1);
@@ -2360,10 +2355,10 @@ static int read_partial_message(struct ceph_connection *con)
                        /* skip this message */
                        dout("alloc_msg said skip message\n");
                        con->in_base_pos = -front_len - middle_len - data_len -
-                               sizeof(m->footer);
+                               sizeof_footer(con);
                        con->in_tag = CEPH_MSGR_TAG_READY;
                        con->in_seq++;
-                       return 0;
+                       return 1;
                }
 
                BUG_ON(!con->in_msg);
@@ -2402,11 +2397,7 @@ static int read_partial_message(struct ceph_connection *con)
        }
 
        /* footer */
-       if (need_sign)
-               size = sizeof(m->footer);
-       else
-               size = sizeof(m->old_footer);
-
+       size = sizeof_footer(con);
        end += size;
        ret = read_partial(con, end, size, &m->footer);
        if (ret <= 0)
@@ -3082,10 +3073,7 @@ void ceph_msg_revoke(struct ceph_msg *msg)
                        con->out_skip += con_out_kvec_skip(con);
                } else {
                        BUG_ON(!msg->data_length);
-                       if (con->peer_features & CEPH_FEATURE_MSG_AUTH)
-                               con->out_skip += sizeof(msg->footer);
-                       else
-                               con->out_skip += sizeof(msg->old_footer);
+                       con->out_skip += sizeof_footer(con);
                }
                /* data, middle, front */
                if (msg->data_length)
This page took 0.032001 seconds and 5 git commands to generate.