blob: 729cdf700eae363728a8057b7b710fa59387ce75 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Sage Weil8fc91fd2009-10-06 11:31:13 -07002#ifndef _FS_CEPH_MSGPOOL
3#define _FS_CEPH_MSGPOOL
4
Sage Weild52f8472010-04-01 15:23:14 -07005#include <linux/mempool.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 */
Ilya Dryomov0d9c1ab2018-10-15 17:38:23 +020016 int max_data_items;
Sage Weil8fc91fd2009-10-06 11:31:13 -070017};
18
Ilya Dryomov0d9c1ab2018-10-15 17:38:23 +020019int ceph_msgpool_init(struct ceph_msgpool *pool, int type,
20 int front_len, int max_data_items, int size,
21 const char *name);
Sage Weil8fc91fd2009-10-06 11:31:13 -070022extern void ceph_msgpool_destroy(struct ceph_msgpool *pool);
Ilya Dryomov0d9c1ab2018-10-15 17:38:23 +020023struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool, int front_len,
24 int max_data_items);
Sage Weil8fc91fd2009-10-06 11:31:13 -070025extern void ceph_msgpool_put(struct ceph_msgpool *, struct ceph_msg *);
26
27#endif