ceph: reset front len on return to msgpool; BUG on mismatched front iov
authorSage Weil <sage@newdream.net>
Mon, 1 Mar 2010 23:25:00 +0000 (15:25 -0800)
committerSage Weil <sage@newdream.net>
Mon, 1 Mar 2010 23:25:00 +0000 (15:25 -0800)
Reset msg front len when a message is returned to the pool: the caller
may have changed it.

BUG if we try to send a message with a hdr.front_len that doesn't match
the front iov.

Signed-off-by: Sage Weil <sage@newdream.net>
fs/ceph/messenger.c
fs/ceph/msgpool.c

index bf4590c77cf6698baedaed1d490f2cacebeffa80..781656a49bf87d101444139cb0483c055df802fb 100644 (file)
@@ -1954,6 +1954,8 @@ void ceph_con_send(struct ceph_connection *con, struct ceph_msg *msg)
        msg->hdr.src.addr = con->msgr->my_enc_addr;
        msg->hdr.orig_src = msg->hdr.src;
 
+       BUG_ON(msg->front.iov_len != le32_to_cpu(msg->hdr.front_len));
+
        /* queue */
        mutex_lock(&con->mutex);
        BUG_ON(!list_empty(&msg->list_head));
index 2f04e0fc466662a9c505784bef5be5e4dc088331..ca3b44a89f2d3e2a3eaaaeb99d263ce5b62353fd 100644 (file)
@@ -166,6 +166,10 @@ void ceph_msgpool_put(struct ceph_msgpool *pool, struct ceph_msg *msg)
 {
        spin_lock(&pool->lock);
        if (pool->num < pool->min) {
+               /* reset msg front_len; user may have changed it */
+               msg->front.iov_len = pool->front_len;
+               msg->hdr.front_len = cpu_to_le32(pool->front_len);
+
                kref_set(&msg->kref, 1);  /* retake a single ref */
                list_add(&msg->list_head, &pool->msgs);
                pool->num++;