IB/uverbs: Lower the test for ongoing disassociation
authorJason Gunthorpe <jgg@mellanox.com>
Thu, 26 Jul 2018 03:40:16 +0000 (21:40 -0600)
committerJason Gunthorpe <jgg@mellanox.com>
Wed, 1 Aug 2018 20:55:48 +0000 (14:55 -0600)
Commands that are reading/writing to objects can test for an ongoing
disassociation during their initial call to rdma_lookup_get_uobject.  This
directly prevents all of these commands from conflicting with an ongoing
disassociation.

Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/rdma_core.c

index 95a8110f186fdf3ec9e1bf8512c4c9baf00944ce..d4de1fed98f2fbdd1cddd5ffb98717296e8f8b13 100644 (file)
@@ -449,6 +449,17 @@ struct ib_uobject *rdma_lookup_get_uobject(const struct uverbs_obj_type *type,
                goto free;
        }
 
+       /*
+        * If we have been disassociated block every command except for
+        * DESTROY based commands.
+        */
+       if (mode != UVERBS_LOOKUP_DESTROY &&
+           !srcu_dereference(ufile->device->ib_dev,
+                             &ufile->device->disassociate_srcu)) {
+               ret = -EIO;
+               goto free;
+       }
+
        ret = uverbs_try_lock_object(uobj, mode);
        if (ret)
                goto free;