[ofa-general] Re: [PATCH v2 2/4] rdma/cma: simplify locking needed for serialization of callbacks
Roland Dreier
rdreier at cisco.com
Tue Jul 8 11:43:48 PDT 2008
> @@ -2570,9 +2557,12 @@ static int cma_ib_mc_handler(int status,
> int ret;
>
> id_priv = mc->id_priv;
> - if (cma_disable_remove(id_priv, CMA_ADDR_BOUND) &&
> - cma_disable_remove(id_priv, CMA_ADDR_RESOLVED))
> + mutex_lock(&id_priv->handler_mutex);
> + if ((id_priv->state != CMA_ADDR_BOUND) &&
> + (id_priv->state != CMA_ADDR_RESOLVED)) {
> + mutex_unlock(&id_priv->handler_mutex);
> return 0;
> + }
why don't you just do
if (cma_disable_callback(id_priv, CMA_ADDR_BOUND) &&
cma_disable_callback(id_priv, CMA_ADDR_RESOLVED))
instead of open-coding here? (&& is specified to have short-circuit
semantics, so if the first call takes the mutex, the second call won't
be made)
It seems your change is a subtle change in semantics and breaks the
encapsulation of this callback disabling here.
- R.
More information about the general
mailing list