xref: /OK3568_Linux_fs/kernel/include/linux/ceph/msgpool.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef _FS_CEPH_MSGPOOL
3*4882a593Smuzhiyun #define _FS_CEPH_MSGPOOL
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #include <linux/mempool.h>
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun /*
8*4882a593Smuzhiyun  * we use memory pools for preallocating messages we may receive, to
9*4882a593Smuzhiyun  * avoid unexpected OOM conditions.
10*4882a593Smuzhiyun  */
11*4882a593Smuzhiyun struct ceph_msgpool {
12*4882a593Smuzhiyun 	const char *name;
13*4882a593Smuzhiyun 	mempool_t *pool;
14*4882a593Smuzhiyun 	int type;               /* preallocated message type */
15*4882a593Smuzhiyun 	int front_len;          /* preallocated payload size */
16*4882a593Smuzhiyun 	int max_data_items;
17*4882a593Smuzhiyun };
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun int ceph_msgpool_init(struct ceph_msgpool *pool, int type,
20*4882a593Smuzhiyun 		      int front_len, int max_data_items, int size,
21*4882a593Smuzhiyun 		      const char *name);
22*4882a593Smuzhiyun extern void ceph_msgpool_destroy(struct ceph_msgpool *pool);
23*4882a593Smuzhiyun struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool, int front_len,
24*4882a593Smuzhiyun 				  int max_data_items);
25*4882a593Smuzhiyun extern void ceph_msgpool_put(struct ceph_msgpool *, struct ceph_msg *);
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun #endif
28