1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 23d14c5d2SYehuda Sadeh #ifndef _FS_CEPH_MSGPOOL 33d14c5d2SYehuda Sadeh #define _FS_CEPH_MSGPOOL 43d14c5d2SYehuda Sadeh 53d14c5d2SYehuda Sadeh #include <linux/mempool.h> 63d14c5d2SYehuda Sadeh 73d14c5d2SYehuda Sadeh /* 83d14c5d2SYehuda Sadeh * we use memory pools for preallocating messages we may receive, to 93d14c5d2SYehuda Sadeh * avoid unexpected OOM conditions. 103d14c5d2SYehuda Sadeh */ 113d14c5d2SYehuda Sadeh struct ceph_msgpool { 123d14c5d2SYehuda Sadeh const char *name; 133d14c5d2SYehuda Sadeh mempool_t *pool; 14d50b409fSSage Weil int type; /* preallocated message type */ 153d14c5d2SYehuda Sadeh int front_len; /* preallocated payload size */ 16*0d9c1ab3SIlya Dryomov int max_data_items; 173d14c5d2SYehuda Sadeh }; 183d14c5d2SYehuda Sadeh 19*0d9c1ab3SIlya Dryomov int ceph_msgpool_init(struct ceph_msgpool *pool, int type, 20*0d9c1ab3SIlya Dryomov int front_len, int max_data_items, int size, 213d14c5d2SYehuda Sadeh const char *name); 223d14c5d2SYehuda Sadeh extern void ceph_msgpool_destroy(struct ceph_msgpool *pool); 23*0d9c1ab3SIlya Dryomov struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool, int front_len, 24*0d9c1ab3SIlya Dryomov int max_data_items); 253d14c5d2SYehuda Sadeh extern void ceph_msgpool_put(struct ceph_msgpool *, struct ceph_msg *); 263d14c5d2SYehuda Sadeh 273d14c5d2SYehuda Sadeh #endif 28