diff options
author | Leon Romanovsky <leonro@mellanox.com> | 2020-09-22 12:11:04 +0300 |
---|---|---|
committer | Jason Gunthorpe <jgg@nvidia.com> | 2020-09-22 19:47:35 -0300 |
commit | 13ef5539def732dc7b9c58c320d97a0a95b52634 (patch) | |
tree | f0b724a51ba1d0847863d29a31053a2af8492a65 /drivers/infiniband/core/restrack.h | |
parent | d7ecab1e5f7d12209549813e61435d01489a1887 (diff) | |
download | linux-13ef5539def732dc7b9c58c320d97a0a95b52634.tar.gz linux-13ef5539def732dc7b9c58c320d97a0a95b52634.tar.bz2 linux-13ef5539def732dc7b9c58c320d97a0a95b52634.zip |
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>
Diffstat (limited to 'drivers/infiniband/core/restrack.h')
-rw-r--r-- | drivers/infiniband/core/restrack.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/infiniband/core/restrack.h b/drivers/infiniband/core/restrack.h index d084e5f89849..16006a5e7408 100644 --- a/drivers/infiniband/core/restrack.h +++ b/drivers/infiniband/core/restrack.h @@ -25,6 +25,9 @@ struct rdma_restrack_root { int rdma_restrack_init(struct ib_device *dev); void rdma_restrack_clean(struct ib_device *dev); +void rdma_restrack_del(struct rdma_restrack_entry *res); +void rdma_restrack_new(struct rdma_restrack_entry *res, + enum rdma_restrack_type type); void rdma_restrack_attach_task(struct rdma_restrack_entry *res, struct task_struct *task); #endif /* _RDMA_CORE_RESTRACK_H_ */ |