Re: [PATCH v2 01/13] IB/core: lock client data with lists_rwsem

Jason Gunthorpe
2015-07-27T17:44:21Z

On Sun, Jul 26, 2015 at 06:33:40PM +0300, Haggai Eran wrote:
> An ib_client callback that is called with the lists_rwsem locked only for
> read is protected from changes to the IB client lists, but not from
> ib_unregister_device() freeing its client data. This is because
> ib_unregister_device() will remove the device from the device list with
> lists_rwsem locked for write, but perform the rest of the cleanup,
> including the call to remove() without that lock.
>
> Mark client data that is undergoing de-registration with a new going_down
> flag in the client data context. Lock the client data list with lists_rwsem
> for write in addition to using the spinlock, so that functions calling the
> callback would be able to lock only lists_rwsem for read and let callbacks
> sleep.
>
> Since ib_unregister_client() now marks the client data context, no need for
> remove() to search the context again, so pass the client data directly to
> remove() callbacks.

This looks fine to me..

Reviewed-By: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

Jason