Skip to content

Commit d50b409

Browse files
author
Sage Weil
committed
libceph: initialize msgpool message types
Initialize the type field for messages in a msgpool. The caller was doing this for osd ops, but not for the reply messages. Reported-by: Alex Elder <elder@inktank.com> Signed-off-by: Sage Weil <sage@inktank.com>
1 parent fbb85a4 commit d50b409

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

‎include/linux/ceph/msgpool.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
struct ceph_msgpool {
1212
const char *name;
1313
mempool_t *pool;
14+
int type; /* preallocated message type */
1415
int front_len; /* preallocated payload size */
1516
};
1617

17-
extern int ceph_msgpool_init(struct ceph_msgpool *pool,
18+
extern int ceph_msgpool_init(struct ceph_msgpool *pool, int type,
1819
int front_len, int size, bool blocking,
1920
const char *name);
2021
extern void ceph_msgpool_destroy(struct ceph_msgpool *pool);

‎net/ceph/msgpool.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ static void *msgpool_alloc(gfp_t gfp_mask, void *arg)
1212
struct ceph_msgpool *pool = arg;
1313
struct ceph_msg *msg;
1414

15-
msg = ceph_msg_new(0, pool->front_len, gfp_mask, true);
15+
msg = ceph_msg_new(pool->type, pool->front_len, gfp_mask, true);
1616
if (!msg) {
1717
dout("msgpool_alloc %s failed\n", pool->name);
1818
} else {
@@ -32,10 +32,11 @@ static void msgpool_free(void *element, void *arg)
3232
ceph_msg_put(msg);
3333
}
3434

35-
int ceph_msgpool_init(struct ceph_msgpool *pool,
35+
int ceph_msgpool_init(struct ceph_msgpool *pool, int type,
3636
int front_len, int size, bool blocking, const char *name)
3737
{
3838
dout("msgpool %s init\n", name);
39+
pool->type = type;
3940
pool->front_len = front_len;
4041
pool->pool = mempool_create(size, msgpool_alloc, msgpool_free, pool);
4142
if (!pool->pool)
@@ -61,7 +62,7 @@ struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool,
6162
WARN_ON(1);
6263

6364
/* try to alloc a fresh message */
64-
return ceph_msg_new(0, front_len, GFP_NOFS, false);
65+
return ceph_msg_new(pool->type, front_len, GFP_NOFS, false);
6566
}
6667

6768
msg = mempool_alloc(pool->pool, GFP_NOFS);

‎net/ceph/osd_client.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
242242
}
243243
ceph_pagelist_init(req->r_trail);
244244
}
245+
245246
/* create request message; allow space for oid */
246247
msg_size += MAX_OBJ_NAME_SIZE;
247248
if (snapc)
@@ -255,7 +256,6 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
255256
return NULL;
256257
}
257258

258-
msg->hdr.type = cpu_to_le16(CEPH_MSG_OSD_OP);
259259
memset(msg->front.iov_base, 0, msg->front.iov_len);
260260

261261
req->r_request = msg;
@@ -1837,11 +1837,12 @@ int ceph_osdc_init(struct ceph_osd_client *osdc, struct ceph_client *client)
18371837
if (!osdc->req_mempool)
18381838
goto out;
18391839

1840-
err = ceph_msgpool_init(&osdc->msgpool_op, OSD_OP_FRONT_LEN, 10, true,
1840+
err = ceph_msgpool_init(&osdc->msgpool_op, CEPH_MSG_OSD_OP,
1841+
OSD_OP_FRONT_LEN, 10, true,
18411842
"osd_op");
18421843
if (err < 0)
18431844
goto out_mempool;
1844-
err = ceph_msgpool_init(&osdc->msgpool_op_reply,
1845+
err = ceph_msgpool_init(&osdc->msgpool_op_reply, CEPH_MSG_OSD_OPREPLY,
18451846
OSD_OPREPLY_FRONT_LEN, 10, true,
18461847
"osd_op_reply");
18471848
if (err < 0)

0 commit comments

Comments
 (0)