mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-25 10:19:47 +00:00
![Ilya Dryomov](/assets/img/avatar_default.png)
Currently message data items are allocated with ceph_msg_data_create()
in setup_request_data() inside send_request(). send_request() has never
been allowed to fail, so each allocation is followed by a BUG_ON:
data = ceph_msg_data_create(...);
BUG_ON(!data);
It's been this way since support for multiple message data items was
added in commit 6644ed7b7e
("libceph: make message data be a pointer")
in 3.10.
There is no reason to delay the allocation of message data items until
the last possible moment and we certainly don't need a linked list of
them as they are only ever appended to the end and never erased. Make
ceph_msg_new2() take max_data_items and adapt the rest of the code.
Reported-by: Jerry Lee <leisurelysw24@gmail.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
27 lines
811 B
C
27 lines
811 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _FS_CEPH_MSGPOOL
|
|
#define _FS_CEPH_MSGPOOL
|
|
|
|
#include <linux/mempool.h>
|
|
|
|
/*
|
|
* we use memory pools for preallocating messages we may receive, to
|
|
* avoid unexpected OOM conditions.
|
|
*/
|
|
struct ceph_msgpool {
|
|
const char *name;
|
|
mempool_t *pool;
|
|
int type; /* preallocated message type */
|
|
int front_len; /* preallocated payload size */
|
|
int max_data_items;
|
|
};
|
|
|
|
int ceph_msgpool_init(struct ceph_msgpool *pool, int type,
|
|
int front_len, int max_data_items, int size,
|
|
const char *name);
|
|
extern void ceph_msgpool_destroy(struct ceph_msgpool *pool);
|
|
struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool, int front_len,
|
|
int max_data_items);
|
|
extern void ceph_msgpool_put(struct ceph_msgpool *, struct ceph_msg *);
|
|
|
|
#endif
|