xfs: modify buffer item reference counting
[safe/jmp/linux-2.6] / fs / ceph / msgpool.c
index 7599b33..ca3b44a 100644 (file)
@@ -140,7 +140,7 @@ struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool, int front_len)
                        return msg;
                }
                pr_err("msgpool_get %p now %d/%d, %s\n", pool, pool->num,
-                      pool->min, pool->blocking ? "waiting" : "failing");
+                      pool->min, pool->blocking ? "waiting" : "may fail");
                spin_unlock(&pool->lock);
 
                if (!pool->blocking) {
@@ -151,6 +151,7 @@ struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool, int front_len)
                        if (!IS_ERR(msg))
                                return msg;
 
+                       pr_err("msgpool_get %p empty + alloc failed\n", pool);
                        return ERR_PTR(-ENOMEM);
                }
 
@@ -165,7 +166,11 @@ void ceph_msgpool_put(struct ceph_msgpool *pool, struct ceph_msg *msg)
 {
        spin_lock(&pool->lock);
        if (pool->num < pool->min) {
-               ceph_msg_get(msg);   /* retake a single ref */
+               /* 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++;
                dout("msgpool_put %p reclaim %p, now %d/%d\n", pool, msg,