提交 081ea519 编写于 作者: P Parav Pandit 提交者: Jason Gunthorpe

RDMA/cma: Use a helper function to enqueue resolve work items

To avoid errors, with attaching ownership of work item and its cm_id
refcount which is decremented in work handler, tie them up in single
helper function. Also avoid code duplication.

Link: https://lore.kernel.org/r/20200126142652.104803-3-leon@kernel.orgSigned-off-by: NParav Pandit <parav@mellanox.com>
Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
上级 bb6d3fb3
...@@ -2687,14 +2687,18 @@ static void cma_init_resolve_route_work(struct cma_work *work, ...@@ -2687,14 +2687,18 @@ static void cma_init_resolve_route_work(struct cma_work *work,
work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED; work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
} }
static void cma_init_resolve_addr_work(struct cma_work *work, static void enqueue_resolve_addr_work(struct cma_work *work,
struct rdma_id_private *id_priv) struct rdma_id_private *id_priv)
{ {
atomic_inc(&id_priv->refcount);
work->id = id_priv; work->id = id_priv;
INIT_WORK(&work->work, cma_work_handler); INIT_WORK(&work->work, cma_work_handler);
work->old_state = RDMA_CM_ADDR_QUERY; work->old_state = RDMA_CM_ADDR_QUERY;
work->new_state = RDMA_CM_ADDR_RESOLVED; work->new_state = RDMA_CM_ADDR_RESOLVED;
work->event.event = RDMA_CM_EVENT_ADDR_RESOLVED; work->event.event = RDMA_CM_EVENT_ADDR_RESOLVED;
queue_work(cma_wq, &work->work);
} }
static int cma_resolve_ib_route(struct rdma_id_private *id_priv, static int cma_resolve_ib_route(struct rdma_id_private *id_priv,
...@@ -3148,9 +3152,7 @@ static int cma_resolve_loopback(struct rdma_id_private *id_priv) ...@@ -3148,9 +3152,7 @@ static int cma_resolve_loopback(struct rdma_id_private *id_priv)
rdma_addr_get_sgid(&id_priv->id.route.addr.dev_addr, &gid); rdma_addr_get_sgid(&id_priv->id.route.addr.dev_addr, &gid);
rdma_addr_set_dgid(&id_priv->id.route.addr.dev_addr, &gid); rdma_addr_set_dgid(&id_priv->id.route.addr.dev_addr, &gid);
atomic_inc(&id_priv->refcount); enqueue_resolve_addr_work(work, id_priv);
cma_init_resolve_addr_work(work, id_priv);
queue_work(cma_wq, &work->work);
return 0; return 0;
err: err:
kfree(work); kfree(work);
...@@ -3175,9 +3177,7 @@ static int cma_resolve_ib_addr(struct rdma_id_private *id_priv) ...@@ -3175,9 +3177,7 @@ static int cma_resolve_ib_addr(struct rdma_id_private *id_priv)
rdma_addr_set_dgid(&id_priv->id.route.addr.dev_addr, (union ib_gid *) rdma_addr_set_dgid(&id_priv->id.route.addr.dev_addr, (union ib_gid *)
&(((struct sockaddr_ib *) &id_priv->id.route.addr.dst_addr)->sib_addr)); &(((struct sockaddr_ib *) &id_priv->id.route.addr.dst_addr)->sib_addr));
atomic_inc(&id_priv->refcount); enqueue_resolve_addr_work(work, id_priv);
cma_init_resolve_addr_work(work, id_priv);
queue_work(cma_wq, &work->work);
return 0; return 0;
err: err:
kfree(work); kfree(work);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册