]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: two msgpool modes: blocking (ala mempool_t) and !blocking (strict)
authorSage Weil <sage@newdream.net>
Fri, 18 Sep 2009 23:41:38 +0000 (16:41 -0700)
committerSage Weil <sage@newdream.net>
Fri, 18 Sep 2009 23:42:09 +0000 (16:42 -0700)
Only warn on !blocking pool depletion!

src/kernel/msgpool.c

index e92e3f2b2a37a4b0367f12fdcfb536b6f7849531..4c5a23bd99ff25900d1278dfc82f79968db503ca 100644 (file)
@@ -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);