diff options
author | Sage Weil <sage@newdream.net> | 2009-10-14 20:36:07 -0400 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2009-10-15 21:14:43 -0400 |
commit | 8f3bc053c610826a657714649ea596f07875db2e (patch) | |
tree | 97823cb2a202439bb9f9839e2d326ac95d728dd0 /fs | |
parent | 07bd10fb9853a41a7f0bb271721cca97d15eccae (diff) |
ceph: warn on allocation from msgpool with larger front_len
Pass the front_len we need when pulling a message off a msgpool,
and WARN if it is greater than the pool's size. Then try to
allocate a new message (to continue without failing).
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ceph/mon_client.c | 7 | ||||
-rw-r--r-- | fs/ceph/msgpool.c | 20 | ||||
-rw-r--r-- | fs/ceph/msgpool.h | 3 | ||||
-rw-r--r-- | fs/ceph/osd_client.c | 5 |
4 files changed, 26 insertions, 9 deletions
diff --git a/fs/ceph/mon_client.c b/fs/ceph/mon_client.c index d52e52968d0..e6e954cac6b 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 39d4d7ed82c..7599b338207 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 | ||
104 | struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool) | 104 | struct 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 07a2decaa6d..bc834bfcd72 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); |
21 | extern void ceph_msgpool_destroy(struct ceph_msgpool *pool); | 21 | extern void ceph_msgpool_destroy(struct ceph_msgpool *pool); |
22 | extern int ceph_msgpool_resv(struct ceph_msgpool *, int delta); | 22 | extern int ceph_msgpool_resv(struct ceph_msgpool *, int delta); |
23 | extern struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *); | 23 | extern struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *, |
24 | int front_len); | ||
24 | extern void ceph_msgpool_put(struct ceph_msgpool *, struct ceph_msg *); | 25 | extern 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 bbd9a5d2371..0a254054a82 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 | } |