hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/net/ceph/msgpool.c
....@@ -14,7 +14,8 @@
1414 struct ceph_msgpool *pool = arg;
1515 struct ceph_msg *msg;
1616
17
- msg = ceph_msg_new(pool->type, pool->front_len, gfp_mask, true);
17
+ msg = ceph_msg_new2(pool->type, pool->front_len, pool->max_data_items,
18
+ gfp_mask, true);
1819 if (!msg) {
1920 dout("msgpool_alloc %s failed\n", pool->name);
2021 } else {
....@@ -35,11 +36,13 @@
3536 }
3637
3738 int ceph_msgpool_init(struct ceph_msgpool *pool, int type,
38
- int front_len, int size, bool blocking, const char *name)
39
+ int front_len, int max_data_items, int size,
40
+ const char *name)
3941 {
4042 dout("msgpool %s init\n", name);
4143 pool->type = type;
4244 pool->front_len = front_len;
45
+ pool->max_data_items = max_data_items;
4346 pool->pool = mempool_create(size, msgpool_alloc, msgpool_free, pool);
4447 if (!pool->pool)
4548 return -ENOMEM;
....@@ -53,18 +56,21 @@
5356 mempool_destroy(pool->pool);
5457 }
5558
56
-struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool,
57
- int front_len)
59
+struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool, int front_len,
60
+ int max_data_items)
5861 {
5962 struct ceph_msg *msg;
6063
61
- if (front_len > pool->front_len) {
62
- dout("msgpool_get %s need front %d, pool size is %d\n",
63
- pool->name, front_len, pool->front_len);
64
- WARN_ON(1);
64
+ if (front_len > pool->front_len ||
65
+ max_data_items > pool->max_data_items) {
66
+ pr_warn_ratelimited("%s need %d/%d, pool %s has %d/%d\n",
67
+ __func__, front_len, max_data_items, pool->name,
68
+ pool->front_len, pool->max_data_items);
69
+ WARN_ON_ONCE(1);
6570
6671 /* try to alloc a fresh message */
67
- return ceph_msg_new(pool->type, front_len, GFP_NOFS, false);
72
+ return ceph_msg_new2(pool->type, front_len, max_data_items,
73
+ GFP_NOFS, false);
6874 }
6975
7076 msg = mempool_alloc(pool->pool, GFP_NOFS);
....@@ -80,6 +86,9 @@
8086 msg->front.iov_len = pool->front_len;
8187 msg->hdr.front_len = cpu_to_le32(pool->front_len);
8288
89
+ msg->data_length = 0;
90
+ msg->num_data_items = 0;
91
+
8392 kref_init(&msg->kref); /* retake single ref */
8493 mempool_free(msg, pool->pool);
8594 }