blob: ddd0d48d0384496fcac771a6d15b0d49ca4182a5 [file] [log] [blame]
Sage Weil8fc91fd2009-10-06 11:31:13 -07001#ifndef _FS_CEPH_MSGPOOL
2#define _FS_CEPH_MSGPOOL
3
Sage Weild52f8472010-04-01 15:23:14 -07004#include <linux/mempool.h>
Sage Weil8fc91fd2009-10-06 11:31:13 -07005
6/*
7 * we use memory pools for preallocating messages we may receive, to
8 * avoid unexpected OOM conditions.
9 */
10struct ceph_msgpool {
Sage Weil4f482802010-04-24 09:56:35 -070011 const char *name;
Sage Weild52f8472010-04-01 15:23:14 -070012 mempool_t *pool;
Sage Weild50b4092012-07-09 14:22:34 -070013 int type; /* preallocated message type */
Sage Weil8fc91fd2009-10-06 11:31:13 -070014 int front_len; /* preallocated payload size */
Sage Weil8fc91fd2009-10-06 11:31:13 -070015};
16
Sage Weild50b4092012-07-09 14:22:34 -070017extern int ceph_msgpool_init(struct ceph_msgpool *pool, int type,
Sage Weil4f482802010-04-24 09:56:35 -070018 int front_len, int size, bool blocking,
19 const char *name);
Sage Weil8fc91fd2009-10-06 11:31:13 -070020extern void ceph_msgpool_destroy(struct ceph_msgpool *pool);
Sage Weil8f3bc052009-10-14 17:36:07 -070021extern struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *,
22 int front_len);
Sage Weil8fc91fd2009-10-06 11:31:13 -070023extern void ceph_msgpool_put(struct ceph_msgpool *, struct ceph_msg *);
24
25#endif