ceph_osdc_put_request(req);
                return ERR_PTR(-ENOMEM);
        }
+       req->r_num_prealloc_reply = num_reply;
 
        req->r_osdc = osdc;
        req->r_mempool = use_mempool;
        else
                msg = ceph_msg_new(CEPH_MSG_OSD_OP, msg_size, 0, 0, NULL);
        if (IS_ERR(msg)) {
-               ceph_msgpool_resv(&osdc->msgpool_op_reply, num_reply);
+               ceph_msgpool_resv(&osdc->msgpool_op_reply, -num_reply);
                ceph_osdc_put_request(req);
                return ERR_PTR(PTR_ERR(msg));
        }
        rb_erase(&req->r_node, &osdc->requests);
        osdc->num_requests--;
 
+       ceph_msgpool_resv(&osdc->msgpool_op_reply, -req->r_num_prealloc_reply);
+
        if (req->r_osd) {
                /* make sure the original request isn't in flight. */
                ceph_con_revoke(&req->r_osd->o_con, req->r_request);
 
        int               r_flags;     /* any additional flags for the osd */
        u32               r_sent;      /* >0 if r_request is sending/sent */
        int r_prepared_pages, r_got_reply;
+       int               r_num_prealloc_reply;
 
        struct ceph_osd_client *r_osdc;
        struct kref       r_kref;