]> git.baikalelectronics.ru Git - kernel.git/commit
RDMA/core: Introduce a helper function to change net namespace of rdma device
authorParav Pandit <parav@mellanox.com>
Mon, 15 Apr 2019 10:22:50 +0000 (13:22 +0300)
committerJason Gunthorpe <jgg@mellanox.com>
Mon, 22 Apr 2019 17:44:58 +0000 (14:44 -0300)
commit8abbf21a548f2bbd9048a925508fd044ed970b87
tree1f39165c9656f4829b2b93e1f82157fcfefed175
parentf7eb94f5bcdbff4c3fa08e03a8d9cf777f4ebb0d
RDMA/core: Introduce a helper function to change net namespace of rdma device

Introduce a helper function that changes rdma device's net namespace which
performs mini disable/enable sequence to have device visible only in
assigned net namespace.

Device unregistration, device rename and device change net namespace
may be invoked concurrently.

(a) device unregistration needs to wait if a device change (rename or net
    namespace change) operation is in progress.
(b) device net namespace change should not proceed if the unregistration
    has started.
(c) while one cpu is changing device net namespace, other cpu should not
    be able to rename or change net namespace.

To address above concurrency,
(a) Use unreg_mutex to synchronize between ib_unregister_device() and net
    namespace change operation
(b) In cases where unregister_device() has started unregistration before
    change_netns got chance to acquire unreg_mutex, validate the refcount
    - if it dropped to zero, abort the net namespace change operation.

Finally use the helper function to change net namespace of ib device to
move the device back to init_net when such net is deleted.

Signed-off-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/device.c