[stgt] [PATCH] iser: limit number of CQ entries requested

Roi Dayan roid at mellanox.com
Mon May 28 13:04:04 CEST 2012


The number of CQ entries passed to ibv_create_cq() was copied from
the IB device attributes (device_attr.max_cqe).
Some versions of IB stack report a very large number there.
Using this number may lead to consumption of unnecessary resources
or even failure to create CQ.
This patch limits the number of CQ entries to a reasonable value.

Signed-off-by: Roi Dayan <roid at mellanox.com>
---
 usr/iscsi/iser.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/usr/iscsi/iser.c b/usr/iscsi/iser.c
index b7152ae..656a8e0 100644
--- a/usr/iscsi/iser.c
+++ b/usr/iscsi/iser.c
@@ -84,6 +84,7 @@ char *iser_portal_addr;
 
 #define DEFAULT_POOL_SIZE_MB    1024
 #define ISER_MAX_QUEUE_CMD      128     /* iSCSI cmd window size */
+#define MAX_CQ_ENTRIES          (128 * 1024)
 
 #define MASK_BY_BIT(b)  	((1UL << b) - 1)
 #define ALIGN_TO_BIT(x, b)      ((((unsigned long)x) + MASK_BY_BIT(b)) & \
@@ -3266,7 +3267,7 @@ static int iser_device_init(struct iser_device *dev)
 		eprintf("ibv_query_device failed, %m\n");
 		goto out;
 	}
-	cqe_num = dev->device_attr.max_cqe;
+	cqe_num = min(dev->device_attr.max_cqe, MAX_CQ_ENTRIES);
 	dprintf("max %d CQEs\n", cqe_num);
 
 	err = -1;
-- 
1.7.8.2

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list