Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

Sage Weil d50b409f fbb85a47

+10 -7
+2 -1
include/linux/ceph/msgpool.h
··· 11 11 struct ceph_msgpool { 12 12 const char *name; 13 13 mempool_t *pool; 14 + int type; /* preallocated message type */ 14 15 int front_len; /* preallocated payload size */ 15 16 }; 16 17 17 - extern int ceph_msgpool_init(struct ceph_msgpool *pool, 18 + extern int ceph_msgpool_init(struct ceph_msgpool *pool, int type, 18 19 int front_len, int size, bool blocking, 19 20 const char *name); 20 21 extern void ceph_msgpool_destroy(struct ceph_msgpool *pool);
+4 -3
net/ceph/msgpool.c
··· 12 12 struct ceph_msgpool *pool = arg; 13 13 struct ceph_msg *msg; 14 14 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); 16 16 if (!msg) { 17 17 dout("msgpool_alloc %s failed\n", pool->name); 18 18 } else { ··· 32 32 ceph_msg_put(msg); 33 33 } 34 34 35 - int ceph_msgpool_init(struct ceph_msgpool *pool, 35 + int ceph_msgpool_init(struct ceph_msgpool *pool, int type, 36 36 int front_len, int size, bool blocking, const char *name) 37 37 { 38 38 dout("msgpool %s init\n", name); 39 + pool->type = type; 39 40 pool->front_len = front_len; 40 41 pool->pool = mempool_create(size, msgpool_alloc, msgpool_free, pool); 41 42 if (!pool->pool) ··· 62 61 WARN_ON(1); 63 62 64 63 /* try to alloc a fresh message */ 65 - return ceph_msg_new(0, front_len, GFP_NOFS, false); 64 + return ceph_msg_new(pool->type, front_len, GFP_NOFS, false); 66 65 } 67 66 68 67 msg = mempool_alloc(pool->pool, GFP_NOFS);
+4 -3
net/ceph/osd_client.c
··· 242 242 } 243 243 ceph_pagelist_init(req->r_trail); 244 244 } 245 + 245 246 /* create request message; allow space for oid */ 246 247 msg_size += MAX_OBJ_NAME_SIZE; 247 248 if (snapc) ··· 256 255 return NULL; 257 256 } 258 257 259 - msg->hdr.type = cpu_to_le16(CEPH_MSG_OSD_OP); 260 258 memset(msg->front.iov_base, 0, msg->front.iov_len); 261 259 262 260 req->r_request = msg; ··· 1837 1837 if (!osdc->req_mempool) 1838 1838 goto out; 1839 1839 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, 1841 1842 "osd_op"); 1842 1843 if (err < 0) 1843 1844 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, 1845 1846 OSD_OPREPLY_FRONT_LEN, 10, true, 1846 1847 "osd_op_reply"); 1847 1848 if (err < 0)