Limit the timeout that the ib_cm will wait to receive a response to a message, to avoid excessively large (on the order of hours) timeout values. This prevents consuming resources tracking requests for extended periods of time.
This helps correct for a bug in the SRP Engenio target sending a large value (> 1 hour) as a service timeout. Signed-off-by: Sean Hefty <[EMAIL PROTECTED]> --- drivers/infiniband/core/cm.c | 30 +++++++++++++++++++----------- 1 files changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index d446998..147b41e 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -54,6 +54,12 @@ MODULE_AUTHOR("Sean Hefty"); MODULE_DESCRIPTION("InfiniBand CM"); MODULE_LICENSE("Dual BSD/GPL"); +/* + * Limit CM msg timeouts to something reasonable. + * 8 seconds, with up to 15 retries, gives per msg timeout of 2 min. + */ +#define IB_CM_MAX_TIMEOUT 21 + static void cm_add_one(struct ib_device *device); static void cm_remove_one(struct ib_device *device); @@ -888,12 +894,12 @@ static void cm_format_req(struct cm_req_msg *req_msg, cm_req_set_resp_res(req_msg, param->responder_resources); cm_req_set_init_depth(req_msg, param->initiator_depth); cm_req_set_remote_resp_timeout(req_msg, - param->remote_cm_response_timeout); + min((u8) IB_CM_MAX_TIMEOUT, param->remote_cm_response_timeout)); cm_req_set_qp_type(req_msg, param->qp_type); cm_req_set_flow_ctrl(req_msg, param->flow_control); cm_req_set_starting_psn(req_msg, cpu_to_be32(param->starting_psn)); cm_req_set_local_resp_timeout(req_msg, - param->local_cm_response_timeout); + min((u8) IB_CM_MAX_TIMEOUT, param->local_cm_response_timeout)); cm_req_set_retry_count(req_msg, param->retry_count); req_msg->pkey = param->primary_path->pkey; cm_req_set_path_mtu(req_msg, param->primary_path->mtu); @@ -999,10 +1005,10 @@ int ib_send_cm_req(struct ib_cm_id *cm_id, } cm_id->service_id = param->service_id; cm_id->service_mask = __constant_cpu_to_be64(~0ULL); - cm_id_priv->timeout_ms = cm_convert_to_ms( - param->primary_path->packet_life_time) * 2 + - cm_convert_to_ms( - param->remote_cm_response_timeout); + cm_id_priv->timeout_ms = + min(IB_CM_MAX_TIMEOUT, + cm_convert_to_ms(param->primary_path->packet_life_time) * 2 + + cm_convert_to_ms(param->remote_cm_response_timeout)); cm_id_priv->max_cm_retries = param->max_cm_retries; cm_id_priv->initiator_depth = param->initiator_depth; cm_id_priv->responder_resources = param->responder_resources; @@ -1400,8 +1406,9 @@ static int cm_req_handler(struct cm_work *work) } } cm_id_priv->tid = req_msg->hdr.tid; - cm_id_priv->timeout_ms = cm_convert_to_ms( - cm_req_get_local_resp_timeout(req_msg)); + cm_id_priv->timeout_ms = + min(IB_CM_MAX_TIMEOUT, + cm_convert_to_ms(cm_req_get_local_resp_timeout(req_msg))); cm_id_priv->max_cm_retries = cm_req_get_max_cm_retries(req_msg); cm_id_priv->remote_qpn = cm_req_get_local_qpn(req_msg); cm_id_priv->initiator_depth = cm_req_get_resp_res(req_msg); @@ -2303,8 +2310,9 @@ static int cm_mra_handler(struct cm_work *work) work->cm_event.private_data = &mra_msg->private_data; work->cm_event.param.mra_rcvd.service_timeout = cm_mra_get_service_timeout(mra_msg); - timeout = cm_convert_to_ms(cm_mra_get_service_timeout(mra_msg)) + - cm_convert_to_ms(cm_id_priv->av.packet_life_time); + timeout = min(IB_CM_MAX_TIMEOUT, + cm_convert_to_ms(cm_mra_get_service_timeout(mra_msg)) + + cm_convert_to_ms(cm_id_priv->av.packet_life_time)); spin_lock_irqsave(&cm_id_priv->lock, flags); switch (cm_id_priv->id.state) { @@ -2707,7 +2715,7 @@ int ib_send_cm_sidr_req(struct ib_cm_id *cm_id, cm_id->service_id = param->service_id; cm_id->service_mask = __constant_cpu_to_be64(~0ULL); - cm_id_priv->timeout_ms = param->timeout_ms; + cm_id_priv->timeout_ms = min(IB_CM_MAX_TIMEOUT, param->timeout_ms); cm_id_priv->max_cm_retries = param->max_cm_retries; ret = cm_alloc_msg(cm_id_priv, &msg); if (ret) -- 1.4.4.3 _______________________________________________ openib-general mailing list openib-general@openib.org http://openib.org/mailman/listinfo/openib-general To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general