blob: 4b0d38960726dd5223d18ec8856bb7d39ffde01e [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>
David Howellsa1ce3922012-10-02 18:01:25 +01005#include <linux/ceph/messenger.h>
Sage Weil8fc91fd2009-10-06 11:31:13 -07006
7/*
8 * we use memory pools for preallocating messages we may receive, to
9 * avoid unexpected OOM conditions.
10 */
11struct ceph_msgpool {
Sage Weil4f482802010-04-24 09:56:35 -070012 const char *name;
Sage Weild52f8472010-04-01 15:23:14 -070013 mempool_t *pool;
Sage Weild50b4092012-07-09 14:22:34 -070014 int type; /* preallocated message type */
Sage Weil8fc91fd2009-10-06 11:31:13 -070015 int front_len; /* preallocated payload size */
Sage Weil8fc91fd2009-10-06 11:31:13 -070016};
17
Sage Weild50b4092012-07-09 14:22:34 -070018extern int ceph_msgpool_init(struct ceph_msgpool *pool, int type,
Sage Weil4f482802010-04-24 09:56:35 -070019 int front_len, int size, bool blocking,
20 const char *name);
Sage Weil8fc91fd2009-10-06 11:31:13 -070021extern void ceph_msgpool_destroy(struct ceph_msgpool *pool);
Sage Weil8f3bc052009-10-14 17:36:07 -070022extern struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *,
23 int front_len);
Sage Weil8fc91fd2009-10-06 11:31:13 -070024extern void ceph_msgpool_put(struct ceph_msgpool *, struct ceph_msg *);
25
26#endif