• Jason Gunthorpe's avatar
    IB/uverbs: Revise the placement of get/puts on uobject · 5671f79b
    Jason Gunthorpe authored
    This wasn't wrong, but the placement of two krefs didn't make any
    sense. Follow some simple rules.
    
    - A kref is held inside uobjects_list
    - A kref is held inside the IDR
    - A kref is held inside file->private
    - A stack based kref is passed bettwen alloc_begin and
      alloc_abort/alloc_commit
    
    Any place we destroy one of the above pointers, we stick a put,
    or 'move' the kref into another pointer.
    
    The key functions have sensible semantics:
    - alloc_uobj fully initializes the common members in uobj, including
      the list
    - Get rid of the uverbs_idr_remove_uobj helper since IDR remove
      does require put, but it depends on the situation. Later
      patches will re-consolidate this differently.
    - alloc_abort always consumes the passed kref, done in the type
    - alloc_commit always consumes the passed kref, done in the type
    - rdma_remove_commit_uobject always pairs with a lookup_get
    
    After it is all done the only control flow change is to:
    - move a get from alloc_commit_fd_uobject to rdma_alloc_commit_uobject
    - add a put to remove_commit_idr_uobject
    - Consistenly use rdma_lookup_put in rdma_remove_commit_uobject at
      the right place
    Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
    5671f79b
rdma_core.c 22 KB