u32 truncate_seq,
u64 truncate_size,
struct timespec *mtime,
- bool use_mempool)
+ bool use_mempool, int num_reply)
{
struct ceph_osd_request *req;
struct ceph_msg *msg;
int do_trunc = truncate_seq && (off + *plen > truncate_size);
int num_op = 1 + do_sync + do_trunc;
size_t msg_size = sizeof(*head) + num_op*sizeof(*op);
- int i;
+ int err, i;
u64 prevofs;
if (use_mempool) {
if (req == NULL)
return ERR_PTR(-ENOMEM);
+ err = ceph_msgpool_resv(&osdc->msgpool_op_reply, num_reply);
+ if (err) {
+ ceph_osdc_put_request(req);
+ return ERR_PTR(-ENOMEM);
+ }
+
req->r_osdc = osdc;
req->r_mempool = use_mempool;
atomic_set(&req->r_ref, 1);
msg_size += 40;
if (snapc)
msg_size += sizeof(u64) * snapc->num_snaps;
- msg = ceph_msg_new(CEPH_MSG_OSD_OP, msg_size, 0, 0, NULL);
+ if (use_mempool)
+ msg = ceph_msgpool_get(&osdc->msgpool_op);
+ else
+ msg = ceph_msg_new(CEPH_MSG_OSD_OP, msg_size, 0, 0, NULL);
if (IS_ERR(msg)) {
- kfree(req);
+ ceph_msgpool_resv(&osdc->msgpool_op_reply, num_reply);
+ ceph_osdc_put_request(req);
return ERR_PTR(PTR_ERR(msg));
}
+ msg->hdr.type = cpu_to_le32(CEPH_MSG_OSD_OP);
memset(msg->front.iov_base, 0, msg->front.iov_len);
head = msg->front.iov_base;
op = (void *)(head + 1);
*/
int ceph_osdc_init(struct ceph_osd_client *osdc, struct ceph_client *client)
{
+ int err;
+
dout("init\n");
osdc->client = client;
osdc->osdmap = NULL;
sizeof(struct ceph_osd_request));
if (!osdc->req_mempool)
return -ENOMEM;
+
+ err = ceph_msgpool_init(&osdc->msgpool_op, 4096, 10, true);
+ if (err < 0)
+ return -ENOMEM;
+ err = ceph_msgpool_init(&osdc->msgpool_op_reply, 512, 0, false);
+ if (err < 0)
+ return -ENOMEM;
+
return 0;
}
osdc->osdmap = NULL;
}
mempool_destroy(osdc->req_mempool);
+ ceph_msgpool_destroy(&osdc->msgpool_op);
+ ceph_msgpool_destroy(&osdc->msgpool_op_reply);
}
/*
req = ceph_osdc_new_request(osdc, layout, vino, off, plen,
CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ,
NULL, 0, truncate_seq, truncate_size, NULL,
- false);
+ false, 1);
if (IS_ERR(req))
return PTR_ERR(req);
CEPH_OSD_FLAG_WRITE,
snapc, do_sync,
truncate_seq, truncate_size, mtime,
- nofail);
+ nofail, 1);
if (IS_ERR(req))
return PTR_ERR(req);
ceph_msg_put(msg);
}
+static struct ceph_msg *alloc_msg(struct ceph_connection *con,
+ struct ceph_msg_header *hdr)
+{
+ struct ceph_osd *osd = con->private;
+ struct ceph_osd_client *osdc = osd->o_osdc;
+ int type = le32_to_cpu(hdr->type);
+
+ switch (type) {
+ case CEPH_MSG_OSD_OPREPLY:
+ return ceph_msgpool_get(&osdc->msgpool_op_reply);
+ }
+ return ceph_alloc_msg(con, hdr);
+}
+
/*
* Wrappers to refcount containing ceph_osd struct
*/
.get = get_osd_con,
.put = put_osd_con,
.dispatch = dispatch,
+ .alloc_msg = alloc_msg,
.peer_reset = osd_reset,
- .alloc_msg = ceph_alloc_msg,
.alloc_middle = ceph_alloc_middle,
.prepare_pages = prepare_pages,
};