From 5dfe8fae0cf7391321c156d5ed099b592fbe819a Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 18 Sep 2009 16:41:38 -0700 Subject: [PATCH] kclient: two msgpool modes: blocking (ala mempool_t) and !blocking (strict) Only warn on !blocking pool depletion! --- src/kernel/msgpool.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/kernel/msgpool.c b/src/kernel/msgpool.c index e92e3f2b2a37a..4c5a23bd99ff2 100644 --- a/src/kernel/msgpool.c +++ b/src/kernel/msgpool.c @@ -106,6 +106,13 @@ struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool) wait_queue_t wait; struct ceph_msg *msg; + if (pool->blocking) { + /* mempool_t behavior; first try to alloc */ + msg = ceph_msg_new(0, pool->front_len, 0, 0, NULL); + if (!IS_ERR(msg)) + return msg; + } + while (1) { spin_lock(&pool->lock); if (likely(pool->num)) { @@ -122,15 +129,16 @@ struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool) pool->min, pool->blocking ? "waiting" : "failing"); spin_unlock(&pool->lock); - WARN_ON(1); + if (!pool->blocking) { + WARN_ON(1); - /* maybe we can allocate it now? */ - msg = ceph_msg_new(0, pool->front_len, 0, 0, NULL); - if (!IS_ERR(msg)) - return msg; + /* maybe we can allocate it now? */ + msg = ceph_msg_new(0, pool->front_len, 0, 0, NULL); + if (!IS_ERR(msg)) + return msg; - if (!pool->blocking) return ERR_PTR(-ENOMEM); + } init_wait(&wait); prepare_to_wait(&pool->wait, &wait, TASK_UNINTERRUPTIBLE); -- 2.39.5