summaryrefslogtreecommitdiff
path: root/fs/ceph/msgpool.c
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2009-10-14 17:36:07 -0700
committerSage Weil <sage@newdream.net>2009-10-15 18:14:43 -0700
commit8f3bc053c610826a657714649ea596f07875db2e (patch)
tree97823cb2a202439bb9f9839e2d326ac95d728dd0 /fs/ceph/msgpool.c
parent07bd10fb9853a41a7f0bb271721cca97d15eccae (diff)
downloadlwn-8f3bc053c610826a657714649ea596f07875db2e.tar.gz
lwn-8f3bc053c610826a657714649ea596f07875db2e.zip
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/ceph/msgpool.c')
-rw-r--r--fs/ceph/msgpool.c20
1 files changed, 17 insertions, 3 deletions
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)
return ret;
}
-struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool)
+struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool, int front_len)
{
wait_queue_t wait;
struct ceph_msg *msg;
+ if (front_len && front_len > pool->front_len) {
+ pr_err("msgpool_get pool %p need front %d, pool size is %d\n",
+ pool, front_len, pool->front_len);
+ WARN_ON(1);
+
+ /* try to alloc a fresh message */
+ msg = ceph_msg_new(0, front_len, 0, 0, NULL);
+ if (!IS_ERR(msg))
+ return msg;
+ }
+
+ if (!front_len)
+ front_len = pool->front_len;
+
if (pool->blocking) {
/* mempool_t behavior; first try to alloc */
- msg = ceph_msg_new(0, pool->front_len, 0, 0, NULL);
+ msg = ceph_msg_new(0, front_len, 0, 0, NULL);
if (!IS_ERR(msg))
return msg;
}
@@ -133,7 +147,7 @@ struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool)
WARN_ON(1);
/* maybe we can allocate it now? */
- msg = ceph_msg_new(0, pool->front_len, 0, 0, NULL);
+ msg = ceph_msg_new(0, front_len, 0, 0, NULL);
if (!IS_ERR(msg))
return msg;