blob: a362605f93682a8ffe213fc8a3bc7d06f4cc3187 [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#include "messenger.h"
6
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 Weil8fc91fd2009-10-06 11:31:13 -070014 int front_len; /* preallocated payload size */
Sage Weil8fc91fd2009-10-06 11:31:13 -070015};
16
17extern int ceph_msgpool_init(struct ceph_msgpool *pool,
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