OSDN Git Service

RDMA/ucma: Rework how new connections are passed through event delivery
authorJason Gunthorpe <jgg@nvidia.com>
Tue, 18 Aug 2020 12:05:25 +0000 (15:05 +0300)
committerJason Gunthorpe <jgg@nvidia.com>
Thu, 27 Aug 2020 11:38:16 +0000 (08:38 -0300)
commita1d33b70dbbc2c331c788ae12d5d54ac36c6744d
tree666d8f41afd686644a6b597112ad7674904e57b4
parent310ca1a7dcd1fd430f0d72e774d480cc200b4fdc
RDMA/ucma: Rework how new connections are passed through event delivery

When a new connection is established the RDMA CM creates a new cm_id and
passes it through to the event handler. However inside the UCMA the new ID
is not assigned a ucma_context until the user retrieves the event from a
syscall.

This creates a weird edge condition where a cm_id's context can continue
to point at the listening_id that created it, and a number of additional
edge conditions on event list clean up related to destroying half created
IDs.

There is also a race condition in ucma_get_events() where the
cm_id->context is being assigned without holding the handler_mutex.

Simplify all of this by creating the ucma_context inside the event handler
itself and eliminating the edge case of a half created cm_id. All cm_id's
can be uniformly destroyed via __destroy_id() or via the close_work.

Link: https://lore.kernel.org/r/20200818120526.702120-14-leon@kernel.org
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/core/ucma.c