aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/ceph/mon_client.c7
-rw-r--r--fs/ceph/msgpool.c20
-rw-r--r--fs/ceph/msgpool.h3
-rw-r--r--fs/ceph/osd_client.c5
4 files changed, 26 insertions, 9 deletions
diff --git a/fs/ceph/mon_client.c b/fs/ceph/mon_client.c
index d52e52968d01..e6e954cac6b9 100644
--- a/fs/ceph/mon_client.c
+++ b/fs/ceph/mon_client.c
@@ -639,14 +639,15 @@ static struct ceph_msg *mon_alloc_msg(struct ceph_connection *con,
639{ 639{
640 struct ceph_mon_client *monc = con->private; 640 struct ceph_mon_client *monc = con->private;
641 int type = le16_to_cpu(hdr->type); 641 int type = le16_to_cpu(hdr->type);
642 int front = le32_to_cpu(hdr->front_len);
642 643
643 switch (type) { 644 switch (type) {
644 case CEPH_MSG_CLIENT_MOUNT_ACK: 645 case CEPH_MSG_CLIENT_MOUNT_ACK:
645 return ceph_msgpool_get(&monc->msgpool_mount_ack); 646 return ceph_msgpool_get(&monc->msgpool_mount_ack, front);
646 case CEPH_MSG_MON_SUBSCRIBE_ACK: 647 case CEPH_MSG_MON_SUBSCRIBE_ACK:
647 return ceph_msgpool_get(&monc->msgpool_subscribe_ack); 648 return ceph_msgpool_get(&monc->msgpool_subscribe_ack, front);
648 case CEPH_MSG_STATFS_REPLY: 649 case CEPH_MSG_STATFS_REPLY:
649 return ceph_msgpool_get(&monc->msgpool_statfs_reply); 650 return ceph_msgpool_get(&monc->msgpool_statfs_reply, front);
650 } 651 }
651 return ceph_alloc_msg(con, hdr); 652 return ceph_alloc_msg(con, hdr);
652} 653}
diff --git a/fs/ceph/msgpool.c b/fs/ceph/msgpool.c
index 39d4d7ed82ce..7599b3382076 100644
--- a/fs/ceph/msgpool.c
+++ b/fs/ceph/msgpool.c
@@ -101,14 +101,28 @@ int ceph_msgpool_resv(struct ceph_msgpool *pool, int delta)
101 return ret; 101 return ret;
102} 102}
103 103
104struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool) 104struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool, int front_len)
105{ 105{
106 wait_queue_t wait; 106 wait_queue_t wait;
107 struct ceph_msg *msg; 107 struct ceph_msg *msg;
108 108
109 if (front_len && front_len > pool->front_len) {
110 pr_err("msgpool_get pool %p need front %d, pool size is %d\n",
111 pool, front_len, pool->front_len);
112 WARN_ON(1);
113
114 /* try to alloc a fresh message */
115 msg = ceph_msg_new(0, front_len, 0, 0, NULL);
116 if (!IS_ERR(msg))
117 return msg;
118 }
119
120 if (!front_len)
121 front_len = pool->front_len;
122
109 if (pool->blocking) { 123 if (pool->blocking) {
110 /* mempool_t behavior; first try to alloc */ 124 /* mempool_t behavior; first try to alloc */
111 msg = ceph_msg_new(0, pool->front_len, 0, 0, NULL); 125 msg = ceph_msg_new(0, front_len, 0, 0, NULL);
112 if (!IS_ERR(msg)) 126 if (!IS_ERR(msg))
113 return msg; 127 return msg;
114 } 128 }
@@ -133,7 +147,7 @@ struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool)
133 WARN_ON(1); 147 WARN_ON(1);
134 148
135 /* maybe we can allocate it now? */ 149 /* maybe we can allocate it now? */
136 msg = ceph_msg_new(0, pool->front_len, 0, 0, NULL); 150 msg = ceph_msg_new(0, front_len, 0, 0, NULL);
137 if (!IS_ERR(msg)) 151 if (!IS_ERR(msg))
138 return msg; 152 return msg;
139 153
diff --git a/fs/ceph/msgpool.h b/fs/ceph/msgpool.h
index 07a2decaa6d8..bc834bfcd720 100644
--- a/fs/ceph/msgpool.h
+++ b/fs/ceph/msgpool.h
@@ -20,7 +20,8 @@ extern int ceph_msgpool_init(struct ceph_msgpool *pool,
20 int front_len, int size, bool blocking); 20 int front_len, int size, bool blocking);
21extern void ceph_msgpool_destroy(struct ceph_msgpool *pool); 21extern void ceph_msgpool_destroy(struct ceph_msgpool *pool);
22extern int ceph_msgpool_resv(struct ceph_msgpool *, int delta); 22extern int ceph_msgpool_resv(struct ceph_msgpool *, int delta);
23extern struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *); 23extern struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *,
24 int front_len);
24extern void ceph_msgpool_put(struct ceph_msgpool *, struct ceph_msg *); 25extern void ceph_msgpool_put(struct ceph_msgpool *, struct ceph_msg *);
25 26
26#endif 27#endif
diff --git a/fs/ceph/osd_client.c b/fs/ceph/osd_client.c
index bbd9a5d23712..0a254054a82a 100644
--- a/fs/ceph/osd_client.c
+++ b/fs/ceph/osd_client.c
@@ -161,7 +161,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
161 if (snapc) 161 if (snapc)
162 msg_size += sizeof(u64) * snapc->num_snaps; 162 msg_size += sizeof(u64) * snapc->num_snaps;
163 if (use_mempool) 163 if (use_mempool)
164 msg = ceph_msgpool_get(&osdc->msgpool_op); 164 msg = ceph_msgpool_get(&osdc->msgpool_op, 0);
165 else 165 else
166 msg = ceph_msg_new(CEPH_MSG_OSD_OP, msg_size, 0, 0, NULL); 166 msg = ceph_msg_new(CEPH_MSG_OSD_OP, msg_size, 0, 0, NULL);
167 if (IS_ERR(msg)) { 167 if (IS_ERR(msg)) {
@@ -1271,10 +1271,11 @@ static struct ceph_msg *alloc_msg(struct ceph_connection *con,
1271 struct ceph_osd *osd = con->private; 1271 struct ceph_osd *osd = con->private;
1272 struct ceph_osd_client *osdc = osd->o_osdc; 1272 struct ceph_osd_client *osdc = osd->o_osdc;
1273 int type = le16_to_cpu(hdr->type); 1273 int type = le16_to_cpu(hdr->type);
1274 int front = le32_to_cpu(hdr->front_len);
1274 1275
1275 switch (type) { 1276 switch (type) {
1276 case CEPH_MSG_OSD_OPREPLY: 1277 case CEPH_MSG_OSD_OPREPLY:
1277 return ceph_msgpool_get(&osdc->msgpool_op_reply); 1278 return ceph_msgpool_get(&osdc->msgpool_op_reply, front);
1278 } 1279 }
1279 return ceph_alloc_msg(con, hdr); 1280 return ceph_alloc_msg(con, hdr);
1280} 1281}