diff options
author | Zach Brown <zach.brown@oracle.com> | 2010-05-18 18:48:51 -0400 |
---|---|---|
committer | Andy Grover <andy.grover@oracle.com> | 2010-09-08 21:15:17 -0400 |
commit | 3e0249f9c05cb77b66f7f09644ca9ca208d991a9 (patch) | |
tree | 2f8aaddb51590d36a54b8f7044224073107d77d9 /net/rds/ib.h | |
parent | 89bf9d4158b5a1b6bd00960eb2e47601ec8cc138 (diff) |
RDS/IB: add refcount tracking to struct rds_ib_device
The RDS IB client .remove callback used to free the rds_ibdev for the given
device unconditionally. This could race other users of the struct. This patch
adds refcounting so that we only free the rds_ibdev once all of its users are
done.
Many rds_ibdev users are tied to connections. We give the connection a
reference and change these users to reference the device in the connection
instead of looking it up in the IB client data. The only user of the IB client
data remaining is the first lookup of the device as connections are built up.
Incrementing the reference count of a device found in the IB client data could
race with final freeing so we use an RCU grace period to make sure that freeing
won't happen until those lookups are done.
MRs need the rds_ibdev to get at the pool that they're freed in to. They exist
outside a connection and many MRs can reference different devices from one
socket, so it was natural to have each MR hold a reference. MR refs can be
dropped from interrupt handlers and final device teardown can block so we push
it off to a work struct. Pool teardown had to be fixed to cancel its pending
work instead of deadlocking waiting for all queued work, including itself, to
finish.
MRs get their reference from the global device list, which gets a reference.
It is left unprotected by locks and remains racy. A simple global lock would
be a significant bottleneck. More scalable (complicated) locking should be
done carefully in a later patch.
Signed-off-by: Zach Brown <zach.brown@oracle.com>
Diffstat (limited to 'net/rds/ib.h')
-rw-r--r-- | net/rds/ib.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/net/rds/ib.h b/net/rds/ib.h index 4bc3e2fba25a..282ec69fe282 100644 --- a/net/rds/ib.h +++ b/net/rds/ib.h | |||
@@ -167,6 +167,8 @@ struct rds_ib_device { | |||
167 | unsigned int max_initiator_depth; | 167 | unsigned int max_initiator_depth; |
168 | unsigned int max_responder_resources; | 168 | unsigned int max_responder_resources; |
169 | spinlock_t spinlock; /* protect the above */ | 169 | spinlock_t spinlock; /* protect the above */ |
170 | atomic_t refcount; | ||
171 | struct work_struct free_work; | ||
170 | }; | 172 | }; |
171 | 173 | ||
172 | #define pcidev_to_node(pcidev) pcibus_to_node(pcidev->bus) | 174 | #define pcidev_to_node(pcidev) pcibus_to_node(pcidev->bus) |
@@ -251,6 +253,8 @@ static inline void rds_ib_dma_sync_sg_for_device(struct ib_device *dev, | |||
251 | extern struct rds_transport rds_ib_transport; | 253 | extern struct rds_transport rds_ib_transport; |
252 | extern void rds_ib_add_one(struct ib_device *device); | 254 | extern void rds_ib_add_one(struct ib_device *device); |
253 | extern void rds_ib_remove_one(struct ib_device *device); | 255 | extern void rds_ib_remove_one(struct ib_device *device); |
256 | struct rds_ib_device *rds_ib_get_client_data(struct ib_device *device); | ||
257 | void rds_ib_dev_put(struct rds_ib_device *rds_ibdev); | ||
254 | extern struct ib_client rds_ib_client; | 258 | extern struct ib_client rds_ib_client; |
255 | 259 | ||
256 | extern unsigned int fmr_pool_size; | 260 | extern unsigned int fmr_pool_size; |