Sage Weil | 8fc91fd | 2009-10-06 11:31:13 -0700 | [diff] [blame] | 1 | #ifndef _FS_CEPH_MSGPOOL |
| 2 | #define _FS_CEPH_MSGPOOL |
| 3 | |
Sage Weil | d52f847 | 2010-04-01 15:23:14 -0700 | [diff] [blame] | 4 | #include <linux/mempool.h> |
Sage Weil | 8fc91fd | 2009-10-06 11:31:13 -0700 | [diff] [blame] | 5 | #include "messenger.h" |
| 6 | |
| 7 | /* |
| 8 | * we use memory pools for preallocating messages we may receive, to |
| 9 | * avoid unexpected OOM conditions. |
| 10 | */ |
| 11 | struct ceph_msgpool { |
Sage Weil | 4f48280 | 2010-04-24 09:56:35 -0700 | [diff] [blame] | 12 | const char *name; |
Sage Weil | d52f847 | 2010-04-01 15:23:14 -0700 | [diff] [blame] | 13 | mempool_t *pool; |
Sage Weil | 8fc91fd | 2009-10-06 11:31:13 -0700 | [diff] [blame] | 14 | int front_len; /* preallocated payload size */ |
Sage Weil | 8fc91fd | 2009-10-06 11:31:13 -0700 | [diff] [blame] | 15 | }; |
| 16 | |
| 17 | extern int ceph_msgpool_init(struct ceph_msgpool *pool, |
Sage Weil | 4f48280 | 2010-04-24 09:56:35 -0700 | [diff] [blame] | 18 | int front_len, int size, bool blocking, |
| 19 | const char *name); |
Sage Weil | 8fc91fd | 2009-10-06 11:31:13 -0700 | [diff] [blame] | 20 | extern void ceph_msgpool_destroy(struct ceph_msgpool *pool); |
Sage Weil | 8f3bc05 | 2009-10-14 17:36:07 -0700 | [diff] [blame] | 21 | extern struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *, |
| 22 | int front_len); |
Sage Weil | 8fc91fd | 2009-10-06 11:31:13 -0700 | [diff] [blame] | 23 | extern void ceph_msgpool_put(struct ceph_msgpool *, struct ceph_msg *); |
| 24 | |
| 25 | #endif |