]> asedeno.scripts.mit.edu Git - linux.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)
commitdecbc7a6b0073f55b200d80a3ecf5a5e205edd06
tree1f39165c9656f4829b2b93e1f82157fcfefed175
parent3042492bd1f9a08e9cf4c1a4621e359fb0f9a126
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