RDMA/restrack: Count references to the verbs objects
authorLeon Romanovsky <leonro@mellanox.com>
Tue, 22 Sep 2020 09:11:04 +0000 (12:11 +0300)
committerJason Gunthorpe <jgg@nvidia.com>
Tue, 22 Sep 2020 22:47:35 +0000 (19:47 -0300)
commit13ef5539def732dc7b9c58c320d97a0a95b52634
treef0b724a51ba1d0847863d29a31053a2af8492a65
parentd7ecab1e5f7d12209549813e61435d01489a1887
RDMA/restrack: Count references to the verbs objects

Refactor the restrack code to make sure the kref inside the restrack entry
properly kref's the object in which it is embedded. This slight change is
needed for future conversions of MR and QP which are refcounted before the
release and kfree.

The ideal flow from ib_core perspective as follows:
* Allocate ib_* structure with rdma_zalloc_*.
* Set everything that is known to ib_core to that newly created object.
* Initialize kref with restrack help
* Call to driver specific allocation functions.
* Insert into restrack DB
....
* Return and release restrack with restrack_put.

Largely this means a rdma_restrack_new() should be called near allocating
the containing structure.

Link: https://lore.kernel.org/r/20200922091106.2152715-4-leon@kernel.org
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/core/cma.c
drivers/infiniband/core/core_priv.h
drivers/infiniband/core/counters.c
drivers/infiniband/core/cq.c
drivers/infiniband/core/restrack.c
drivers/infiniband/core/restrack.h
drivers/infiniband/core/uverbs_cmd.c
drivers/infiniband/core/uverbs_std_types_cq.c
drivers/infiniband/core/verbs.c
include/rdma/restrack.h